Skip to content

Commit

Permalink
Powerpack add support for prefix and available values (#2683)
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 Sep 18, 2024
1 parent c2a8983 commit 5190102
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 7 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.6",
"regenerated": "2024-09-16 14:02:51.270254",
"spec_repo_commit": "966987f5"
"regenerated": "2024-09-18 14:45:12.928672",
"spec_repo_commit": "bae57ce1"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-16 14:02:51.288296",
"spec_repo_commit": "966987f5"
"regenerated": "2024-09-18 14:45:12.947003",
"spec_repo_commit": "bae57ce1"
}
}
}
18 changes: 18 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16297,6 +16297,18 @@ components:
PowerpackTemplateVariable:
description: Powerpack template variables.
properties:
available_values:
description: The list of values that the template variable drop-down is
limited to.
example:
- my-host
- host1
- host2
items:
description: Template variable value.
type: string
nullable: true
type: array
defaults:
description: One or many template variable default values within the saved
view, which are unioned together using `OR` if more than one is specified.
Expand All @@ -16309,6 +16321,12 @@ components:
description: The name of the variable.
example: datacenter
type: string
prefix:
description: The tag prefix associated with the variable. Only tags with
this prefix appear in the variable drop-down.
example: host
nullable: true
type: string
required:
- name
type: object
Expand Down
98 changes: 95 additions & 3 deletions api/datadogV2/model_powerpack_template_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import (

// PowerpackTemplateVariable Powerpack template variables.
type PowerpackTemplateVariable struct {
// The list of values that the template variable drop-down is limited to.
AvailableValues datadog.NullableList[string] `json:"available_values,omitempty"`
// One or many template variable default values within the saved view, which are unioned together using `OR` if more than one is specified.
Defaults []string `json:"defaults,omitempty"`
// The name of the variable.
Name string `json:"name"`
// The tag prefix associated with the variable. Only tags with this prefix appear in the variable drop-down.
Prefix datadog.NullableString `json:"prefix,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{} `json:"-"`
Expand All @@ -39,6 +43,45 @@ func NewPowerpackTemplateVariableWithDefaults() *PowerpackTemplateVariable {
return &this
}

// GetAvailableValues returns the AvailableValues field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *PowerpackTemplateVariable) GetAvailableValues() []string {
if o == nil || o.AvailableValues.Get() == nil {
var ret []string
return ret
}
return *o.AvailableValues.Get()
}

// GetAvailableValuesOk returns a tuple with the AvailableValues field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned.
func (o *PowerpackTemplateVariable) GetAvailableValuesOk() (*[]string, bool) {
if o == nil {
return nil, false
}
return o.AvailableValues.Get(), o.AvailableValues.IsSet()
}

// HasAvailableValues returns a boolean if a field has been set.
func (o *PowerpackTemplateVariable) HasAvailableValues() bool {
return o != nil && o.AvailableValues.IsSet()
}

// SetAvailableValues gets a reference to the given datadog.NullableList[string] and assigns it to the AvailableValues field.
func (o *PowerpackTemplateVariable) SetAvailableValues(v []string) {
o.AvailableValues.Set(&v)
}

// SetAvailableValuesNil sets the value for AvailableValues to be an explicit nil.
func (o *PowerpackTemplateVariable) SetAvailableValuesNil() {
o.AvailableValues.Set(nil)
}

// UnsetAvailableValues ensures that no value is present for AvailableValues, not even an explicit nil.
func (o *PowerpackTemplateVariable) UnsetAvailableValues() {
o.AvailableValues.Unset()
}

// GetDefaults returns the Defaults field value if set, zero value otherwise.
func (o *PowerpackTemplateVariable) GetDefaults() []string {
if o == nil || o.Defaults == nil {
Expand Down Expand Up @@ -90,16 +133,61 @@ func (o *PowerpackTemplateVariable) SetName(v string) {
o.Name = v
}

// GetPrefix returns the Prefix field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *PowerpackTemplateVariable) GetPrefix() string {
if o == nil || o.Prefix.Get() == nil {
var ret string
return ret
}
return *o.Prefix.Get()
}

// GetPrefixOk returns a tuple with the Prefix field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned.
func (o *PowerpackTemplateVariable) GetPrefixOk() (*string, bool) {
if o == nil {
return nil, false
}
return o.Prefix.Get(), o.Prefix.IsSet()
}

// HasPrefix returns a boolean if a field has been set.
func (o *PowerpackTemplateVariable) HasPrefix() bool {
return o != nil && o.Prefix.IsSet()
}

// SetPrefix gets a reference to the given datadog.NullableString and assigns it to the Prefix field.
func (o *PowerpackTemplateVariable) SetPrefix(v string) {
o.Prefix.Set(&v)
}

// SetPrefixNil sets the value for Prefix to be an explicit nil.
func (o *PowerpackTemplateVariable) SetPrefixNil() {
o.Prefix.Set(nil)
}

// UnsetPrefix ensures that no value is present for Prefix, not even an explicit nil.
func (o *PowerpackTemplateVariable) UnsetPrefix() {
o.Prefix.Unset()
}

// MarshalJSON serializes the struct using spec logic.
func (o PowerpackTemplateVariable) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.AvailableValues.IsSet() {
toSerialize["available_values"] = o.AvailableValues.Get()
}
if o.Defaults != nil {
toSerialize["defaults"] = o.Defaults
}
toSerialize["name"] = o.Name
if o.Prefix.IsSet() {
toSerialize["prefix"] = o.Prefix.Get()
}

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
Expand All @@ -110,8 +198,10 @@ func (o PowerpackTemplateVariable) MarshalJSON() ([]byte, error) {
// UnmarshalJSON deserializes the given payload.
func (o *PowerpackTemplateVariable) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Defaults []string `json:"defaults,omitempty"`
Name *string `json:"name"`
AvailableValues datadog.NullableList[string] `json:"available_values,omitempty"`
Defaults []string `json:"defaults,omitempty"`
Name *string `json:"name"`
Prefix datadog.NullableString `json:"prefix,omitempty"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
Expand All @@ -121,12 +211,14 @@ func (o *PowerpackTemplateVariable) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"defaults", "name"})
datadog.DeleteKeys(additionalProperties, &[]string{"available_values", "defaults", "name", "prefix"})
} else {
return err
}
o.AvailableValues = all.AvailableValues
o.Defaults = all.Defaults
o.Name = *all.Name
o.Prefix = all.Prefix

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

0 comments on commit 5190102

Please sign in to comment.