Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
457 changes: 457 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/datadog/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
121 changes: 121 additions & 0 deletions api/datadogV2/api_dashboard_sharing.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
1 change: 1 addition & 0 deletions api/datadogV2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
// - [DashboardSecureEmbedApi.DeleteDashboardSecureEmbed]
// - [DashboardSecureEmbedApi.GetDashboardSecureEmbed]
// - [DashboardSecureEmbedApi.UpdateDashboardSecureEmbed]
// - [DashboardSharingApi.ListSharedDashboardsByDashboardId]
// - [DashboardsApi.GetDashboardUsage]
// - [DashboardsApi.ListDashboardsUsage]
// - [DataDeletionApi.CancelDataDeletionRequest]
Expand Down
133 changes: 133 additions & 0 deletions api/datadogV2/model_list_shared_dashboards_response.go
Original file line number Diff line number Diff line change
@@ -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
}
105 changes: 105 additions & 0 deletions api/datadogV2/model_shared_dashboard_included.go
Original file line number Diff line number Diff line change
@@ -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
}
Loading
Loading