Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Cloudflare API zone and resource fields #2339

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-08 16:03:30.338792",
"spec_repo_commit": "8b5aed97"
"regenerated": "2024-01-08 19:23:25.986235",
"spec_repo_commit": "150ace98"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-08 16:03:30.357818",
"spec_repo_commit": "8b5aed97"
"regenerated": "2024-01-08 19:23:26.005218",
"spec_repo_commit": "150ace98"
}
}
}
48 changes: 48 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3776,6 +3776,22 @@ components:
description: The name of the Cloudflare account.
example: test-name
type: string
resources:
description: An allowlist of resources to restrict pulling metrics for.
example:
- web
- dns
items:
type: string
type: array
zones:
description: An allowlist of zones to restrict pulling metrics for.
example:
- zone_id_1
- zone_id_2
items:
type: string
type: array
required:
- api_key
- name
Expand Down Expand Up @@ -3808,6 +3824,22 @@ components:
description: The name of the Cloudflare account.
example: test-name
type: string
resources:
description: An allowlist of resources to restrict pulling metrics for.
example:
- web
- dns
items:
type: string
type: array
zones:
description: An allowlist of zones to restrict pulling metrics for.
example:
- zone_id_1
- zone_id_2
items:
type: string
type: array
required:
- name
type: object
Expand Down Expand Up @@ -3856,6 +3888,22 @@ components:
key is provided (and not a token), this field is also required.
example: [email protected]
type: string
resources:
description: An allowlist of resources to restrict pulling metrics for.
example:
- web
- dns
items:
type: string
type: array
zones:
description: An allowlist of zones to restrict pulling metrics for.
example:
- zone_id_1
- zone_id_2
items:
type: string
type: array
required:
- api_key
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type CloudflareAccountCreateRequestAttributes struct {
Email *string `json:"email,omitempty"`
// The name of the Cloudflare account.
Name string `json:"name"`
// An allowlist of resources to restrict pulling metrics for.
Resources []string `json:"resources,omitempty"`
// An allowlist of zones to restrict pulling metrics for.
Zones []string `json:"zones,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{}
Expand Down Expand Up @@ -116,6 +120,62 @@ func (o *CloudflareAccountCreateRequestAttributes) SetName(v string) {
o.Name = v
}

// GetResources returns the Resources field value if set, zero value otherwise.
func (o *CloudflareAccountCreateRequestAttributes) GetResources() []string {
if o == nil || o.Resources == nil {
var ret []string
return ret
}
return o.Resources
}

// GetResourcesOk returns a tuple with the Resources field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CloudflareAccountCreateRequestAttributes) GetResourcesOk() (*[]string, bool) {
if o == nil || o.Resources == nil {
return nil, false
}
return &o.Resources, true
}

// HasResources returns a boolean if a field has been set.
func (o *CloudflareAccountCreateRequestAttributes) HasResources() bool {
return o != nil && o.Resources != nil
}

// SetResources gets a reference to the given []string and assigns it to the Resources field.
func (o *CloudflareAccountCreateRequestAttributes) SetResources(v []string) {
o.Resources = v
}

// GetZones returns the Zones field value if set, zero value otherwise.
func (o *CloudflareAccountCreateRequestAttributes) GetZones() []string {
if o == nil || o.Zones == nil {
var ret []string
return ret
}
return o.Zones
}

// GetZonesOk returns a tuple with the Zones field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CloudflareAccountCreateRequestAttributes) GetZonesOk() (*[]string, bool) {
if o == nil || o.Zones == nil {
return nil, false
}
return &o.Zones, true
}

// HasZones returns a boolean if a field has been set.
func (o *CloudflareAccountCreateRequestAttributes) HasZones() bool {
return o != nil && o.Zones != nil
}

// SetZones gets a reference to the given []string and assigns it to the Zones field.
func (o *CloudflareAccountCreateRequestAttributes) SetZones(v []string) {
o.Zones = v
}

// MarshalJSON serializes the struct using spec logic.
func (o CloudflareAccountCreateRequestAttributes) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -127,6 +187,12 @@ func (o CloudflareAccountCreateRequestAttributes) MarshalJSON() ([]byte, error)
toSerialize["email"] = o.Email
}
toSerialize["name"] = o.Name
if o.Resources != nil {
toSerialize["resources"] = o.Resources
}
if o.Zones != nil {
toSerialize["zones"] = o.Zones
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -137,9 +203,11 @@ func (o CloudflareAccountCreateRequestAttributes) MarshalJSON() ([]byte, error)
// UnmarshalJSON deserializes the given payload.
func (o *CloudflareAccountCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
ApiKey *string `json:"api_key"`
Email *string `json:"email,omitempty"`
Name *string `json:"name"`
ApiKey *string `json:"api_key"`
Email *string `json:"email,omitempty"`
Name *string `json:"name"`
Resources []string `json:"resources,omitempty"`
Zones []string `json:"zones,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -152,13 +220,15 @@ func (o *CloudflareAccountCreateRequestAttributes) UnmarshalJSON(bytes []byte) (
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"api_key", "email", "name"})
datadog.DeleteKeys(additionalProperties, &[]string{"api_key", "email", "name", "resources", "zones"})
} else {
return err
}
o.ApiKey = *all.ApiKey
o.Email = all.Email
o.Name = *all.Name
o.Resources = all.Resources
o.Zones = all.Zones

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
Expand Down
76 changes: 73 additions & 3 deletions api/datadogV2/model_cloudflare_account_response_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ type CloudflareAccountResponseAttributes struct {
Email *string `json:"email,omitempty"`
// The name of the Cloudflare account.
Name string `json:"name"`
// An allowlist of resources to restrict pulling metrics for.
Resources []string `json:"resources,omitempty"`
// An allowlist of zones to restrict pulling metrics for.
Zones []string `json:"zones,omitempty"`
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject map[string]interface{} `json:"-"`
AdditionalProperties map[string]interface{}
Expand Down Expand Up @@ -90,6 +94,62 @@ func (o *CloudflareAccountResponseAttributes) SetName(v string) {
o.Name = v
}

// GetResources returns the Resources field value if set, zero value otherwise.
func (o *CloudflareAccountResponseAttributes) GetResources() []string {
if o == nil || o.Resources == nil {
var ret []string
return ret
}
return o.Resources
}

// GetResourcesOk returns a tuple with the Resources field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CloudflareAccountResponseAttributes) GetResourcesOk() (*[]string, bool) {
if o == nil || o.Resources == nil {
return nil, false
}
return &o.Resources, true
}

