From f44a84bd646ccf4720c95991197d5164a0854667 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 08:14:54 +0000 Subject: [PATCH 1/4] Regenerate client from commit a73013e of spec repo (#4209) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 457 ++++++++++++++ api/datadog/configuration.go | 1 + api/datadogV2/api_dashboard_sharing.go | 121 ++++ api/datadogV2/doc.go | 1 + .../model_list_shared_dashboards_response.go | 133 ++++ .../model_shared_dashboard_included.go | 105 ++++ ...del_shared_dashboard_included_dashboard.go | 180 ++++++ ...dashboard_included_dashboard_attributes.go | 101 +++ ...hared_dashboard_included_dashboard_type.go | 64 ++ .../model_shared_dashboard_included_user.go | 180 ++++++ ...ared_dashboard_included_user_attributes.go | 133 ++++ .../model_shared_dashboard_invitee.go | 172 ++++++ ...shared_dashboard_relationship_dashboard.go | 110 ++++ ...d_dashboard_relationship_dashboard_data.go | 145 +++++ ...el_shared_dashboard_relationship_sharer.go | 110 ++++ .../model_shared_dashboard_relationships.go | 145 +++++ .../model_shared_dashboard_response.go | 215 +++++++ ...el_shared_dashboard_response_attributes.go | 579 ++++++++++++++++++ ..._dashboard_selectable_template_variable.go | 261 ++++++++ .../model_shared_dashboard_share_type.go | 70 +++ .../model_shared_dashboard_status.go | 66 ++ api/datadogV2/model_shared_dashboard_type.go | 64 ++ ...el_shared_dashboard_viewing_preferences.go | 143 +++++ ...red_dashboard_viewing_preferences_theme.go | 68 ++ .../ListSharedDashboardsByDashboardId.go | 30 + tests/scenarios/api_mappings.go | 1 + .../features/v2/dashboard_sharing.feature | 22 + tests/scenarios/features/v2/undo.json | 6 + 28 files changed, 3683 insertions(+) create mode 100644 api/datadogV2/api_dashboard_sharing.go create mode 100644 api/datadogV2/model_list_shared_dashboards_response.go create mode 100644 api/datadogV2/model_shared_dashboard_included.go create mode 100644 api/datadogV2/model_shared_dashboard_included_dashboard.go create mode 100644 api/datadogV2/model_shared_dashboard_included_dashboard_attributes.go create mode 100644 api/datadogV2/model_shared_dashboard_included_dashboard_type.go create mode 100644 api/datadogV2/model_shared_dashboard_included_user.go create mode 100644 api/datadogV2/model_shared_dashboard_included_user_attributes.go create mode 100644 api/datadogV2/model_shared_dashboard_invitee.go create mode 100644 api/datadogV2/model_shared_dashboard_relationship_dashboard.go create mode 100644 api/datadogV2/model_shared_dashboard_relationship_dashboard_data.go create mode 100644 api/datadogV2/model_shared_dashboard_relationship_sharer.go create mode 100644 api/datadogV2/model_shared_dashboard_relationships.go create mode 100644 api/datadogV2/model_shared_dashboard_response.go create mode 100644 api/datadogV2/model_shared_dashboard_response_attributes.go create mode 100644 api/datadogV2/model_shared_dashboard_selectable_template_variable.go create mode 100644 api/datadogV2/model_shared_dashboard_share_type.go create mode 100644 api/datadogV2/model_shared_dashboard_status.go create mode 100644 api/datadogV2/model_shared_dashboard_type.go create mode 100644 api/datadogV2/model_shared_dashboard_viewing_preferences.go create mode 100644 api/datadogV2/model_shared_dashboard_viewing_preferences_theme.go create mode 100644 examples/v2/dashboard-sharing/ListSharedDashboardsByDashboardId.go create mode 100644 tests/scenarios/features/v2/dashboard_sharing.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index bf25604f04a..6c36643fc41 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1758,6 +1758,14 @@ components: schema: example: "my-service" type: string + SharedDashboardDashboardIDPathParameter: + description: ID of the dashboard. + in: path + name: dashboard_id + required: true + schema: + example: abc-def-ghi + type: string SignalID: description: The ID of the signal. in: path @@ -53408,6 +53416,23 @@ components: meta: $ref: "#/components/schemas/ServiceAccessTokenResponseMeta" type: object + ListSharedDashboardsResponse: + description: Response containing shared dashboards for a dashboard. + properties: + data: + description: Shared dashboards for the dashboard. + items: + $ref: "#/components/schemas/SharedDashboardResponse" + type: array + included: + description: Users and dashboards related to the shared dashboards. + items: + $ref: "#/components/schemas/SharedDashboardIncluded" + type: array + required: + - data + - included + type: object ListSourcemapsResponse: description: Response containing a paginated list of source maps. properties: @@ -88122,6 +88147,347 @@ components: required: - type type: object + SharedDashboardGlobalTime: + additionalProperties: {} + description: Default time range configuration for the shared dashboard. + example: + live_span: 1h + nullable: true + type: object + SharedDashboardIncluded: + description: Resource included with a shared dashboard. + oneOf: + - $ref: "#/components/schemas/SharedDashboardIncludedDashboard" + - $ref: "#/components/schemas/SharedDashboardIncludedUser" + SharedDashboardIncludedDashboard: + description: Included dashboard resource. + properties: + attributes: + $ref: "#/components/schemas/SharedDashboardIncludedDashboardAttributes" + id: + description: ID of the dashboard. + example: abc-def-ghi + type: string + type: + $ref: "#/components/schemas/SharedDashboardIncludedDashboardType" + required: + - id + - type + - attributes + type: object + SharedDashboardIncludedDashboardAttributes: + description: Attributes of the included dashboard. + properties: + title: + description: Dashboard title. + example: Q1 Metrics Dashboard + type: string + required: + - title + type: object + SharedDashboardIncludedDashboardType: + default: dashboard + description: Included dashboard resource type. + enum: + - dashboard + example: dashboard + type: string + x-enum-varnames: + - DASHBOARD + SharedDashboardIncludedUser: + description: Included user resource. + properties: + attributes: + $ref: "#/components/schemas/SharedDashboardIncludedUserAttributes" + id: + description: ID of the user. + example: 00000000-0000-0000-0000-000000000000 + type: string + type: + $ref: "#/components/schemas/UserResourceType" + required: + - id + - type + - attributes + type: object + SharedDashboardIncludedUserAttributes: + description: Attributes of the included user. + properties: + handle: + description: User handle. + example: jane.doe@example.com + type: string + name: + description: User display name. + example: Jane Doe + type: string + required: + - handle + - name + type: object + SharedDashboardInvitee: + description: Invitee that can access an invite-only shared dashboard. + properties: + access_expiration: + description: Time when the invitee's access expires. + example: "2026-01-15T09:30:00.000Z" + format: date-time + nullable: true + type: string + created_at: + description: Time when the invitee was added. + example: "2026-01-01T00:00:00.000Z" + format: date-time + type: string + email: + description: Email address of the invitee. + example: jane.doe@example.com + type: string + required: + - email + - access_expiration + - created_at + type: object + SharedDashboardRelationshipDashboard: + description: Dashboard associated with the shared dashboard. + properties: + data: + $ref: "#/components/schemas/SharedDashboardRelationshipDashboardData" + required: + - data + type: object + SharedDashboardRelationshipDashboardData: + description: Dashboard relationship data. + properties: + id: + description: ID of the dashboard. + example: abc-def-ghi + type: string + type: + $ref: "#/components/schemas/SharedDashboardIncludedDashboardType" + required: + - id + - type + type: object + SharedDashboardRelationshipSharer: + description: User who shared the dashboard. + properties: + data: + $ref: "#/components/schemas/UserRelationshipData" + required: + - data + type: object + SharedDashboardRelationships: + description: Relationships of a shared dashboard. + properties: + dashboard: + $ref: "#/components/schemas/SharedDashboardRelationshipDashboard" + sharer: + $ref: "#/components/schemas/SharedDashboardRelationshipSharer" + required: + - dashboard + - sharer + type: object + SharedDashboardResponse: + description: A shared dashboard response resource. + properties: + attributes: + $ref: "#/components/schemas/SharedDashboardResponseAttributes" + id: + description: ID of the shared dashboard. + example: "12345" + type: string + relationships: + $ref: "#/components/schemas/SharedDashboardRelationships" + type: + $ref: "#/components/schemas/SharedDashboardType" + required: + - id + - type + - attributes + - relationships + type: object + SharedDashboardResponseAttributes: + description: Attributes of a shared dashboard response. + properties: + created_at: + description: Time when the shared dashboard was created. + example: "2026-01-01T00:00:00.000Z" + format: date-time + type: string + embeddable_domains: + description: Domains where embed-type shared dashboards can be embedded. + example: ["https://example.com"] + items: + description: An embeddable domain. + type: string + type: array + expiration: + description: Time when the shared dashboard expires. + example: "2026-02-01T00:00:00.000Z" + format: date-time + nullable: true + type: string + global_time: + $ref: "#/components/schemas/SharedDashboardGlobalTime" + global_time_selectable: + description: Whether viewers can select a different global time setting. + example: false + type: boolean + invitees: + description: Invitees for invite-only shared dashboards. + items: + $ref: "#/components/schemas/SharedDashboardInvitee" + type: array + last_accessed: + description: Time when the shared dashboard was last accessed. + example: "2026-01-15T09:30:00.000Z" + format: date-time + nullable: true + type: string + selectable_template_vars: + description: Template variables that viewers can modify. + items: + $ref: "#/components/schemas/SharedDashboardSelectableTemplateVariable" + type: array + share_type: + $ref: "#/components/schemas/SharedDashboardShareType" + sharer_disabled: + description: Whether the user who shared the dashboard is disabled. + example: false + type: boolean + status: + $ref: "#/components/schemas/SharedDashboardStatus" + title: + description: Display title for the shared dashboard. + example: Q1 Metrics Dashboard + type: string + token: + description: Token assigned to the shared dashboard. + example: abc-123-token + type: string + url: + description: URL for the shared dashboard. + example: https://p.datadoghq.com/sb/abc-123-token + type: string + viewing_preferences: + $ref: "#/components/schemas/SharedDashboardViewingPreferences" + required: + - token + - title + - url + - viewing_preferences + - global_time_selectable + - global_time + - selectable_template_vars + - created_at + - last_accessed + - status + - share_type + - invitees + - embeddable_domains + - expiration + - sharer_disabled + type: object + SharedDashboardSelectableTemplateVariable: + description: A template variable that viewers can modify on the shared dashboard. + properties: + allow_any_value: + description: Whether viewers can see all tag values for the template variable and specify any value. + example: false + type: boolean + default_values: + description: Default selected values for the variable. + example: ["prod"] + items: + description: A default value for the template variable. + type: string + type: array + name: + description: Name of the template variable. + example: environment + type: string + prefix: + description: Tag prefix for the variable. + example: env + type: string + type: + description: Type of the template variable. + example: group + type: string + visible_tags: + description: Restricts which tag values are visible to the viewer. + example: ["prod"] + items: + description: A visible tag value for the template variable. + type: string + type: array + required: + - name + - prefix + - type + - allow_any_value + - default_values + - visible_tags + type: object + SharedDashboardShareType: + description: Type of dashboard sharing. + enum: + - open + - invite + - embed + - secure-embed + example: invite + type: string + x-enum-varnames: + - OPEN + - INVITE + - EMBED + - SECURE_EMBED + SharedDashboardStatus: + description: Status of the shared dashboard. + enum: + - active + - paused + example: active + type: string + x-enum-varnames: + - ACTIVE + - PAUSED + SharedDashboardType: + default: shared_dashboard + description: Shared dashboard resource type. + enum: + - shared_dashboard + example: shared_dashboard + type: string + x-enum-varnames: + - SHARED_DASHBOARD + SharedDashboardViewingPreferences: + description: Display settings for the shared dashboard. + properties: + high_density: + description: Whether widgets are displayed in high-density mode. + example: false + type: boolean + theme: + $ref: "#/components/schemas/SharedDashboardViewingPreferencesTheme" + required: + - high_density + - theme + type: object + SharedDashboardViewingPreferencesTheme: + description: The theme of the shared dashboard view. `system` follows the viewer's system default. + enum: + - system + - light + - dark + example: system + type: string + x-enum-varnames: + - SYSTEM + - LIGHT + - DARK Shift: description: An on-call shift with its associated data and relationships. example: @@ -123503,6 +123869,95 @@ paths: tags: - Dashboard Lists x-codegen-request-body-name: body + /api/v2/dashboard/{dashboard_id}/shared: + get: + description: Retrieve shared dashboards associated with the specified dashboard. + operationId: ListSharedDashboardsByDashboardId + parameters: + - $ref: "#/components/parameters/SharedDashboardDashboardIDPathParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + created_at: "2026-01-01T00:00:00.000Z" + embeddable_domains: [] + expiration: + global_time: + live_span: 1h + global_time_selectable: false + invitees: + - access_expiration: + created_at: "2026-01-01T00:00:00.000Z" + email: jane.doe@example.com + last_accessed: + selectable_template_vars: [] + share_type: invite + sharer_disabled: false + status: active + title: Q1 Metrics Dashboard + token: abc-123-token + url: https://p.datadoghq.com/sb/abc-123-token + viewing_preferences: + high_density: false + theme: system + id: "12345" + relationships: + dashboard: + data: + id: abc-def-ghi + type: dashboard + sharer: + data: + id: 00000000-0000-0000-0000-000000000000 + type: user + type: shared_dashboard + included: + - attributes: + title: Q1 Metrics Dashboard + id: abc-def-ghi + type: dashboard + - attributes: + handle: jane.doe@example.com + name: Jane Doe + id: 00000000-0000-0000-0000-000000000000 + type: user + schema: + $ref: "#/components/schemas/ListSharedDashboardsResponse" + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Dashboard Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - dashboards_read + summary: List shared dashboards for a dashboard + tags: + - Dashboard Sharing + "x-permission": + operator: OR + permissions: + - dashboards_read + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/dashboard/{dashboard_id}/shared/secure-embed: post: description: >- @@ -185450,6 +185905,8 @@ tags: - **Embed** sharing must be enabled under **Organization Settings** > **Public Sharing** > **Shared Dashboards**. - You need [an API key and an application key](https://docs.datadoghq.com/account_management/api-app-keys/) to interact with these endpoints. name: Dashboard Secure Embed + - description: Manage dashboard sharing configurations. + name: Dashboard Sharing - description: |- Get usage statistics for the dashboards in your organization, including view counts, last-edit times, widget counts, and quality scores. See the diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index ee05d743a05..b4243d3d375 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -882,6 +882,7 @@ func NewConfiguration() *Configuration { "v2.ListCSMAgentlessHosts": false, "v2.ListCSMUnifiedHostFacets": false, "v2.ListCSMUnifiedHosts": false, + "v2.ListSharedDashboardsByDashboardId": false, "v2.CreateDashboardSecureEmbed": false, "v2.DeleteDashboardSecureEmbed": false, "v2.GetDashboardSecureEmbed": false, diff --git a/api/datadogV2/api_dashboard_sharing.go b/api/datadogV2/api_dashboard_sharing.go new file mode 100644 index 00000000000..32cd2868951 --- /dev/null +++ b/api/datadogV2/api_dashboard_sharing.go @@ -0,0 +1,121 @@ +// 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" +) + +// DashboardSharingApi service type +type DashboardSharingApi datadog.Service + +// ListSharedDashboardsByDashboardId List shared dashboards for a dashboard. +// Retrieve shared dashboards associated with the specified dashboard. +func (a *DashboardSharingApi) ListSharedDashboardsByDashboardId(ctx _context.Context, dashboardId string) (ListSharedDashboardsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ListSharedDashboardsResponse + ) + + operationId := "v2.ListSharedDashboardsByDashboardId" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DashboardSharingApi.ListSharedDashboardsByDashboardId") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/dashboard/{dashboard_id}/shared" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{dashboard_id}", _neturl.PathEscape(datadog.ParameterToString(dashboardId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 403 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + 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 + } + if 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 +} + +// NewDashboardSharingApi Returns NewDashboardSharingApi. +func NewDashboardSharingApi(client *datadog.APIClient) *DashboardSharingApi { + return &DashboardSharingApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 2a9fdf75af8..ed1697bfe5d 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -356,6 +356,7 @@ // - [DashboardSecureEmbedApi.DeleteDashboardSecureEmbed] // - [DashboardSecureEmbedApi.GetDashboardSecureEmbed] // - [DashboardSecureEmbedApi.UpdateDashboardSecureEmbed] +// - [DashboardSharingApi.ListSharedDashboardsByDashboardId] // - [DashboardsApi.GetDashboardUsage] // - [DashboardsApi.ListDashboardsUsage] // - [DataDeletionApi.CancelDataDeletionRequest] diff --git a/api/datadogV2/model_list_shared_dashboards_response.go b/api/datadogV2/model_list_shared_dashboards_response.go new file mode 100644 index 00000000000..5f408fa7464 --- /dev/null +++ b/api/datadogV2/model_list_shared_dashboards_response.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ListSharedDashboardsResponse Response containing shared dashboards for a dashboard. +type ListSharedDashboardsResponse struct { + // Shared dashboards for the dashboard. + Data []SharedDashboardResponse `json:"data"` + // Users and dashboards related to the shared dashboards. + Included []SharedDashboardIncluded `json:"included"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewListSharedDashboardsResponse instantiates a new ListSharedDashboardsResponse 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 NewListSharedDashboardsResponse(data []SharedDashboardResponse, included []SharedDashboardIncluded) *ListSharedDashboardsResponse { + this := ListSharedDashboardsResponse{} + this.Data = data + this.Included = included + return &this +} + +// NewListSharedDashboardsResponseWithDefaults instantiates a new ListSharedDashboardsResponse 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 NewListSharedDashboardsResponseWithDefaults() *ListSharedDashboardsResponse { + this := ListSharedDashboardsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ListSharedDashboardsResponse) GetData() []SharedDashboardResponse { + if o == nil { + var ret []SharedDashboardResponse + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ListSharedDashboardsResponse) GetDataOk() (*[]SharedDashboardResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ListSharedDashboardsResponse) SetData(v []SharedDashboardResponse) { + o.Data = v +} + +// GetIncluded returns the Included field value. +func (o *ListSharedDashboardsResponse) GetIncluded() []SharedDashboardIncluded { + if o == nil { + var ret []SharedDashboardIncluded + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value +// and a boolean to check if the value has been set. +func (o *ListSharedDashboardsResponse) GetIncludedOk() (*[]SharedDashboardIncluded, bool) { + if o == nil { + return nil, false + } + return &o.Included, true +} + +// SetIncluded sets field value. +func (o *ListSharedDashboardsResponse) SetIncluded(v []SharedDashboardIncluded) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ListSharedDashboardsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + toSerialize["included"] = o.Included + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ListSharedDashboardsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]SharedDashboardResponse `json:"data"` + Included *[]SharedDashboardIncluded `json:"included"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + if all.Included == nil { + return fmt.Errorf("required field included missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + o.Data = *all.Data + o.Included = *all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_included.go b/api/datadogV2/model_shared_dashboard_included.go new file mode 100644 index 00000000000..f8beecd62b7 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_included.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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardIncluded - Resource included with a shared dashboard. +type SharedDashboardIncluded struct { + SharedDashboardIncludedDashboard *SharedDashboardIncludedDashboard + SharedDashboardIncludedUser *SharedDashboardIncludedUser + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// SharedDashboardIncludedDashboardAsSharedDashboardIncluded is a convenience function that returns SharedDashboardIncludedDashboard wrapped in SharedDashboardIncluded. +func SharedDashboardIncludedDashboardAsSharedDashboardIncluded(v *SharedDashboardIncludedDashboard) SharedDashboardIncluded { + return SharedDashboardIncluded{SharedDashboardIncludedDashboard: v} +} + +// SharedDashboardIncludedUserAsSharedDashboardIncluded is a convenience function that returns SharedDashboardIncludedUser wrapped in SharedDashboardIncluded. +func SharedDashboardIncludedUserAsSharedDashboardIncluded(v *SharedDashboardIncludedUser) SharedDashboardIncluded { + return SharedDashboardIncluded{SharedDashboardIncludedUser: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *SharedDashboardIncluded) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into SharedDashboardIncludedDashboard + err = datadog.Unmarshal(data, &obj.SharedDashboardIncludedDashboard) + if err == nil { + if obj.SharedDashboardIncludedDashboard != nil && obj.SharedDashboardIncludedDashboard.UnparsedObject == nil { + jsonSharedDashboardIncludedDashboard, _ := datadog.Marshal(obj.SharedDashboardIncludedDashboard) + if string(jsonSharedDashboardIncludedDashboard) == "{}" { // empty struct + obj.SharedDashboardIncludedDashboard = nil + } else { + match++ + } + } else { + obj.SharedDashboardIncludedDashboard = nil + } + } else { + obj.SharedDashboardIncludedDashboard = nil + } + + // try to unmarshal data into SharedDashboardIncludedUser + err = datadog.Unmarshal(data, &obj.SharedDashboardIncludedUser) + if err == nil { + if obj.SharedDashboardIncludedUser != nil && obj.SharedDashboardIncludedUser.UnparsedObject == nil { + jsonSharedDashboardIncludedUser, _ := datadog.Marshal(obj.SharedDashboardIncludedUser) + if string(jsonSharedDashboardIncludedUser) == "{}" { // empty struct + obj.SharedDashboardIncludedUser = nil + } else { + match++ + } + } else { + obj.SharedDashboardIncludedUser = nil + } + } else { + obj.SharedDashboardIncludedUser = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.SharedDashboardIncludedDashboard = nil + obj.SharedDashboardIncludedUser = nil + return datadog.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 SharedDashboardIncluded) MarshalJSON() ([]byte, error) { + if obj.SharedDashboardIncludedDashboard != nil { + return datadog.Marshal(&obj.SharedDashboardIncludedDashboard) + } + + if obj.SharedDashboardIncludedUser != nil { + return datadog.Marshal(&obj.SharedDashboardIncludedUser) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *SharedDashboardIncluded) GetActualInstance() interface{} { + if obj.SharedDashboardIncludedDashboard != nil { + return obj.SharedDashboardIncludedDashboard + } + + if obj.SharedDashboardIncludedUser != nil { + return obj.SharedDashboardIncludedUser + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_included_dashboard.go b/api/datadogV2/model_shared_dashboard_included_dashboard.go new file mode 100644 index 00000000000..396a1ac41f1 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_included_dashboard.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardIncludedDashboard Included dashboard resource. +type SharedDashboardIncludedDashboard struct { + // Attributes of the included dashboard. + Attributes SharedDashboardIncludedDashboardAttributes `json:"attributes"` + // ID of the dashboard. + Id string `json:"id"` + // Included dashboard resource type. + Type SharedDashboardIncludedDashboardType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardIncludedDashboard instantiates a new SharedDashboardIncludedDashboard 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 NewSharedDashboardIncludedDashboard(attributes SharedDashboardIncludedDashboardAttributes, id string, typeVar SharedDashboardIncludedDashboardType) *SharedDashboardIncludedDashboard { + this := SharedDashboardIncludedDashboard{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewSharedDashboardIncludedDashboardWithDefaults instantiates a new SharedDashboardIncludedDashboard 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 NewSharedDashboardIncludedDashboardWithDefaults() *SharedDashboardIncludedDashboard { + this := SharedDashboardIncludedDashboard{} + var typeVar SharedDashboardIncludedDashboardType = SHAREDDASHBOARDINCLUDEDDASHBOARDTYPE_DASHBOARD + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *SharedDashboardIncludedDashboard) GetAttributes() SharedDashboardIncludedDashboardAttributes { + if o == nil { + var ret SharedDashboardIncludedDashboardAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedDashboard) GetAttributesOk() (*SharedDashboardIncludedDashboardAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *SharedDashboardIncludedDashboard) SetAttributes(v SharedDashboardIncludedDashboardAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *SharedDashboardIncludedDashboard) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedDashboard) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *SharedDashboardIncludedDashboard) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *SharedDashboardIncludedDashboard) GetType() SharedDashboardIncludedDashboardType { + if o == nil { + var ret SharedDashboardIncludedDashboardType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedDashboard) GetTypeOk() (*SharedDashboardIncludedDashboardType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SharedDashboardIncludedDashboard) SetType(v SharedDashboardIncludedDashboardType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardIncludedDashboard) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardIncludedDashboard) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SharedDashboardIncludedDashboardAttributes `json:"attributes"` + Id *string `json:"id"` + Type *SharedDashboardIncludedDashboardType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_included_dashboard_attributes.go b/api/datadogV2/model_shared_dashboard_included_dashboard_attributes.go new file mode 100644 index 00000000000..5d05024f3d0 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_included_dashboard_attributes.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardIncludedDashboardAttributes Attributes of the included dashboard. +type SharedDashboardIncludedDashboardAttributes struct { + // Dashboard title. + Title string `json:"title"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardIncludedDashboardAttributes instantiates a new SharedDashboardIncludedDashboardAttributes 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 NewSharedDashboardIncludedDashboardAttributes(title string) *SharedDashboardIncludedDashboardAttributes { + this := SharedDashboardIncludedDashboardAttributes{} + this.Title = title + return &this +} + +// NewSharedDashboardIncludedDashboardAttributesWithDefaults instantiates a new SharedDashboardIncludedDashboardAttributes 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 NewSharedDashboardIncludedDashboardAttributesWithDefaults() *SharedDashboardIncludedDashboardAttributes { + this := SharedDashboardIncludedDashboardAttributes{} + return &this +} + +// GetTitle returns the Title field value. +func (o *SharedDashboardIncludedDashboardAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedDashboardAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *SharedDashboardIncludedDashboardAttributes) SetTitle(v string) { + o.Title = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardIncludedDashboardAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["title"] = o.Title + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardIncludedDashboardAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Title *string `json:"title"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"title"}) + } else { + return err + } + o.Title = *all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_included_dashboard_type.go b/api/datadogV2/model_shared_dashboard_included_dashboard_type.go new file mode 100644 index 00000000000..5c3ba52c6a8 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_included_dashboard_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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardIncludedDashboardType Included dashboard resource type. +type SharedDashboardIncludedDashboardType string + +// List of SharedDashboardIncludedDashboardType. +const ( + SHAREDDASHBOARDINCLUDEDDASHBOARDTYPE_DASHBOARD SharedDashboardIncludedDashboardType = "dashboard" +) + +var allowedSharedDashboardIncludedDashboardTypeEnumValues = []SharedDashboardIncludedDashboardType{ + SHAREDDASHBOARDINCLUDEDDASHBOARDTYPE_DASHBOARD, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SharedDashboardIncludedDashboardType) GetAllowedValues() []SharedDashboardIncludedDashboardType { + return allowedSharedDashboardIncludedDashboardTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SharedDashboardIncludedDashboardType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SharedDashboardIncludedDashboardType(value) + return nil +} + +// NewSharedDashboardIncludedDashboardTypeFromValue returns a pointer to a valid SharedDashboardIncludedDashboardType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSharedDashboardIncludedDashboardTypeFromValue(v string) (*SharedDashboardIncludedDashboardType, error) { + ev := SharedDashboardIncludedDashboardType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SharedDashboardIncludedDashboardType: valid values are %v", v, allowedSharedDashboardIncludedDashboardTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SharedDashboardIncludedDashboardType) IsValid() bool { + for _, existing := range allowedSharedDashboardIncludedDashboardTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SharedDashboardIncludedDashboardType value. +func (v SharedDashboardIncludedDashboardType) Ptr() *SharedDashboardIncludedDashboardType { + return &v +} diff --git a/api/datadogV2/model_shared_dashboard_included_user.go b/api/datadogV2/model_shared_dashboard_included_user.go new file mode 100644 index 00000000000..042ce8794a8 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_included_user.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardIncludedUser Included user resource. +type SharedDashboardIncludedUser struct { + // Attributes of the included user. + Attributes SharedDashboardIncludedUserAttributes `json:"attributes"` + // ID of the user. + Id string `json:"id"` + // User resource type. + Type UserResourceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardIncludedUser instantiates a new SharedDashboardIncludedUser 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 NewSharedDashboardIncludedUser(attributes SharedDashboardIncludedUserAttributes, id string, typeVar UserResourceType) *SharedDashboardIncludedUser { + this := SharedDashboardIncludedUser{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewSharedDashboardIncludedUserWithDefaults instantiates a new SharedDashboardIncludedUser 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 NewSharedDashboardIncludedUserWithDefaults() *SharedDashboardIncludedUser { + this := SharedDashboardIncludedUser{} + var typeVar UserResourceType = USERRESOURCETYPE_USER + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *SharedDashboardIncludedUser) GetAttributes() SharedDashboardIncludedUserAttributes { + if o == nil { + var ret SharedDashboardIncludedUserAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedUser) GetAttributesOk() (*SharedDashboardIncludedUserAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *SharedDashboardIncludedUser) SetAttributes(v SharedDashboardIncludedUserAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *SharedDashboardIncludedUser) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedUser) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *SharedDashboardIncludedUser) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *SharedDashboardIncludedUser) GetType() UserResourceType { + if o == nil { + var ret UserResourceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedUser) GetTypeOk() (*UserResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SharedDashboardIncludedUser) SetType(v UserResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardIncludedUser) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardIncludedUser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SharedDashboardIncludedUserAttributes `json:"attributes"` + Id *string `json:"id"` + Type *UserResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_included_user_attributes.go b/api/datadogV2/model_shared_dashboard_included_user_attributes.go new file mode 100644 index 00000000000..78f2085d81a --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_included_user_attributes.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardIncludedUserAttributes Attributes of the included user. +type SharedDashboardIncludedUserAttributes struct { + // User handle. + Handle string `json:"handle"` + // User display name. + Name string `json:"name"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardIncludedUserAttributes instantiates a new SharedDashboardIncludedUserAttributes 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 NewSharedDashboardIncludedUserAttributes(handle string, name string) *SharedDashboardIncludedUserAttributes { + this := SharedDashboardIncludedUserAttributes{} + this.Handle = handle + this.Name = name + return &this +} + +// NewSharedDashboardIncludedUserAttributesWithDefaults instantiates a new SharedDashboardIncludedUserAttributes 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 NewSharedDashboardIncludedUserAttributesWithDefaults() *SharedDashboardIncludedUserAttributes { + this := SharedDashboardIncludedUserAttributes{} + return &this +} + +// GetHandle returns the Handle field value. +func (o *SharedDashboardIncludedUserAttributes) GetHandle() string { + if o == nil { + var ret string + return ret + } + return o.Handle +} + +// GetHandleOk returns a tuple with the Handle field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedUserAttributes) GetHandleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Handle, true +} + +// SetHandle sets field value. +func (o *SharedDashboardIncludedUserAttributes) SetHandle(v string) { + o.Handle = v +} + +// GetName returns the Name field value. +func (o *SharedDashboardIncludedUserAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardIncludedUserAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *SharedDashboardIncludedUserAttributes) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardIncludedUserAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["handle"] = o.Handle + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardIncludedUserAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Handle *string `json:"handle"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Handle == nil { + return fmt.Errorf("required field handle missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"handle", "name"}) + } else { + return err + } + o.Handle = *all.Handle + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_invitee.go b/api/datadogV2/model_shared_dashboard_invitee.go new file mode 100644 index 00000000000..8b4047e778d --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_invitee.go @@ -0,0 +1,172 @@ +// 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" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardInvitee Invitee that can access an invite-only shared dashboard. +type SharedDashboardInvitee struct { + // Time when the invitee's access expires. + AccessExpiration datadog.NullableTime `json:"access_expiration"` + // Time when the invitee was added. + CreatedAt time.Time `json:"created_at"` + // Email address of the invitee. + Email string `json:"email"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardInvitee instantiates a new SharedDashboardInvitee 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 NewSharedDashboardInvitee(accessExpiration datadog.NullableTime, createdAt time.Time, email string) *SharedDashboardInvitee { + this := SharedDashboardInvitee{} + this.AccessExpiration = accessExpiration + this.CreatedAt = createdAt + this.Email = email + return &this +} + +// NewSharedDashboardInviteeWithDefaults instantiates a new SharedDashboardInvitee 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 NewSharedDashboardInviteeWithDefaults() *SharedDashboardInvitee { + this := SharedDashboardInvitee{} + return &this +} + +// GetAccessExpiration returns the AccessExpiration field value. +// If the value is explicit nil, the zero value for time.Time will be returned. +func (o *SharedDashboardInvitee) GetAccessExpiration() time.Time { + if o == nil || o.AccessExpiration.Get() == nil { + var ret time.Time + return ret + } + return *o.AccessExpiration.Get() +} + +// GetAccessExpirationOk returns a tuple with the AccessExpiration field value +// 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 *SharedDashboardInvitee) GetAccessExpirationOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.AccessExpiration.Get(), o.AccessExpiration.IsSet() +} + +// SetAccessExpiration sets field value. +func (o *SharedDashboardInvitee) SetAccessExpiration(v time.Time) { + o.AccessExpiration.Set(&v) +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *SharedDashboardInvitee) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardInvitee) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *SharedDashboardInvitee) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetEmail returns the Email field value. +func (o *SharedDashboardInvitee) GetEmail() string { + if o == nil { + var ret string + return ret + } + return o.Email +} + +// GetEmailOk returns a tuple with the Email field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardInvitee) GetEmailOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Email, true +} + +// SetEmail sets field value. +func (o *SharedDashboardInvitee) SetEmail(v string) { + o.Email = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardInvitee) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["access_expiration"] = o.AccessExpiration.Get() + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["email"] = o.Email + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardInvitee) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AccessExpiration datadog.NullableTime `json:"access_expiration"` + CreatedAt *time.Time `json:"created_at"` + Email *string `json:"email"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if !all.AccessExpiration.IsSet() { + return fmt.Errorf("required field access_expiration missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.Email == nil { + return fmt.Errorf("required field email missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"access_expiration", "created_at", "email"}) + } else { + return err + } + o.AccessExpiration = all.AccessExpiration + o.CreatedAt = *all.CreatedAt + o.Email = *all.Email + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_relationship_dashboard.go b/api/datadogV2/model_shared_dashboard_relationship_dashboard.go new file mode 100644 index 00000000000..b3a072afca9 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_relationship_dashboard.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardRelationshipDashboard Dashboard associated with the shared dashboard. +type SharedDashboardRelationshipDashboard struct { + // Dashboard relationship data. + Data SharedDashboardRelationshipDashboardData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardRelationshipDashboard instantiates a new SharedDashboardRelationshipDashboard 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 NewSharedDashboardRelationshipDashboard(data SharedDashboardRelationshipDashboardData) *SharedDashboardRelationshipDashboard { + this := SharedDashboardRelationshipDashboard{} + this.Data = data + return &this +} + +// NewSharedDashboardRelationshipDashboardWithDefaults instantiates a new SharedDashboardRelationshipDashboard 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 NewSharedDashboardRelationshipDashboardWithDefaults() *SharedDashboardRelationshipDashboard { + this := SharedDashboardRelationshipDashboard{} + return &this +} + +// GetData returns the Data field value. +func (o *SharedDashboardRelationshipDashboard) GetData() SharedDashboardRelationshipDashboardData { + if o == nil { + var ret SharedDashboardRelationshipDashboardData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardRelationshipDashboard) GetDataOk() (*SharedDashboardRelationshipDashboardData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SharedDashboardRelationshipDashboard) SetData(v SharedDashboardRelationshipDashboardData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardRelationshipDashboard) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardRelationshipDashboard) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *SharedDashboardRelationshipDashboardData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_relationship_dashboard_data.go b/api/datadogV2/model_shared_dashboard_relationship_dashboard_data.go new file mode 100644 index 00000000000..bd4003f05f3 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_relationship_dashboard_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardRelationshipDashboardData Dashboard relationship data. +type SharedDashboardRelationshipDashboardData struct { + // ID of the dashboard. + Id string `json:"id"` + // Included dashboard resource type. + Type SharedDashboardIncludedDashboardType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardRelationshipDashboardData instantiates a new SharedDashboardRelationshipDashboardData 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 NewSharedDashboardRelationshipDashboardData(id string, typeVar SharedDashboardIncludedDashboardType) *SharedDashboardRelationshipDashboardData { + this := SharedDashboardRelationshipDashboardData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewSharedDashboardRelationshipDashboardDataWithDefaults instantiates a new SharedDashboardRelationshipDashboardData 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 NewSharedDashboardRelationshipDashboardDataWithDefaults() *SharedDashboardRelationshipDashboardData { + this := SharedDashboardRelationshipDashboardData{} + var typeVar SharedDashboardIncludedDashboardType = SHAREDDASHBOARDINCLUDEDDASHBOARDTYPE_DASHBOARD + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *SharedDashboardRelationshipDashboardData) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardRelationshipDashboardData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *SharedDashboardRelationshipDashboardData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *SharedDashboardRelationshipDashboardData) GetType() SharedDashboardIncludedDashboardType { + if o == nil { + var ret SharedDashboardIncludedDashboardType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardRelationshipDashboardData) GetTypeOk() (*SharedDashboardIncludedDashboardType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SharedDashboardRelationshipDashboardData) SetType(v SharedDashboardIncludedDashboardType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardRelationshipDashboardData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardRelationshipDashboardData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *SharedDashboardIncludedDashboardType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_relationship_sharer.go b/api/datadogV2/model_shared_dashboard_relationship_sharer.go new file mode 100644 index 00000000000..6c356134125 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_relationship_sharer.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardRelationshipSharer User who shared the dashboard. +type SharedDashboardRelationshipSharer struct { + // Relationship to user object. + Data UserRelationshipData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardRelationshipSharer instantiates a new SharedDashboardRelationshipSharer 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 NewSharedDashboardRelationshipSharer(data UserRelationshipData) *SharedDashboardRelationshipSharer { + this := SharedDashboardRelationshipSharer{} + this.Data = data + return &this +} + +// NewSharedDashboardRelationshipSharerWithDefaults instantiates a new SharedDashboardRelationshipSharer 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 NewSharedDashboardRelationshipSharerWithDefaults() *SharedDashboardRelationshipSharer { + this := SharedDashboardRelationshipSharer{} + return &this +} + +// GetData returns the Data field value. +func (o *SharedDashboardRelationshipSharer) GetData() UserRelationshipData { + if o == nil { + var ret UserRelationshipData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardRelationshipSharer) GetDataOk() (*UserRelationshipData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SharedDashboardRelationshipSharer) SetData(v UserRelationshipData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardRelationshipSharer) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardRelationshipSharer) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *UserRelationshipData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_relationships.go b/api/datadogV2/model_shared_dashboard_relationships.go new file mode 100644 index 00000000000..bb9ba626615 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_relationships.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardRelationships Relationships of a shared dashboard. +type SharedDashboardRelationships struct { + // Dashboard associated with the shared dashboard. + Dashboard SharedDashboardRelationshipDashboard `json:"dashboard"` + // User who shared the dashboard. + Sharer SharedDashboardRelationshipSharer `json:"sharer"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardRelationships instantiates a new SharedDashboardRelationships 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 NewSharedDashboardRelationships(dashboard SharedDashboardRelationshipDashboard, sharer SharedDashboardRelationshipSharer) *SharedDashboardRelationships { + this := SharedDashboardRelationships{} + this.Dashboard = dashboard + this.Sharer = sharer + return &this +} + +// NewSharedDashboardRelationshipsWithDefaults instantiates a new SharedDashboardRelationships 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 NewSharedDashboardRelationshipsWithDefaults() *SharedDashboardRelationships { + this := SharedDashboardRelationships{} + return &this +} + +// GetDashboard returns the Dashboard field value. +func (o *SharedDashboardRelationships) GetDashboard() SharedDashboardRelationshipDashboard { + if o == nil { + var ret SharedDashboardRelationshipDashboard + return ret + } + return o.Dashboard +} + +// GetDashboardOk returns a tuple with the Dashboard field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardRelationships) GetDashboardOk() (*SharedDashboardRelationshipDashboard, bool) { + if o == nil { + return nil, false + } + return &o.Dashboard, true +} + +// SetDashboard sets field value. +func (o *SharedDashboardRelationships) SetDashboard(v SharedDashboardRelationshipDashboard) { + o.Dashboard = v +} + +// GetSharer returns the Sharer field value. +func (o *SharedDashboardRelationships) GetSharer() SharedDashboardRelationshipSharer { + if o == nil { + var ret SharedDashboardRelationshipSharer + return ret + } + return o.Sharer +} + +// GetSharerOk returns a tuple with the Sharer field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardRelationships) GetSharerOk() (*SharedDashboardRelationshipSharer, bool) { + if o == nil { + return nil, false + } + return &o.Sharer, true +} + +// SetSharer sets field value. +func (o *SharedDashboardRelationships) SetSharer(v SharedDashboardRelationshipSharer) { + o.Sharer = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["dashboard"] = o.Dashboard + toSerialize["sharer"] = o.Sharer + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Dashboard *SharedDashboardRelationshipDashboard `json:"dashboard"` + Sharer *SharedDashboardRelationshipSharer `json:"sharer"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Dashboard == nil { + return fmt.Errorf("required field dashboard missing") + } + if all.Sharer == nil { + return fmt.Errorf("required field sharer missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"dashboard", "sharer"}) + } else { + return err + } + + hasInvalidField := false + if all.Dashboard.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Dashboard = *all.Dashboard + if all.Sharer.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Sharer = *all.Sharer + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_response.go b/api/datadogV2/model_shared_dashboard_response.go new file mode 100644 index 00000000000..19677bfadf0 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_response.go @@ -0,0 +1,215 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardResponse A shared dashboard response resource. +type SharedDashboardResponse struct { + // Attributes of a shared dashboard response. + Attributes SharedDashboardResponseAttributes `json:"attributes"` + // ID of the shared dashboard. + Id string `json:"id"` + // Relationships of a shared dashboard. + Relationships SharedDashboardRelationships `json:"relationships"` + // Shared dashboard resource type. + Type SharedDashboardType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardResponse instantiates a new SharedDashboardResponse 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 NewSharedDashboardResponse(attributes SharedDashboardResponseAttributes, id string, relationships SharedDashboardRelationships, typeVar SharedDashboardType) *SharedDashboardResponse { + this := SharedDashboardResponse{} + this.Attributes = attributes + this.Id = id + this.Relationships = relationships + this.Type = typeVar + return &this +} + +// NewSharedDashboardResponseWithDefaults instantiates a new SharedDashboardResponse 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 NewSharedDashboardResponseWithDefaults() *SharedDashboardResponse { + this := SharedDashboardResponse{} + var typeVar SharedDashboardType = SHAREDDASHBOARDTYPE_SHARED_DASHBOARD + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *SharedDashboardResponse) GetAttributes() SharedDashboardResponseAttributes { + if o == nil { + var ret SharedDashboardResponseAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponse) GetAttributesOk() (*SharedDashboardResponseAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *SharedDashboardResponse) SetAttributes(v SharedDashboardResponseAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *SharedDashboardResponse) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponse) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *SharedDashboardResponse) SetId(v string) { + o.Id = v +} + +// GetRelationships returns the Relationships field value. +func (o *SharedDashboardResponse) GetRelationships() SharedDashboardRelationships { + if o == nil { + var ret SharedDashboardRelationships + return ret + } + return o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponse) GetRelationshipsOk() (*SharedDashboardRelationships, bool) { + if o == nil { + return nil, false + } + return &o.Relationships, true +} + +// SetRelationships sets field value. +func (o *SharedDashboardResponse) SetRelationships(v SharedDashboardRelationships) { + o.Relationships = v +} + +// GetType returns the Type field value. +func (o *SharedDashboardResponse) GetType() SharedDashboardType { + if o == nil { + var ret SharedDashboardType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponse) GetTypeOk() (*SharedDashboardType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SharedDashboardResponse) SetType(v SharedDashboardType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["relationships"] = o.Relationships + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *SharedDashboardResponseAttributes `json:"attributes"` + Id *string `json:"id"` + Relationships *SharedDashboardRelationships `json:"relationships"` + Type *SharedDashboardType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Relationships == nil { + return fmt.Errorf("required field relationships missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = *all.Relationships + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_response_attributes.go b/api/datadogV2/model_shared_dashboard_response_attributes.go new file mode 100644 index 00000000000..f9b3c4075a5 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_response_attributes.go @@ -0,0 +1,579 @@ +// 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" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardResponseAttributes Attributes of a shared dashboard response. +type SharedDashboardResponseAttributes struct { + // Time when the shared dashboard was created. + CreatedAt time.Time `json:"created_at"` + // Domains where embed-type shared dashboards can be embedded. + EmbeddableDomains []string `json:"embeddable_domains"` + // Time when the shared dashboard expires. + Expiration datadog.NullableTime `json:"expiration"` + // Default time range configuration for the shared dashboard. + GlobalTime map[string]interface{} `json:"global_time"` + // Whether viewers can select a different global time setting. + GlobalTimeSelectable bool `json:"global_time_selectable"` + // Invitees for invite-only shared dashboards. + Invitees []SharedDashboardInvitee `json:"invitees"` + // Time when the shared dashboard was last accessed. + LastAccessed datadog.NullableTime `json:"last_accessed"` + // Template variables that viewers can modify. + SelectableTemplateVars []SharedDashboardSelectableTemplateVariable `json:"selectable_template_vars"` + // Type of dashboard sharing. + ShareType SharedDashboardShareType `json:"share_type"` + // Whether the user who shared the dashboard is disabled. + SharerDisabled bool `json:"sharer_disabled"` + // Status of the shared dashboard. + Status SharedDashboardStatus `json:"status"` + // Display title for the shared dashboard. + Title string `json:"title"` + // Token assigned to the shared dashboard. + Token string `json:"token"` + // URL for the shared dashboard. + Url string `json:"url"` + // Display settings for the shared dashboard. + ViewingPreferences SharedDashboardViewingPreferences `json:"viewing_preferences"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardResponseAttributes instantiates a new SharedDashboardResponseAttributes 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 NewSharedDashboardResponseAttributes(createdAt time.Time, embeddableDomains []string, expiration datadog.NullableTime, globalTime map[string]interface{}, globalTimeSelectable bool, invitees []SharedDashboardInvitee, lastAccessed datadog.NullableTime, selectableTemplateVars []SharedDashboardSelectableTemplateVariable, shareType SharedDashboardShareType, sharerDisabled bool, status SharedDashboardStatus, title string, token string, url string, viewingPreferences SharedDashboardViewingPreferences) *SharedDashboardResponseAttributes { + this := SharedDashboardResponseAttributes{} + this.CreatedAt = createdAt + this.EmbeddableDomains = embeddableDomains + this.Expiration = expiration + this.GlobalTime = globalTime + this.GlobalTimeSelectable = globalTimeSelectable + this.Invitees = invitees + this.LastAccessed = lastAccessed + this.SelectableTemplateVars = selectableTemplateVars + this.ShareType = shareType + this.SharerDisabled = sharerDisabled + this.Status = status + this.Title = title + this.Token = token + this.Url = url + this.ViewingPreferences = viewingPreferences + return &this +} + +// NewSharedDashboardResponseAttributesWithDefaults instantiates a new SharedDashboardResponseAttributes 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 NewSharedDashboardResponseAttributesWithDefaults() *SharedDashboardResponseAttributes { + this := SharedDashboardResponseAttributes{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *SharedDashboardResponseAttributes) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *SharedDashboardResponseAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetEmbeddableDomains returns the EmbeddableDomains field value. +func (o *SharedDashboardResponseAttributes) GetEmbeddableDomains() []string { + if o == nil { + var ret []string + return ret + } + return o.EmbeddableDomains +} + +// GetEmbeddableDomainsOk returns a tuple with the EmbeddableDomains field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetEmbeddableDomainsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.EmbeddableDomains, true +} + +// SetEmbeddableDomains sets field value. +func (o *SharedDashboardResponseAttributes) SetEmbeddableDomains(v []string) { + o.EmbeddableDomains = v +} + +// GetExpiration returns the Expiration field value. +// If the value is explicit nil, the zero value for time.Time will be returned. +func (o *SharedDashboardResponseAttributes) GetExpiration() time.Time { + if o == nil || o.Expiration.Get() == nil { + var ret time.Time + return ret + } + return *o.Expiration.Get() +} + +// GetExpirationOk returns a tuple with the Expiration field value +// 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 *SharedDashboardResponseAttributes) GetExpirationOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.Expiration.Get(), o.Expiration.IsSet() +} + +// SetExpiration sets field value. +func (o *SharedDashboardResponseAttributes) SetExpiration(v time.Time) { + o.Expiration.Set(&v) +} + +// GetGlobalTime returns the GlobalTime field value. +// If the value is explicit nil, the zero value for map[string]interface{} will be returned. +func (o *SharedDashboardResponseAttributes) GetGlobalTime() map[string]interface{} { + if o == nil { + var ret map[string]interface{} + return ret + } + return o.GlobalTime +} + +// GetGlobalTimeOk returns a tuple with the GlobalTime field value +// 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 *SharedDashboardResponseAttributes) GetGlobalTimeOk() (*map[string]interface{}, bool) { + if o == nil || o.GlobalTime == nil { + return nil, false + } + return &o.GlobalTime, true +} + +// SetGlobalTime sets field value. +func (o *SharedDashboardResponseAttributes) SetGlobalTime(v map[string]interface{}) { + o.GlobalTime = v +} + +// GetGlobalTimeSelectable returns the GlobalTimeSelectable field value. +func (o *SharedDashboardResponseAttributes) GetGlobalTimeSelectable() bool { + if o == nil { + var ret bool + return ret + } + return o.GlobalTimeSelectable +} + +// GetGlobalTimeSelectableOk returns a tuple with the GlobalTimeSelectable field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetGlobalTimeSelectableOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.GlobalTimeSelectable, true +} + +// SetGlobalTimeSelectable sets field value. +func (o *SharedDashboardResponseAttributes) SetGlobalTimeSelectable(v bool) { + o.GlobalTimeSelectable = v +} + +// GetInvitees returns the Invitees field value. +func (o *SharedDashboardResponseAttributes) GetInvitees() []SharedDashboardInvitee { + if o == nil { + var ret []SharedDashboardInvitee + return ret + } + return o.Invitees +} + +// GetInviteesOk returns a tuple with the Invitees field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetInviteesOk() (*[]SharedDashboardInvitee, bool) { + if o == nil { + return nil, false + } + return &o.Invitees, true +} + +// SetInvitees sets field value. +func (o *SharedDashboardResponseAttributes) SetInvitees(v []SharedDashboardInvitee) { + o.Invitees = v +} + +// GetLastAccessed returns the LastAccessed field value. +// If the value is explicit nil, the zero value for time.Time will be returned. +func (o *SharedDashboardResponseAttributes) GetLastAccessed() time.Time { + if o == nil || o.LastAccessed.Get() == nil { + var ret time.Time + return ret + } + return *o.LastAccessed.Get() +} + +// GetLastAccessedOk returns a tuple with the LastAccessed field value +// 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 *SharedDashboardResponseAttributes) GetLastAccessedOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.LastAccessed.Get(), o.LastAccessed.IsSet() +} + +// SetLastAccessed sets field value. +func (o *SharedDashboardResponseAttributes) SetLastAccessed(v time.Time) { + o.LastAccessed.Set(&v) +} + +// GetSelectableTemplateVars returns the SelectableTemplateVars field value. +func (o *SharedDashboardResponseAttributes) GetSelectableTemplateVars() []SharedDashboardSelectableTemplateVariable { + if o == nil { + var ret []SharedDashboardSelectableTemplateVariable + return ret + } + return o.SelectableTemplateVars +} + +// GetSelectableTemplateVarsOk returns a tuple with the SelectableTemplateVars field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetSelectableTemplateVarsOk() (*[]SharedDashboardSelectableTemplateVariable, bool) { + if o == nil { + return nil, false + } + return &o.SelectableTemplateVars, true +} + +// SetSelectableTemplateVars sets field value. +func (o *SharedDashboardResponseAttributes) SetSelectableTemplateVars(v []SharedDashboardSelectableTemplateVariable) { + o.SelectableTemplateVars = v +} + +// GetShareType returns the ShareType field value. +func (o *SharedDashboardResponseAttributes) GetShareType() SharedDashboardShareType { + if o == nil { + var ret SharedDashboardShareType + return ret + } + return o.ShareType +} + +// GetShareTypeOk returns a tuple with the ShareType field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetShareTypeOk() (*SharedDashboardShareType, bool) { + if o == nil { + return nil, false + } + return &o.ShareType, true +} + +// SetShareType sets field value. +func (o *SharedDashboardResponseAttributes) SetShareType(v SharedDashboardShareType) { + o.ShareType = v +} + +// GetSharerDisabled returns the SharerDisabled field value. +func (o *SharedDashboardResponseAttributes) GetSharerDisabled() bool { + if o == nil { + var ret bool + return ret + } + return o.SharerDisabled +} + +// GetSharerDisabledOk returns a tuple with the SharerDisabled field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetSharerDisabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.SharerDisabled, true +} + +// SetSharerDisabled sets field value. +func (o *SharedDashboardResponseAttributes) SetSharerDisabled(v bool) { + o.SharerDisabled = v +} + +// GetStatus returns the Status field value. +func (o *SharedDashboardResponseAttributes) GetStatus() SharedDashboardStatus { + if o == nil { + var ret SharedDashboardStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetStatusOk() (*SharedDashboardStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *SharedDashboardResponseAttributes) SetStatus(v SharedDashboardStatus) { + o.Status = v +} + +// GetTitle returns the Title field value. +func (o *SharedDashboardResponseAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *SharedDashboardResponseAttributes) SetTitle(v string) { + o.Title = v +} + +// GetToken returns the Token field value. +func (o *SharedDashboardResponseAttributes) GetToken() string { + if o == nil { + var ret string + return ret + } + return o.Token +} + +// GetTokenOk returns a tuple with the Token field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetTokenOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Token, true +} + +// SetToken sets field value. +func (o *SharedDashboardResponseAttributes) SetToken(v string) { + o.Token = v +} + +// GetUrl returns the Url field value. +func (o *SharedDashboardResponseAttributes) GetUrl() string { + if o == nil { + var ret string + return ret + } + return o.Url +} + +// GetUrlOk returns a tuple with the Url field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetUrlOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Url, true +} + +// SetUrl sets field value. +func (o *SharedDashboardResponseAttributes) SetUrl(v string) { + o.Url = v +} + +// GetViewingPreferences returns the ViewingPreferences field value. +func (o *SharedDashboardResponseAttributes) GetViewingPreferences() SharedDashboardViewingPreferences { + if o == nil { + var ret SharedDashboardViewingPreferences + return ret + } + return o.ViewingPreferences +} + +// GetViewingPreferencesOk returns a tuple with the ViewingPreferences field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardResponseAttributes) GetViewingPreferencesOk() (*SharedDashboardViewingPreferences, bool) { + if o == nil { + return nil, false + } + return &o.ViewingPreferences, true +} + +// SetViewingPreferences sets field value. +func (o *SharedDashboardResponseAttributes) SetViewingPreferences(v SharedDashboardViewingPreferences) { + o.ViewingPreferences = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["embeddable_domains"] = o.EmbeddableDomains + toSerialize["expiration"] = o.Expiration.Get() + if o.GlobalTime != nil { + toSerialize["global_time"] = o.GlobalTime + } + toSerialize["global_time_selectable"] = o.GlobalTimeSelectable + toSerialize["invitees"] = o.Invitees + toSerialize["last_accessed"] = o.LastAccessed.Get() + toSerialize["selectable_template_vars"] = o.SelectableTemplateVars + toSerialize["share_type"] = o.ShareType + toSerialize["sharer_disabled"] = o.SharerDisabled + toSerialize["status"] = o.Status + toSerialize["title"] = o.Title + toSerialize["token"] = o.Token + toSerialize["url"] = o.Url + toSerialize["viewing_preferences"] = o.ViewingPreferences + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"created_at"` + EmbeddableDomains *[]string `json:"embeddable_domains"` + Expiration datadog.NullableTime `json:"expiration"` + GlobalTime map[string]interface{} `json:"global_time"` + GlobalTimeSelectable *bool `json:"global_time_selectable"` + Invitees *[]SharedDashboardInvitee `json:"invitees"` + LastAccessed datadog.NullableTime `json:"last_accessed"` + SelectableTemplateVars *[]SharedDashboardSelectableTemplateVariable `json:"selectable_template_vars"` + ShareType *SharedDashboardShareType `json:"share_type"` + SharerDisabled *bool `json:"sharer_disabled"` + Status *SharedDashboardStatus `json:"status"` + Title *string `json:"title"` + Token *string `json:"token"` + Url *string `json:"url"` + ViewingPreferences *SharedDashboardViewingPreferences `json:"viewing_preferences"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.EmbeddableDomains == nil { + return fmt.Errorf("required field embeddable_domains missing") + } + if !all.Expiration.IsSet() { + return fmt.Errorf("required field expiration missing") + } + if all.GlobalTime == nil { + return fmt.Errorf("required field global_time missing") + } + if all.GlobalTimeSelectable == nil { + return fmt.Errorf("required field global_time_selectable missing") + } + if all.Invitees == nil { + return fmt.Errorf("required field invitees missing") + } + if !all.LastAccessed.IsSet() { + return fmt.Errorf("required field last_accessed missing") + } + if all.SelectableTemplateVars == nil { + return fmt.Errorf("required field selectable_template_vars missing") + } + if all.ShareType == nil { + return fmt.Errorf("required field share_type missing") + } + if all.SharerDisabled == nil { + return fmt.Errorf("required field sharer_disabled missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + if all.Token == nil { + return fmt.Errorf("required field token missing") + } + if all.Url == nil { + return fmt.Errorf("required field url missing") + } + if all.ViewingPreferences == nil { + return fmt.Errorf("required field viewing_preferences missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_at", "embeddable_domains", "expiration", "global_time", "global_time_selectable", "invitees", "last_accessed", "selectable_template_vars", "share_type", "sharer_disabled", "status", "title", "token", "url", "viewing_preferences"}) + } else { + return err + } + + hasInvalidField := false + o.CreatedAt = *all.CreatedAt + o.EmbeddableDomains = *all.EmbeddableDomains + o.Expiration = all.Expiration + o.GlobalTime = all.GlobalTime + o.GlobalTimeSelectable = *all.GlobalTimeSelectable + o.Invitees = *all.Invitees + o.LastAccessed = all.LastAccessed + o.SelectableTemplateVars = *all.SelectableTemplateVars + if !all.ShareType.IsValid() { + hasInvalidField = true + } else { + o.ShareType = *all.ShareType + } + o.SharerDisabled = *all.SharerDisabled + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + o.Title = *all.Title + o.Token = *all.Token + o.Url = *all.Url + if all.ViewingPreferences.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.ViewingPreferences = *all.ViewingPreferences + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_selectable_template_variable.go b/api/datadogV2/model_shared_dashboard_selectable_template_variable.go new file mode 100644 index 00000000000..2ecdb6eee5e --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_selectable_template_variable.go @@ -0,0 +1,261 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardSelectableTemplateVariable A template variable that viewers can modify on the shared dashboard. +type SharedDashboardSelectableTemplateVariable struct { + // Whether viewers can see all tag values for the template variable and specify any value. + AllowAnyValue bool `json:"allow_any_value"` + // Default selected values for the variable. + DefaultValues []string `json:"default_values"` + // Name of the template variable. + Name string `json:"name"` + // Tag prefix for the variable. + Prefix string `json:"prefix"` + // Type of the template variable. + Type string `json:"type"` + // Restricts which tag values are visible to the viewer. + VisibleTags []string `json:"visible_tags"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardSelectableTemplateVariable instantiates a new SharedDashboardSelectableTemplateVariable 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 NewSharedDashboardSelectableTemplateVariable(allowAnyValue bool, defaultValues []string, name string, prefix string, typeVar string, visibleTags []string) *SharedDashboardSelectableTemplateVariable { + this := SharedDashboardSelectableTemplateVariable{} + this.AllowAnyValue = allowAnyValue + this.DefaultValues = defaultValues + this.Name = name + this.Prefix = prefix + this.Type = typeVar + this.VisibleTags = visibleTags + return &this +} + +// NewSharedDashboardSelectableTemplateVariableWithDefaults instantiates a new SharedDashboardSelectableTemplateVariable 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 NewSharedDashboardSelectableTemplateVariableWithDefaults() *SharedDashboardSelectableTemplateVariable { + this := SharedDashboardSelectableTemplateVariable{} + return &this +} + +// GetAllowAnyValue returns the AllowAnyValue field value. +func (o *SharedDashboardSelectableTemplateVariable) GetAllowAnyValue() bool { + if o == nil { + var ret bool + return ret + } + return o.AllowAnyValue +} + +// GetAllowAnyValueOk returns a tuple with the AllowAnyValue field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardSelectableTemplateVariable) GetAllowAnyValueOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.AllowAnyValue, true +} + +// SetAllowAnyValue sets field value. +func (o *SharedDashboardSelectableTemplateVariable) SetAllowAnyValue(v bool) { + o.AllowAnyValue = v +} + +// GetDefaultValues returns the DefaultValues field value. +func (o *SharedDashboardSelectableTemplateVariable) GetDefaultValues() []string { + if o == nil { + var ret []string + return ret + } + return o.DefaultValues +} + +// GetDefaultValuesOk returns a tuple with the DefaultValues field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardSelectableTemplateVariable) GetDefaultValuesOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.DefaultValues, true +} + +// SetDefaultValues sets field value. +func (o *SharedDashboardSelectableTemplateVariable) SetDefaultValues(v []string) { + o.DefaultValues = v +} + +// GetName returns the Name field value. +func (o *SharedDashboardSelectableTemplateVariable) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardSelectableTemplateVariable) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *SharedDashboardSelectableTemplateVariable) SetName(v string) { + o.Name = v +} + +// GetPrefix returns the Prefix field value. +func (o *SharedDashboardSelectableTemplateVariable) GetPrefix() string { + if o == nil { + var ret string + return ret + } + return o.Prefix +} + +// GetPrefixOk returns a tuple with the Prefix field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardSelectableTemplateVariable) GetPrefixOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Prefix, true +} + +// SetPrefix sets field value. +func (o *SharedDashboardSelectableTemplateVariable) SetPrefix(v string) { + o.Prefix = v +} + +// GetType returns the Type field value. +func (o *SharedDashboardSelectableTemplateVariable) GetType() string { + if o == nil { + var ret string + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardSelectableTemplateVariable) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *SharedDashboardSelectableTemplateVariable) SetType(v string) { + o.Type = v +} + +// GetVisibleTags returns the VisibleTags field value. +func (o *SharedDashboardSelectableTemplateVariable) GetVisibleTags() []string { + if o == nil { + var ret []string + return ret + } + return o.VisibleTags +} + +// GetVisibleTagsOk returns a tuple with the VisibleTags field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardSelectableTemplateVariable) GetVisibleTagsOk() (*[]string, bool) { + if o == nil { + return nil, false + } + return &o.VisibleTags, true +} + +// SetVisibleTags sets field value. +func (o *SharedDashboardSelectableTemplateVariable) SetVisibleTags(v []string) { + o.VisibleTags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardSelectableTemplateVariable) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["allow_any_value"] = o.AllowAnyValue + toSerialize["default_values"] = o.DefaultValues + toSerialize["name"] = o.Name + toSerialize["prefix"] = o.Prefix + toSerialize["type"] = o.Type + toSerialize["visible_tags"] = o.VisibleTags + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardSelectableTemplateVariable) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AllowAnyValue *bool `json:"allow_any_value"` + DefaultValues *[]string `json:"default_values"` + Name *string `json:"name"` + Prefix *string `json:"prefix"` + Type *string `json:"type"` + VisibleTags *[]string `json:"visible_tags"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AllowAnyValue == nil { + return fmt.Errorf("required field allow_any_value missing") + } + if all.DefaultValues == nil { + return fmt.Errorf("required field default_values missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Prefix == nil { + return fmt.Errorf("required field prefix missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + if all.VisibleTags == nil { + return fmt.Errorf("required field visible_tags missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"allow_any_value", "default_values", "name", "prefix", "type", "visible_tags"}) + } else { + return err + } + o.AllowAnyValue = *all.AllowAnyValue + o.DefaultValues = *all.DefaultValues + o.Name = *all.Name + o.Prefix = *all.Prefix + o.Type = *all.Type + o.VisibleTags = *all.VisibleTags + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_share_type.go b/api/datadogV2/model_shared_dashboard_share_type.go new file mode 100644 index 00000000000..f61e80c2ae1 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_share_type.go @@ -0,0 +1,70 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardShareType Type of dashboard sharing. +type SharedDashboardShareType string + +// List of SharedDashboardShareType. +const ( + SHAREDDASHBOARDSHARETYPE_OPEN SharedDashboardShareType = "open" + SHAREDDASHBOARDSHARETYPE_INVITE SharedDashboardShareType = "invite" + SHAREDDASHBOARDSHARETYPE_EMBED SharedDashboardShareType = "embed" + SHAREDDASHBOARDSHARETYPE_SECURE_EMBED SharedDashboardShareType = "secure-embed" +) + +var allowedSharedDashboardShareTypeEnumValues = []SharedDashboardShareType{ + SHAREDDASHBOARDSHARETYPE_OPEN, + SHAREDDASHBOARDSHARETYPE_INVITE, + SHAREDDASHBOARDSHARETYPE_EMBED, + SHAREDDASHBOARDSHARETYPE_SECURE_EMBED, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SharedDashboardShareType) GetAllowedValues() []SharedDashboardShareType { + return allowedSharedDashboardShareTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SharedDashboardShareType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SharedDashboardShareType(value) + return nil +} + +// NewSharedDashboardShareTypeFromValue returns a pointer to a valid SharedDashboardShareType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSharedDashboardShareTypeFromValue(v string) (*SharedDashboardShareType, error) { + ev := SharedDashboardShareType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SharedDashboardShareType: valid values are %v", v, allowedSharedDashboardShareTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SharedDashboardShareType) IsValid() bool { + for _, existing := range allowedSharedDashboardShareTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SharedDashboardShareType value. +func (v SharedDashboardShareType) Ptr() *SharedDashboardShareType { + return &v +} diff --git a/api/datadogV2/model_shared_dashboard_status.go b/api/datadogV2/model_shared_dashboard_status.go new file mode 100644 index 00000000000..1eb9df184bb --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_status.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardStatus Status of the shared dashboard. +type SharedDashboardStatus string + +// List of SharedDashboardStatus. +const ( + SHAREDDASHBOARDSTATUS_ACTIVE SharedDashboardStatus = "active" + SHAREDDASHBOARDSTATUS_PAUSED SharedDashboardStatus = "paused" +) + +var allowedSharedDashboardStatusEnumValues = []SharedDashboardStatus{ + SHAREDDASHBOARDSTATUS_ACTIVE, + SHAREDDASHBOARDSTATUS_PAUSED, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SharedDashboardStatus) GetAllowedValues() []SharedDashboardStatus { + return allowedSharedDashboardStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SharedDashboardStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SharedDashboardStatus(value) + return nil +} + +// NewSharedDashboardStatusFromValue returns a pointer to a valid SharedDashboardStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSharedDashboardStatusFromValue(v string) (*SharedDashboardStatus, error) { + ev := SharedDashboardStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SharedDashboardStatus: valid values are %v", v, allowedSharedDashboardStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SharedDashboardStatus) IsValid() bool { + for _, existing := range allowedSharedDashboardStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SharedDashboardStatus value. +func (v SharedDashboardStatus) Ptr() *SharedDashboardStatus { + return &v +} diff --git a/api/datadogV2/model_shared_dashboard_type.go b/api/datadogV2/model_shared_dashboard_type.go new file mode 100644 index 00000000000..8453dd27dc5 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardType Shared dashboard resource type. +type SharedDashboardType string + +// List of SharedDashboardType. +const ( + SHAREDDASHBOARDTYPE_SHARED_DASHBOARD SharedDashboardType = "shared_dashboard" +) + +var allowedSharedDashboardTypeEnumValues = []SharedDashboardType{ + SHAREDDASHBOARDTYPE_SHARED_DASHBOARD, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SharedDashboardType) GetAllowedValues() []SharedDashboardType { + return allowedSharedDashboardTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SharedDashboardType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SharedDashboardType(value) + return nil +} + +// NewSharedDashboardTypeFromValue returns a pointer to a valid SharedDashboardType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSharedDashboardTypeFromValue(v string) (*SharedDashboardType, error) { + ev := SharedDashboardType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SharedDashboardType: valid values are %v", v, allowedSharedDashboardTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SharedDashboardType) IsValid() bool { + for _, existing := range allowedSharedDashboardTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SharedDashboardType value. +func (v SharedDashboardType) Ptr() *SharedDashboardType { + return &v +} diff --git a/api/datadogV2/model_shared_dashboard_viewing_preferences.go b/api/datadogV2/model_shared_dashboard_viewing_preferences.go new file mode 100644 index 00000000000..2fab51119e6 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_viewing_preferences.go @@ -0,0 +1,143 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardViewingPreferences Display settings for the shared dashboard. +type SharedDashboardViewingPreferences struct { + // Whether widgets are displayed in high-density mode. + HighDensity bool `json:"high_density"` + // The theme of the shared dashboard view. `system` follows the viewer's system default. + Theme SharedDashboardViewingPreferencesTheme `json:"theme"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSharedDashboardViewingPreferences instantiates a new SharedDashboardViewingPreferences 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 NewSharedDashboardViewingPreferences(highDensity bool, theme SharedDashboardViewingPreferencesTheme) *SharedDashboardViewingPreferences { + this := SharedDashboardViewingPreferences{} + this.HighDensity = highDensity + this.Theme = theme + return &this +} + +// NewSharedDashboardViewingPreferencesWithDefaults instantiates a new SharedDashboardViewingPreferences 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 NewSharedDashboardViewingPreferencesWithDefaults() *SharedDashboardViewingPreferences { + this := SharedDashboardViewingPreferences{} + return &this +} + +// GetHighDensity returns the HighDensity field value. +func (o *SharedDashboardViewingPreferences) GetHighDensity() bool { + if o == nil { + var ret bool + return ret + } + return o.HighDensity +} + +// GetHighDensityOk returns a tuple with the HighDensity field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardViewingPreferences) GetHighDensityOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.HighDensity, true +} + +// SetHighDensity sets field value. +func (o *SharedDashboardViewingPreferences) SetHighDensity(v bool) { + o.HighDensity = v +} + +// GetTheme returns the Theme field value. +func (o *SharedDashboardViewingPreferences) GetTheme() SharedDashboardViewingPreferencesTheme { + if o == nil { + var ret SharedDashboardViewingPreferencesTheme + return ret + } + return o.Theme +} + +// GetThemeOk returns a tuple with the Theme field value +// and a boolean to check if the value has been set. +func (o *SharedDashboardViewingPreferences) GetThemeOk() (*SharedDashboardViewingPreferencesTheme, bool) { + if o == nil { + return nil, false + } + return &o.Theme, true +} + +// SetTheme sets field value. +func (o *SharedDashboardViewingPreferences) SetTheme(v SharedDashboardViewingPreferencesTheme) { + o.Theme = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SharedDashboardViewingPreferences) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["high_density"] = o.HighDensity + toSerialize["theme"] = o.Theme + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SharedDashboardViewingPreferences) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + HighDensity *bool `json:"high_density"` + Theme *SharedDashboardViewingPreferencesTheme `json:"theme"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.HighDensity == nil { + return fmt.Errorf("required field high_density missing") + } + if all.Theme == nil { + return fmt.Errorf("required field theme missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"high_density", "theme"}) + } else { + return err + } + + hasInvalidField := false + o.HighDensity = *all.HighDensity + if !all.Theme.IsValid() { + hasInvalidField = true + } else { + o.Theme = *all.Theme + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_shared_dashboard_viewing_preferences_theme.go b/api/datadogV2/model_shared_dashboard_viewing_preferences_theme.go new file mode 100644 index 00000000000..8629fefe468 --- /dev/null +++ b/api/datadogV2/model_shared_dashboard_viewing_preferences_theme.go @@ -0,0 +1,68 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SharedDashboardViewingPreferencesTheme The theme of the shared dashboard view. `system` follows the viewer's system default. +type SharedDashboardViewingPreferencesTheme string + +// List of SharedDashboardViewingPreferencesTheme. +const ( + SHAREDDASHBOARDVIEWINGPREFERENCESTHEME_SYSTEM SharedDashboardViewingPreferencesTheme = "system" + SHAREDDASHBOARDVIEWINGPREFERENCESTHEME_LIGHT SharedDashboardViewingPreferencesTheme = "light" + SHAREDDASHBOARDVIEWINGPREFERENCESTHEME_DARK SharedDashboardViewingPreferencesTheme = "dark" +) + +var allowedSharedDashboardViewingPreferencesThemeEnumValues = []SharedDashboardViewingPreferencesTheme{ + SHAREDDASHBOARDVIEWINGPREFERENCESTHEME_SYSTEM, + SHAREDDASHBOARDVIEWINGPREFERENCESTHEME_LIGHT, + SHAREDDASHBOARDVIEWINGPREFERENCESTHEME_DARK, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SharedDashboardViewingPreferencesTheme) GetAllowedValues() []SharedDashboardViewingPreferencesTheme { + return allowedSharedDashboardViewingPreferencesThemeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SharedDashboardViewingPreferencesTheme) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SharedDashboardViewingPreferencesTheme(value) + return nil +} + +// NewSharedDashboardViewingPreferencesThemeFromValue returns a pointer to a valid SharedDashboardViewingPreferencesTheme +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSharedDashboardViewingPreferencesThemeFromValue(v string) (*SharedDashboardViewingPreferencesTheme, error) { + ev := SharedDashboardViewingPreferencesTheme(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SharedDashboardViewingPreferencesTheme: valid values are %v", v, allowedSharedDashboardViewingPreferencesThemeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SharedDashboardViewingPreferencesTheme) IsValid() bool { + for _, existing := range allowedSharedDashboardViewingPreferencesThemeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SharedDashboardViewingPreferencesTheme value. +func (v SharedDashboardViewingPreferencesTheme) Ptr() *SharedDashboardViewingPreferencesTheme { + return &v +} diff --git a/examples/v2/dashboard-sharing/ListSharedDashboardsByDashboardId.go b/examples/v2/dashboard-sharing/ListSharedDashboardsByDashboardId.go new file mode 100644 index 00000000000..11170781a4a --- /dev/null +++ b/examples/v2/dashboard-sharing/ListSharedDashboardsByDashboardId.go @@ -0,0 +1,30 @@ +// List shared dashboards for a dashboard 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.ListSharedDashboardsByDashboardId", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewDashboardSharingApi(apiClient) + resp, r, err := api.ListSharedDashboardsByDashboardId(ctx, "abc-def-ghi") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardSharingApi.ListSharedDashboardsByDashboardId`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardSharingApi.ListSharedDashboardsByDashboardId`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 234efed308f..54fe9af3a10 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -82,6 +82,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "CSMOwnershipApi": reflect.ValueOf(datadogV2.NewCSMOwnershipApi), "CSMSettingsApi": reflect.ValueOf(datadogV2.NewCSMSettingsApi), "DashboardListsApi": reflect.ValueOf(datadogV2.NewDashboardListsApi), + "DashboardSharingApi": reflect.ValueOf(datadogV2.NewDashboardSharingApi), "DashboardSecureEmbedApi": reflect.ValueOf(datadogV2.NewDashboardSecureEmbedApi), "DashboardsApi": reflect.ValueOf(datadogV2.NewDashboardsApi), "DatasetsApi": reflect.ValueOf(datadogV2.NewDatasetsApi), diff --git a/tests/scenarios/features/v2/dashboard_sharing.feature b/tests/scenarios/features/v2/dashboard_sharing.feature new file mode 100644 index 00000000000..45257252d39 --- /dev/null +++ b/tests/scenarios/features/v2/dashboard_sharing.feature @@ -0,0 +1,22 @@ +@endpoint(dashboard-sharing) @endpoint(dashboard-sharing-v2) +Feature: Dashboard Sharing + Manage dashboard sharing configurations. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "DashboardSharing" API + And operation "ListSharedDashboardsByDashboardId" enabled + And new "ListSharedDashboardsByDashboardId" request + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: List shared dashboards for a dashboard returns "Dashboard Not Found" response + Given request contains "dashboard_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Dashboard Not Found + + @generated @skip @team:DataDog/reporting-and-sharing + Scenario: List shared dashboards for a dashboard returns "OK" response + Given request contains "dashboard_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 25fb6bb2dc2..9d1d831d98c 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2165,6 +2165,12 @@ "type": "safe" } }, + "ListSharedDashboardsByDashboardId": { + "tag": "Dashboard Sharing", + "undo": { + "type": "safe" + } + }, "CreateDashboardSecureEmbed": { "tag": "Dashboard Secure Embed", "undo": { From d507c38110aa2d6b386808e946b1c07d7850066b Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 08:43:13 +0000 Subject: [PATCH 2/4] Regenerate client from commit fc1fa35 of spec repo (#4230) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 76 +++++++++ api/datadogV2/api_slack_integration.go | 102 ++++++++++++ api/datadogV2/doc.go | 1 + .../model_slack_user_binding_data.go | 151 ++++++++++++++++++ .../model_slack_user_binding_type.go | 64 ++++++++ .../model_slack_user_bindings_response.go | 101 ++++++++++++ .../ListSlackUserBindings.go | 30 ++++ tests/scenarios/api_mappings.go | 1 + .../features/v2/slack_integration.feature | 23 +++ tests/scenarios/features/v2/undo.json | 6 + 10 files changed, 555 insertions(+) create mode 100644 api/datadogV2/api_slack_integration.go create mode 100644 api/datadogV2/model_slack_user_binding_data.go create mode 100644 api/datadogV2/model_slack_user_binding_type.go create mode 100644 api/datadogV2/model_slack_user_bindings_response.go create mode 100644 examples/v2/slack-integration/ListSlackUserBindings.go create mode 100644 tests/scenarios/features/v2/slack_integration.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6c36643fc41..73fd548ab55 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1780,6 +1780,14 @@ components: required: false schema: type: boolean + SlackUserUuidQueryParameter: + description: The UUID of the Datadog user to list Slack bindings for. + in: query + name: user_uuid + required: true + schema: + format: uuid + type: string SloID: description: The ID of the SLO. in: path @@ -89039,6 +89047,37 @@ components: required: - slackTrigger type: object + SlackUserBindingData: + description: Slack team ID data from a response. + properties: + id: + description: The Slack team ID. + example: "T01234567" + type: string + type: + $ref: "#/components/schemas/SlackUserBindingType" + type: object + SlackUserBindingType: + default: team_id + description: Slack user binding resource type. + enum: + - team_id + example: team_id + type: string + x-enum-varnames: + - TEAM_ID + SlackUserBindingsResponse: + description: Response with a list of Slack user bindings. + properties: + data: + description: An array of Slack user bindings. + example: [{"id": "T01234567", "type": "team_id"}, {"id": "T09876543", "type": "team_id"}] + items: + $ref: "#/components/schemas/SlackUserBindingData" + type: array + required: + - data + type: object SloDataSource: default: slo description: A data source for SLO queries. @@ -136401,6 +136440,36 @@ paths: summary: List ServiceNow users tags: - ServiceNow Integration + /api/v2/integration/slack/user-bindings: + get: + description: List all Slack user bindings for a given Datadog user from the Datadog Slack integration. + operationId: ListSlackUserBindings + parameters: + - $ref: "#/components/parameters/SlackUserUuidQueryParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - id: T01234567 + type: team_id + - id: T09876543 + type: team_id + schema: + $ref: "#/components/schemas/SlackUserBindingsResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List Slack user bindings + tags: + - Slack Integration /api/v2/integration/statuspage/account: delete: description: Delete the Statuspage account configured for your organization. @@ -186271,6 +186340,13 @@ tags: name: Service Level Objectives - description: Manage your ServiceNow Integration. ServiceNow is a cloud-based platform that helps organizations manage digital workflows for enterprise operations. name: ServiceNow Integration + - description: |- + Configure your [Datadog Slack integration](https://docs.datadoghq.com/integrations/slack/) + directly through the Datadog API. + externalDocs: + description: For more information about the Datadog Slack integration, see the integration page. + url: https://docs.datadoghq.com/integrations/slack/ + name: Slack Integration - description: |- API to create, update, retrieve, and delete Software Catalog entities. externalDocs: diff --git a/api/datadogV2/api_slack_integration.go b/api/datadogV2/api_slack_integration.go new file mode 100644 index 00000000000..c094de7660f --- /dev/null +++ b/api/datadogV2/api_slack_integration.go @@ -0,0 +1,102 @@ +// 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" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/google/uuid" +) + +// SlackIntegrationApi service type +type SlackIntegrationApi datadog.Service + +// ListSlackUserBindings List Slack user bindings. +// List all Slack user bindings for a given Datadog user from the Datadog Slack integration. +func (a *SlackIntegrationApi) ListSlackUserBindings(ctx _context.Context, userUuid uuid.UUID) (SlackUserBindingsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue SlackUserBindingsResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SlackIntegrationApi.ListSlackUserBindings") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/slack/user-bindings" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarQueryParams.Add("user_uuid", datadog.ParameterToString(userUuid, "")) + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 +} + +// NewSlackIntegrationApi Returns NewSlackIntegrationApi. +func NewSlackIntegrationApi(client *datadog.APIClient) *SlackIntegrationApi { + return &SlackIntegrationApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index ed1697bfe5d..d04ab2db857 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -1112,6 +1112,7 @@ // - [ServiceNowIntegrationApi.ListServiceNowTemplates] // - [ServiceNowIntegrationApi.ListServiceNowUsers] // - [ServiceNowIntegrationApi.UpdateServiceNowTemplate] +// - [SlackIntegrationApi.ListSlackUserBindings] // - [SoftwareCatalogApi.DeleteCatalogEntity] // - [SoftwareCatalogApi.DeleteCatalogKind] // - [SoftwareCatalogApi.ListCatalogEntity] diff --git a/api/datadogV2/model_slack_user_binding_data.go b/api/datadogV2/model_slack_user_binding_data.go new file mode 100644 index 00000000000..f41dba203c3 --- /dev/null +++ b/api/datadogV2/model_slack_user_binding_data.go @@ -0,0 +1,151 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SlackUserBindingData Slack team ID data from a response. +type SlackUserBindingData struct { + // The Slack team ID. + Id *string `json:"id,omitempty"` + // Slack user binding resource type. + Type *SlackUserBindingType `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{} `json:"-"` +} + +// NewSlackUserBindingData instantiates a new SlackUserBindingData 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 NewSlackUserBindingData() *SlackUserBindingData { + this := SlackUserBindingData{} + var typeVar SlackUserBindingType = SLACKUSERBINDINGTYPE_TEAM_ID + this.Type = &typeVar + return &this +} + +// NewSlackUserBindingDataWithDefaults instantiates a new SlackUserBindingData 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 NewSlackUserBindingDataWithDefaults() *SlackUserBindingData { + this := SlackUserBindingData{} + var typeVar SlackUserBindingType = SLACKUSERBINDINGTYPE_TEAM_ID + this.Type = &typeVar + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *SlackUserBindingData) 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 *SlackUserBindingData) 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 *SlackUserBindingData) 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 *SlackUserBindingData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *SlackUserBindingData) GetType() SlackUserBindingType { + if o == nil || o.Type == nil { + var ret SlackUserBindingType + 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 *SlackUserBindingData) GetTypeOk() (*SlackUserBindingType, 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 *SlackUserBindingData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given SlackUserBindingType and assigns it to the Type field. +func (o *SlackUserBindingData) SetType(v SlackUserBindingType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SlackUserBindingData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + 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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SlackUserBindingData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + Type *SlackUserBindingType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + 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 datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_slack_user_binding_type.go b/api/datadogV2/model_slack_user_binding_type.go new file mode 100644 index 00000000000..2df3d24aed2 --- /dev/null +++ b/api/datadogV2/model_slack_user_binding_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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SlackUserBindingType Slack user binding resource type. +type SlackUserBindingType string + +// List of SlackUserBindingType. +const ( + SLACKUSERBINDINGTYPE_TEAM_ID SlackUserBindingType = "team_id" +) + +var allowedSlackUserBindingTypeEnumValues = []SlackUserBindingType{ + SLACKUSERBINDINGTYPE_TEAM_ID, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *SlackUserBindingType) GetAllowedValues() []SlackUserBindingType { + return allowedSlackUserBindingTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *SlackUserBindingType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = SlackUserBindingType(value) + return nil +} + +// NewSlackUserBindingTypeFromValue returns a pointer to a valid SlackUserBindingType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewSlackUserBindingTypeFromValue(v string) (*SlackUserBindingType, error) { + ev := SlackUserBindingType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for SlackUserBindingType: valid values are %v", v, allowedSlackUserBindingTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v SlackUserBindingType) IsValid() bool { + for _, existing := range allowedSlackUserBindingTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to SlackUserBindingType value. +func (v SlackUserBindingType) Ptr() *SlackUserBindingType { + return &v +} diff --git a/api/datadogV2/model_slack_user_bindings_response.go b/api/datadogV2/model_slack_user_bindings_response.go new file mode 100644 index 00000000000..f9577ed81e2 --- /dev/null +++ b/api/datadogV2/model_slack_user_bindings_response.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// SlackUserBindingsResponse Response with a list of Slack user bindings. +type SlackUserBindingsResponse struct { + // An array of Slack user bindings. + Data []SlackUserBindingData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewSlackUserBindingsResponse instantiates a new SlackUserBindingsResponse 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 NewSlackUserBindingsResponse(data []SlackUserBindingData) *SlackUserBindingsResponse { + this := SlackUserBindingsResponse{} + this.Data = data + return &this +} + +// NewSlackUserBindingsResponseWithDefaults instantiates a new SlackUserBindingsResponse 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 NewSlackUserBindingsResponseWithDefaults() *SlackUserBindingsResponse { + this := SlackUserBindingsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *SlackUserBindingsResponse) GetData() []SlackUserBindingData { + if o == nil { + var ret []SlackUserBindingData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *SlackUserBindingsResponse) GetDataOk() (*[]SlackUserBindingData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *SlackUserBindingsResponse) SetData(v []SlackUserBindingData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o SlackUserBindingsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *SlackUserBindingsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]SlackUserBindingData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/slack-integration/ListSlackUserBindings.go b/examples/v2/slack-integration/ListSlackUserBindings.go new file mode 100644 index 00000000000..d49c00d3cd5 --- /dev/null +++ b/examples/v2/slack-integration/ListSlackUserBindings.go @@ -0,0 +1,30 @@ +// List Slack user bindings 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" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewSlackIntegrationApi(apiClient) + resp, r, err := api.ListSlackUserBindings(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SlackIntegrationApi.ListSlackUserBindings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `SlackIntegrationApi.ListSlackUserBindings`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 54fe9af3a10..f9a2f1886d6 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -108,6 +108,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "OpsgenieIntegrationApi": reflect.ValueOf(datadogV2.NewOpsgenieIntegrationApi), "SalesforceIntegrationApi": reflect.ValueOf(datadogV2.NewSalesforceIntegrationApi), "ServiceNowIntegrationApi": reflect.ValueOf(datadogV2.NewServiceNowIntegrationApi), + "SlackIntegrationApi": reflect.ValueOf(datadogV2.NewSlackIntegrationApi), "StatuspageIntegrationApi": reflect.ValueOf(datadogV2.NewStatuspageIntegrationApi), "WebhooksIntegrationApi": reflect.ValueOf(datadogV2.NewWebhooksIntegrationApi), "IntegrationsApi": reflect.ValueOf(datadogV2.NewIntegrationsApi), diff --git a/tests/scenarios/features/v2/slack_integration.feature b/tests/scenarios/features/v2/slack_integration.feature new file mode 100644 index 00000000000..0ef645a642a --- /dev/null +++ b/tests/scenarios/features/v2/slack_integration.feature @@ -0,0 +1,23 @@ +@endpoint(slack-integration) @endpoint(slack-integration-v2) +Feature: Slack Integration + Configure your [Datadog Slack + integration](https://docs.datadoghq.com/integrations/slack/) directly + through the Datadog API. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "SlackIntegration" API + And new "ListSlackUserBindings" request + + @generated @skip @team:DataDog/chat-integrations + Scenario: List Slack user bindings returns "Bad Request" response + Given request contains "user_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/chat-integrations + Scenario: List Slack user bindings returns "OK" response + Given request contains "user_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 9d1d831d98c..caa628ae031 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3781,6 +3781,12 @@ "type": "safe" } }, + "ListSlackUserBindings": { + "tag": "Slack Integration", + "undo": { + "type": "safe" + } + }, "DeleteStatuspageAccount": { "tag": "Statuspage Integration", "undo": { From 7f07b077dc19afe09ba39c8b79c836de45e0de8e Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 09:37:01 +0000 Subject: [PATCH 3/4] Regenerate client from commit 34e91d4 of spec repo (#4238) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 27 ++++++++ .../api_microsoft_teams_integration.go | 68 +++++++++++++++++++ api/datadogV2/doc.go | 1 + .../DeleteMSTeamsUserBinding.go | 25 +++++++ .../v2/microsoft_teams_integration.feature | 21 ++++++ tests/scenarios/features/v2/undo.json | 6 ++ 6 files changed, 148 insertions(+) create mode 100644 examples/v2/microsoft-teams-integration/DeleteMSTeamsUserBinding.go diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 73fd548ab55..86edc028374 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1012,6 +1012,13 @@ components: required: true schema: type: string + MicrosoftTeamsTenantIDPathParameter: + description: Your tenant id. + in: path + name: tenant_id + required: true + schema: + type: string MicrosoftTeamsTenantIDQueryParameter: description: Your tenant id. in: query @@ -134956,6 +134963,26 @@ paths: tags: - Microsoft Teams Integration x-codegen-request-body-name: body + /api/v2/integration/ms-teams/configuration/user-binding/{tenant_id}: + delete: + description: Delete the user binding for a given tenant from the Datadog Microsoft Teams integration. + operationId: DeleteMSTeamsUserBinding + parameters: + - $ref: "#/components/parameters/MicrosoftTeamsTenantIDPathParameter" + responses: + "204": + description: No Content + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "412": + $ref: "#/components/responses/PreconditionFailedResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete user binding + tags: + - Microsoft Teams Integration /api/v2/integration/ms-teams/configuration/workflows-webhook-handles: get: description: Get a list of all Workflows webhook handles from the Datadog Microsoft Teams integration. diff --git a/api/datadogV2/api_microsoft_teams_integration.go b/api/datadogV2/api_microsoft_teams_integration.go index 497260697a7..67f48057a38 100644 --- a/api/datadogV2/api_microsoft_teams_integration.go +++ b/api/datadogV2/api_microsoft_teams_integration.go @@ -175,6 +175,74 @@ func (a *MicrosoftTeamsIntegrationApi) CreateWorkflowsWebhookHandle(ctx _context return localVarReturnValue, localVarHTTPResponse, nil } +// DeleteMSTeamsUserBinding Delete user binding. +// Delete the user binding for a given tenant from the Datadog Microsoft Teams integration. +func (a *MicrosoftTeamsIntegrationApi) DeleteMSTeamsUserBinding(ctx _context.Context, tenantId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.MicrosoftTeamsIntegrationApi.DeleteMSTeamsUserBinding") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/ms-teams/configuration/user-binding/{tenant_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{tenant_id}", _neturl.PathEscape(datadog.ParameterToString(tenantId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 412 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // DeleteTenantBasedHandle Delete tenant-based handle. // Delete a tenant-based handle from the Datadog Microsoft Teams integration. func (a *MicrosoftTeamsIntegrationApi) DeleteTenantBasedHandle(ctx _context.Context, handleId string) (*_nethttp.Response, error) { diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index d04ab2db857..7ddb1bad132 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -678,6 +678,7 @@ // - [MetricsApi.UpdateTagIndexingRule] // - [MicrosoftTeamsIntegrationApi.CreateTenantBasedHandle] // - [MicrosoftTeamsIntegrationApi.CreateWorkflowsWebhookHandle] +// - [MicrosoftTeamsIntegrationApi.DeleteMSTeamsUserBinding] // - [MicrosoftTeamsIntegrationApi.DeleteTenantBasedHandle] // - [MicrosoftTeamsIntegrationApi.DeleteWorkflowsWebhookHandle] // - [MicrosoftTeamsIntegrationApi.GetChannelByName] diff --git a/examples/v2/microsoft-teams-integration/DeleteMSTeamsUserBinding.go b/examples/v2/microsoft-teams-integration/DeleteMSTeamsUserBinding.go new file mode 100644 index 00000000000..6a83e2da1f6 --- /dev/null +++ b/examples/v2/microsoft-teams-integration/DeleteMSTeamsUserBinding.go @@ -0,0 +1,25 @@ +// Delete user binding returns "No Content" response + +package main + +import ( + "context" + "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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewMicrosoftTeamsIntegrationApi(apiClient) + r, err := api.DeleteMSTeamsUserBinding(ctx, "tenant_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `MicrosoftTeamsIntegrationApi.DeleteMSTeamsUserBinding`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/tests/scenarios/features/v2/microsoft_teams_integration.feature b/tests/scenarios/features/v2/microsoft_teams_integration.feature index d76425d3759..ddbffd96275 100644 --- a/tests/scenarios/features/v2/microsoft_teams_integration.feature +++ b/tests/scenarios/features/v2/microsoft_teams_integration.feature @@ -146,6 +146,27 @@ Feature: Microsoft Teams Integration When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete user binding returns "Bad Request" response + Given new "DeleteMSTeamsUserBinding" request + And request contains "tenant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete user binding returns "Failed Precondition" response + Given new "DeleteMSTeamsUserBinding" request + And request contains "tenant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 412 Failed Precondition + + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete user binding returns "No Content" response + Given new "DeleteMSTeamsUserBinding" request + And request contains "tenant_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + @team:DataDog/chat-integrations Scenario: Delete workflow webhook handle returns "OK" response Given there is a valid "workflows_webhook_handle" in the system diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index caa628ae031..6af3231d4fe 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3529,6 +3529,12 @@ "type": "idempotent" } }, + "DeleteMSTeamsUserBinding": { + "tag": "Microsoft Teams Integration", + "undo": { + "type": "idempotent" + } + }, "ListWorkflowsWebhookHandles": { "tag": "Microsoft Teams Integration", "undo": { From f64c1562073f358c2dfe9e9237d94acc9decfe1b Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Fri, 12 Jun 2026 10:14:12 +0000 Subject: [PATCH 4/4] Regenerate client from commit d733453 of spec repo (#4214) Co-authored-by: ci.datadog-api-spec --- .generator/schemas/v2/openapi.yaml | 589 ++++++++++++ api/datadogV2/api_google_chat_integration.go | 844 +++++++++++++++++- api/datadogV2/doc.go | 10 + ...l_google_chat_delegated_user_attributes.go | 172 ++++ .../model_google_chat_delegated_user_data.go | 189 ++++ ...del_google_chat_delegated_user_response.go | 110 +++ .../model_google_chat_delegated_user_type.go | 64 ++ ...del_google_chat_organization_attributes.go | 137 +++ .../model_google_chat_organization_data.go | 227 +++++ ..._google_chat_organization_relationships.go | 111 +++ ...ganization_relationships_delegated_user.go | 111 +++ ...ation_relationships_delegated_user_data.go | 151 ++++ ...model_google_chat_organization_response.go | 110 +++ .../model_google_chat_organization_type.go | 64 ++ ...odel_google_chat_organizations_response.go | 101 +++ ..._google_chat_target_audience_attributes.go | 133 +++ ...gle_chat_target_audience_create_request.go | 110 +++ ...rget_audience_create_request_attributes.go | 133 +++ ...hat_target_audience_create_request_data.go | 148 +++ .../model_google_chat_target_audience_data.go | 189 ++++ ...el_google_chat_target_audience_response.go | 110 +++ .../model_google_chat_target_audience_type.go | 64 ++ ...gle_chat_target_audience_update_request.go | 110 +++ ...rget_audience_update_request_attributes.go | 137 +++ ...hat_target_audience_update_request_data.go | 148 +++ ...l_google_chat_target_audiences_response.go | 101 +++ .../CreateGoogleChatTargetAudience.go | 38 + .../DeleteGoogleChatDelegatedUser.go | 25 + .../DeleteGoogleChatOrganization.go | 25 + .../DeleteGoogleChatTargetAudience.go | 25 + .../GetGoogleChatDelegatedUser.go | 29 + .../GetGoogleChatOrganization.go | 29 + .../GetGoogleChatTargetAudience.go | 29 + .../ListGoogleChatOrganizations.go | 29 + .../ListGoogleChatTargetAudiences.go | 29 + .../UpdateGoogleChatTargetAudience.go | 38 + tests/scenarios/features/v2/given.json | 16 + .../v2/google_chat_integration.feature | 167 ++++ tests/scenarios/features/v2/undo.json | 72 ++ 39 files changed, 4881 insertions(+), 43 deletions(-) create mode 100644 api/datadogV2/model_google_chat_delegated_user_attributes.go create mode 100644 api/datadogV2/model_google_chat_delegated_user_data.go create mode 100644 api/datadogV2/model_google_chat_delegated_user_response.go create mode 100644 api/datadogV2/model_google_chat_delegated_user_type.go create mode 100644 api/datadogV2/model_google_chat_organization_attributes.go create mode 100644 api/datadogV2/model_google_chat_organization_data.go create mode 100644 api/datadogV2/model_google_chat_organization_relationships.go create mode 100644 api/datadogV2/model_google_chat_organization_relationships_delegated_user.go create mode 100644 api/datadogV2/model_google_chat_organization_relationships_delegated_user_data.go create mode 100644 api/datadogV2/model_google_chat_organization_response.go create mode 100644 api/datadogV2/model_google_chat_organization_type.go create mode 100644 api/datadogV2/model_google_chat_organizations_response.go create mode 100644 api/datadogV2/model_google_chat_target_audience_attributes.go create mode 100644 api/datadogV2/model_google_chat_target_audience_create_request.go create mode 100644 api/datadogV2/model_google_chat_target_audience_create_request_attributes.go create mode 100644 api/datadogV2/model_google_chat_target_audience_create_request_data.go create mode 100644 api/datadogV2/model_google_chat_target_audience_data.go create mode 100644 api/datadogV2/model_google_chat_target_audience_response.go create mode 100644 api/datadogV2/model_google_chat_target_audience_type.go create mode 100644 api/datadogV2/model_google_chat_target_audience_update_request.go create mode 100644 api/datadogV2/model_google_chat_target_audience_update_request_attributes.go create mode 100644 api/datadogV2/model_google_chat_target_audience_update_request_data.go create mode 100644 api/datadogV2/model_google_chat_target_audiences_response.go create mode 100644 examples/v2/google-chat-integration/CreateGoogleChatTargetAudience.go create mode 100644 examples/v2/google-chat-integration/DeleteGoogleChatDelegatedUser.go create mode 100644 examples/v2/google-chat-integration/DeleteGoogleChatOrganization.go create mode 100644 examples/v2/google-chat-integration/DeleteGoogleChatTargetAudience.go create mode 100644 examples/v2/google-chat-integration/GetGoogleChatDelegatedUser.go create mode 100644 examples/v2/google-chat-integration/GetGoogleChatOrganization.go create mode 100644 examples/v2/google-chat-integration/GetGoogleChatTargetAudience.go create mode 100644 examples/v2/google-chat-integration/ListGoogleChatOrganizations.go create mode 100644 examples/v2/google-chat-integration/ListGoogleChatTargetAudiences.go create mode 100644 examples/v2/google-chat-integration/UpdateGoogleChatTargetAudience.go diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 86edc028374..ce0ea5b8443 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -668,6 +668,13 @@ components: required: true schema: type: string + GoogleChatTargetAudienceIdPathParameter: + description: Your target audience ID. + in: path + name: target_audience_id + required: true + schema: + type: string HistoricalJobID: description: The ID of the job. in: path @@ -40091,6 +40098,84 @@ components: required: - attributes type: object + GoogleChatDelegatedUserAttributes: + description: Google Chat delegated user attributes. + properties: + display_name: + description: The delegated user's display name. + example: "fake-display-name" + type: string + email: + description: The delegated user's email address. + example: "user@example.com" + type: string + features: + description: The list of features enabled for the delegated user. + items: + type: string + type: array + type: object + GoogleChatDelegatedUserData: + description: Google Chat delegated user data from a response. + properties: + attributes: + $ref: "#/components/schemas/GoogleChatDelegatedUserAttributes" + id: + description: The ID of the delegated user. + example: "2b3c4d5e-6f78-9012-bcde-f23456789012" + maxLength: 100 + minLength: 1 + type: string + type: + $ref: "#/components/schemas/GoogleChatDelegatedUserType" + type: object + GoogleChatDelegatedUserResponse: + description: Response containing a Google Chat delegated user. + properties: + data: + $ref: "#/components/schemas/GoogleChatDelegatedUserData" + required: + - data + type: object + GoogleChatDelegatedUserType: + default: google-chat-delegated-user + description: Google Chat delegated user resource type. + enum: + - google-chat-delegated-user + example: google-chat-delegated-user + type: string + x-enum-varnames: + - GOOGLE_CHAT_DELEGATED_USER_TYPE + GoogleChatOrganizationAttributes: + description: Google Chat organization attributes. + properties: + domain_id: + description: The Google Chat organization domain ID. + example: "fake-domain-id" + maxLength: 255 + type: string + domain_name: + description: The Google Chat organization domain name. + example: "example.com" + maxLength: 255 + type: string + type: object + GoogleChatOrganizationData: + description: Google Chat organization data from a response. + properties: + attributes: + $ref: "#/components/schemas/GoogleChatOrganizationAttributes" + id: + description: The ID of the Google Chat organization binding. + example: "5ce87709-a12f-4086-fcc8-147045b73a19" + maxLength: 100 + minLength: 1 + type: string + relationships: + $ref: "#/components/schemas/GoogleChatOrganizationRelationships" + type: + $ref: "#/components/schemas/GoogleChatOrganizationType" + type: object GoogleChatOrganizationHandleResponse: description: Organization handle for monitor notifications to a Google Chat space within a Google organization. properties: @@ -40153,6 +40238,184 @@ components: required: - data type: object + GoogleChatOrganizationRelationships: + description: Google Chat organization relationships. + properties: + delegated_user: + $ref: "#/components/schemas/GoogleChatOrganizationRelationshipsDelegatedUser" + type: object + GoogleChatOrganizationRelationshipsDelegatedUser: + description: The delegated user relationship. + properties: + data: + $ref: "#/components/schemas/GoogleChatOrganizationRelationshipsDelegatedUserData" + type: object + GoogleChatOrganizationRelationshipsDelegatedUserData: + description: Delegated user relationship data. + properties: + id: + description: The ID of the delegated user. + example: "2b3c4d5e-6f78-9012-bcde-f23456789012" + type: string + type: + $ref: "#/components/schemas/GoogleChatDelegatedUserType" + type: object + GoogleChatOrganizationResponse: + description: Response containing a Google Chat organization binding. + properties: + data: + $ref: "#/components/schemas/GoogleChatOrganizationData" + required: + - data + type: object + GoogleChatOrganizationType: + default: google-chat-organization + description: Google Chat organization resource type. + enum: + - google-chat-organization + example: google-chat-organization + type: string + x-enum-varnames: + - GOOGLE_CHAT_ORGANIZATION_TYPE + GoogleChatOrganizationsResponse: + description: Response containing a list of Google Chat organization bindings. + properties: + data: + description: An array of Google Chat organization bindings. + items: + $ref: "#/components/schemas/GoogleChatOrganizationData" + type: array + required: + - data + type: object + GoogleChatTargetAudienceAttributes: + description: Google Chat target audience attributes. + properties: + audience_id: + description: The audience ID. + example: "fake-audience-id-1" + maxLength: 255 + type: string + audience_name: + description: The audience name. + example: "fake audience name 1" + maxLength: 255 + type: string + required: + - audience_name + - audience_id + type: object + GoogleChatTargetAudienceCreateRequest: + description: Create target audience request. + properties: + data: + $ref: "#/components/schemas/GoogleChatTargetAudienceCreateRequestData" + required: + - data + type: object + GoogleChatTargetAudienceCreateRequestAttributes: + description: Attributes for creating a Google Chat target audience. + properties: + audience_id: + description: The audience ID. + example: "fake-audience-id-1" + maxLength: 255 + type: string + audience_name: + description: The audience name. + example: "fake audience name 1" + maxLength: 255 + type: string + required: + - audience_name + - audience_id + type: object + GoogleChatTargetAudienceCreateRequestData: + description: Data for a create target audience request. + properties: + attributes: + $ref: "#/components/schemas/GoogleChatTargetAudienceCreateRequestAttributes" + type: + $ref: "#/components/schemas/GoogleChatTargetAudienceType" + required: + - type + - attributes + type: object + GoogleChatTargetAudienceData: + description: Google Chat target audience data from a response. + properties: + attributes: + $ref: "#/components/schemas/GoogleChatTargetAudienceAttributes" + id: + description: The ID of the target audience. + example: "1f3e5ce6-944a-4075-97ae-105b5920b5cb" + maxLength: 100 + minLength: 1 + type: string + type: + $ref: "#/components/schemas/GoogleChatTargetAudienceType" + type: object + GoogleChatTargetAudienceResponse: + description: Response containing a Google Chat target audience. + properties: + data: + $ref: "#/components/schemas/GoogleChatTargetAudienceData" + required: + - data + type: object + GoogleChatTargetAudienceType: + default: google-chat-target-audience + description: Google Chat target audience resource type. + enum: + - google-chat-target-audience + example: google-chat-target-audience + type: string + x-enum-varnames: + - GOOGLE_CHAT_TARGET_AUDIENCE_TYPE + GoogleChatTargetAudienceUpdateRequest: + description: Update target audience request. + properties: + data: + $ref: "#/components/schemas/GoogleChatTargetAudienceUpdateRequestData" + required: + - data + type: object + GoogleChatTargetAudienceUpdateRequestAttributes: + description: Attributes for updating a Google Chat target audience. + properties: + audience_id: + description: The audience ID. + example: "fake-audience-id-1" + maxLength: 255 + type: string + audience_name: + description: The audience name. + example: "fake audience name 1" + maxLength: 255 + type: string + type: object + GoogleChatTargetAudienceUpdateRequestData: + description: Data for an update target audience request. + properties: + attributes: + $ref: "#/components/schemas/GoogleChatTargetAudienceUpdateRequestAttributes" + type: + $ref: "#/components/schemas/GoogleChatTargetAudienceType" + required: + - type + - attributes + type: object + GoogleChatTargetAudiencesResponse: + description: Response containing a list of Google Chat target audiences. + properties: + data: + description: An array of Google Chat target audiences. + items: + $ref: "#/components/schemas/GoogleChatTargetAudienceData" + type: array + required: + - data + type: object GoogleChatUpdateOrganizationHandleRequest: description: Update organization handle request. properties: @@ -134187,6 +134450,43 @@ paths: operator: OR permissions: - gcp_configuration_edit + /api/v2/integration/google-chat/organizations: + get: + description: Get a list of all Google Chat organization bindings in the Datadog Google Chat integration. + operationId: ListGoogleChatOrganizations + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + domain_id: fake-domain-id + domain_name: example.com + id: 00000000-0000-0000-0000-000000000001 + relationships: + delegated_user: + data: + id: 00000000-0000-0000-0000-000000000002 + type: google-chat-delegated-user + type: google-chat-organization + - attributes: + domain_id: fake-domain-id-2 + domain_name: example2.com + id: 00000000-0000-0000-0000-000000000003 + type: google-chat-organization + schema: + $ref: "#/components/schemas/GoogleChatOrganizationsResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get all Google Chat organization bindings + tags: + - Google Chat Integration /api/v2/integration/google-chat/organizations/app/named-spaces/{domain_name}/{space_display_name}: get: description: Get the resource name and organization binding ID of a space in the Datadog Google Chat integration. @@ -134223,6 +134523,110 @@ paths: summary: Get space information by display name tags: - Google Chat Integration + /api/v2/integration/google-chat/organizations/{organization_binding_id}: + delete: + description: Delete a Google Chat organization binding from the Datadog Google Chat integration. + operationId: DeleteGoogleChatOrganization + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + responses: + "204": + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete a Google Chat organization binding + tags: + - Google Chat Integration + get: + description: Get a Google Chat organization binding from the Datadog Google Chat integration. + operationId: GetGoogleChatOrganization + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + domain_id: fake-domain-id + domain_name: example.com + id: 00000000-0000-0000-0000-000000000001 + relationships: + delegated_user: + data: + id: 00000000-0000-0000-0000-000000000002 + type: google-chat-delegated-user + type: google-chat-organization + schema: + $ref: "#/components/schemas/GoogleChatOrganizationResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get a Google Chat organization binding + tags: + - Google Chat Integration + /api/v2/integration/google-chat/organizations/{organization_binding_id}/delegated-user: + delete: + description: Delete the delegated user for a Google Chat organization binding from the Datadog Google Chat integration. + operationId: DeleteGoogleChatDelegatedUser + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + responses: + "204": + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete the delegated user + tags: + - Google Chat Integration + get: + description: Get the delegated user for a Google Chat organization binding in the Datadog Google Chat integration. + operationId: GetGoogleChatDelegatedUser + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + display_name: fake-display-name + email: user@example.com + features: + - incident-automatic-space-creation + - workflow-space-creation + id: 00000000-0000-0000-0000-000000000002 + type: google-chat-delegated-user + schema: + $ref: "#/components/schemas/GoogleChatDelegatedUserResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get the delegated user + tags: + - Google Chat Integration /api/v2/integration/google-chat/organizations/{organization_binding_id}/organization-handles: get: description: Get a list of all organization handles from the Datadog Google Chat integration. @@ -134423,6 +134827,191 @@ paths: tags: - Google Chat Integration x-codegen-request-body-name: body + /api/v2/integration/google-chat/organizations/{organization_binding_id}/target-audiences: + get: + description: Get a list of all target audiences for a Google Chat organization binding in the Datadog Google Chat integration. + operationId: ListGoogleChatTargetAudiences + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + audience_id: fake-audience-id-1 + audience_name: fake audience name 1 + id: 00000000-0000-0000-0000-000000000004 + type: google-chat-target-audience + - attributes: + audience_id: fake-audience-id-2 + audience_name: fake-audience-name-2 + id: 00000000-0000-0000-0000-000000000005 + type: google-chat-target-audience + schema: + $ref: "#/components/schemas/GoogleChatTargetAudiencesResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get all target audiences + tags: + - Google Chat Integration + post: + description: Create a target audience for a Google Chat organization binding in the Datadog Google Chat integration. + operationId: CreateGoogleChatTargetAudience + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + audience_id: fake-audience-id-1 + audience_name: fake audience name 1 + type: google-chat-target-audience + schema: + $ref: "#/components/schemas/GoogleChatTargetAudienceCreateRequest" + description: Target audience payload. + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + audience_id: fake-audience-id-1 + audience_name: fake audience name 1 + id: 00000000-0000-0000-0000-000000000004 + type: google-chat-target-audience + schema: + $ref: "#/components/schemas/GoogleChatTargetAudienceResponse" + description: CREATED + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "409": + $ref: "#/components/responses/ConflictResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Create a target audience + tags: + - Google Chat Integration + x-codegen-request-body-name: body + /api/v2/integration/google-chat/organizations/{organization_binding_id}/target-audiences/{target_audience_id}: + delete: + description: Delete a target audience from a Google Chat organization binding in the Datadog Google Chat integration. + operationId: DeleteGoogleChatTargetAudience + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + - $ref: "#/components/parameters/GoogleChatTargetAudienceIdPathParameter" + responses: + "204": + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Delete a target audience + tags: + - Google Chat Integration + get: + description: Get a target audience for a Google Chat organization binding in the Datadog Google Chat integration. + operationId: GetGoogleChatTargetAudience + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + - $ref: "#/components/parameters/GoogleChatTargetAudienceIdPathParameter" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + audience_id: fake-audience-id-1 + audience_name: fake audience name 1 + id: 00000000-0000-0000-0000-000000000004 + type: google-chat-target-audience + schema: + $ref: "#/components/schemas/GoogleChatTargetAudienceResponse" + description: OK + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Get a target audience + tags: + - Google Chat Integration + patch: + description: Update a target audience for a Google Chat organization binding in the Datadog Google Chat integration. + operationId: UpdateGoogleChatTargetAudience + parameters: + - $ref: "#/components/parameters/GoogleChatOrganizationBindingIdPathParameter" + - $ref: "#/components/parameters/GoogleChatTargetAudienceIdPathParameter" + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + audience_id: updated-audience-id + audience_name: updated-audience-name + type: google-chat-target-audience + schema: + $ref: "#/components/schemas/GoogleChatTargetAudienceUpdateRequest" + description: Target audience payload. + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + audience_id: updated-audience-id + audience_name: updated-audience-name + id: 00000000-0000-0000-0000-000000000004 + type: google-chat-target-audience + schema: + $ref: "#/components/schemas/GoogleChatTargetAudienceResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/ForbiddenResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Update a target audience + tags: + - Google Chat Integration + x-codegen-request-body-name: body /api/v2/integration/jira/accounts: get: description: |- diff --git a/api/datadogV2/api_google_chat_integration.go b/api/datadogV2/api_google_chat_integration.go index dcf1ace94b2..518db122b91 100644 --- a/api/datadogV2/api_google_chat_integration.go +++ b/api/datadogV2/api_google_chat_integration.go @@ -15,6 +15,87 @@ import ( // GoogleChatIntegrationApi service type type GoogleChatIntegrationApi datadog.Service +// CreateGoogleChatTargetAudience Create a target audience. +// Create a target audience for a Google Chat organization binding in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) CreateGoogleChatTargetAudience(ctx _context.Context, organizationBindingId string, body GoogleChatTargetAudienceCreateRequest) (GoogleChatTargetAudienceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue GoogleChatTargetAudienceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.CreateGoogleChatTargetAudience") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/target-audiences" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 404 || localVarHTTPResponse.StatusCode == 409 || 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 +} + // CreateOrganizationHandle Create organization handle. // Create an organization handle in the Datadog Google Chat integration. func (a *GoogleChatIntegrationApi) CreateOrganizationHandle(ctx _context.Context, organizationBindingId string, body GoogleChatCreateOrganizationHandleRequest) (GoogleChatOrganizationHandleResponse, *_nethttp.Response, error) { @@ -96,22 +177,89 @@ func (a *GoogleChatIntegrationApi) CreateOrganizationHandle(ctx _context.Context return localVarReturnValue, localVarHTTPResponse, nil } -// DeleteOrganizationHandle Delete organization handle. -// Delete an organization handle from the Datadog Google Chat integration. -func (a *GoogleChatIntegrationApi) DeleteOrganizationHandle(ctx _context.Context, organizationBindingId string, handleId string) (*_nethttp.Response, error) { +// DeleteGoogleChatDelegatedUser Delete the delegated user. +// Delete the delegated user for a Google Chat organization binding from the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) DeleteGoogleChatDelegatedUser(ctx _context.Context, organizationBindingId string) (*_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodDelete localVarPostBody interface{} ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.DeleteOrganizationHandle") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.DeleteGoogleChatDelegatedUser") if err != nil { return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/organization-handles/{handle_id}" + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/delegated-user" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// DeleteGoogleChatOrganization Delete a Google Chat organization binding. +// Delete a Google Chat organization binding from the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) DeleteGoogleChatOrganization(ctx _context.Context, organizationBindingId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.DeleteGoogleChatOrganization") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}" localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) - localVarPath = datadog.ReplacePathParameter(localVarPath, "{handle_id}", _neturl.PathEscape(datadog.ParameterToString(handleId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -165,33 +313,32 @@ func (a *GoogleChatIntegrationApi) DeleteOrganizationHandle(ctx _context.Context return localVarHTTPResponse, nil } -// GetOrganizationHandle Get organization handle. -// Get an organization handle from the Datadog Google Chat integration. -func (a *GoogleChatIntegrationApi) GetOrganizationHandle(ctx _context.Context, organizationBindingId string, handleId string) (GoogleChatOrganizationHandleResponse, *_nethttp.Response, error) { +// DeleteGoogleChatTargetAudience Delete a target audience. +// Delete a target audience from a Google Chat organization binding in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) DeleteGoogleChatTargetAudience(ctx _context.Context, organizationBindingId string, targetAudienceId string) (*_nethttp.Response, error) { var ( - localVarHTTPMethod = _nethttp.MethodGet - localVarPostBody interface{} - localVarReturnValue GoogleChatOrganizationHandleResponse + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.GetOrganizationHandle") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.DeleteGoogleChatTargetAudience") if err != nil { - return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/organization-handles/{handle_id}" + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/target-audiences/{target_audience_id}" localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) - localVarPath = datadog.ReplacePathParameter(localVarPath, "{handle_id}", _neturl.PathEscape(datadog.ParameterToString(handleId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{target_audience_id}", _neturl.PathEscape(datadog.ParameterToString(targetAudienceId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} localVarFormParams := _neturl.Values{} - localVarHeaderParams["Accept"] = "application/json" + localVarHeaderParams["Accept"] = "*/*" if a.Client.Cfg.DelegatedTokenConfig != nil { err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) if err != nil { - return localVarReturnValue, nil, err + return nil, err } } else { datadog.SetAuthKeys( @@ -203,17 +350,17 @@ func (a *GoogleChatIntegrationApi) GetOrganizationHandle(ctx _context.Context, o } req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) if err != nil { - return localVarReturnValue, nil, err + return nil, err } localVarHTTPResponse, err := a.Client.CallAPI(req) if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err + return localVarHTTPResponse, err } localVarBody, err := datadog.ReadBody(localVarHTTPResponse) if err != nil { - return localVarReturnValue, localVarHTTPResponse, err + return localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -221,46 +368,105 @@ func (a *GoogleChatIntegrationApi) GetOrganizationHandle(ctx _context.Context, o ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { - return localVarReturnValue, localVarHTTPResponse, newErr + return localVarHTTPResponse, newErr } newErr.ErrorModel = v } - return localVarReturnValue, localVarHTTPResponse, newErr + return localVarHTTPResponse, newErr } - err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + return localVarHTTPResponse, nil +} + +// DeleteOrganizationHandle Delete organization handle. +// Delete an organization handle from the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) DeleteOrganizationHandle(ctx _context.Context, organizationBindingId string, handleId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.DeleteOrganizationHandle") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/organization-handles/{handle_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{handle_id}", _neturl.PathEscape(datadog.ParameterToString(handleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { newErr := datadog.GenericOpenAPIError{ ErrorBody: localVarBody, - ErrorMessage: err.Error(), + ErrorMessage: localVarHTTPResponse.Status, } - return localVarReturnValue, localVarHTTPResponse, newErr + 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 localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr } - return localVarReturnValue, localVarHTTPResponse, nil + return localVarHTTPResponse, nil } -// GetSpaceByDisplayName Get space information by display name. -// Get the resource name and organization binding ID of a space in the Datadog Google Chat integration. -func (a *GoogleChatIntegrationApi) GetSpaceByDisplayName(ctx _context.Context, domainName string, spaceDisplayName string) (GoogleChatAppNamedSpaceResponse, *_nethttp.Response, error) { +// GetGoogleChatDelegatedUser Get the delegated user. +// Get the delegated user for a Google Chat organization binding in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) GetGoogleChatDelegatedUser(ctx _context.Context, organizationBindingId string) (GoogleChatDelegatedUserResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue GoogleChatAppNamedSpaceResponse + localVarReturnValue GoogleChatDelegatedUserResponse ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.GetSpaceByDisplayName") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.GetGoogleChatDelegatedUser") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/app/named-spaces/{domain_name}/{space_display_name}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{domain_name}", _neturl.PathEscape(datadog.ParameterToString(domainName, ""))) - localVarPath = datadog.ReplacePathParameter(localVarPath, "{space_display_name}", _neturl.PathEscape(datadog.ParameterToString(spaceDisplayName, ""))) + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/delegated-user" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -300,7 +506,7 @@ func (a *GoogleChatIntegrationApi) GetSpaceByDisplayName(ctx _context.Context, d ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -323,21 +529,21 @@ func (a *GoogleChatIntegrationApi) GetSpaceByDisplayName(ctx _context.Context, d return localVarReturnValue, localVarHTTPResponse, nil } -// ListOrganizationHandles Get all organization handles. -// Get a list of all organization handles from the Datadog Google Chat integration. -func (a *GoogleChatIntegrationApi) ListOrganizationHandles(ctx _context.Context, organizationBindingId string) (GoogleChatOrganizationHandlesResponse, *_nethttp.Response, error) { +// GetGoogleChatOrganization Get a Google Chat organization binding. +// Get a Google Chat organization binding from the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) GetGoogleChatOrganization(ctx _context.Context, organizationBindingId string) (GoogleChatOrganizationResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue GoogleChatOrganizationHandlesResponse + localVarReturnValue GoogleChatOrganizationResponse ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.ListOrganizationHandles") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.GetGoogleChatOrganization") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/organization-handles" + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}" localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) localVarHeaderParams := make(map[string]string) @@ -373,6 +579,558 @@ func (a *GoogleChatIntegrationApi) ListOrganizationHandles(ctx _context.Context, return localVarReturnValue, localVarHTTPResponse, err } + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || 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 +} + +// GetGoogleChatTargetAudience Get a target audience. +// Get a target audience for a Google Chat organization binding in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) GetGoogleChatTargetAudience(ctx _context.Context, organizationBindingId string, targetAudienceId string) (GoogleChatTargetAudienceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GoogleChatTargetAudienceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.GetGoogleChatTargetAudience") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/target-audiences/{target_audience_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{target_audience_id}", _neturl.PathEscape(datadog.ParameterToString(targetAudienceId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 403 || localVarHTTPResponse.StatusCode == 404 || 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 +} + +// GetOrganizationHandle Get organization handle. +// Get an organization handle from the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) GetOrganizationHandle(ctx _context.Context, organizationBindingId string, handleId string) (GoogleChatOrganizationHandleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GoogleChatOrganizationHandleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.GetOrganizationHandle") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/organization-handles/{handle_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{handle_id}", _neturl.PathEscape(datadog.ParameterToString(handleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 404 || 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 +} + +// GetSpaceByDisplayName Get space information by display name. +// Get the resource name and organization binding ID of a space in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) GetSpaceByDisplayName(ctx _context.Context, domainName string, spaceDisplayName string) (GoogleChatAppNamedSpaceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GoogleChatAppNamedSpaceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.GetSpaceByDisplayName") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/app/named-spaces/{domain_name}/{space_display_name}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{domain_name}", _neturl.PathEscape(datadog.ParameterToString(domainName, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{space_display_name}", _neturl.PathEscape(datadog.ParameterToString(spaceDisplayName, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 404 || 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 +} + +// ListGoogleChatOrganizations Get all Google Chat organization bindings. +// Get a list of all Google Chat organization bindings in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) ListGoogleChatOrganizations(ctx _context.Context) (GoogleChatOrganizationsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GoogleChatOrganizationsResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.ListGoogleChatOrganizations") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 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 +} + +// ListGoogleChatTargetAudiences Get all target audiences. +// Get a list of all target audiences for a Google Chat organization binding in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) ListGoogleChatTargetAudiences(ctx _context.Context, organizationBindingId string) (GoogleChatTargetAudiencesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GoogleChatTargetAudiencesResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.ListGoogleChatTargetAudiences") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/target-audiences" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 403 || localVarHTTPResponse.StatusCode == 404 || 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 +} + +// ListOrganizationHandles Get all organization handles. +// Get a list of all organization handles from the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) ListOrganizationHandles(ctx _context.Context, organizationBindingId string) (GoogleChatOrganizationHandlesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue GoogleChatOrganizationHandlesResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.ListOrganizationHandles") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/organization-handles" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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 == 404 || 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 +} + +// UpdateGoogleChatTargetAudience Update a target audience. +// Update a target audience for a Google Chat organization binding in the Datadog Google Chat integration. +func (a *GoogleChatIntegrationApi) UpdateGoogleChatTargetAudience(ctx _context.Context, organizationBindingId string, targetAudienceId string, body GoogleChatTargetAudienceUpdateRequest) (GoogleChatTargetAudienceResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue GoogleChatTargetAudienceResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.GoogleChatIntegrationApi.UpdateGoogleChatTargetAudience") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/google-chat/organizations/{organization_binding_id}/target-audiences/{target_audience_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{organization_binding_id}", _neturl.PathEscape(datadog.ParameterToString(organizationBindingId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{target_audience_id}", _neturl.PathEscape(datadog.ParameterToString(targetAudienceId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + 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, diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 7ddb1bad132..c74004601b9 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -462,11 +462,21 @@ // - [GCPIntegrationApi.ListGCPSTSAccounts] // - [GCPIntegrationApi.MakeGCPSTSDelegate] // - [GCPIntegrationApi.UpdateGCPSTSAccount] +// - [GoogleChatIntegrationApi.CreateGoogleChatTargetAudience] // - [GoogleChatIntegrationApi.CreateOrganizationHandle] +// - [GoogleChatIntegrationApi.DeleteGoogleChatDelegatedUser] +// - [GoogleChatIntegrationApi.DeleteGoogleChatOrganization] +// - [GoogleChatIntegrationApi.DeleteGoogleChatTargetAudience] // - [GoogleChatIntegrationApi.DeleteOrganizationHandle] +// - [GoogleChatIntegrationApi.GetGoogleChatDelegatedUser] +// - [GoogleChatIntegrationApi.GetGoogleChatOrganization] +// - [GoogleChatIntegrationApi.GetGoogleChatTargetAudience] // - [GoogleChatIntegrationApi.GetOrganizationHandle] // - [GoogleChatIntegrationApi.GetSpaceByDisplayName] +// - [GoogleChatIntegrationApi.ListGoogleChatOrganizations] +// - [GoogleChatIntegrationApi.ListGoogleChatTargetAudiences] // - [GoogleChatIntegrationApi.ListOrganizationHandles] +// - [GoogleChatIntegrationApi.UpdateGoogleChatTargetAudience] // - [GoogleChatIntegrationApi.UpdateOrganizationHandle] // - [HighAvailabilityMultiRegionApi.CreateHamrOrgConnection] // - [HighAvailabilityMultiRegionApi.GetHamrOrgConnection] diff --git a/api/datadogV2/model_google_chat_delegated_user_attributes.go b/api/datadogV2/model_google_chat_delegated_user_attributes.go new file mode 100644 index 00000000000..123b127ec22 --- /dev/null +++ b/api/datadogV2/model_google_chat_delegated_user_attributes.go @@ -0,0 +1,172 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatDelegatedUserAttributes Google Chat delegated user attributes. +type GoogleChatDelegatedUserAttributes struct { + // The delegated user's display name. + DisplayName *string `json:"display_name,omitempty"` + // The delegated user's email address. + Email *string `json:"email,omitempty"` + // The list of features enabled for the delegated user. + Features []string `json:"features,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatDelegatedUserAttributes instantiates a new GoogleChatDelegatedUserAttributes 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 NewGoogleChatDelegatedUserAttributes() *GoogleChatDelegatedUserAttributes { + this := GoogleChatDelegatedUserAttributes{} + return &this +} + +// NewGoogleChatDelegatedUserAttributesWithDefaults instantiates a new GoogleChatDelegatedUserAttributes 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 NewGoogleChatDelegatedUserAttributesWithDefaults() *GoogleChatDelegatedUserAttributes { + this := GoogleChatDelegatedUserAttributes{} + return &this +} + +// GetDisplayName returns the DisplayName field value if set, zero value otherwise. +func (o *GoogleChatDelegatedUserAttributes) GetDisplayName() string { + if o == nil || o.DisplayName == nil { + var ret string + return ret + } + return *o.DisplayName +} + +// GetDisplayNameOk returns a tuple with the DisplayName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatDelegatedUserAttributes) GetDisplayNameOk() (*string, bool) { + if o == nil || o.DisplayName == nil { + return nil, false + } + return o.DisplayName, true +} + +// HasDisplayName returns a boolean if a field has been set. +func (o *GoogleChatDelegatedUserAttributes) HasDisplayName() bool { + return o != nil && o.DisplayName != nil +} + +// SetDisplayName gets a reference to the given string and assigns it to the DisplayName field. +func (o *GoogleChatDelegatedUserAttributes) SetDisplayName(v string) { + o.DisplayName = &v +} + +// GetEmail returns the Email field value if set, zero value otherwise. +func (o *GoogleChatDelegatedUserAttributes) GetEmail() string { + if o == nil || o.Email == nil { + var ret string + return ret + } + return *o.Email +} + +// GetEmailOk returns a tuple with the Email field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatDelegatedUserAttributes) GetEmailOk() (*string, bool) { + if o == nil || o.Email == nil { + return nil, false + } + return o.Email, true +} + +// HasEmail returns a boolean if a field has been set. +func (o *GoogleChatDelegatedUserAttributes) HasEmail() bool { + return o != nil && o.Email != nil +} + +// SetEmail gets a reference to the given string and assigns it to the Email field. +func (o *GoogleChatDelegatedUserAttributes) SetEmail(v string) { + o.Email = &v +} + +// GetFeatures returns the Features field value if set, zero value otherwise. +func (o *GoogleChatDelegatedUserAttributes) GetFeatures() []string { + if o == nil || o.Features == nil { + var ret []string + return ret + } + return o.Features +} + +// GetFeaturesOk returns a tuple with the Features field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatDelegatedUserAttributes) GetFeaturesOk() (*[]string, bool) { + if o == nil || o.Features == nil { + return nil, false + } + return &o.Features, true +} + +// HasFeatures returns a boolean if a field has been set. +func (o *GoogleChatDelegatedUserAttributes) HasFeatures() bool { + return o != nil && o.Features != nil +} + +// SetFeatures gets a reference to the given []string and assigns it to the Features field. +func (o *GoogleChatDelegatedUserAttributes) SetFeatures(v []string) { + o.Features = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatDelegatedUserAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.DisplayName != nil { + toSerialize["display_name"] = o.DisplayName + } + if o.Email != nil { + toSerialize["email"] = o.Email + } + if o.Features != nil { + toSerialize["features"] = o.Features + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatDelegatedUserAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DisplayName *string `json:"display_name,omitempty"` + Email *string `json:"email,omitempty"` + Features []string `json:"features,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"display_name", "email", "features"}) + } else { + return err + } + o.DisplayName = all.DisplayName + o.Email = all.Email + o.Features = all.Features + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_delegated_user_data.go b/api/datadogV2/model_google_chat_delegated_user_data.go new file mode 100644 index 00000000000..99846fad91e --- /dev/null +++ b/api/datadogV2/model_google_chat_delegated_user_data.go @@ -0,0 +1,189 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatDelegatedUserData Google Chat delegated user data from a response. +type GoogleChatDelegatedUserData struct { + // Google Chat delegated user attributes. + Attributes *GoogleChatDelegatedUserAttributes `json:"attributes,omitempty"` + // The ID of the delegated user. + Id *string `json:"id,omitempty"` + // Google Chat delegated user resource type. + Type *GoogleChatDelegatedUserType `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{} `json:"-"` +} + +// NewGoogleChatDelegatedUserData instantiates a new GoogleChatDelegatedUserData 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 NewGoogleChatDelegatedUserData() *GoogleChatDelegatedUserData { + this := GoogleChatDelegatedUserData{} + var typeVar GoogleChatDelegatedUserType = GOOGLECHATDELEGATEDUSERTYPE_GOOGLE_CHAT_DELEGATED_USER_TYPE + this.Type = &typeVar + return &this +} + +// NewGoogleChatDelegatedUserDataWithDefaults instantiates a new GoogleChatDelegatedUserData 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 NewGoogleChatDelegatedUserDataWithDefaults() *GoogleChatDelegatedUserData { + this := GoogleChatDelegatedUserData{} + var typeVar GoogleChatDelegatedUserType = GOOGLECHATDELEGATEDUSERTYPE_GOOGLE_CHAT_DELEGATED_USER_TYPE + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GoogleChatDelegatedUserData) GetAttributes() GoogleChatDelegatedUserAttributes { + if o == nil || o.Attributes == nil { + var ret GoogleChatDelegatedUserAttributes + 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 *GoogleChatDelegatedUserData) GetAttributesOk() (*GoogleChatDelegatedUserAttributes, 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 *GoogleChatDelegatedUserData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GoogleChatDelegatedUserAttributes and assigns it to the Attributes field. +func (o *GoogleChatDelegatedUserData) SetAttributes(v GoogleChatDelegatedUserAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GoogleChatDelegatedUserData) 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 *GoogleChatDelegatedUserData) 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 *GoogleChatDelegatedUserData) 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 *GoogleChatDelegatedUserData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GoogleChatDelegatedUserData) GetType() GoogleChatDelegatedUserType { + if o == nil || o.Type == nil { + var ret GoogleChatDelegatedUserType + 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 *GoogleChatDelegatedUserData) GetTypeOk() (*GoogleChatDelegatedUserType, 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 *GoogleChatDelegatedUserData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GoogleChatDelegatedUserType and assigns it to the Type field. +func (o *GoogleChatDelegatedUserData) SetType(v GoogleChatDelegatedUserType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatDelegatedUserData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatDelegatedUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GoogleChatDelegatedUserAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *GoogleChatDelegatedUserType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(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 datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_delegated_user_response.go b/api/datadogV2/model_google_chat_delegated_user_response.go new file mode 100644 index 00000000000..fc22b815536 --- /dev/null +++ b/api/datadogV2/model_google_chat_delegated_user_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatDelegatedUserResponse Response containing a Google Chat delegated user. +type GoogleChatDelegatedUserResponse struct { + // Google Chat delegated user data from a response. + Data GoogleChatDelegatedUserData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatDelegatedUserResponse instantiates a new GoogleChatDelegatedUserResponse 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 NewGoogleChatDelegatedUserResponse(data GoogleChatDelegatedUserData) *GoogleChatDelegatedUserResponse { + this := GoogleChatDelegatedUserResponse{} + this.Data = data + return &this +} + +// NewGoogleChatDelegatedUserResponseWithDefaults instantiates a new GoogleChatDelegatedUserResponse 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 NewGoogleChatDelegatedUserResponseWithDefaults() *GoogleChatDelegatedUserResponse { + this := GoogleChatDelegatedUserResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GoogleChatDelegatedUserResponse) GetData() GoogleChatDelegatedUserData { + if o == nil { + var ret GoogleChatDelegatedUserData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GoogleChatDelegatedUserResponse) GetDataOk() (*GoogleChatDelegatedUserData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GoogleChatDelegatedUserResponse) SetData(v GoogleChatDelegatedUserData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatDelegatedUserResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatDelegatedUserResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GoogleChatDelegatedUserData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_delegated_user_type.go b/api/datadogV2/model_google_chat_delegated_user_type.go new file mode 100644 index 00000000000..810d662ac43 --- /dev/null +++ b/api/datadogV2/model_google_chat_delegated_user_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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatDelegatedUserType Google Chat delegated user resource type. +type GoogleChatDelegatedUserType string + +// List of GoogleChatDelegatedUserType. +const ( + GOOGLECHATDELEGATEDUSERTYPE_GOOGLE_CHAT_DELEGATED_USER_TYPE GoogleChatDelegatedUserType = "google-chat-delegated-user" +) + +var allowedGoogleChatDelegatedUserTypeEnumValues = []GoogleChatDelegatedUserType{ + GOOGLECHATDELEGATEDUSERTYPE_GOOGLE_CHAT_DELEGATED_USER_TYPE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GoogleChatDelegatedUserType) GetAllowedValues() []GoogleChatDelegatedUserType { + return allowedGoogleChatDelegatedUserTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GoogleChatDelegatedUserType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GoogleChatDelegatedUserType(value) + return nil +} + +// NewGoogleChatDelegatedUserTypeFromValue returns a pointer to a valid GoogleChatDelegatedUserType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGoogleChatDelegatedUserTypeFromValue(v string) (*GoogleChatDelegatedUserType, error) { + ev := GoogleChatDelegatedUserType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GoogleChatDelegatedUserType: valid values are %v", v, allowedGoogleChatDelegatedUserTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GoogleChatDelegatedUserType) IsValid() bool { + for _, existing := range allowedGoogleChatDelegatedUserTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GoogleChatDelegatedUserType value. +func (v GoogleChatDelegatedUserType) Ptr() *GoogleChatDelegatedUserType { + return &v +} diff --git a/api/datadogV2/model_google_chat_organization_attributes.go b/api/datadogV2/model_google_chat_organization_attributes.go new file mode 100644 index 00000000000..9ddba3b538f --- /dev/null +++ b/api/datadogV2/model_google_chat_organization_attributes.go @@ -0,0 +1,137 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationAttributes Google Chat organization attributes. +type GoogleChatOrganizationAttributes struct { + // The Google Chat organization domain ID. + DomainId *string `json:"domain_id,omitempty"` + // The Google Chat organization domain name. + DomainName *string `json:"domain_name,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatOrganizationAttributes instantiates a new GoogleChatOrganizationAttributes 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 NewGoogleChatOrganizationAttributes() *GoogleChatOrganizationAttributes { + this := GoogleChatOrganizationAttributes{} + return &this +} + +// NewGoogleChatOrganizationAttributesWithDefaults instantiates a new GoogleChatOrganizationAttributes 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 NewGoogleChatOrganizationAttributesWithDefaults() *GoogleChatOrganizationAttributes { + this := GoogleChatOrganizationAttributes{} + return &this +} + +// GetDomainId returns the DomainId field value if set, zero value otherwise. +func (o *GoogleChatOrganizationAttributes) GetDomainId() string { + if o == nil || o.DomainId == nil { + var ret string + return ret + } + return *o.DomainId +} + +// GetDomainIdOk returns a tuple with the DomainId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatOrganizationAttributes) GetDomainIdOk() (*string, bool) { + if o == nil || o.DomainId == nil { + return nil, false + } + return o.DomainId, true +} + +// HasDomainId returns a boolean if a field has been set. +func (o *GoogleChatOrganizationAttributes) HasDomainId() bool { + return o != nil && o.DomainId != nil +} + +// SetDomainId gets a reference to the given string and assigns it to the DomainId field. +func (o *GoogleChatOrganizationAttributes) SetDomainId(v string) { + o.DomainId = &v +} + +// GetDomainName returns the DomainName field value if set, zero value otherwise. +func (o *GoogleChatOrganizationAttributes) GetDomainName() string { + if o == nil || o.DomainName == nil { + var ret string + return ret + } + return *o.DomainName +} + +// GetDomainNameOk returns a tuple with the DomainName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatOrganizationAttributes) GetDomainNameOk() (*string, bool) { + if o == nil || o.DomainName == nil { + return nil, false + } + return o.DomainName, true +} + +// HasDomainName returns a boolean if a field has been set. +func (o *GoogleChatOrganizationAttributes) HasDomainName() bool { + return o != nil && o.DomainName != nil +} + +// SetDomainName gets a reference to the given string and assigns it to the DomainName field. +func (o *GoogleChatOrganizationAttributes) SetDomainName(v string) { + o.DomainName = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatOrganizationAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.DomainId != nil { + toSerialize["domain_id"] = o.DomainId + } + if o.DomainName != nil { + toSerialize["domain_name"] = o.DomainName + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatOrganizationAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DomainId *string `json:"domain_id,omitempty"` + DomainName *string `json:"domain_name,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"domain_id", "domain_name"}) + } else { + return err + } + o.DomainId = all.DomainId + o.DomainName = all.DomainName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_organization_data.go b/api/datadogV2/model_google_chat_organization_data.go new file mode 100644 index 00000000000..a2a63a79cb7 --- /dev/null +++ b/api/datadogV2/model_google_chat_organization_data.go @@ -0,0 +1,227 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationData Google Chat organization data from a response. +type GoogleChatOrganizationData struct { + // Google Chat organization attributes. + Attributes *GoogleChatOrganizationAttributes `json:"attributes,omitempty"` + // The ID of the Google Chat organization binding. + Id *string `json:"id,omitempty"` + // Google Chat organization relationships. + Relationships *GoogleChatOrganizationRelationships `json:"relationships,omitempty"` + // Google Chat organization resource type. + Type *GoogleChatOrganizationType `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{} `json:"-"` +} + +// NewGoogleChatOrganizationData instantiates a new GoogleChatOrganizationData 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 NewGoogleChatOrganizationData() *GoogleChatOrganizationData { + this := GoogleChatOrganizationData{} + var typeVar GoogleChatOrganizationType = GOOGLECHATORGANIZATIONTYPE_GOOGLE_CHAT_ORGANIZATION_TYPE + this.Type = &typeVar + return &this +} + +// NewGoogleChatOrganizationDataWithDefaults instantiates a new GoogleChatOrganizationData 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 NewGoogleChatOrganizationDataWithDefaults() *GoogleChatOrganizationData { + this := GoogleChatOrganizationData{} + var typeVar GoogleChatOrganizationType = GOOGLECHATORGANIZATIONTYPE_GOOGLE_CHAT_ORGANIZATION_TYPE + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GoogleChatOrganizationData) GetAttributes() GoogleChatOrganizationAttributes { + if o == nil || o.Attributes == nil { + var ret GoogleChatOrganizationAttributes + 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 *GoogleChatOrganizationData) GetAttributesOk() (*GoogleChatOrganizationAttributes, 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 *GoogleChatOrganizationData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GoogleChatOrganizationAttributes and assigns it to the Attributes field. +func (o *GoogleChatOrganizationData) SetAttributes(v GoogleChatOrganizationAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GoogleChatOrganizationData) 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 *GoogleChatOrganizationData) 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 *GoogleChatOrganizationData) 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 *GoogleChatOrganizationData) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *GoogleChatOrganizationData) GetRelationships() GoogleChatOrganizationRelationships { + if o == nil || o.Relationships == nil { + var ret GoogleChatOrganizationRelationships + 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 *GoogleChatOrganizationData) GetRelationshipsOk() (*GoogleChatOrganizationRelationships, 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 *GoogleChatOrganizationData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given GoogleChatOrganizationRelationships and assigns it to the Relationships field. +func (o *GoogleChatOrganizationData) SetRelationships(v GoogleChatOrganizationRelationships) { + o.Relationships = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GoogleChatOrganizationData) GetType() GoogleChatOrganizationType { + if o == nil || o.Type == nil { + var ret GoogleChatOrganizationType + 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 *GoogleChatOrganizationData) GetTypeOk() (*GoogleChatOrganizationType, 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 *GoogleChatOrganizationData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GoogleChatOrganizationType and assigns it to the Type field. +func (o *GoogleChatOrganizationData) SetType(v GoogleChatOrganizationType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatOrganizationData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatOrganizationData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GoogleChatOrganizationAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Relationships *GoogleChatOrganizationRelationships `json:"relationships,omitempty"` + Type *GoogleChatOrganizationType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(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 datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_organization_relationships.go b/api/datadogV2/model_google_chat_organization_relationships.go new file mode 100644 index 00000000000..8aca6cae4a9 --- /dev/null +++ b/api/datadogV2/model_google_chat_organization_relationships.go @@ -0,0 +1,111 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationRelationships Google Chat organization relationships. +type GoogleChatOrganizationRelationships struct { + // The delegated user relationship. + DelegatedUser *GoogleChatOrganizationRelationshipsDelegatedUser `json:"delegated_user,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatOrganizationRelationships instantiates a new GoogleChatOrganizationRelationships 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 NewGoogleChatOrganizationRelationships() *GoogleChatOrganizationRelationships { + this := GoogleChatOrganizationRelationships{} + return &this +} + +// NewGoogleChatOrganizationRelationshipsWithDefaults instantiates a new GoogleChatOrganizationRelationships 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 NewGoogleChatOrganizationRelationshipsWithDefaults() *GoogleChatOrganizationRelationships { + this := GoogleChatOrganizationRelationships{} + return &this +} + +// GetDelegatedUser returns the DelegatedUser field value if set, zero value otherwise. +func (o *GoogleChatOrganizationRelationships) GetDelegatedUser() GoogleChatOrganizationRelationshipsDelegatedUser { + if o == nil || o.DelegatedUser == nil { + var ret GoogleChatOrganizationRelationshipsDelegatedUser + return ret + } + return *o.DelegatedUser +} + +// GetDelegatedUserOk returns a tuple with the DelegatedUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatOrganizationRelationships) GetDelegatedUserOk() (*GoogleChatOrganizationRelationshipsDelegatedUser, bool) { + if o == nil || o.DelegatedUser == nil { + return nil, false + } + return o.DelegatedUser, true +} + +// HasDelegatedUser returns a boolean if a field has been set. +func (o *GoogleChatOrganizationRelationships) HasDelegatedUser() bool { + return o != nil && o.DelegatedUser != nil +} + +// SetDelegatedUser gets a reference to the given GoogleChatOrganizationRelationshipsDelegatedUser and assigns it to the DelegatedUser field. +func (o *GoogleChatOrganizationRelationships) SetDelegatedUser(v GoogleChatOrganizationRelationshipsDelegatedUser) { + o.DelegatedUser = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatOrganizationRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.DelegatedUser != nil { + toSerialize["delegated_user"] = o.DelegatedUser + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatOrganizationRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DelegatedUser *GoogleChatOrganizationRelationshipsDelegatedUser `json:"delegated_user,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"delegated_user"}) + } else { + return err + } + + hasInvalidField := false + if all.DelegatedUser != nil && all.DelegatedUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.DelegatedUser = all.DelegatedUser + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_organization_relationships_delegated_user.go b/api/datadogV2/model_google_chat_organization_relationships_delegated_user.go new file mode 100644 index 00000000000..6a8e1311e5f --- /dev/null +++ b/api/datadogV2/model_google_chat_organization_relationships_delegated_user.go @@ -0,0 +1,111 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationRelationshipsDelegatedUser The delegated user relationship. +type GoogleChatOrganizationRelationshipsDelegatedUser struct { + // Delegated user relationship data. + Data *GoogleChatOrganizationRelationshipsDelegatedUserData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatOrganizationRelationshipsDelegatedUser instantiates a new GoogleChatOrganizationRelationshipsDelegatedUser 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 NewGoogleChatOrganizationRelationshipsDelegatedUser() *GoogleChatOrganizationRelationshipsDelegatedUser { + this := GoogleChatOrganizationRelationshipsDelegatedUser{} + return &this +} + +// NewGoogleChatOrganizationRelationshipsDelegatedUserWithDefaults instantiates a new GoogleChatOrganizationRelationshipsDelegatedUser 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 NewGoogleChatOrganizationRelationshipsDelegatedUserWithDefaults() *GoogleChatOrganizationRelationshipsDelegatedUser { + this := GoogleChatOrganizationRelationshipsDelegatedUser{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *GoogleChatOrganizationRelationshipsDelegatedUser) GetData() GoogleChatOrganizationRelationshipsDelegatedUserData { + if o == nil || o.Data == nil { + var ret GoogleChatOrganizationRelationshipsDelegatedUserData + 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 *GoogleChatOrganizationRelationshipsDelegatedUser) GetDataOk() (*GoogleChatOrganizationRelationshipsDelegatedUserData, 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 *GoogleChatOrganizationRelationshipsDelegatedUser) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given GoogleChatOrganizationRelationshipsDelegatedUserData and assigns it to the Data field. +func (o *GoogleChatOrganizationRelationshipsDelegatedUser) SetData(v GoogleChatOrganizationRelationshipsDelegatedUserData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatOrganizationRelationshipsDelegatedUser) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatOrganizationRelationshipsDelegatedUser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GoogleChatOrganizationRelationshipsDelegatedUserData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_organization_relationships_delegated_user_data.go b/api/datadogV2/model_google_chat_organization_relationships_delegated_user_data.go new file mode 100644 index 00000000000..28fe7f72d3d --- /dev/null +++ b/api/datadogV2/model_google_chat_organization_relationships_delegated_user_data.go @@ -0,0 +1,151 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationRelationshipsDelegatedUserData Delegated user relationship data. +type GoogleChatOrganizationRelationshipsDelegatedUserData struct { + // The ID of the delegated user. + Id *string `json:"id,omitempty"` + // Google Chat delegated user resource type. + Type *GoogleChatDelegatedUserType `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{} `json:"-"` +} + +// NewGoogleChatOrganizationRelationshipsDelegatedUserData instantiates a new GoogleChatOrganizationRelationshipsDelegatedUserData 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 NewGoogleChatOrganizationRelationshipsDelegatedUserData() *GoogleChatOrganizationRelationshipsDelegatedUserData { + this := GoogleChatOrganizationRelationshipsDelegatedUserData{} + var typeVar GoogleChatDelegatedUserType = GOOGLECHATDELEGATEDUSERTYPE_GOOGLE_CHAT_DELEGATED_USER_TYPE + this.Type = &typeVar + return &this +} + +// NewGoogleChatOrganizationRelationshipsDelegatedUserDataWithDefaults instantiates a new GoogleChatOrganizationRelationshipsDelegatedUserData 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 NewGoogleChatOrganizationRelationshipsDelegatedUserDataWithDefaults() *GoogleChatOrganizationRelationshipsDelegatedUserData { + this := GoogleChatOrganizationRelationshipsDelegatedUserData{} + var typeVar GoogleChatDelegatedUserType = GOOGLECHATDELEGATEDUSERTYPE_GOOGLE_CHAT_DELEGATED_USER_TYPE + this.Type = &typeVar + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GoogleChatOrganizationRelationshipsDelegatedUserData) 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 *GoogleChatOrganizationRelationshipsDelegatedUserData) 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 *GoogleChatOrganizationRelationshipsDelegatedUserData) 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 *GoogleChatOrganizationRelationshipsDelegatedUserData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GoogleChatOrganizationRelationshipsDelegatedUserData) GetType() GoogleChatDelegatedUserType { + if o == nil || o.Type == nil { + var ret GoogleChatDelegatedUserType + 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 *GoogleChatOrganizationRelationshipsDelegatedUserData) GetTypeOk() (*GoogleChatDelegatedUserType, 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 *GoogleChatOrganizationRelationshipsDelegatedUserData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GoogleChatDelegatedUserType and assigns it to the Type field. +func (o *GoogleChatOrganizationRelationshipsDelegatedUserData) SetType(v GoogleChatDelegatedUserType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatOrganizationRelationshipsDelegatedUserData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + 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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatOrganizationRelationshipsDelegatedUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + Type *GoogleChatDelegatedUserType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + 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 datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_organization_response.go b/api/datadogV2/model_google_chat_organization_response.go new file mode 100644 index 00000000000..89c11927bf6 --- /dev/null +++ b/api/datadogV2/model_google_chat_organization_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationResponse Response containing a Google Chat organization binding. +type GoogleChatOrganizationResponse struct { + // Google Chat organization data from a response. + Data GoogleChatOrganizationData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatOrganizationResponse instantiates a new GoogleChatOrganizationResponse 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 NewGoogleChatOrganizationResponse(data GoogleChatOrganizationData) *GoogleChatOrganizationResponse { + this := GoogleChatOrganizationResponse{} + this.Data = data + return &this +} + +// NewGoogleChatOrganizationResponseWithDefaults instantiates a new GoogleChatOrganizationResponse 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 NewGoogleChatOrganizationResponseWithDefaults() *GoogleChatOrganizationResponse { + this := GoogleChatOrganizationResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GoogleChatOrganizationResponse) GetData() GoogleChatOrganizationData { + if o == nil { + var ret GoogleChatOrganizationData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GoogleChatOrganizationResponse) GetDataOk() (*GoogleChatOrganizationData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GoogleChatOrganizationResponse) SetData(v GoogleChatOrganizationData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatOrganizationResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatOrganizationResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GoogleChatOrganizationData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_organization_type.go b/api/datadogV2/model_google_chat_organization_type.go new file mode 100644 index 00000000000..7355ec0ea84 --- /dev/null +++ b/api/datadogV2/model_google_chat_organization_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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationType Google Chat organization resource type. +type GoogleChatOrganizationType string + +// List of GoogleChatOrganizationType. +const ( + GOOGLECHATORGANIZATIONTYPE_GOOGLE_CHAT_ORGANIZATION_TYPE GoogleChatOrganizationType = "google-chat-organization" +) + +var allowedGoogleChatOrganizationTypeEnumValues = []GoogleChatOrganizationType{ + GOOGLECHATORGANIZATIONTYPE_GOOGLE_CHAT_ORGANIZATION_TYPE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GoogleChatOrganizationType) GetAllowedValues() []GoogleChatOrganizationType { + return allowedGoogleChatOrganizationTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GoogleChatOrganizationType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GoogleChatOrganizationType(value) + return nil +} + +// NewGoogleChatOrganizationTypeFromValue returns a pointer to a valid GoogleChatOrganizationType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGoogleChatOrganizationTypeFromValue(v string) (*GoogleChatOrganizationType, error) { + ev := GoogleChatOrganizationType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GoogleChatOrganizationType: valid values are %v", v, allowedGoogleChatOrganizationTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GoogleChatOrganizationType) IsValid() bool { + for _, existing := range allowedGoogleChatOrganizationTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GoogleChatOrganizationType value. +func (v GoogleChatOrganizationType) Ptr() *GoogleChatOrganizationType { + return &v +} diff --git a/api/datadogV2/model_google_chat_organizations_response.go b/api/datadogV2/model_google_chat_organizations_response.go new file mode 100644 index 00000000000..ef43adcae73 --- /dev/null +++ b/api/datadogV2/model_google_chat_organizations_response.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatOrganizationsResponse Response containing a list of Google Chat organization bindings. +type GoogleChatOrganizationsResponse struct { + // An array of Google Chat organization bindings. + Data []GoogleChatOrganizationData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatOrganizationsResponse instantiates a new GoogleChatOrganizationsResponse 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 NewGoogleChatOrganizationsResponse(data []GoogleChatOrganizationData) *GoogleChatOrganizationsResponse { + this := GoogleChatOrganizationsResponse{} + this.Data = data + return &this +} + +// NewGoogleChatOrganizationsResponseWithDefaults instantiates a new GoogleChatOrganizationsResponse 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 NewGoogleChatOrganizationsResponseWithDefaults() *GoogleChatOrganizationsResponse { + this := GoogleChatOrganizationsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GoogleChatOrganizationsResponse) GetData() []GoogleChatOrganizationData { + if o == nil { + var ret []GoogleChatOrganizationData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GoogleChatOrganizationsResponse) GetDataOk() (*[]GoogleChatOrganizationData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GoogleChatOrganizationsResponse) SetData(v []GoogleChatOrganizationData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatOrganizationsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatOrganizationsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]GoogleChatOrganizationData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_attributes.go b/api/datadogV2/model_google_chat_target_audience_attributes.go new file mode 100644 index 00000000000..f8be4d2a25a --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_attributes.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceAttributes Google Chat target audience attributes. +type GoogleChatTargetAudienceAttributes struct { + // The audience ID. + AudienceId string `json:"audience_id"` + // The audience name. + AudienceName string `json:"audience_name"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceAttributes instantiates a new GoogleChatTargetAudienceAttributes 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 NewGoogleChatTargetAudienceAttributes(audienceId string, audienceName string) *GoogleChatTargetAudienceAttributes { + this := GoogleChatTargetAudienceAttributes{} + this.AudienceId = audienceId + this.AudienceName = audienceName + return &this +} + +// NewGoogleChatTargetAudienceAttributesWithDefaults instantiates a new GoogleChatTargetAudienceAttributes 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 NewGoogleChatTargetAudienceAttributesWithDefaults() *GoogleChatTargetAudienceAttributes { + this := GoogleChatTargetAudienceAttributes{} + return &this +} + +// GetAudienceId returns the AudienceId field value. +func (o *GoogleChatTargetAudienceAttributes) GetAudienceId() string { + if o == nil { + var ret string + return ret + } + return o.AudienceId +} + +// GetAudienceIdOk returns a tuple with the AudienceId field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceAttributes) GetAudienceIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AudienceId, true +} + +// SetAudienceId sets field value. +func (o *GoogleChatTargetAudienceAttributes) SetAudienceId(v string) { + o.AudienceId = v +} + +// GetAudienceName returns the AudienceName field value. +func (o *GoogleChatTargetAudienceAttributes) GetAudienceName() string { + if o == nil { + var ret string + return ret + } + return o.AudienceName +} + +// GetAudienceNameOk returns a tuple with the AudienceName field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceAttributes) GetAudienceNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AudienceName, true +} + +// SetAudienceName sets field value. +func (o *GoogleChatTargetAudienceAttributes) SetAudienceName(v string) { + o.AudienceName = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["audience_id"] = o.AudienceId + toSerialize["audience_name"] = o.AudienceName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AudienceId *string `json:"audience_id"` + AudienceName *string `json:"audience_name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AudienceId == nil { + return fmt.Errorf("required field audience_id missing") + } + if all.AudienceName == nil { + return fmt.Errorf("required field audience_name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"audience_id", "audience_name"}) + } else { + return err + } + o.AudienceId = *all.AudienceId + o.AudienceName = *all.AudienceName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_create_request.go b/api/datadogV2/model_google_chat_target_audience_create_request.go new file mode 100644 index 00000000000..da120c06fb0 --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_create_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceCreateRequest Create target audience request. +type GoogleChatTargetAudienceCreateRequest struct { + // Data for a create target audience request. + Data GoogleChatTargetAudienceCreateRequestData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceCreateRequest instantiates a new GoogleChatTargetAudienceCreateRequest 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 NewGoogleChatTargetAudienceCreateRequest(data GoogleChatTargetAudienceCreateRequestData) *GoogleChatTargetAudienceCreateRequest { + this := GoogleChatTargetAudienceCreateRequest{} + this.Data = data + return &this +} + +// NewGoogleChatTargetAudienceCreateRequestWithDefaults instantiates a new GoogleChatTargetAudienceCreateRequest 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 NewGoogleChatTargetAudienceCreateRequestWithDefaults() *GoogleChatTargetAudienceCreateRequest { + this := GoogleChatTargetAudienceCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *GoogleChatTargetAudienceCreateRequest) GetData() GoogleChatTargetAudienceCreateRequestData { + if o == nil { + var ret GoogleChatTargetAudienceCreateRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceCreateRequest) GetDataOk() (*GoogleChatTargetAudienceCreateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GoogleChatTargetAudienceCreateRequest) SetData(v GoogleChatTargetAudienceCreateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GoogleChatTargetAudienceCreateRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_create_request_attributes.go b/api/datadogV2/model_google_chat_target_audience_create_request_attributes.go new file mode 100644 index 00000000000..2f6e1353968 --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_create_request_attributes.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceCreateRequestAttributes Attributes for creating a Google Chat target audience. +type GoogleChatTargetAudienceCreateRequestAttributes struct { + // The audience ID. + AudienceId string `json:"audience_id"` + // The audience name. + AudienceName string `json:"audience_name"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceCreateRequestAttributes instantiates a new GoogleChatTargetAudienceCreateRequestAttributes 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 NewGoogleChatTargetAudienceCreateRequestAttributes(audienceId string, audienceName string) *GoogleChatTargetAudienceCreateRequestAttributes { + this := GoogleChatTargetAudienceCreateRequestAttributes{} + this.AudienceId = audienceId + this.AudienceName = audienceName + return &this +} + +// NewGoogleChatTargetAudienceCreateRequestAttributesWithDefaults instantiates a new GoogleChatTargetAudienceCreateRequestAttributes 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 NewGoogleChatTargetAudienceCreateRequestAttributesWithDefaults() *GoogleChatTargetAudienceCreateRequestAttributes { + this := GoogleChatTargetAudienceCreateRequestAttributes{} + return &this +} + +// GetAudienceId returns the AudienceId field value. +func (o *GoogleChatTargetAudienceCreateRequestAttributes) GetAudienceId() string { + if o == nil { + var ret string + return ret + } + return o.AudienceId +} + +// GetAudienceIdOk returns a tuple with the AudienceId field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceCreateRequestAttributes) GetAudienceIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AudienceId, true +} + +// SetAudienceId sets field value. +func (o *GoogleChatTargetAudienceCreateRequestAttributes) SetAudienceId(v string) { + o.AudienceId = v +} + +// GetAudienceName returns the AudienceName field value. +func (o *GoogleChatTargetAudienceCreateRequestAttributes) GetAudienceName() string { + if o == nil { + var ret string + return ret + } + return o.AudienceName +} + +// GetAudienceNameOk returns a tuple with the AudienceName field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceCreateRequestAttributes) GetAudienceNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AudienceName, true +} + +// SetAudienceName sets field value. +func (o *GoogleChatTargetAudienceCreateRequestAttributes) SetAudienceName(v string) { + o.AudienceName = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceCreateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["audience_id"] = o.AudienceId + toSerialize["audience_name"] = o.AudienceName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AudienceId *string `json:"audience_id"` + AudienceName *string `json:"audience_name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AudienceId == nil { + return fmt.Errorf("required field audience_id missing") + } + if all.AudienceName == nil { + return fmt.Errorf("required field audience_name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"audience_id", "audience_name"}) + } else { + return err + } + o.AudienceId = *all.AudienceId + o.AudienceName = *all.AudienceName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_create_request_data.go b/api/datadogV2/model_google_chat_target_audience_create_request_data.go new file mode 100644 index 00000000000..304b8b11088 --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_create_request_data.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceCreateRequestData Data for a create target audience request. +type GoogleChatTargetAudienceCreateRequestData struct { + // Attributes for creating a Google Chat target audience. + Attributes GoogleChatTargetAudienceCreateRequestAttributes `json:"attributes"` + // Google Chat target audience resource type. + Type GoogleChatTargetAudienceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceCreateRequestData instantiates a new GoogleChatTargetAudienceCreateRequestData 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 NewGoogleChatTargetAudienceCreateRequestData(attributes GoogleChatTargetAudienceCreateRequestAttributes, typeVar GoogleChatTargetAudienceType) *GoogleChatTargetAudienceCreateRequestData { + this := GoogleChatTargetAudienceCreateRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewGoogleChatTargetAudienceCreateRequestDataWithDefaults instantiates a new GoogleChatTargetAudienceCreateRequestData 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 NewGoogleChatTargetAudienceCreateRequestDataWithDefaults() *GoogleChatTargetAudienceCreateRequestData { + this := GoogleChatTargetAudienceCreateRequestData{} + var typeVar GoogleChatTargetAudienceType = GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *GoogleChatTargetAudienceCreateRequestData) GetAttributes() GoogleChatTargetAudienceCreateRequestAttributes { + if o == nil { + var ret GoogleChatTargetAudienceCreateRequestAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceCreateRequestData) GetAttributesOk() (*GoogleChatTargetAudienceCreateRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *GoogleChatTargetAudienceCreateRequestData) SetAttributes(v GoogleChatTargetAudienceCreateRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *GoogleChatTargetAudienceCreateRequestData) GetType() GoogleChatTargetAudienceType { + if o == nil { + var ret GoogleChatTargetAudienceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceCreateRequestData) GetTypeOk() (*GoogleChatTargetAudienceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *GoogleChatTargetAudienceCreateRequestData) SetType(v GoogleChatTargetAudienceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceCreateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceCreateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GoogleChatTargetAudienceCreateRequestAttributes `json:"attributes"` + Type *GoogleChatTargetAudienceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_data.go b/api/datadogV2/model_google_chat_target_audience_data.go new file mode 100644 index 00000000000..4c284c8da98 --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_data.go @@ -0,0 +1,189 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceData Google Chat target audience data from a response. +type GoogleChatTargetAudienceData struct { + // Google Chat target audience attributes. + Attributes *GoogleChatTargetAudienceAttributes `json:"attributes,omitempty"` + // The ID of the target audience. + Id *string `json:"id,omitempty"` + // Google Chat target audience resource type. + Type *GoogleChatTargetAudienceType `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{} `json:"-"` +} + +// NewGoogleChatTargetAudienceData instantiates a new GoogleChatTargetAudienceData 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 NewGoogleChatTargetAudienceData() *GoogleChatTargetAudienceData { + this := GoogleChatTargetAudienceData{} + var typeVar GoogleChatTargetAudienceType = GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE + this.Type = &typeVar + return &this +} + +// NewGoogleChatTargetAudienceDataWithDefaults instantiates a new GoogleChatTargetAudienceData 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 NewGoogleChatTargetAudienceDataWithDefaults() *GoogleChatTargetAudienceData { + this := GoogleChatTargetAudienceData{} + var typeVar GoogleChatTargetAudienceType = GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GoogleChatTargetAudienceData) GetAttributes() GoogleChatTargetAudienceAttributes { + if o == nil || o.Attributes == nil { + var ret GoogleChatTargetAudienceAttributes + 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 *GoogleChatTargetAudienceData) GetAttributesOk() (*GoogleChatTargetAudienceAttributes, 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 *GoogleChatTargetAudienceData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GoogleChatTargetAudienceAttributes and assigns it to the Attributes field. +func (o *GoogleChatTargetAudienceData) SetAttributes(v GoogleChatTargetAudienceAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *GoogleChatTargetAudienceData) 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 *GoogleChatTargetAudienceData) 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 *GoogleChatTargetAudienceData) 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 *GoogleChatTargetAudienceData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *GoogleChatTargetAudienceData) GetType() GoogleChatTargetAudienceType { + if o == nil || o.Type == nil { + var ret GoogleChatTargetAudienceType + 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 *GoogleChatTargetAudienceData) GetTypeOk() (*GoogleChatTargetAudienceType, 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 *GoogleChatTargetAudienceData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given GoogleChatTargetAudienceType and assigns it to the Type field. +func (o *GoogleChatTargetAudienceData) SetType(v GoogleChatTargetAudienceType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.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 datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GoogleChatTargetAudienceAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *GoogleChatTargetAudienceType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(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 datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_response.go b/api/datadogV2/model_google_chat_target_audience_response.go new file mode 100644 index 00000000000..42bb713f5f9 --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceResponse Response containing a Google Chat target audience. +type GoogleChatTargetAudienceResponse struct { + // Google Chat target audience data from a response. + Data GoogleChatTargetAudienceData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceResponse instantiates a new GoogleChatTargetAudienceResponse 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 NewGoogleChatTargetAudienceResponse(data GoogleChatTargetAudienceData) *GoogleChatTargetAudienceResponse { + this := GoogleChatTargetAudienceResponse{} + this.Data = data + return &this +} + +// NewGoogleChatTargetAudienceResponseWithDefaults instantiates a new GoogleChatTargetAudienceResponse 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 NewGoogleChatTargetAudienceResponseWithDefaults() *GoogleChatTargetAudienceResponse { + this := GoogleChatTargetAudienceResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GoogleChatTargetAudienceResponse) GetData() GoogleChatTargetAudienceData { + if o == nil { + var ret GoogleChatTargetAudienceData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceResponse) GetDataOk() (*GoogleChatTargetAudienceData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GoogleChatTargetAudienceResponse) SetData(v GoogleChatTargetAudienceData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GoogleChatTargetAudienceData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_type.go b/api/datadogV2/model_google_chat_target_audience_type.go new file mode 100644 index 00000000000..a3b73dd1b3d --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceType Google Chat target audience resource type. +type GoogleChatTargetAudienceType string + +// List of GoogleChatTargetAudienceType. +const ( + GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE GoogleChatTargetAudienceType = "google-chat-target-audience" +) + +var allowedGoogleChatTargetAudienceTypeEnumValues = []GoogleChatTargetAudienceType{ + GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GoogleChatTargetAudienceType) GetAllowedValues() []GoogleChatTargetAudienceType { + return allowedGoogleChatTargetAudienceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GoogleChatTargetAudienceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GoogleChatTargetAudienceType(value) + return nil +} + +// NewGoogleChatTargetAudienceTypeFromValue returns a pointer to a valid GoogleChatTargetAudienceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGoogleChatTargetAudienceTypeFromValue(v string) (*GoogleChatTargetAudienceType, error) { + ev := GoogleChatTargetAudienceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GoogleChatTargetAudienceType: valid values are %v", v, allowedGoogleChatTargetAudienceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GoogleChatTargetAudienceType) IsValid() bool { + for _, existing := range allowedGoogleChatTargetAudienceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GoogleChatTargetAudienceType value. +func (v GoogleChatTargetAudienceType) Ptr() *GoogleChatTargetAudienceType { + return &v +} diff --git a/api/datadogV2/model_google_chat_target_audience_update_request.go b/api/datadogV2/model_google_chat_target_audience_update_request.go new file mode 100644 index 00000000000..818223c047e --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_update_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceUpdateRequest Update target audience request. +type GoogleChatTargetAudienceUpdateRequest struct { + // Data for an update target audience request. + Data GoogleChatTargetAudienceUpdateRequestData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceUpdateRequest instantiates a new GoogleChatTargetAudienceUpdateRequest 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 NewGoogleChatTargetAudienceUpdateRequest(data GoogleChatTargetAudienceUpdateRequestData) *GoogleChatTargetAudienceUpdateRequest { + this := GoogleChatTargetAudienceUpdateRequest{} + this.Data = data + return &this +} + +// NewGoogleChatTargetAudienceUpdateRequestWithDefaults instantiates a new GoogleChatTargetAudienceUpdateRequest 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 NewGoogleChatTargetAudienceUpdateRequestWithDefaults() *GoogleChatTargetAudienceUpdateRequest { + this := GoogleChatTargetAudienceUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *GoogleChatTargetAudienceUpdateRequest) GetData() GoogleChatTargetAudienceUpdateRequestData { + if o == nil { + var ret GoogleChatTargetAudienceUpdateRequestData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceUpdateRequest) GetDataOk() (*GoogleChatTargetAudienceUpdateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GoogleChatTargetAudienceUpdateRequest) SetData(v GoogleChatTargetAudienceUpdateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GoogleChatTargetAudienceUpdateRequestData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_update_request_attributes.go b/api/datadogV2/model_google_chat_target_audience_update_request_attributes.go new file mode 100644 index 00000000000..f730347523f --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_update_request_attributes.go @@ -0,0 +1,137 @@ +// 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/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceUpdateRequestAttributes Attributes for updating a Google Chat target audience. +type GoogleChatTargetAudienceUpdateRequestAttributes struct { + // The audience ID. + AudienceId *string `json:"audience_id,omitempty"` + // The audience name. + AudienceName *string `json:"audience_name,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceUpdateRequestAttributes instantiates a new GoogleChatTargetAudienceUpdateRequestAttributes 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 NewGoogleChatTargetAudienceUpdateRequestAttributes() *GoogleChatTargetAudienceUpdateRequestAttributes { + this := GoogleChatTargetAudienceUpdateRequestAttributes{} + return &this +} + +// NewGoogleChatTargetAudienceUpdateRequestAttributesWithDefaults instantiates a new GoogleChatTargetAudienceUpdateRequestAttributes 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 NewGoogleChatTargetAudienceUpdateRequestAttributesWithDefaults() *GoogleChatTargetAudienceUpdateRequestAttributes { + this := GoogleChatTargetAudienceUpdateRequestAttributes{} + return &this +} + +// GetAudienceId returns the AudienceId field value if set, zero value otherwise. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) GetAudienceId() string { + if o == nil || o.AudienceId == nil { + var ret string + return ret + } + return *o.AudienceId +} + +// GetAudienceIdOk returns a tuple with the AudienceId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) GetAudienceIdOk() (*string, bool) { + if o == nil || o.AudienceId == nil { + return nil, false + } + return o.AudienceId, true +} + +// HasAudienceId returns a boolean if a field has been set. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) HasAudienceId() bool { + return o != nil && o.AudienceId != nil +} + +// SetAudienceId gets a reference to the given string and assigns it to the AudienceId field. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) SetAudienceId(v string) { + o.AudienceId = &v +} + +// GetAudienceName returns the AudienceName field value if set, zero value otherwise. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) GetAudienceName() string { + if o == nil || o.AudienceName == nil { + var ret string + return ret + } + return *o.AudienceName +} + +// GetAudienceNameOk returns a tuple with the AudienceName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) GetAudienceNameOk() (*string, bool) { + if o == nil || o.AudienceName == nil { + return nil, false + } + return o.AudienceName, true +} + +// HasAudienceName returns a boolean if a field has been set. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) HasAudienceName() bool { + return o != nil && o.AudienceName != nil +} + +// SetAudienceName gets a reference to the given string and assigns it to the AudienceName field. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) SetAudienceName(v string) { + o.AudienceName = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceUpdateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AudienceId != nil { + toSerialize["audience_id"] = o.AudienceId + } + if o.AudienceName != nil { + toSerialize["audience_name"] = o.AudienceName + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceUpdateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AudienceId *string `json:"audience_id,omitempty"` + AudienceName *string `json:"audience_name,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"audience_id", "audience_name"}) + } else { + return err + } + o.AudienceId = all.AudienceId + o.AudienceName = all.AudienceName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audience_update_request_data.go b/api/datadogV2/model_google_chat_target_audience_update_request_data.go new file mode 100644 index 00000000000..4737c506e31 --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audience_update_request_data.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudienceUpdateRequestData Data for an update target audience request. +type GoogleChatTargetAudienceUpdateRequestData struct { + // Attributes for updating a Google Chat target audience. + Attributes GoogleChatTargetAudienceUpdateRequestAttributes `json:"attributes"` + // Google Chat target audience resource type. + Type GoogleChatTargetAudienceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudienceUpdateRequestData instantiates a new GoogleChatTargetAudienceUpdateRequestData 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 NewGoogleChatTargetAudienceUpdateRequestData(attributes GoogleChatTargetAudienceUpdateRequestAttributes, typeVar GoogleChatTargetAudienceType) *GoogleChatTargetAudienceUpdateRequestData { + this := GoogleChatTargetAudienceUpdateRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewGoogleChatTargetAudienceUpdateRequestDataWithDefaults instantiates a new GoogleChatTargetAudienceUpdateRequestData 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 NewGoogleChatTargetAudienceUpdateRequestDataWithDefaults() *GoogleChatTargetAudienceUpdateRequestData { + this := GoogleChatTargetAudienceUpdateRequestData{} + var typeVar GoogleChatTargetAudienceType = GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *GoogleChatTargetAudienceUpdateRequestData) GetAttributes() GoogleChatTargetAudienceUpdateRequestAttributes { + if o == nil { + var ret GoogleChatTargetAudienceUpdateRequestAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceUpdateRequestData) GetAttributesOk() (*GoogleChatTargetAudienceUpdateRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *GoogleChatTargetAudienceUpdateRequestData) SetAttributes(v GoogleChatTargetAudienceUpdateRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *GoogleChatTargetAudienceUpdateRequestData) GetType() GoogleChatTargetAudienceType { + if o == nil { + var ret GoogleChatTargetAudienceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudienceUpdateRequestData) GetTypeOk() (*GoogleChatTargetAudienceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *GoogleChatTargetAudienceUpdateRequestData) SetType(v GoogleChatTargetAudienceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudienceUpdateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudienceUpdateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GoogleChatTargetAudienceUpdateRequestAttributes `json:"attributes"` + Type *GoogleChatTargetAudienceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_google_chat_target_audiences_response.go b/api/datadogV2/model_google_chat_target_audiences_response.go new file mode 100644 index 00000000000..854904e303e --- /dev/null +++ b/api/datadogV2/model_google_chat_target_audiences_response.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GoogleChatTargetAudiencesResponse Response containing a list of Google Chat target audiences. +type GoogleChatTargetAudiencesResponse struct { + // An array of Google Chat target audiences. + Data []GoogleChatTargetAudienceData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGoogleChatTargetAudiencesResponse instantiates a new GoogleChatTargetAudiencesResponse 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 NewGoogleChatTargetAudiencesResponse(data []GoogleChatTargetAudienceData) *GoogleChatTargetAudiencesResponse { + this := GoogleChatTargetAudiencesResponse{} + this.Data = data + return &this +} + +// NewGoogleChatTargetAudiencesResponseWithDefaults instantiates a new GoogleChatTargetAudiencesResponse 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 NewGoogleChatTargetAudiencesResponseWithDefaults() *GoogleChatTargetAudiencesResponse { + this := GoogleChatTargetAudiencesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GoogleChatTargetAudiencesResponse) GetData() []GoogleChatTargetAudienceData { + if o == nil { + var ret []GoogleChatTargetAudienceData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GoogleChatTargetAudiencesResponse) GetDataOk() (*[]GoogleChatTargetAudienceData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GoogleChatTargetAudiencesResponse) SetData(v []GoogleChatTargetAudienceData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GoogleChatTargetAudiencesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GoogleChatTargetAudiencesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]GoogleChatTargetAudienceData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/google-chat-integration/CreateGoogleChatTargetAudience.go b/examples/v2/google-chat-integration/CreateGoogleChatTargetAudience.go new file mode 100644 index 00000000000..287ace49c83 --- /dev/null +++ b/examples/v2/google-chat-integration/CreateGoogleChatTargetAudience.go @@ -0,0 +1,38 @@ +// Create a target audience returns "CREATED" 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() { + body := datadogV2.GoogleChatTargetAudienceCreateRequest{ + Data: datadogV2.GoogleChatTargetAudienceCreateRequestData{ + Attributes: datadogV2.GoogleChatTargetAudienceCreateRequestAttributes{ + AudienceId: "fake-audience-id-1", + AudienceName: "fake audience name 1", + }, + Type: datadogV2.GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + resp, r, err := api.CreateGoogleChatTargetAudience(ctx, "organization_binding_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.CreateGoogleChatTargetAudience`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GoogleChatIntegrationApi.CreateGoogleChatTargetAudience`:\n%s\n", responseContent) +} diff --git a/examples/v2/google-chat-integration/DeleteGoogleChatDelegatedUser.go b/examples/v2/google-chat-integration/DeleteGoogleChatDelegatedUser.go new file mode 100644 index 00000000000..15fcc139ad5 --- /dev/null +++ b/examples/v2/google-chat-integration/DeleteGoogleChatDelegatedUser.go @@ -0,0 +1,25 @@ +// Delete the delegated user returns "OK" response + +package main + +import ( + "context" + "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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + r, err := api.DeleteGoogleChatDelegatedUser(ctx, "organization_binding_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.DeleteGoogleChatDelegatedUser`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/google-chat-integration/DeleteGoogleChatOrganization.go b/examples/v2/google-chat-integration/DeleteGoogleChatOrganization.go new file mode 100644 index 00000000000..d9ee2c8d996 --- /dev/null +++ b/examples/v2/google-chat-integration/DeleteGoogleChatOrganization.go @@ -0,0 +1,25 @@ +// Delete a Google Chat organization binding returns "OK" response + +package main + +import ( + "context" + "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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + r, err := api.DeleteGoogleChatOrganization(ctx, "organization_binding_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.DeleteGoogleChatOrganization`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/google-chat-integration/DeleteGoogleChatTargetAudience.go b/examples/v2/google-chat-integration/DeleteGoogleChatTargetAudience.go new file mode 100644 index 00000000000..068f10cf063 --- /dev/null +++ b/examples/v2/google-chat-integration/DeleteGoogleChatTargetAudience.go @@ -0,0 +1,25 @@ +// Delete a target audience returns "OK" response + +package main + +import ( + "context" + "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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + r, err := api.DeleteGoogleChatTargetAudience(ctx, "organization_binding_id", "target_audience_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.DeleteGoogleChatTargetAudience`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/google-chat-integration/GetGoogleChatDelegatedUser.go b/examples/v2/google-chat-integration/GetGoogleChatDelegatedUser.go new file mode 100644 index 00000000000..9eaea97672b --- /dev/null +++ b/examples/v2/google-chat-integration/GetGoogleChatDelegatedUser.go @@ -0,0 +1,29 @@ +// Get the delegated user 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + resp, r, err := api.GetGoogleChatDelegatedUser(ctx, "organization_binding_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.GetGoogleChatDelegatedUser`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GoogleChatIntegrationApi.GetGoogleChatDelegatedUser`:\n%s\n", responseContent) +} diff --git a/examples/v2/google-chat-integration/GetGoogleChatOrganization.go b/examples/v2/google-chat-integration/GetGoogleChatOrganization.go new file mode 100644 index 00000000000..5c6a56f52de --- /dev/null +++ b/examples/v2/google-chat-integration/GetGoogleChatOrganization.go @@ -0,0 +1,29 @@ +// Get a Google Chat organization binding 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + resp, r, err := api.GetGoogleChatOrganization(ctx, "organization_binding_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.GetGoogleChatOrganization`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GoogleChatIntegrationApi.GetGoogleChatOrganization`:\n%s\n", responseContent) +} diff --git a/examples/v2/google-chat-integration/GetGoogleChatTargetAudience.go b/examples/v2/google-chat-integration/GetGoogleChatTargetAudience.go new file mode 100644 index 00000000000..7e4cfa90fd8 --- /dev/null +++ b/examples/v2/google-chat-integration/GetGoogleChatTargetAudience.go @@ -0,0 +1,29 @@ +// Get a target audience 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + resp, r, err := api.GetGoogleChatTargetAudience(ctx, "organization_binding_id", "target_audience_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.GetGoogleChatTargetAudience`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GoogleChatIntegrationApi.GetGoogleChatTargetAudience`:\n%s\n", responseContent) +} diff --git a/examples/v2/google-chat-integration/ListGoogleChatOrganizations.go b/examples/v2/google-chat-integration/ListGoogleChatOrganizations.go new file mode 100644 index 00000000000..912a6ca709b --- /dev/null +++ b/examples/v2/google-chat-integration/ListGoogleChatOrganizations.go @@ -0,0 +1,29 @@ +// Get all Google Chat organization bindings 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + resp, r, err := api.ListGoogleChatOrganizations(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.ListGoogleChatOrganizations`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GoogleChatIntegrationApi.ListGoogleChatOrganizations`:\n%s\n", responseContent) +} diff --git a/examples/v2/google-chat-integration/ListGoogleChatTargetAudiences.go b/examples/v2/google-chat-integration/ListGoogleChatTargetAudiences.go new file mode 100644 index 00000000000..3d8e3e6ac33 --- /dev/null +++ b/examples/v2/google-chat-integration/ListGoogleChatTargetAudiences.go @@ -0,0 +1,29 @@ +// Get all target audiences 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + resp, r, err := api.ListGoogleChatTargetAudiences(ctx, "organization_binding_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.ListGoogleChatTargetAudiences`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GoogleChatIntegrationApi.ListGoogleChatTargetAudiences`:\n%s\n", responseContent) +} diff --git a/examples/v2/google-chat-integration/UpdateGoogleChatTargetAudience.go b/examples/v2/google-chat-integration/UpdateGoogleChatTargetAudience.go new file mode 100644 index 00000000000..448093d2c88 --- /dev/null +++ b/examples/v2/google-chat-integration/UpdateGoogleChatTargetAudience.go @@ -0,0 +1,38 @@ +// Update a target audience 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() { + body := datadogV2.GoogleChatTargetAudienceUpdateRequest{ + Data: datadogV2.GoogleChatTargetAudienceUpdateRequestData{ + Attributes: datadogV2.GoogleChatTargetAudienceUpdateRequestAttributes{ + AudienceId: datadog.PtrString("fake-audience-id-1"), + AudienceName: datadog.PtrString("fake audience name 1"), + }, + Type: datadogV2.GOOGLECHATTARGETAUDIENCETYPE_GOOGLE_CHAT_TARGET_AUDIENCE_TYPE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewGoogleChatIntegrationApi(apiClient) + resp, r, err := api.UpdateGoogleChatTargetAudience(ctx, "organization_binding_id", "target_audience_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `GoogleChatIntegrationApi.UpdateGoogleChatTargetAudience`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `GoogleChatIntegrationApi.UpdateGoogleChatTargetAudience`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 0a6db71d718..6b90cd6f657 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -674,6 +674,22 @@ "tag": "Google Chat Integration", "operationId": "CreateOrganizationHandle" }, + { + "parameters": [ + { + "name": "organization_binding_id", + "value": "\"e54cb570-c674-529c-769d-84b312288ed7\"" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"google-chat-target-audience\",\n \"attributes\": {\n \"audience_name\": \"{{ unique }}\",\n \"audience_id\": \"{{ unique }}\"\n }\n }\n}" + } + ], + "step": "there is a valid \"google_chat_target_audience\" in the system", + "key": "google_chat_target_audience", + "tag": "Google Chat Integration", + "operationId": "CreateGoogleChatTargetAudience" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/google_chat_integration.feature b/tests/scenarios/features/v2/google_chat_integration.feature index f722a7ea208..65c1f264a6b 100644 --- a/tests/scenarios/features/v2/google_chat_integration.feature +++ b/tests/scenarios/features/v2/google_chat_integration.feature @@ -9,6 +9,38 @@ Feature: Google Chat Integration And a valid "appKeyAuth" key in the system And an instance of "GoogleChatIntegration" API + @generated @skip @team:DataDog/chat-integrations + Scenario: Create a target audience returns "Bad Request" response + Given new "CreateGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"audience_id": "fake-audience-id-1", "audience_name": "fake audience name 1"}, "type": "google-chat-target-audience"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/chat-integrations + Scenario: Create a target audience returns "CREATED" response + Given new "CreateGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"audience_id": "fake-audience-id-1", "audience_name": "fake audience name 1"}, "type": "google-chat-target-audience"}} + When the request is sent + Then the response status is 201 CREATED + + @generated @skip @team:DataDog/chat-integrations + Scenario: Create a target audience returns "Conflict" response + Given new "CreateGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"audience_id": "fake-audience-id-1", "audience_name": "fake audience name 1"}, "type": "google-chat-target-audience"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/chat-integrations + Scenario: Create a target audience returns "Not Found" response + Given new "CreateGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"audience_id": "fake-audience-id-1", "audience_name": "fake audience name 1"}, "type": "google-chat-target-audience"}} + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/chat-integrations Scenario: Create organization handle returns "Bad Request" response Given new "CreateOrganizationHandle" request @@ -42,6 +74,36 @@ Feature: Google Chat Integration When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete a Google Chat organization binding returns "Bad Request" response + Given new "DeleteGoogleChatOrganization" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete a Google Chat organization binding returns "OK" response + Given new "DeleteGoogleChatOrganization" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete a target audience returns "Not Found" response + Given new "DeleteGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And request contains "target_audience_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete a target audience returns "OK" response + Given new "DeleteGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And request contains "target_audience_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + @generated @skip @team:DataDog/chat-integrations Scenario: Delete organization handle returns "Bad Request" response Given new "DeleteOrganizationHandle" request @@ -59,6 +121,56 @@ Feature: Google Chat Integration When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete the delegated user returns "Not Found" response + Given new "DeleteGoogleChatDelegatedUser" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/chat-integrations + Scenario: Delete the delegated user returns "OK" response + Given new "DeleteGoogleChatDelegatedUser" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:DataDog/chat-integrations + Scenario: Get a Google Chat organization binding returns "Not Found" response + Given new "GetGoogleChatOrganization" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/chat-integrations + Scenario: Get a Google Chat organization binding returns "OK" response + Given new "GetGoogleChatOrganization" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/chat-integrations + Scenario: Get a target audience returns "Not Found" response + Given new "GetGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And request contains "target_audience_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/chat-integrations + Scenario: Get a target audience returns "OK" response + Given new "GetGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And request contains "target_audience_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/chat-integrations + Scenario: Get all Google Chat organization bindings returns "OK" response + Given new "ListGoogleChatOrganizations" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/chat-integrations Scenario: Get all organization handles returns "Bad Request" response Given new "ListOrganizationHandles" request @@ -82,6 +194,20 @@ Feature: Google Chat Integration Then the response status is 200 OK And the response "data[0].type" is equal to "google-chat-organization-handle" + @generated @skip @team:DataDog/chat-integrations + Scenario: Get all target audiences returns "Not Found" response + Given new "ListGoogleChatTargetAudiences" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/chat-integrations + Scenario: Get all target audiences returns "OK" response + Given new "ListGoogleChatTargetAudiences" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/chat-integrations Scenario: Get organization handle returns "Bad Request" response Given new "GetOrganizationHandle" request @@ -136,6 +262,47 @@ Feature: Google Chat Integration And the response "data.attributes.resource_name" is equal to "spaces/AAQA-zFIks8" And the response "data.attributes.organization_binding_id" is equal to "e54cb570-c674-529c-769d-84b312288ed7" + @generated @skip @team:DataDog/chat-integrations + Scenario: Get the delegated user returns "Not Found" response + Given new "GetGoogleChatDelegatedUser" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/chat-integrations + Scenario: Get the delegated user returns "OK" response + Given new "GetGoogleChatDelegatedUser" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/chat-integrations + Scenario: Update a target audience returns "Bad Request" response + Given new "UpdateGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And request contains "target_audience_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"audience_id": "fake-audience-id-1", "audience_name": "fake audience name 1"}, "type": "google-chat-target-audience"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/chat-integrations + Scenario: Update a target audience returns "Not Found" response + Given new "UpdateGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And request contains "target_audience_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"audience_id": "fake-audience-id-1", "audience_name": "fake audience name 1"}, "type": "google-chat-target-audience"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/chat-integrations + Scenario: Update a target audience returns "OK" response + Given new "UpdateGoogleChatTargetAudience" request + And request contains "organization_binding_id" parameter from "REPLACE.ME" + And request contains "target_audience_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"audience_id": "fake-audience-id-1", "audience_name": "fake audience name 1"}, "type": "google-chat-target-audience"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/chat-integrations Scenario: Update organization handle returns "Bad Request" response Given new "UpdateOrganizationHandle" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 6af3231d4fe..3a15f0b470c 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -3389,12 +3389,42 @@ "type": "idempotent" } }, + "ListGoogleChatOrganizations": { + "tag": "Google Chat Integration", + "undo": { + "type": "safe" + } + }, "GetSpaceByDisplayName": { "tag": "Google Chat Integration", "undo": { "type": "safe" } }, + "DeleteGoogleChatOrganization": { + "tag": "Google Chat Integration", + "undo": { + "type": "idempotent" + } + }, + "GetGoogleChatOrganization": { + "tag": "Google Chat Integration", + "undo": { + "type": "safe" + } + }, + "DeleteGoogleChatDelegatedUser": { + "tag": "Google Chat Integration", + "undo": { + "type": "idempotent" + } + }, + "GetGoogleChatDelegatedUser": { + "tag": "Google Chat Integration", + "undo": { + "type": "safe" + } + }, "ListOrganizationHandles": { "tag": "Google Chat Integration", "undo": { @@ -3437,6 +3467,48 @@ "type": "idempotent" } }, + "ListGoogleChatTargetAudiences": { + "tag": "Google Chat Integration", + "undo": { + "type": "safe" + } + }, + "CreateGoogleChatTargetAudience": { + "tag": "Google Chat Integration", + "undo": { + "operationId": "DeleteGoogleChatTargetAudience", + "parameters": [ + { + "name": "organization_binding_id", + "origin": "path", + "source": "organization_binding_id" + }, + { + "name": "target_audience_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteGoogleChatTargetAudience": { + "tag": "Google Chat Integration", + "undo": { + "type": "idempotent" + } + }, + "GetGoogleChatTargetAudience": { + "tag": "Google Chat Integration", + "undo": { + "type": "safe" + } + }, + "UpdateGoogleChatTargetAudience": { + "tag": "Google Chat Integration", + "undo": { + "type": "idempotent" + } + }, "ListJiraAccounts": { "tag": "Jira Integration", "undo": {