Skip to content

Commit

Permalink
Add encryption field to logs archive destination (#2889)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Jan 23, 2025
1 parent 201ca63 commit 395df36
Show file tree
Hide file tree
Showing 5 changed files with 283 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.6",
"regenerated": "2025-01-23 20:01:34.590919",
"spec_repo_commit": "f985f8bc"
"regenerated": "2025-01-23 20:45:53.862249",
"spec_repo_commit": "2350cf2b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-23 20:01:34.606317",
"spec_repo_commit": "f985f8bc"
"regenerated": "2025-01-23 20:45:53.877699",
"spec_repo_commit": "2350cf2b"
}
}
}
26 changes: 26 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16762,6 +16762,8 @@ components:
description: The bucket where the archive will be stored.
example: bucket-name
type: string
encryption:
$ref: '#/components/schemas/LogsArchiveEncryptionS3'
integration:
$ref: '#/components/schemas/LogsArchiveIntegrationS3'
path:
Expand All @@ -16783,6 +16785,30 @@ components:
type: string
x-enum-varnames:
- S3
LogsArchiveEncryptionS3:
description: The S3 encryption settings.
properties:
key:
description: An Amazon Resource Name (ARN) used to identify an AWS KMS key.
example: arn:aws:kms:us-east-1:012345678901:key/DatadogIntegrationRoleKms
type: string
type:
$ref: '#/components/schemas/LogsArchiveEncryptionS3Type'
required:
- type
type: object
LogsArchiveEncryptionS3Type:
description: Type of S3 encryption for a destination.
enum:
- NO_OVERRIDE
- SSE_S3
- SSE_KMS
example: SSE_S3
type: string
x-enum-varnames:
- NO_OVERRIDE
- SSE_S3
- SSE_KMS
LogsArchiveIntegrationAzure:
description: The Azure archive's integration destination.
properties:
Expand Down
40 changes: 39 additions & 1 deletion api/datadogV2/model_logs_archive_destination_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
type LogsArchiveDestinationS3 struct {
// The bucket where the archive will be stored.
Bucket string `json:"bucket"`
// The S3 encryption settings.
Encryption *LogsArchiveEncryptionS3 `json:"encryption,omitempty"`
// The S3 Archive's integration destination.
Integration LogsArchiveIntegrationS3 `json:"integration"`
// The archive path.
Expand Down Expand Up @@ -70,6 +72,34 @@ func (o *LogsArchiveDestinationS3) SetBucket(v string) {
o.Bucket = v
}

// GetEncryption returns the Encryption field value if set, zero value otherwise.
func (o *LogsArchiveDestinationS3) GetEncryption() LogsArchiveEncryptionS3 {
if o == nil || o.Encryption == nil {
var ret LogsArchiveEncryptionS3
return ret
}
return *o.Encryption
}

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

// HasEncryption returns a boolean if a field has been set.
func (o *LogsArchiveDestinationS3) HasEncryption() bool {
return o != nil && o.Encryption != nil
}

// SetEncryption gets a reference to the given LogsArchiveEncryptionS3 and assigns it to the Encryption field.
func (o *LogsArchiveDestinationS3) SetEncryption(v LogsArchiveEncryptionS3) {
o.Encryption = &v
}

// GetIntegration returns the Integration field value.
func (o *LogsArchiveDestinationS3) GetIntegration() LogsArchiveIntegrationS3 {
if o == nil {
Expand Down Expand Up @@ -151,6 +181,9 @@ func (o LogsArchiveDestinationS3) MarshalJSON() ([]byte, error) {
return datadog.Marshal(o.UnparsedObject)
}
toSerialize["bucket"] = o.Bucket
if o.Encryption != nil {
toSerialize["encryption"] = o.Encryption
}
toSerialize["integration"] = o.Integration
if o.Path != nil {
toSerialize["path"] = o.Path
Expand All @@ -167,6 +200,7 @@ func (o LogsArchiveDestinationS3) MarshalJSON() ([]byte, error) {
func (o *LogsArchiveDestinationS3) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Bucket *string `json:"bucket"`
Encryption *LogsArchiveEncryptionS3 `json:"encryption,omitempty"`
Integration *LogsArchiveIntegrationS3 `json:"integration"`
Path *string `json:"path,omitempty"`
Type *LogsArchiveDestinationS3Type `json:"type"`
Expand All @@ -185,13 +219,17 @@ func (o *LogsArchiveDestinationS3) UnmarshalJSON(bytes []byte) (err error) {
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"bucket", "integration", "path", "type"})
datadog.DeleteKeys(additionalProperties, &[]string{"bucket", "encryption", "integration", "path", "type"})
} else {
return err
}

hasInvalidField := false
o.Bucket = *all.Bucket
if all.Encryption != nil && all.Encryption.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
}
o.Encryption = all.Encryption
if all.Integration.UnparsedObject != nil && o.UnparsedObject == nil {
hasInvalidField = true
}
Expand Down
146 changes: 146 additions & 0 deletions api/datadogV2/model_logs_archive_encryption_s3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// 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/DataDog/datadog-api-client-go/v2/api/datadog"
)

// LogsArchiveEncryptionS3 The S3 encryption settings.
type LogsArchiveEncryptionS3 struct {
// An Amazon Resource Name (ARN) used to identify an AWS KMS key.
Key *string `json:"key,omitempty"`
// Type of S3 encryption for a destination.
Type LogsArchiveEncryptionS3Type `json:"type"`
// 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:"-"`
}

// NewLogsArchiveEncryptionS3 instantiates a new LogsArchiveEncryptionS3 object.
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed.
func NewLogsArchiveEncryptionS3(typeVar LogsArchiveEncryptionS3Type) *LogsArchiveEncryptionS3 {
this := LogsArchiveEncryptionS3{}
this.Type = typeVar
return &this
}

// NewLogsArchiveEncryptionS3WithDefaults instantiates a new LogsArchiveEncryptionS3 object.
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set.
func NewLogsArchiveEncryptionS3WithDefaults() *LogsArchiveEncryptionS3 {
this := LogsArchiveEncryptionS3{}
return &this
}

// GetKey returns the Key field value if set, zero value otherwise.
func (o *LogsArchiveEncryptionS3) GetKey() string {
if o == nil || o.Key == nil {
var ret string
return ret
}
return *o.Key
}

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

// HasKey returns a boolean if a field has been set.
func (o *LogsArchiveEncryptionS3) HasKey() bool {
return o != nil && o.Key != nil
}

// SetKey gets a reference to the given string and assigns it to the Key field.
func (o *LogsArchiveEncryptionS3) SetKey(v string) {
o.Key = &v
}

// GetType returns the Type field value.
func (o *LogsArchiveEncryptionS3) GetType() LogsArchiveEncryptionS3Type {
if o == nil {
var ret LogsArchiveEncryptionS3Type
return ret
}
return o.Type
}

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

// SetType sets field value.
func (o *LogsArchiveEncryptionS3) SetType(v LogsArchiveEncryptionS3Type) {
o.Type = v
}

// MarshalJSON serializes the struct using spec logic.
func (o LogsArchiveEncryptionS3) MarshalJSON() ([]byte, error) {
toSerialize := map[string]interface{}{}
if o.UnparsedObject != nil {
return datadog.Marshal(o.UnparsedObject)
}
if o.Key != nil {
toSerialize["key"] = o.Key
}
toSerialize["type"] = o.Type

for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return datadog.Marshal(toSerialize)
}

// UnmarshalJSON deserializes the given payload.
func (o *LogsArchiveEncryptionS3) UnmarshalJSON(bytes []byte) (err error) {
all := struct {
Key *string `json:"key,omitempty"`
Type *LogsArchiveEncryptionS3Type `json:"type"`
}{}
if err = datadog.Unmarshal(bytes, &all); err != nil {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}
if all.Type == nil {
return fmt.Errorf("required field type missing")
}
additionalProperties := make(map[string]interface{})
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
datadog.DeleteKeys(additionalProperties, &[]string{"key", "type"})
} else {
return err
}

hasInvalidField := false
o.Key = all.Key
if !all.Type.IsValid() {
hasInvalidField = true
} else {
o.Type = *all.Type
}

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

if hasInvalidField {
return datadog.Unmarshal(bytes, &o.UnparsedObject)
}

return nil
}
68 changes: 68 additions & 0 deletions api/datadogV2/model_logs_archive_encryption_s3_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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/DataDog/datadog-api-client-go/v2/api/datadog"
)

// LogsArchiveEncryptionS3Type Type of S3 encryption for a destination.
type LogsArchiveEncryptionS3Type string

// List of LogsArchiveEncryptionS3Type.
const (
LOGSARCHIVEENCRYPTIONS3TYPE_NO_OVERRIDE LogsArchiveEncryptionS3Type = "NO_OVERRIDE"
LOGSARCHIVEENCRYPTIONS3TYPE_SSE_S3 LogsArchiveEncryptionS3Type = "SSE_S3"
LOGSARCHIVEENCRYPTIONS3TYPE_SSE_KMS LogsArchiveEncryptionS3Type = "SSE_KMS"
)

var allowedLogsArchiveEncryptionS3TypeEnumValues = []LogsArchiveEncryptionS3Type{
LOGSARCHIVEENCRYPTIONS3TYPE_NO_OVERRIDE,
LOGSARCHIVEENCRYPTIONS3TYPE_SSE_S3,
LOGSARCHIVEENCRYPTIONS3TYPE_SSE_KMS,
}

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

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

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

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

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

0 comments on commit 395df36

Please sign in to comment.