// HasResources returns a boolean if a field has been set.
func (o *CloudflareAccountResponseAttributes) HasResources() bool {
return o != nil && o.Resources != nil
}

// SetResources gets a reference to the given []string and assigns it to the Resources field.
func (o *CloudflareAccountResponseAttributes) SetResources(v []string) {
o.Resources = v
}

// GetZones returns the Zones field value if set, zero value otherwise.
func (o *CloudflareAccountResponseAttributes) GetZones() []string {
if o == nil || o.Zones == nil {
var ret []string
return ret
}
return o.Zones
}

// GetZonesOk returns a tuple with the Zones field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CloudflareAccountResponseAttributes) GetZonesOk() (*[]string, bool) {
if o == nil || o.Zones == nil {
return nil, false
}
return &o.Zones, true
}

// HasZones returns a boolean if a field has been set.
func (o *CloudflareAccountResponseAttributes) HasZones() bool {
return o != nil && o.Zones != nil
}

// SetZones gets a reference to the given []string and assigns it to the Zones field.
func (o *CloudflareAccountResponseAttributes) SetZones(v []string) {
o.Zones = v
}

// MarshalJSON serializes the struct using spec logic.
func (o CloudflareAccountResponseAttributes) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -100,6 +160,12 @@ func (o CloudflareAccountResponseAttributes) MarshalJSON() ([]byte, error) {
toSerialize["email"] = o.Email
}
toSerialize["name"] = o.Name
if o.Resources != nil {
toSerialize["resources"] = o.Resources
}
if o.Zones != nil {
toSerialize["zones"] = o.Zones
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -110,8 +176,10 @@ func (o CloudflareAccountResponseAttributes) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *CloudflareAccountResponseAttributes) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Email *string `json:"email,omitempty"`
Name *string `json:"name"`
Email *string `json:"email,omitempty"`
Name *string `json:"name"`
Resources []string `json:"resources,omitempty"`
Zones []string `json:"zones,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -121,12 +189,14 @@ func (o *CloudflareAccountResponseAttributes) UnmarshalJSON(bytes []byte) (err e
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"email", "name"})
datadog.DeleteKeys(additionalProperties, &[]string{"email", "name", "resources", "zones"})
} else {
return err
}
o.Email = all.Email
o.Name = *all.Name
o.Resources = all.Resources
o.Zones = all.Zones

if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
Expand Down
Loading
Loading