diff --git a/.apigentools-info b/.apigentools-info index 3f7fa122d02..a81bcbeef52 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-13 14:48:31.209305", - "spec_repo_commit": "9c0d47b3" + "regenerated": "2023-10-16 16:10:15.325916", + "spec_repo_commit": "1f05be0a" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2023-10-13 14:48:31.229549", - "spec_repo_commit": "9c0d47b3" + "regenerated": "2023-10-16 16:10:15.351961", + "spec_repo_commit": "1f05be0a" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6f5545f6bc4..bc53203e4fc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -3441,6 +3441,101 @@ components: $ref: '#/components/schemas/ConfluentResourceResponseData' type: array type: object + Container: + description: Container object. + properties: + attributes: + $ref: '#/components/schemas/ContainerAttributes' + id: + description: Container ID. + type: string + type: + $ref: '#/components/schemas/ContainerType' + type: object + ContainerAttributes: + description: Attributes for a container. + properties: + container_id: + description: The ID of the container. + type: string + created_at: + description: Time the container was created. + type: string + host: + description: Hostname of the host running the container. + type: string + image_digest: + description: Digest of the compressed image manifest. + type: string + image_name: + description: Name of the associated container image. + type: string + image_tags: + description: List of image tags associated with the container image. + items: + type: string + type: array + name: + description: Name of the container. + type: string + started_at: + description: Time the container was started. + type: string + state: + description: State of the container. This depends on the container runtime. + type: string + tags: + description: List of tags associated with the container. + items: + type: string + type: array + type: object + ContainerGroup: + description: Container group object. + properties: + attributes: + $ref: '#/components/schemas/ContainerGroupAttributes' + id: + description: Container Group ID. + type: string + relationships: + $ref: '#/components/schemas/ContainerGroupRelationships' + type: + $ref: '#/components/schemas/ContainerGroupType' + type: object + ContainerGroupAttributes: + description: Attributes for a container group. + properties: + count: + description: Number of containers in the group. + format: int64 + type: integer + tags: + description: Tags from the group name parsed in key/value format. + type: object + type: object + ContainerGroupRelationships: + description: Relationships to containers inside a container group. + properties: + links: + $ref: '#/components/schemas/ContainerGroupRelationshipsLinks' + type: object + ContainerGroupRelationshipsLinks: + description: Links attributes. + properties: + related: + description: Link to related containers. + type: string + type: object + ContainerGroupType: + default: container_group + description: Type of container group. + enum: + - container_group + example: container_group + type: string + x-enum-varnames: + - CONTAINER_GROUP ContainerImage: description: Container Image object. properties: @@ -3751,6 +3846,73 @@ components: description: Link to current page. type: string type: object + ContainerItem: + description: Possible Container models. + oneOf: + - $ref: '#/components/schemas/Container' + - $ref: '#/components/schemas/ContainerGroup' + ContainerMeta: + description: Response metadata object. + properties: + pagination: + $ref: '#/components/schemas/ContainerMetaPage' + type: object + ContainerMetaPage: + description: Paging attributes. + properties: + limit: + description: Number of results returned + format: int32 + maximum: 10000 + minimum: 0 + type: integer + next_cursor: + description: The cursor used to get the next results, if any. + type: string + total: + description: Total number of records that match the query. + format: int64 + type: integer + type: object + ContainerType: + default: container + description: Type of container. + enum: + - container + example: container + type: string + x-enum-varnames: + - CONTAINER + ContainersResponse: + description: List of containers. + properties: + data: + description: Array of Container objects. + items: + $ref: '#/components/schemas/ContainerItem' + type: array + links: + $ref: '#/components/schemas/ContainersResponseLinks' + meta: + $ref: '#/components/schemas/ContainerMeta' + type: object + ContainersResponseLinks: + description: Pagination links. + properties: + first: + description: Link to the first page. + type: string + next: + description: Link to the next page. + type: string + prev: + description: Link to previous page. + nullable: true + type: string + self: + description: Link to current page. + type: string + type: object ContentEncoding: description: HTTP header used to compress the media-type. enum: @@ -19814,6 +19976,86 @@ paths: x-unstable: '**Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/containers: + get: + description: Get all containers for your organization. + operationId: ListContainers + parameters: + - description: Comma-separated list of tags to filter containers by. + example: env:prod,short_image:cassandra + in: query + name: filter[tags] + required: false + schema: + type: string + - description: Comma-separated list of tags to group containers by. + example: datacenter,cluster + in: query + name: group_by + required: false + schema: + type: string + - description: Attribute to sort containers by. + example: started_at + in: query + name: sort + required: false + schema: + type: string + - description: Maximum number of results returned. + in: query + name: page[size] + required: false + schema: + default: 1000 + format: int32 + maximum: 10000 + minimum: 1 + type: integer + - description: 'String to query the next page of results. + + This key is provided with each valid response from the API in `meta.pagination.next_cursor`.' + in: query + name: page[cursor] + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ContainersResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Authentication Error + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Get All Containers + tags: + - Containers + x-pagination: + cursorParam: page[cursor] + cursorPath: meta.pagination.next_cursor + limitParam: page[size] + resultsPath: data + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/current_user/application_keys: get: description: List all application keys available for current user @@ -29384,6 +29626,8 @@ tags: - description: The Container Images API allows you to query Container Image data for your organization. name: Container Images +- description: The Containers API allows you to query container data for your organization. + name: Containers - description: 'Interact with your dashboard lists through the API to organize, find, and share all of your dashboards with your team and diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 4ba65b363a6..a1a444d324b 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -324,6 +324,7 @@ func NewConfiguration() *Configuration { }, unstableOperations: map[string]bool{ "v2.ListContainerImages": false, + "v2.ListContainers": false, "v2.ListEvents": false, "v2.SearchEvents": false, "v2.CreateIncident": false, diff --git a/api/datadogV2/api_containers.go b/api/datadogV2/api_containers.go new file mode 100644 index 00000000000..969606e0a3e --- /dev/null +++ b/api/datadogV2/api_containers.go @@ -0,0 +1,228 @@ +// 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 ( + _context "context" + _fmt "fmt" + _log "log" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainersApi service type +type ContainersApi datadog.Service + +// ListContainersOptionalParameters holds optional parameters for ListContainers. +type ListContainersOptionalParameters struct { + FilterTags *string + GroupBy *string + Sort *string + PageSize *int32 + PageCursor *string +} + +// NewListContainersOptionalParameters creates an empty struct for parameters. +func NewListContainersOptionalParameters() *ListContainersOptionalParameters { + this := ListContainersOptionalParameters{} + return &this +} + +// WithFilterTags sets the corresponding parameter name and returns the struct. +func (r *ListContainersOptionalParameters) WithFilterTags(filterTags string) *ListContainersOptionalParameters { + r.FilterTags = &filterTags + return r +} + +// WithGroupBy sets the corresponding parameter name and returns the struct. +func (r *ListContainersOptionalParameters) WithGroupBy(groupBy string) *ListContainersOptionalParameters { + r.GroupBy = &groupBy + return r +} + +// WithSort sets the corresponding parameter name and returns the struct. +func (r *ListContainersOptionalParameters) WithSort(sort string) *ListContainersOptionalParameters { + r.Sort = &sort + return r +} + +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListContainersOptionalParameters) WithPageSize(pageSize int32) *ListContainersOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageCursor sets the corresponding parameter name and returns the struct. +func (r *ListContainersOptionalParameters) WithPageCursor(pageCursor string) *ListContainersOptionalParameters { + r.PageCursor = &pageCursor + return r +} + +// ListContainers Get All Containers. +// Get all containers for your organization. +func (a *ContainersApi) ListContainers(ctx _context.Context, o ...ListContainersOptionalParameters) (ContainersResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ContainersResponse + optionalParams ListContainersOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListContainersOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListContainers" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ContainersApi.ListContainers") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/containers" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.FilterTags != nil { + localVarQueryParams.Add("filter[tags]", datadog.ParameterToString(*optionalParams.FilterTags, "")) + } + if optionalParams.GroupBy != nil { + localVarQueryParams.Add("group_by", datadog.ParameterToString(*optionalParams.GroupBy, "")) + } + if optionalParams.Sort != nil { + localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, "")) + } + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageCursor != nil { + localVarQueryParams.Add("page[cursor]", datadog.ParameterToString(*optionalParams.PageCursor, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListContainersWithPagination provides a paginated version of ListContainers returning a channel with all items. +func (a *ContainersApi) ListContainersWithPagination(ctx _context.Context, o ...ListContainersOptionalParameters) (<-chan datadog.PaginationResult[ContainerItem], func()) { + ctx, cancel := _context.WithCancel(ctx) + pageSize_ := int32(1000) + if len(o) == 0 { + o = append(o, ListContainersOptionalParameters{}) + } + if o[0].PageSize != nil { + pageSize_ = *o[0].PageSize + } + o[0].PageSize = &pageSize_ + + items := make(chan datadog.PaginationResult[ContainerItem], pageSize_) + go func() { + for { + resp, _, err := a.ListContainers(ctx, o...) + if err != nil { + var returnItem ContainerItem + items <- datadog.PaginationResult[ContainerItem]{returnItem, err} + break + } + respData, ok := resp.GetDataOk() + if !ok { + break + } + results := *respData + + for _, item := range results { + select { + case items <- datadog.PaginationResult[ContainerItem]{item, nil}: + case <-ctx.Done(): + close(items) + return + } + } + if len(results) < int(pageSize_) { + break + } + cursorMeta, ok := resp.GetMetaOk() + if !ok { + break + } + cursorMetaPagination, ok := cursorMeta.GetPaginationOk() + if !ok { + break + } + cursorMetaPaginationNextCursor, ok := cursorMetaPagination.GetNextCursorOk() + if !ok { + break + } + + o[0].PageCursor = cursorMetaPaginationNextCursor + } + close(items) + }() + return items, cancel +} + +// NewContainersApi Returns NewContainersApi. +func NewContainersApi(client *datadog.APIClient) *ContainersApi { + return &ContainersApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 3a555f910c8..2331dd3f899 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -45,6 +45,7 @@ // - [ConfluentCloudApi.UpdateConfluentAccount] // - [ConfluentCloudApi.UpdateConfluentResource] // - [ContainerImagesApi.ListContainerImages] +// - [ContainersApi.ListContainers] // - [DashboardListsApi.CreateDashboardListItems] // - [DashboardListsApi.DeleteDashboardListItems] // - [DashboardListsApi.GetDashboardListItems] diff --git a/api/datadogV2/model_container.go b/api/datadogV2/model_container.go new file mode 100644 index 00000000000..8f57ab2b69b --- /dev/null +++ b/api/datadogV2/model_container.go @@ -0,0 +1,191 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// Container Container object. +type Container struct { + // Attributes for a container. + Attributes *ContainerAttributes `json:"attributes,omitempty"` + // Container ID. + Id *string `json:"id,omitempty"` + // Type of container. + Type *ContainerType `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{} +} + +// NewContainer instantiates a new Container 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 NewContainer() *Container { + this := Container{} + var typeVar ContainerType = CONTAINERTYPE_CONTAINER + this.Type = &typeVar + return &this +} + +// NewContainerWithDefaults instantiates a new Container 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 NewContainerWithDefaults() *Container { + this := Container{} + var typeVar ContainerType = CONTAINERTYPE_CONTAINER + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *Container) GetAttributes() ContainerAttributes { + if o == nil || o.Attributes == nil { + var ret ContainerAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Container) GetAttributesOk() (*ContainerAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *Container) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ContainerAttributes and assigns it to the Attributes field. +func (o *Container) SetAttributes(v ContainerAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *Container) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Container) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *Container) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *Container) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *Container) GetType() ContainerType { + if o == nil || o.Type == nil { + var ret ContainerType + 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 *Container) GetTypeOk() (*ContainerType, 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 *Container) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ContainerType and assigns it to the Type field. +func (o *Container) SetType(v ContainerType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Container) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Container) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ContainerAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *ContainerType `json:"type,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_container_attributes.go b/api/datadogV2/model_container_attributes.go new file mode 100644 index 00000000000..b6ecb7de61f --- /dev/null +++ b/api/datadogV2/model_container_attributes.go @@ -0,0 +1,419 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainerAttributes Attributes for a container. +type ContainerAttributes struct { + // The ID of the container. + ContainerId *string `json:"container_id,omitempty"` + // Time the container was created. + CreatedAt *string `json:"created_at,omitempty"` + // Hostname of the host running the container. + Host *string `json:"host,omitempty"` + // Digest of the compressed image manifest. + ImageDigest *string `json:"image_digest,omitempty"` + // Name of the associated container image. + ImageName *string `json:"image_name,omitempty"` + // List of image tags associated with the container image. + ImageTags []string `json:"image_tags,omitempty"` + // Name of the container. + Name *string `json:"name,omitempty"` + // Time the container was started. + StartedAt *string `json:"started_at,omitempty"` + // State of the container. This depends on the container runtime. + State *string `json:"state,omitempty"` + // List of tags associated with the container. + Tags []string `json:"tags,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{} +} + +// NewContainerAttributes instantiates a new ContainerAttributes 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 NewContainerAttributes() *ContainerAttributes { + this := ContainerAttributes{} + return &this +} + +// NewContainerAttributesWithDefaults instantiates a new ContainerAttributes 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 NewContainerAttributesWithDefaults() *ContainerAttributes { + this := ContainerAttributes{} + return &this +} + +// GetContainerId returns the ContainerId field value if set, zero value otherwise. +func (o *ContainerAttributes) GetContainerId() string { + if o == nil || o.ContainerId == nil { + var ret string + return ret + } + return *o.ContainerId +} + +// GetContainerIdOk returns a tuple with the ContainerId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetContainerIdOk() (*string, bool) { + if o == nil || o.ContainerId == nil { + return nil, false + } + return o.ContainerId, true +} + +// HasContainerId returns a boolean if a field has been set. +func (o *ContainerAttributes) HasContainerId() bool { + return o != nil && o.ContainerId != nil +} + +// SetContainerId gets a reference to the given string and assigns it to the ContainerId field. +func (o *ContainerAttributes) SetContainerId(v string) { + o.ContainerId = &v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *ContainerAttributes) GetCreatedAt() string { + if o == nil || o.CreatedAt == nil { + var ret string + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetCreatedAtOk() (*string, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *ContainerAttributes) HasCreatedAt() bool { + return o != nil && o.CreatedAt != nil +} + +// SetCreatedAt gets a reference to the given string and assigns it to the CreatedAt field. +func (o *ContainerAttributes) SetCreatedAt(v string) { + o.CreatedAt = &v +} + +// GetHost returns the Host field value if set, zero value otherwise. +func (o *ContainerAttributes) GetHost() string { + if o == nil || o.Host == nil { + var ret string + return ret + } + return *o.Host +} + +// GetHostOk returns a tuple with the Host field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetHostOk() (*string, bool) { + if o == nil || o.Host == nil { + return nil, false + } + return o.Host, true +} + +// HasHost returns a boolean if a field has been set. +func (o *ContainerAttributes) HasHost() bool { + return o != nil && o.Host != nil +} + +// SetHost gets a reference to the given string and assigns it to the Host field. +func (o *ContainerAttributes) SetHost(v string) { + o.Host = &v +} + +// GetImageDigest returns the ImageDigest field value if set, zero value otherwise. +func (o *ContainerAttributes) GetImageDigest() string { + if o == nil || o.ImageDigest == nil { + var ret string + return ret + } + return *o.ImageDigest +} + +// GetImageDigestOk returns a tuple with the ImageDigest field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetImageDigestOk() (*string, bool) { + if o == nil || o.ImageDigest == nil { + return nil, false + } + return o.ImageDigest, true +} + +// HasImageDigest returns a boolean if a field has been set. +func (o *ContainerAttributes) HasImageDigest() bool { + return o != nil && o.ImageDigest != nil +} + +// SetImageDigest gets a reference to the given string and assigns it to the ImageDigest field. +func (o *ContainerAttributes) SetImageDigest(v string) { + o.ImageDigest = &v +} + +// GetImageName returns the ImageName field value if set, zero value otherwise. +func (o *ContainerAttributes) GetImageName() string { + if o == nil || o.ImageName == nil { + var ret string + return ret + } + return *o.ImageName +} + +// GetImageNameOk returns a tuple with the ImageName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetImageNameOk() (*string, bool) { + if o == nil || o.ImageName == nil { + return nil, false + } + return o.ImageName, true +} + +// HasImageName returns a boolean if a field has been set. +func (o *ContainerAttributes) HasImageName() bool { + return o != nil && o.ImageName != nil +} + +// SetImageName gets a reference to the given string and assigns it to the ImageName field. +func (o *ContainerAttributes) SetImageName(v string) { + o.ImageName = &v +} + +// GetImageTags returns the ImageTags field value if set, zero value otherwise. +func (o *ContainerAttributes) GetImageTags() []string { + if o == nil || o.ImageTags == nil { + var ret []string + return ret + } + return o.ImageTags +} + +// GetImageTagsOk returns a tuple with the ImageTags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetImageTagsOk() (*[]string, bool) { + if o == nil || o.ImageTags == nil { + return nil, false + } + return &o.ImageTags, true +} + +// HasImageTags returns a boolean if a field has been set. +func (o *ContainerAttributes) HasImageTags() bool { + return o != nil && o.ImageTags != nil +} + +// SetImageTags gets a reference to the given []string and assigns it to the ImageTags field. +func (o *ContainerAttributes) SetImageTags(v []string) { + o.ImageTags = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ContainerAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ContainerAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ContainerAttributes) SetName(v string) { + o.Name = &v +} + +// GetStartedAt returns the StartedAt field value if set, zero value otherwise. +func (o *ContainerAttributes) GetStartedAt() string { + if o == nil || o.StartedAt == nil { + var ret string + return ret + } + return *o.StartedAt +} + +// GetStartedAtOk returns a tuple with the StartedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetStartedAtOk() (*string, bool) { + if o == nil || o.StartedAt == nil { + return nil, false + } + return o.StartedAt, true +} + +// HasStartedAt returns a boolean if a field has been set. +func (o *ContainerAttributes) HasStartedAt() bool { + return o != nil && o.StartedAt != nil +} + +// SetStartedAt gets a reference to the given string and assigns it to the StartedAt field. +func (o *ContainerAttributes) SetStartedAt(v string) { + o.StartedAt = &v +} + +// GetState returns the State field value if set, zero value otherwise. +func (o *ContainerAttributes) GetState() string { + if o == nil || o.State == nil { + var ret string + return ret + } + return *o.State +} + +// GetStateOk returns a tuple with the State field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetStateOk() (*string, bool) { + if o == nil || o.State == nil { + return nil, false + } + return o.State, true +} + +// HasState returns a boolean if a field has been set. +func (o *ContainerAttributes) HasState() bool { + return o != nil && o.State != nil +} + +// SetState gets a reference to the given string and assigns it to the State field. +func (o *ContainerAttributes) SetState(v string) { + o.State = &v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *ContainerAttributes) GetTags() []string { + if o == nil || o.Tags == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerAttributes) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *ContainerAttributes) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *ContainerAttributes) SetTags(v []string) { + o.Tags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainerAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.ContainerId != nil { + toSerialize["container_id"] = o.ContainerId + } + if o.CreatedAt != nil { + toSerialize["created_at"] = o.CreatedAt + } + if o.Host != nil { + toSerialize["host"] = o.Host + } + if o.ImageDigest != nil { + toSerialize["image_digest"] = o.ImageDigest + } + if o.ImageName != nil { + toSerialize["image_name"] = o.ImageName + } + if o.ImageTags != nil { + toSerialize["image_tags"] = o.ImageTags + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.StartedAt != nil { + toSerialize["started_at"] = o.StartedAt + } + if o.State != nil { + toSerialize["state"] = o.State + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainerAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ContainerId *string `json:"container_id,omitempty"` + CreatedAt *string `json:"created_at,omitempty"` + Host *string `json:"host,omitempty"` + ImageDigest *string `json:"image_digest,omitempty"` + ImageName *string `json:"image_name,omitempty"` + ImageTags []string `json:"image_tags,omitempty"` + Name *string `json:"name,omitempty"` + StartedAt *string `json:"started_at,omitempty"` + State *string `json:"state,omitempty"` + Tags []string `json:"tags,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"container_id", "created_at", "host", "image_digest", "image_name", "image_tags", "name", "started_at", "state", "tags"}) + } else { + return err + } + o.ContainerId = all.ContainerId + o.CreatedAt = all.CreatedAt + o.Host = all.Host + o.ImageDigest = all.ImageDigest + o.ImageName = all.ImageName + o.ImageTags = all.ImageTags + o.Name = all.Name + o.StartedAt = all.StartedAt + o.State = all.State + o.Tags = all.Tags + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_container_group.go b/api/datadogV2/model_container_group.go new file mode 100644 index 00000000000..557352d9b1c --- /dev/null +++ b/api/datadogV2/model_container_group.go @@ -0,0 +1,229 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainerGroup Container group object. +type ContainerGroup struct { + // Attributes for a container group. + Attributes *ContainerGroupAttributes `json:"attributes,omitempty"` + // Container Group ID. + Id *string `json:"id,omitempty"` + // Relationships to containers inside a container group. + Relationships *ContainerGroupRelationships `json:"relationships,omitempty"` + // Type of container group. + Type *ContainerGroupType `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{} +} + +// NewContainerGroup instantiates a new ContainerGroup 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 NewContainerGroup() *ContainerGroup { + this := ContainerGroup{} + var typeVar ContainerGroupType = CONTAINERGROUPTYPE_CONTAINER_GROUP + this.Type = &typeVar + return &this +} + +// NewContainerGroupWithDefaults instantiates a new ContainerGroup 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 NewContainerGroupWithDefaults() *ContainerGroup { + this := ContainerGroup{} + var typeVar ContainerGroupType = CONTAINERGROUPTYPE_CONTAINER_GROUP + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *ContainerGroup) GetAttributes() ContainerGroupAttributes { + if o == nil || o.Attributes == nil { + var ret ContainerGroupAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerGroup) GetAttributesOk() (*ContainerGroupAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *ContainerGroup) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ContainerGroupAttributes and assigns it to the Attributes field. +func (o *ContainerGroup) SetAttributes(v ContainerGroupAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ContainerGroup) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerGroup) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *ContainerGroup) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *ContainerGroup) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *ContainerGroup) GetRelationships() ContainerGroupRelationships { + if o == nil || o.Relationships == nil { + var ret ContainerGroupRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerGroup) GetRelationshipsOk() (*ContainerGroupRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *ContainerGroup) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given ContainerGroupRelationships and assigns it to the Relationships field. +func (o *ContainerGroup) SetRelationships(v ContainerGroupRelationships) { + o.Relationships = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ContainerGroup) GetType() ContainerGroupType { + if o == nil || o.Type == nil { + var ret ContainerGroupType + 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 *ContainerGroup) GetTypeOk() (*ContainerGroupType, 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 *ContainerGroup) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ContainerGroupType and assigns it to the Type field. +func (o *ContainerGroup) SetType(v ContainerGroupType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainerGroup) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainerGroup) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ContainerGroupAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Relationships *ContainerGroupRelationships `json:"relationships,omitempty"` + Type *ContainerGroupType `json:"type,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_container_group_attributes.go b/api/datadogV2/model_container_group_attributes.go new file mode 100644 index 00000000000..ce6dbcf147b --- /dev/null +++ b/api/datadogV2/model_container_group_attributes.go @@ -0,0 +1,139 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainerGroupAttributes Attributes for a container group. +type ContainerGroupAttributes struct { + // Number of containers in the group. + Count *int64 `json:"count,omitempty"` + // Tags from the group name parsed in key/value format. + Tags interface{} `json:"tags,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{} +} + +// NewContainerGroupAttributes instantiates a new ContainerGroupAttributes 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 NewContainerGroupAttributes() *ContainerGroupAttributes { + this := ContainerGroupAttributes{} + return &this +} + +// NewContainerGroupAttributesWithDefaults instantiates a new ContainerGroupAttributes 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 NewContainerGroupAttributesWithDefaults() *ContainerGroupAttributes { + this := ContainerGroupAttributes{} + return &this +} + +// GetCount returns the Count field value if set, zero value otherwise. +func (o *ContainerGroupAttributes) GetCount() int64 { + if o == nil || o.Count == nil { + var ret int64 + return ret + } + return *o.Count +} + +// GetCountOk returns a tuple with the Count field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerGroupAttributes) GetCountOk() (*int64, bool) { + if o == nil || o.Count == nil { + return nil, false + } + return o.Count, true +} + +// HasCount returns a boolean if a field has been set. +func (o *ContainerGroupAttributes) HasCount() bool { + return o != nil && o.Count != nil +} + +// SetCount gets a reference to the given int64 and assigns it to the Count field. +func (o *ContainerGroupAttributes) SetCount(v int64) { + o.Count = &v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *ContainerGroupAttributes) GetTags() interface{} { + if o == nil || o.Tags == nil { + var ret interface{} + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerGroupAttributes) GetTagsOk() (*interface{}, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *ContainerGroupAttributes) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given interface{} and assigns it to the Tags field. +func (o *ContainerGroupAttributes) SetTags(v interface{}) { + o.Tags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainerGroupAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Count != nil { + toSerialize["count"] = o.Count + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainerGroupAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Count *int64 `json:"count,omitempty"` + Tags interface{} `json:"tags,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"count", "tags"}) + } else { + return err + } + o.Count = all.Count + o.Tags = all.Tags + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_container_group_relationships.go b/api/datadogV2/model_container_group_relationships.go new file mode 100644 index 00000000000..05227a7b5dd --- /dev/null +++ b/api/datadogV2/model_container_group_relationships.go @@ -0,0 +1,113 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainerGroupRelationships Relationships to containers inside a container group. +type ContainerGroupRelationships struct { + // Links attributes. + Links *ContainerGroupRelationshipsLinks `json:"links,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{} +} + +// NewContainerGroupRelationships instantiates a new ContainerGroupRelationships 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 NewContainerGroupRelationships() *ContainerGroupRelationships { + this := ContainerGroupRelationships{} + return &this +} + +// NewContainerGroupRelationshipsWithDefaults instantiates a new ContainerGroupRelationships 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 NewContainerGroupRelationshipsWithDefaults() *ContainerGroupRelationships { + this := ContainerGroupRelationships{} + return &this +} + +// GetLinks returns the Links field value if set, zero value otherwise. +func (o *ContainerGroupRelationships) GetLinks() ContainerGroupRelationshipsLinks { + if o == nil || o.Links == nil { + var ret ContainerGroupRelationshipsLinks + return ret + } + return *o.Links +} + +// GetLinksOk returns a tuple with the Links field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerGroupRelationships) GetLinksOk() (*ContainerGroupRelationshipsLinks, bool) { + if o == nil || o.Links == nil { + return nil, false + } + return o.Links, true +} + +// HasLinks returns a boolean if a field has been set. +func (o *ContainerGroupRelationships) HasLinks() bool { + return o != nil && o.Links != nil +} + +// SetLinks gets a reference to the given ContainerGroupRelationshipsLinks and assigns it to the Links field. +func (o *ContainerGroupRelationships) SetLinks(v ContainerGroupRelationshipsLinks) { + o.Links = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainerGroupRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Links != nil { + toSerialize["links"] = o.Links + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainerGroupRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Links *ContainerGroupRelationshipsLinks `json:"links,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"links"}) + } else { + return err + } + + hasInvalidField := false + if all.Links != nil && all.Links.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Links = all.Links + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_container_group_relationships_links.go b/api/datadogV2/model_container_group_relationships_links.go new file mode 100644 index 00000000000..ea846c01e45 --- /dev/null +++ b/api/datadogV2/model_container_group_relationships_links.go @@ -0,0 +1,104 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainerGroupRelationshipsLinks Links attributes. +type ContainerGroupRelationshipsLinks struct { + // Link to related containers. + Related *string `json:"related,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{} +} + +// NewContainerGroupRelationshipsLinks instantiates a new ContainerGroupRelationshipsLinks 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 NewContainerGroupRelationshipsLinks() *ContainerGroupRelationshipsLinks { + this := ContainerGroupRelationshipsLinks{} + return &this +} + +// NewContainerGroupRelationshipsLinksWithDefaults instantiates a new ContainerGroupRelationshipsLinks 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 NewContainerGroupRelationshipsLinksWithDefaults() *ContainerGroupRelationshipsLinks { + this := ContainerGroupRelationshipsLinks{} + return &this +} + +// GetRelated returns the Related field value if set, zero value otherwise. +func (o *ContainerGroupRelationshipsLinks) GetRelated() string { + if o == nil || o.Related == nil { + var ret string + return ret + } + return *o.Related +} + +// GetRelatedOk returns a tuple with the Related field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerGroupRelationshipsLinks) GetRelatedOk() (*string, bool) { + if o == nil || o.Related == nil { + return nil, false + } + return o.Related, true +} + +// HasRelated returns a boolean if a field has been set. +func (o *ContainerGroupRelationshipsLinks) HasRelated() bool { + return o != nil && o.Related != nil +} + +// SetRelated gets a reference to the given string and assigns it to the Related field. +func (o *ContainerGroupRelationshipsLinks) SetRelated(v string) { + o.Related = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainerGroupRelationshipsLinks) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Related != nil { + toSerialize["related"] = o.Related + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainerGroupRelationshipsLinks) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Related *string `json:"related,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"related"}) + } else { + return err + } + o.Related = all.Related + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_container_group_type.go b/api/datadogV2/model_container_group_type.go new file mode 100644 index 00000000000..ec8a71f464f --- /dev/null +++ b/api/datadogV2/model_container_group_type.go @@ -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" +) + +// ContainerGroupType Type of container group. +type ContainerGroupType string + +// List of ContainerGroupType. +const ( + CONTAINERGROUPTYPE_CONTAINER_GROUP ContainerGroupType = "container_group" +) + +var allowedContainerGroupTypeEnumValues = []ContainerGroupType{ + CONTAINERGROUPTYPE_CONTAINER_GROUP, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ContainerGroupType) GetAllowedValues() []ContainerGroupType { + return allowedContainerGroupTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ContainerGroupType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ContainerGroupType(value) + return nil +} + +// NewContainerGroupTypeFromValue returns a pointer to a valid ContainerGroupType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewContainerGroupTypeFromValue(v string) (*ContainerGroupType, error) { + ev := ContainerGroupType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ContainerGroupType: valid values are %v", v, allowedContainerGroupTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ContainerGroupType) IsValid() bool { + for _, existing := range allowedContainerGroupTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ContainerGroupType value. +func (v ContainerGroupType) Ptr() *ContainerGroupType { + return &v +} diff --git a/api/datadogV2/model_container_item.go b/api/datadogV2/model_container_item.go new file mode 100644 index 00000000000..2988f37c417 --- /dev/null +++ b/api/datadogV2/model_container_item.go @@ -0,0 +1,105 @@ +// 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 ( + "github.com/goccy/go-json" +) + +// ContainerItem - Possible Container models. +type ContainerItem struct { + Container *Container + ContainerGroup *ContainerGroup + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// ContainerAsContainerItem is a convenience function that returns Container wrapped in ContainerItem. +func ContainerAsContainerItem(v *Container) ContainerItem { + return ContainerItem{Container: v} +} + +// ContainerGroupAsContainerItem is a convenience function that returns ContainerGroup wrapped in ContainerItem. +func ContainerGroupAsContainerItem(v *ContainerGroup) ContainerItem { + return ContainerItem{ContainerGroup: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *ContainerItem) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into Container + err = json.Unmarshal(data, &obj.Container) + if err == nil { + if obj.Container != nil && obj.Container.UnparsedObject == nil { + jsonContainer, _ := json.Marshal(obj.Container) + if string(jsonContainer) == "{}" { // empty struct + obj.Container = nil + } else { + match++ + } + } else { + obj.Container = nil + } + } else { + obj.Container = nil + } + + // try to unmarshal data into ContainerGroup + err = json.Unmarshal(data, &obj.ContainerGroup) + if err == nil { + if obj.ContainerGroup != nil && obj.ContainerGroup.UnparsedObject == nil { + jsonContainerGroup, _ := json.Marshal(obj.ContainerGroup) + if string(jsonContainerGroup) == "{}" { // empty struct + obj.ContainerGroup = nil + } else { + match++ + } + } else { + obj.ContainerGroup = nil + } + } else { + obj.ContainerGroup = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.Container = nil + obj.ContainerGroup = nil + return json.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj ContainerItem) MarshalJSON() ([]byte, error) { + if obj.Container != nil { + return json.Marshal(&obj.Container) + } + + if obj.ContainerGroup != nil { + return json.Marshal(&obj.ContainerGroup) + } + + if obj.UnparsedObject != nil { + return json.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *ContainerItem) GetActualInstance() interface{} { + if obj.Container != nil { + return obj.Container + } + + if obj.ContainerGroup != nil { + return obj.ContainerGroup + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_container_meta.go b/api/datadogV2/model_container_meta.go new file mode 100644 index 00000000000..135e894f5dd --- /dev/null +++ b/api/datadogV2/model_container_meta.go @@ -0,0 +1,113 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainerMeta Response metadata object. +type ContainerMeta struct { + // Paging attributes. + Pagination *ContainerMetaPage `json:"pagination,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{} +} + +// NewContainerMeta instantiates a new ContainerMeta 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 NewContainerMeta() *ContainerMeta { + this := ContainerMeta{} + return &this +} + +// NewContainerMetaWithDefaults instantiates a new ContainerMeta 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 NewContainerMetaWithDefaults() *ContainerMeta { + this := ContainerMeta{} + return &this +} + +// GetPagination returns the Pagination field value if set, zero value otherwise. +func (o *ContainerMeta) GetPagination() ContainerMetaPage { + if o == nil || o.Pagination == nil { + var ret ContainerMetaPage + return ret + } + return *o.Pagination +} + +// GetPaginationOk returns a tuple with the Pagination field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerMeta) GetPaginationOk() (*ContainerMetaPage, bool) { + if o == nil || o.Pagination == nil { + return nil, false + } + return o.Pagination, true +} + +// HasPagination returns a boolean if a field has been set. +func (o *ContainerMeta) HasPagination() bool { + return o != nil && o.Pagination != nil +} + +// SetPagination gets a reference to the given ContainerMetaPage and assigns it to the Pagination field. +func (o *ContainerMeta) SetPagination(v ContainerMetaPage) { + o.Pagination = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainerMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Pagination != nil { + toSerialize["pagination"] = o.Pagination + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainerMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Pagination *ContainerMetaPage `json:"pagination,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"pagination"}) + } else { + return err + } + + hasInvalidField := false + if all.Pagination != nil && all.Pagination.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Pagination = all.Pagination + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_container_meta_page.go b/api/datadogV2/model_container_meta_page.go new file mode 100644 index 00000000000..378c99474c4 --- /dev/null +++ b/api/datadogV2/model_container_meta_page.go @@ -0,0 +1,174 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainerMetaPage Paging attributes. +type ContainerMetaPage struct { + // Number of results returned + Limit *int32 `json:"limit,omitempty"` + // The cursor used to get the next results, if any. + NextCursor *string `json:"next_cursor,omitempty"` + // Total number of records that match the query. + Total *int64 `json:"total,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{} +} + +// NewContainerMetaPage instantiates a new ContainerMetaPage 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 NewContainerMetaPage() *ContainerMetaPage { + this := ContainerMetaPage{} + return &this +} + +// NewContainerMetaPageWithDefaults instantiates a new ContainerMetaPage 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 NewContainerMetaPageWithDefaults() *ContainerMetaPage { + this := ContainerMetaPage{} + return &this +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *ContainerMetaPage) GetLimit() int32 { + if o == nil || o.Limit == nil { + var ret int32 + return ret + } + return *o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerMetaPage) GetLimitOk() (*int32, bool) { + if o == nil || o.Limit == nil { + return nil, false + } + return o.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (o *ContainerMetaPage) HasLimit() bool { + return o != nil && o.Limit != nil +} + +// SetLimit gets a reference to the given int32 and assigns it to the Limit field. +func (o *ContainerMetaPage) SetLimit(v int32) { + o.Limit = &v +} + +// GetNextCursor returns the NextCursor field value if set, zero value otherwise. +func (o *ContainerMetaPage) GetNextCursor() string { + if o == nil || o.NextCursor == nil { + var ret string + return ret + } + return *o.NextCursor +} + +// GetNextCursorOk returns a tuple with the NextCursor field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerMetaPage) GetNextCursorOk() (*string, bool) { + if o == nil || o.NextCursor == nil { + return nil, false + } + return o.NextCursor, true +} + +// HasNextCursor returns a boolean if a field has been set. +func (o *ContainerMetaPage) HasNextCursor() bool { + return o != nil && o.NextCursor != nil +} + +// SetNextCursor gets a reference to the given string and assigns it to the NextCursor field. +func (o *ContainerMetaPage) SetNextCursor(v string) { + o.NextCursor = &v +} + +// GetTotal returns the Total field value if set, zero value otherwise. +func (o *ContainerMetaPage) GetTotal() int64 { + if o == nil || o.Total == nil { + var ret int64 + return ret + } + return *o.Total +} + +// GetTotalOk returns a tuple with the Total field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainerMetaPage) GetTotalOk() (*int64, bool) { + if o == nil || o.Total == nil { + return nil, false + } + return o.Total, true +} + +// HasTotal returns a boolean if a field has been set. +func (o *ContainerMetaPage) HasTotal() bool { + return o != nil && o.Total != nil +} + +// SetTotal gets a reference to the given int64 and assigns it to the Total field. +func (o *ContainerMetaPage) SetTotal(v int64) { + o.Total = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainerMetaPage) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + if o.NextCursor != nil { + toSerialize["next_cursor"] = o.NextCursor + } + if o.Total != nil { + toSerialize["total"] = o.Total + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainerMetaPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Limit *int32 `json:"limit,omitempty"` + NextCursor *string `json:"next_cursor,omitempty"` + Total *int64 `json:"total,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"limit", "next_cursor", "total"}) + } else { + return err + } + o.Limit = all.Limit + o.NextCursor = all.NextCursor + o.Total = all.Total + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_container_type.go b/api/datadogV2/model_container_type.go new file mode 100644 index 00000000000..4cc832b90eb --- /dev/null +++ b/api/datadogV2/model_container_type.go @@ -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" +) + +// ContainerType Type of container. +type ContainerType string + +// List of ContainerType. +const ( + CONTAINERTYPE_CONTAINER ContainerType = "container" +) + +var allowedContainerTypeEnumValues = []ContainerType{ + CONTAINERTYPE_CONTAINER, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ContainerType) GetAllowedValues() []ContainerType { + return allowedContainerTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ContainerType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ContainerType(value) + return nil +} + +// NewContainerTypeFromValue returns a pointer to a valid ContainerType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewContainerTypeFromValue(v string) (*ContainerType, error) { + ev := ContainerType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ContainerType: valid values are %v", v, allowedContainerTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ContainerType) IsValid() bool { + for _, existing := range allowedContainerTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ContainerType value. +func (v ContainerType) Ptr() *ContainerType { + return &v +} diff --git a/api/datadogV2/model_containers_response.go b/api/datadogV2/model_containers_response.go new file mode 100644 index 00000000000..dd9c506899f --- /dev/null +++ b/api/datadogV2/model_containers_response.go @@ -0,0 +1,186 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainersResponse List of containers. +type ContainersResponse struct { + // Array of Container objects. + Data []ContainerItem `json:"data,omitempty"` + // Pagination links. + Links *ContainersResponseLinks `json:"links,omitempty"` + // Response metadata object. + Meta *ContainerMeta `json:"meta,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{} +} + +// NewContainersResponse instantiates a new ContainersResponse 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 NewContainersResponse() *ContainersResponse { + this := ContainersResponse{} + return &this +} + +// NewContainersResponseWithDefaults instantiates a new ContainersResponse 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 NewContainersResponseWithDefaults() *ContainersResponse { + this := ContainersResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ContainersResponse) GetData() []ContainerItem { + if o == nil || o.Data == nil { + var ret []ContainerItem + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainersResponse) GetDataOk() (*[]ContainerItem, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return &o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ContainersResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []ContainerItem and assigns it to the Data field. +func (o *ContainersResponse) SetData(v []ContainerItem) { + o.Data = v +} + +// GetLinks returns the Links field value if set, zero value otherwise. +func (o *ContainersResponse) GetLinks() ContainersResponseLinks { + if o == nil || o.Links == nil { + var ret ContainersResponseLinks + return ret + } + return *o.Links +} + +// GetLinksOk returns a tuple with the Links field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainersResponse) GetLinksOk() (*ContainersResponseLinks, bool) { + if o == nil || o.Links == nil { + return nil, false + } + return o.Links, true +} + +// HasLinks returns a boolean if a field has been set. +func (o *ContainersResponse) HasLinks() bool { + return o != nil && o.Links != nil +} + +// SetLinks gets a reference to the given ContainersResponseLinks and assigns it to the Links field. +func (o *ContainersResponse) SetLinks(v ContainersResponseLinks) { + o.Links = &v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *ContainersResponse) GetMeta() ContainerMeta { + if o == nil || o.Meta == nil { + var ret ContainerMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainersResponse) GetMetaOk() (*ContainerMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *ContainersResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given ContainerMeta and assigns it to the Meta field. +func (o *ContainersResponse) SetMeta(v ContainerMeta) { + o.Meta = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainersResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Links != nil { + toSerialize["links"] = o.Links + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainersResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []ContainerItem `json:"data,omitempty"` + Links *ContainersResponseLinks `json:"links,omitempty"` + Meta *ContainerMeta `json:"meta,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "links", "meta"}) + } else { + return err + } + + hasInvalidField := false + o.Data = all.Data + if all.Links != nil && all.Links.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Links = all.Links + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_containers_response_links.go b/api/datadogV2/model_containers_response_links.go new file mode 100644 index 00000000000..f0ff35b07dd --- /dev/null +++ b/api/datadogV2/model_containers_response_links.go @@ -0,0 +1,220 @@ +// 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 ( + "github.com/goccy/go-json" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ContainersResponseLinks Pagination links. +type ContainersResponseLinks struct { + // Link to the first page. + First *string `json:"first,omitempty"` + // Link to the next page. + Next *string `json:"next,omitempty"` + // Link to previous page. + Prev datadog.NullableString `json:"prev,omitempty"` + // Link to current page. + Self *string `json:"self,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{} +} + +// NewContainersResponseLinks instantiates a new ContainersResponseLinks 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 NewContainersResponseLinks() *ContainersResponseLinks { + this := ContainersResponseLinks{} + return &this +} + +// NewContainersResponseLinksWithDefaults instantiates a new ContainersResponseLinks 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 NewContainersResponseLinksWithDefaults() *ContainersResponseLinks { + this := ContainersResponseLinks{} + return &this +} + +// GetFirst returns the First field value if set, zero value otherwise. +func (o *ContainersResponseLinks) GetFirst() string { + if o == nil || o.First == nil { + var ret string + return ret + } + return *o.First +} + +// GetFirstOk returns a tuple with the First field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainersResponseLinks) GetFirstOk() (*string, bool) { + if o == nil || o.First == nil { + return nil, false + } + return o.First, true +} + +// HasFirst returns a boolean if a field has been set. +func (o *ContainersResponseLinks) HasFirst() bool { + return o != nil && o.First != nil +} + +// SetFirst gets a reference to the given string and assigns it to the First field. +func (o *ContainersResponseLinks) SetFirst(v string) { + o.First = &v +} + +// GetNext returns the Next field value if set, zero value otherwise. +func (o *ContainersResponseLinks) GetNext() string { + if o == nil || o.Next == nil { + var ret string + return ret + } + return *o.Next +} + +// GetNextOk returns a tuple with the Next field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainersResponseLinks) GetNextOk() (*string, bool) { + if o == nil || o.Next == nil { + return nil, false + } + return o.Next, true +} + +// HasNext returns a boolean if a field has been set. +func (o *ContainersResponseLinks) HasNext() bool { + return o != nil && o.Next != nil +} + +// SetNext gets a reference to the given string and assigns it to the Next field. +func (o *ContainersResponseLinks) SetNext(v string) { + o.Next = &v +} + +// GetPrev returns the Prev field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ContainersResponseLinks) GetPrev() string { + if o == nil || o.Prev.Get() == nil { + var ret string + return ret + } + return *o.Prev.Get() +} + +// GetPrevOk returns a tuple with the Prev 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 *ContainersResponseLinks) GetPrevOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Prev.Get(), o.Prev.IsSet() +} + +// HasPrev returns a boolean if a field has been set. +func (o *ContainersResponseLinks) HasPrev() bool { + return o != nil && o.Prev.IsSet() +} + +// SetPrev gets a reference to the given datadog.NullableString and assigns it to the Prev field. +func (o *ContainersResponseLinks) SetPrev(v string) { + o.Prev.Set(&v) +} + +// SetPrevNil sets the value for Prev to be an explicit nil. +func (o *ContainersResponseLinks) SetPrevNil() { + o.Prev.Set(nil) +} + +// UnsetPrev ensures that no value is present for Prev, not even an explicit nil. +func (o *ContainersResponseLinks) UnsetPrev() { + o.Prev.Unset() +} + +// GetSelf returns the Self field value if set, zero value otherwise. +func (o *ContainersResponseLinks) GetSelf() string { + if o == nil || o.Self == nil { + var ret string + return ret + } + return *o.Self +} + +// GetSelfOk returns a tuple with the Self field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ContainersResponseLinks) GetSelfOk() (*string, bool) { + if o == nil || o.Self == nil { + return nil, false + } + return o.Self, true +} + +// HasSelf returns a boolean if a field has been set. +func (o *ContainersResponseLinks) HasSelf() bool { + return o != nil && o.Self != nil +} + +// SetSelf gets a reference to the given string and assigns it to the Self field. +func (o *ContainersResponseLinks) SetSelf(v string) { + o.Self = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ContainersResponseLinks) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.First != nil { + toSerialize["first"] = o.First + } + if o.Next != nil { + toSerialize["next"] = o.Next + } + if o.Prev.IsSet() { + toSerialize["prev"] = o.Prev.Get() + } + if o.Self != nil { + toSerialize["self"] = o.Self + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ContainersResponseLinks) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + First *string `json:"first,omitempty"` + Next *string `json:"next,omitempty"` + Prev datadog.NullableString `json:"prev,omitempty"` + Self *string `json:"self,omitempty"` + }{} + if err = json.Unmarshal(bytes, &all); err != nil { + return json.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = json.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"first", "next", "prev", "self"}) + } else { + return err + } + o.First = all.First + o.Next = all.Next + o.Prev = all.Prev + o.Self = all.Self + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/containers/ListContainers.go b/examples/v2/containers/ListContainers.go new file mode 100644 index 00000000000..cb4a334f993 --- /dev/null +++ b/examples/v2/containers/ListContainers.go @@ -0,0 +1,30 @@ +// Get All Containers returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListContainers", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewContainersApi(apiClient) + resp, r, err := api.ListContainers(ctx, *datadogV2.NewListContainersOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ContainersApi.ListContainers`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ContainersApi.ListContainers`:\n%s\n", responseContent) +} diff --git a/examples/v2/containers/ListContainers_2175733917.go b/examples/v2/containers/ListContainers_2175733917.go new file mode 100644 index 00000000000..c67ebe02a9d --- /dev/null +++ b/examples/v2/containers/ListContainers_2175733917.go @@ -0,0 +1,30 @@ +// Get All Container groups returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListContainers", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewContainersApi(apiClient) + resp, r, err := api.ListContainers(ctx, *datadogV2.NewListContainersOptionalParameters().WithGroupBy("short_image")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ContainersApi.ListContainers`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ContainersApi.ListContainers`:\n%s\n", responseContent) +} diff --git a/examples/v2/containers/ListContainers_931009654.go b/examples/v2/containers/ListContainers_931009654.go new file mode 100644 index 00000000000..9a1ac08e9b5 --- /dev/null +++ b/examples/v2/containers/ListContainers_931009654.go @@ -0,0 +1,30 @@ +// Get All Containers returns "OK" response with pagination + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListContainers", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewContainersApi(apiClient) + resp, _ := api.ListContainersWithPagination(ctx, *datadogV2.NewListContainersOptionalParameters().WithPageSize(2)) + + for paginationResult := range resp { + if paginationResult.Error != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ContainersApi.ListContainers`: %v\n", paginationResult.Error) + } + responseContent, _ := json.MarshalIndent(paginationResult.Item, "", " ") + fmt.Fprintf(os.Stdout, "%s\n", responseContent) + } +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index b4efabc0a5a..097c4a86f46 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -52,6 +52,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "CIVisibilityPipelinesApi": reflect.ValueOf(datadogV2.NewCIVisibilityPipelinesApi), "CIVisibilityTestsApi": reflect.ValueOf(datadogV2.NewCIVisibilityTestsApi), "ContainerImagesApi": reflect.ValueOf(datadogV2.NewContainerImagesApi), + "ContainersApi": reflect.ValueOf(datadogV2.NewContainersApi), "DashboardListsApi": reflect.ValueOf(datadogV2.NewDashboardListsApi), "DowntimesApi": reflect.ValueOf(datadogV2.NewDowntimesApi), "EventsApi": reflect.ValueOf(datadogV2.NewEventsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Container_groups_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Container_groups_returns_OK_response.freeze new file mode 100644 index 00000000000..64db214f9ed --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Container_groups_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-10-16T15:58:19.882Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Container_groups_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Container_groups_returns_OK_response.yaml new file mode 100644 index 00000000000..01233ebe0bc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Container_groups_returns_OK_response.yaml @@ -0,0 +1,270 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/containers?group_by=short_image + response: + body: '{"data": [{"type": "container_group", "id": "test_id", "attributes": {"count": + 123, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}, {"type": "container_group", "id": "test_id", "attributes": {"count": + 1, "tags": {"short_image": "test_short_image"}}, "relationships": {"containers": + {"links": {"related": "test_related"}, "data": []}}}, {"type": "container_group", + "id": "test_id", "attributes": {"count": 1, "tags": {"short_image": "test_short_image"}}, + "relationships": {"containers": {"links": {"related": "test_related"}, "data": + []}}}], "meta": {"pagination": {"cursor": "", "prev_cursor": null, "next_cursor": + "", "limit": 100, "type": "cursor_limit", "total": 0}}, "links": {"self": "https://api.datadoghq.com/api/v2/containers?group_by=short_image", + "last": null, "next": null, "prev": null, "first": "https://api.datadoghq.com/api/v2/containers?group_by=short_image&page[size]=100"}}' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response.freeze new file mode 100644 index 00000000000..019c60dd87f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-10-16T15:45:21.038Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response.yaml new file mode 100644 index 00000000000..fd1fcb79640 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/containers + response: + body: '{"data":[{"type":"container","id":"15e90400bf66f26f4e7d3098406c30e11e2bc921","attributes":{"name":"test_name","created_at":"2023-10-12T13:46:51","started_at":"2023-10-12T13:46:51","state":"running","container_id":"22f5bcc1-492a-435c-6d45-889e","host":"compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","image_name":"","image_tags":null,"image_digest":null,"tags":["app_guid:c3e77ef9-1248-4ef8-aa75-9bf063ad1512","app_id:c3e77ef9-1248-4ef8-aa75-9bf063ad1512","app_instance_guid:22f5bcc1-492a-435c-6d45-889e","app_instance_index:0","app_name:go-sample-app-modebeige","bosh_address:10.0.4.8","bosh_az:us-central1-f","bosh_deployment:cf-df4d3b7647b663c19610","bosh_id:6c2718cc-dfd1-4768-9237-08132d11122f","bosh_index:0","bosh_ip:10.0.4.8","bosh_job:compute","bosh_name:compute","cf-df4d3b7647b663c19610","cf-df4d3b7647b663c19610-compute","cloudfoundry","compute","container_name:go-sample-app-modebeige_0","created_at:2023-10-09t08:30:42z","deployment:cf-df4d3b7647b663c19610","director:p-bosh","env:pcf-modebeige","foo:bar","host:compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","id:6c2718cc-dfd1-4768-9237-08132d11122f","index:0","index:6c2718cc-dfd1-4768-9237-08132d11122f","instance-id:3340011639055189196","instance-type:n1-highmem-2","instance_group:compute","internal-hostname:vm-6dd9ae88-c203-463e-580e-26a7b561b870.c.cf-platform-engineering-cipp2.internal","ip:10.0.4.8","job:compute","label_key:label_value","metadata_key:metadata_value","name:compute/6c2718cc-dfd1-4768-9237-08132d11122f","numeric_project_id:946413340424","org_id:9f4bffd9-6234-49dd-bc4e-d0282a7cf333","org_name:Org + 1","p-bosh","p-bosh-cf-df4d3b7647b663c19610","p-bosh-cf-df4d3b7647b663c19610-compute","pcf-modebeige","project:cf-platform-engineering-cipp2","service:go-sample-app-modebeige","sidecar_count:1","sidecar_present:true","space_id:6c41b5e8-8ed8-465f-902a-48e03b465ffe","space_name:Space + 1","user_data:_server_:_name_:_vm-6dd9ae88-c203-463e-580e-26a7b561b870_registry_:_endpoint_:_://:_:0_dns_:_nameserver_:_8.8.8.8","version:1.0.0","zone:us-central1-f"]}},{"type":"container","id":"15e90400f5a7fd8072ebcc2e7eadb58c7acf1fe6","attributes":{"name":"python-sample-app-modebeige_0","created_at":"2023-10-12T13:46:51","started_at":"2023-10-12T13:46:51","state":"running","container_id":"288bdf1c-ee25-43a2-6470-11e0","host":"compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","image_name":"","image_tags":null,"image_digest":null,"tags":["app_guid:3d575664-cced-4000-b2fd-2ab4199722c7","app_id:3d575664-cced-4000-b2fd-2ab4199722c7","app_instance_guid:288bdf1c-ee25-43a2-6470-11e0","app_instance_index:0","app_name:python-sample-app-modebeige","bosh_address:10.0.4.8","bosh_az:us-central1-f","bosh_deployment:cf-df4d3b7647b663c19610","bosh_id:6c2718cc-dfd1-4768-9237-08132d11122f","bosh_index:0","bosh_ip:10.0.4.8","bosh_job:compute","bosh_name:compute","cf-df4d3b7647b663c19610","cf-df4d3b7647b663c19610-compute","cloudfoundry","compute","container_name:python-sample-app-modebeige_0","created_at:2023-10-09t08:30:42z","deployment:cf-df4d3b7647b663c19610","director:p-bosh","env:pcf-modebeige","foo:bar","host:compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","id:6c2718cc-dfd1-4768-9237-08132d11122f","index:0","index:6c2718cc-dfd1-4768-9237-08132d11122f","instance-id:3340011639055189196","instance-type:n1-highmem-2","instance_group:compute","internal-hostname:vm-6dd9ae88-c203-463e-580e-26a7b561b870.c.cf-platform-engineering-cipp2.internal","ip:10.0.4.8","job:compute","label_key:label_value","metadata_key:metadata_value","name:compute/6c2718cc-dfd1-4768-9237-08132d11122f","numeric_project_id:946413340424","org_id:9f4bffd9-6234-49dd-bc4e-d0282a7cf333","org_name:Org + 1","p-bosh","p-bosh-cf-df4d3b7647b663c19610","p-bosh-cf-df4d3b7647b663c19610-compute","pcf-modebeige","project:cf-platform-engineering-cipp2","service:python-sample-app-modebeige","sidecar_count:1","sidecar_present:true","space_id:6c41b5e8-8ed8-465f-902a-48e03b465ffe","space_name:Space + 1","user_data:_server_:_name_:_vm-6dd9ae88-c203-463e-580e-26a7b561b870_registry_:_endpoint_:_://:_:0_dns_:_nameserver_:_8.8.8.8","version:1.0.0","zone:us-central1-f"]}}],"meta":{"pagination":{"cursor":"","prev_cursor":null,"next_cursor":"c3RhcnRlZDoxNjk3NDY2MDI4MDAwLjAwMDAwMHxpZC5yYXc6M2U0MTU3ZjgtZjdmNC00OTdjLTRmNWMtMzk0Zg==","limit":1000,"type":"cursor_limit","total":10}},"links":{"self":"https://api.datadoghq.com/api/v2/containers","last":null,"next":"https://api.datadoghq.com/api/v2/containers?page[cursor]=c3RhcnRlZDoxNjk3NDY2MDI4MDAwLjAwMDAwMHxpZC5yYXc6M2U0MTU3ZjgtZjdmNC00OTdjLTRmNWMtMzk0Zg==&page[size]=1000","prev":null,"first":"https://api.datadoghq.com/api/v2/containers?page[size]=1000"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response_with_pagination.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response_with_pagination.freeze new file mode 100644 index 00000000000..0b92c13bb49 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response_with_pagination.freeze @@ -0,0 +1 @@ +2023-10-16T16:01:59.143Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response_with_pagination.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response_with_pagination.yaml new file mode 100644 index 00000000000..ecc89c6b119 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Containers/Scenario_Get_All_Containers_returns_OK_response_with_pagination.yaml @@ -0,0 +1,44 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/containers?page%5Bsize%5D=2 + response: + body: '{"data":[{"type":"container","id":"15e90400bf66f26f4e7d3098406c30e11e2bc921","attributes":{"name":"go-sample-app-modebeige_0","created_at":"2023-10-12T13:46:51","started_at":"2023-10-12T13:46:51","state":"running","container_id":"22f5bcc1-492a-435c-6d45-889e","host":"compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","image_name":"","image_tags":null,"image_digest":null,"tags":["app_guid:c3e77ef9-1248-4ef8-aa75-9bf063ad1512","app_id:c3e77ef9-1248-4ef8-aa75-9bf063ad1512","app_instance_guid:22f5bcc1-492a-435c-6d45-889e","app_instance_index:0","app_name:go-sample-app-modebeige","bosh_address:10.0.4.8","bosh_az:us-central1-f","bosh_deployment:cf-df4d3b7647b663c19610","bosh_id:6c2718cc-dfd1-4768-9237-08132d11122f","bosh_index:0","bosh_ip:10.0.4.8","bosh_job:compute","bosh_name:compute","cf-df4d3b7647b663c19610","cf-df4d3b7647b663c19610-compute","cloudfoundry","compute","container_name:go-sample-app-modebeige_0","created_at:2023-10-09t08:30:42z","deployment:cf-df4d3b7647b663c19610","director:p-bosh","env:pcf-modebeige","foo:bar","host:compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","id:6c2718cc-dfd1-4768-9237-08132d11122f","index:0","index:6c2718cc-dfd1-4768-9237-08132d11122f","instance-id:3340011639055189196","instance-type:n1-highmem-2","instance_group:compute","internal-hostname:vm-6dd9ae88-c203-463e-580e-26a7b561b870.c.cf-platform-engineering-cipp2.internal","ip:10.0.4.8","job:compute","label_key:label_value","metadata_key:metadata_value","name:compute/6c2718cc-dfd1-4768-9237-08132d11122f","numeric_project_id:946413340424","org_id:9f4bffd9-6234-49dd-bc4e-d0282a7cf333","org_name:Org + 1","p-bosh","p-bosh-cf-df4d3b7647b663c19610","p-bosh-cf-df4d3b7647b663c19610-compute","pcf-modebeige","project:cf-platform-engineering-cipp2","service:go-sample-app-modebeige","sidecar_count:1","sidecar_present:true","space_id:6c41b5e8-8ed8-465f-902a-48e03b465ffe","space_name:Space + 1","user_data:_server_:_name_:_vm-6dd9ae88-c203-463e-580e-26a7b561b870_registry_:_endpoint_:_://:_:0_dns_:_nameserver_:_8.8.8.8","version:1.0.0","zone:us-central1-f"]}},{"type":"container","id":"15e90400f5a7fd8072ebcc2e7eadb58c7acf1fe6","attributes":{"name":"python-sample-app-modebeige_0","created_at":"2023-10-12T13:46:51","started_at":"2023-10-12T13:46:51","state":"running","container_id":"288bdf1c-ee25-43a2-6470-11e0","host":"compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","image_name":"","image_tags":null,"image_digest":null,"tags":["app_guid:3d575664-cced-4000-b2fd-2ab4199722c7","app_id:3d575664-cced-4000-b2fd-2ab4199722c7","app_instance_guid:288bdf1c-ee25-43a2-6470-11e0","app_instance_index:0","app_name:python-sample-app-modebeige","bosh_address:10.0.4.8","bosh_az:us-central1-f","bosh_deployment:cf-df4d3b7647b663c19610","bosh_id:6c2718cc-dfd1-4768-9237-08132d11122f","bosh_index:0","bosh_ip:10.0.4.8","bosh_job:compute","bosh_name:compute","cf-df4d3b7647b663c19610","cf-df4d3b7647b663c19610-compute","cloudfoundry","compute","container_name:python-sample-app-modebeige_0","created_at:2023-10-09t08:30:42z","deployment:cf-df4d3b7647b663c19610","director:p-bosh","env:pcf-modebeige","foo:bar","host:compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","id:6c2718cc-dfd1-4768-9237-08132d11122f","index:0","index:6c2718cc-dfd1-4768-9237-08132d11122f","instance-id:3340011639055189196","instance-type:n1-highmem-2","instance_group:compute","internal-hostname:vm-6dd9ae88-c203-463e-580e-26a7b561b870.c.cf-platform-engineering-cipp2.internal","ip:10.0.4.8","job:compute","label_key:label_value","metadata_key:metadata_value","name:compute/6c2718cc-dfd1-4768-9237-08132d11122f","numeric_project_id:946413340424","org_id:9f4bffd9-6234-49dd-bc4e-d0282a7cf333","org_name:Org + 1","p-bosh","p-bosh-cf-df4d3b7647b663c19610","p-bosh-cf-df4d3b7647b663c19610-compute","pcf-modebeige","project:cf-platform-engineering-cipp2","service:python-sample-app-modebeige","sidecar_count:1","sidecar_present:true","space_id:6c41b5e8-8ed8-465f-902a-48e03b465ffe","space_name:Space + 1","user_data:_server_:_name_:_vm-6dd9ae88-c203-463e-580e-26a7b561b870_registry_:_endpoint_:_://:_:0_dns_:_nameserver_:_8.8.8.8","version:1.0.0","zone:us-central1-f"]}}],"meta":{"pagination":{"cursor":"","prev_cursor":null,"next_cursor":"c3RhcnRlZDoxNjk3MTE4NDExMDAwLjAwMDAwMHxpZC5yYXc6Mjg4YmRmMWMtZWUyNS00M2EyLTY0NzAtMTFlMA==","limit":2,"type":"cursor_limit","total":10}},"links":{"self":"https://api.datadoghq.com/api/v2/containers?page%5Bsize%5D=2","last":null,"next":"https://api.datadoghq.com/api/v2/containers?page[cursor]=c3RhcnRlZDoxNjk3MTE4NDExMDAwLjAwMDAwMHxpZC5yYXc6Mjg4YmRmMWMtZWUyNS00M2EyLTY0NzAtMTFlMA==&page[size]=2","prev":null,"first":"https://api.datadoghq.com/api/v2/containers?page[size]=2"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v2/containers?page%5Bsize%5D=2&page%5Bcursor%5D=c3RhcnRlZDoxNjk3MTE4NDExMDAwLjAwMDAwMHxpZC5yYXc6Mjg4YmRmMWMtZWUyNS00M2EyLTY0NzAtMTFlMA%3D%3D + response: + body: '{"data":[{"type":"container","id":"15e90400d72ce956da898384526fb3411a96ac48","attributes":{"name":"java-sample-app-modebeige_0","created_at":"2023-10-12T13:46:51","started_at":"2023-10-12T13:46:51","state":"running","container_id":"5b2a80d0-da17-4e9b-4260-d0e1","host":"compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","image_name":"","image_tags":null,"image_digest":null,"tags":["app_guid:cda17465-f9b8-4577-b53a-57a161a1326b","app_id:cda17465-f9b8-4577-b53a-57a161a1326b","app_instance_guid:5b2a80d0-da17-4e9b-4260-d0e1","app_instance_index:0","app_name:java-sample-app-modebeige","bosh_address:10.0.4.8","bosh_az:us-central1-f","bosh_deployment:cf-df4d3b7647b663c19610","bosh_id:6c2718cc-dfd1-4768-9237-08132d11122f","bosh_index:0","bosh_ip:10.0.4.8","bosh_job:compute","bosh_name:compute","cf-df4d3b7647b663c19610","cf-df4d3b7647b663c19610-compute","cloudfoundry","compute","container_name:java-sample-app-modebeige_0","created_at:2023-10-09t08:30:42z","deployment:cf-df4d3b7647b663c19610","director:p-bosh","env:pcf-modebeige","foo:bar","host:compute-0-6c2718cc-dfd1-4768-9237-08132d11122f","id:6c2718cc-dfd1-4768-9237-08132d11122f","index:0","index:6c2718cc-dfd1-4768-9237-08132d11122f","instance-id:3340011639055189196","instance-type:n1-highmem-2","instance_group:compute","internal-hostname:vm-6dd9ae88-c203-463e-580e-26a7b561b870.c.cf-platform-engineering-cipp2.internal","ip:10.0.4.8","job:compute","label_key:label_value","metadata_key:metadata_value","name:compute/6c2718cc-dfd1-4768-9237-08132d11122f","numeric_project_id:946413340424","org_id:9f4bffd9-6234-49dd-bc4e-d0282a7cf333","org_name:Org + 1","p-bosh","p-bosh-cf-df4d3b7647b663c19610","p-bosh-cf-df4d3b7647b663c19610-compute","pcf-modebeige","project:cf-platform-engineering-cipp2","service:java-sample-app-modebeige","sidecar_count:1","sidecar_present:true","space_id:6c41b5e8-8ed8-465f-902a-48e03b465ffe","space_name:Space + 1","user_data:_server_:_name_:_vm-6dd9ae88-c203-463e-580e-26a7b561b870_registry_:_endpoint_:_://:_:0_dns_:_nameserver_:_8.8.8.8","version:1.0.0","zone:us-central1-f"]}}],"meta":{"pagination":{"cursor":"c3RhcnRlZDoxNjk3MTE4NDExMDAwLjAwMDAwMHxpZC5yYXc6Mjg4YmRmMWMtZWUyNS00M2EyLTY0NzAtMTFlMA==","prev_cursor":null,"next_cursor":"c3RhcnRlZDoxNjk3MTE4NDExMDAwLjAwMDAwMHxpZC5yYXc6ODY4OWY2ODUtZTQ0MS00ODJjLTYwNDMtNWQ5ZA==","limit":2,"type":"cursor_limit","total":10}},"links":{"self":"https://api.datadoghq.com/api/v2/containers?page%5Bsize%5D=2&page%5Bcursor%5D=c3RhcnRlZDoxNjk3MTE4NDExMDAwLjAwMDAwMHxpZC5yYXc6Mjg4YmRmMWMtZWUyNS00M2EyLTY0NzAtMTFlMA%3D%3D","last":null,"next":"https://api.datadoghq.com/api/v2/containers?page[cursor]=c3RhcnRlZDoxNjk3MTE4NDExMDAwLjAwMDAwMHxpZC5yYXc6ODY4OWY2ODUtZTQ0MS00ODJjLTYwNDMtNWQ5ZA==&page[size]=2","prev":null,"first":"https://api.datadoghq.com/api/v2/containers?page[size]=2"}} + + ' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/features/v2/containers.feature b/tests/scenarios/features/v2/containers.feature new file mode 100644 index 00000000000..42625b9e039 --- /dev/null +++ b/tests/scenarios/features/v2/containers.feature @@ -0,0 +1,36 @@ +@endpoint(containers) @endpoint(containers-v2) +Feature: Containers + The Containers API allows you to query container data for your + organization. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Containers" API + And operation "ListContainers" enabled + And new "ListContainers" request + + @replay-only @team:DataDog/processes + Scenario: Get All Container groups returns "OK" response + Given request contains "group_by" parameter with value "short_image" + When the request is sent + Then the response status is 200 OK + And the response "data[0].attributes.count" is equal to 123 + + @generated @skip @team:DataDog/processes + Scenario: Get All Containers returns "Bad Request" response + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/processes + Scenario: Get All Containers returns "OK" response + When the request is sent + Then the response status is 200 OK + And the response "data[0].attributes.name" is equal to "test_name" + + @replay-only @skip-validation @team:DataDog/processes @with-pagination + Scenario: Get All Containers returns "OK" response with pagination + Given request contains "page[size]" parameter with value 2 + When the request with pagination is sent + Then the response status is 200 OK + And the response has 3 items diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 60e785f3bdf..58eb5421def 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -237,6 +237,12 @@ "type": "safe" } }, + "ListContainers": { + "tag": "Containers", + "undo": { + "type": "safe" + } + }, "ListCurrentUserApplicationKeys": { "tag": "Key Management", "undo": {