From a7264b97c2054eba8887c820f20989e672fa1c60 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 8 Jun 2026 16:47:13 +0000 Subject: [PATCH] Regenerate client from commit e9a2b14 of spec repo --- .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 2d470c8f2f0..f9eef58dc1e 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 @@ -52576,6 +52584,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: @@ -85992,6 +86017,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: @@ -120533,6 +120899,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: >- @@ -181189,6 +181644,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 2ec902edc12..765e7648a8e 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -871,6 +871,7 @@ func NewConfiguration() *Configuration { "v2.ListCostTagMetadataMonths": false, "v2.ListCostTagMetadataOrchestrators": false, "v2.SearchCostRecommendations": 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 7378152a951..bc780ee0017 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -344,6 +344,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 b3cd3bbbd91..f8eb49426e4 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -80,6 +80,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "CSMAgentsApi": reflect.ValueOf(datadogV2.NewCSMAgentsApi), "CSMCoverageAnalysisApi": reflect.ValueOf(datadogV2.NewCSMCoverageAnalysisApi), "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 9101d0155cb..0802a2039c9 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2105,6 +2105,12 @@ "type": "safe" } }, + "ListSharedDashboardsByDashboardId": { + "tag": "Dashboard Sharing", + "undo": { + "type": "safe" + } + }, "CreateDashboardSecureEmbed": { "tag": "Dashboard Secure Embed", "undo": {