Skip to content

Commit

Permalink
Add missing type field for OnDemandConcurrencyCap response (#2101)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Jul 26, 2023
1 parent 43fd94a commit 19c66cc
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 5 deletions.
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.5",
"regenerated": "2023-07-26 14:17:56.191620",
"spec_repo_commit": "835cb6df"
"regenerated": "2023-07-26 14:58:27.908695",
"spec_repo_commit": "3d6b3d5a"
},
"v2": {
"apigentools_version": "1.6.5",
"regenerated": "2023-07-26 14:17:56.204862",
"spec_repo_commit": "835cb6df"
"regenerated": "2023-07-26 14:58:27.923303",
"spec_repo_commit": "3d6b3d5a"
}
}
}
9 changes: 9 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10110,6 +10110,8 @@ components:
properties:
attributes:
$ref: '#/components/schemas/OnDemandConcurrencyCapAttributes'
type:
$ref: '#/components/schemas/OnDemandConcurrencyCapType'
type: object
OnDemandConcurrencyCapAttributes:
description: On-demand concurrency cap attributes.
Expand All @@ -10125,6 +10127,13 @@ components:
data:
$ref: '#/components/schemas/OnDemandConcurrencyCap'
type: object
OnDemandConcurrencyCapType:
description: On-demand concurrency cap type.
enum:
- on_demand_concurrency_cap
type: string
x-enum-varnames:
- ON_DEMAND_CONCURRENCY_CAP
OpsgenieServiceCreateAttributes:
description: The Opsgenie service attributes for a create request.
properties:
Expand Down
45 changes: 44 additions & 1 deletion api/datadogV2/model_on_demand_concurrency_cap.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
type OnDemandConcurrencyCap struct {
// On-demand concurrency cap attributes.
Attributes *OnDemandConcurrencyCapAttributes `json:"attributes,omitempty"`
// On-demand concurrency cap type.
Type *OnDemandConcurrencyCapType `json:"type,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 @@ -64,6 +66,34 @@ func (o *OnDemandConcurrencyCap) SetAttributes(v OnDemandConcurrencyCapAttribute
o.Attributes = &v
}

// GetType returns the Type field value if set, zero value otherwise.
func (o *OnDemandConcurrencyCap) GetType() OnDemandConcurrencyCapType {
if o == nil || o.Type == nil {
var ret OnDemandConcurrencyCapType
return ret
}
return *o.Type
}

// GetTypeOk returns a tuple with the Type field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *OnDemandConcurrencyCap) GetTypeOk() (*OnDemandConcurrencyCapType, bool) {
if o == nil || o.Type == nil {
return nil, false
}
return o.Type, true
}

// HasType returns a boolean if a field has been set.
func (o *OnDemandConcurrencyCap) HasType() bool {
return o != nil && o.Type != nil
}

// SetType gets a reference to the given OnDemandConcurrencyCapType and assigns it to the Type field.
func (o *OnDemandConcurrencyCap) SetType(v OnDemandConcurrencyCapType) {
o.Type = &v
}

// MarshalJSON serializes the struct using spec logic.
func (o OnDemandConcurrencyCap) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
Expand All @@ -73,6 +103,9 @@ func (o OnDemandConcurrencyCap) MarshalJSON() ([]byte, error) {
if o.Attributes != nil {
toSerialize["attributes"] = o.Attributes
}
if o.Type != nil {
toSerialize["type"] = o.Type
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -85,6 +118,7 @@ func (o *OnDemandConcurrencyCap) UnmarshalJSON(bytes []byte) (err error) {
raw := map[string]interface{}{}
all := struct {
Attributes *OnDemandConcurrencyCapAttributes `json:"attributes,omitempty"`
Type *OnDemandConcurrencyCapType `json:"type,omitempty"`
}{}
if err = json.Unmarshal(bytes, &all); err != nil {
err = json.Unmarshal(bytes, &raw)
Expand All @@ -96,10 +130,18 @@ func (o *OnDemandConcurrencyCap) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"attributes"})
datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"})
} else {
return err
}
if v := all.Type; v != nil && !v.IsValid() {
err = json.Unmarshal(bytes, &raw)
if err != nil {
return err
}
o.UnparsedObject = raw
return nil
}
if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil {
err = json.Unmarshal(bytes, &raw)
if err != nil {
Expand All @@ -108,6 +150,7 @@ func (o *OnDemandConcurrencyCap) UnmarshalJSON(bytes []byte) (err error) {
o.UnparsedObject = raw
}
o.Attributes = all.Attributes
o.Type = all.Type
if len(additionalProperties) > 0 {
o.AdditionalProperties = additionalProperties
}
Expand Down
64 changes: 64 additions & 0 deletions api/datadogV2/model_on_demand_concurrency_cap_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

package datadogV2

import (
"fmt"

"github.com/goccy/go-json"
)

// OnDemandConcurrencyCapType On-demand concurrency cap type.
type OnDemandConcurrencyCapType string

// List of OnDemandConcurrencyCapType.
const (
ONDEMANDCONCURRENCYCAPTYPE_ON_DEMAND_CONCURRENCY_CAP OnDemandConcurrencyCapType = "on_demand_concurrency_cap"
)

var allowedOnDemandConcurrencyCapTypeEnumValues = []OnDemandConcurrencyCapType{
ONDEMANDCONCURRENCYCAPTYPE_ON_DEMAND_CONCURRENCY_CAP,
}

// GetAllowedValues reeturns the list of possible values.
func (v *OnDemandConcurrencyCapType) GetAllowedValues() []OnDemandConcurrencyCapType {
return allowedOnDemandConcurrencyCapTypeEnumValues
}

// UnmarshalJSON deserializes the given payload.
func (v *OnDemandConcurrencyCapType) UnmarshalJSON(src []byte) error {
var value string
err := json.Unmarshal(src, &value)
if err != nil {
return err
}
*v = OnDemandConcurrencyCapType(value)
return nil
}

// NewOnDemandConcurrencyCapTypeFromValue returns a pointer to a valid OnDemandConcurrencyCapType
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
func NewOnDemandConcurrencyCapTypeFromValue(v string) (*OnDemandConcurrencyCapType, error) {
ev := OnDemandConcurrencyCapType(v)
if ev.IsValid() {
return &ev, nil
}
return nil, fmt.Errorf("invalid value '%v' for OnDemandConcurrencyCapType: valid values are %v", v, allowedOnDemandConcurrencyCapTypeEnumValues)
}

// IsValid return true if the value is valid for the enum, false otherwise.
func (v OnDemandConcurrencyCapType) IsValid() bool {
for _, existing := range allowedOnDemandConcurrencyCapTypeEnumValues {
if existing == v {
return true
}
}
return false
}

// Ptr returns reference to OnDemandConcurrencyCapType value.
func (v OnDemandConcurrencyCapType) Ptr() *OnDemandConcurrencyCapType {
return &v
}

0 comments on commit 19c66cc

Please sign in to comment.