Skip to content

Commit f44a84b

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit a73013e of spec repo (#4209)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3975539 commit f44a84b

28 files changed

Lines changed: 3683 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 457 additions & 0 deletions
Large diffs are not rendered by default.

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ func NewConfiguration() *Configuration {
882882
"v2.ListCSMAgentlessHosts": false,
883883
"v2.ListCSMUnifiedHostFacets": false,
884884
"v2.ListCSMUnifiedHosts": false,
885+
"v2.ListSharedDashboardsByDashboardId": false,
885886
"v2.CreateDashboardSecureEmbed": false,
886887
"v2.DeleteDashboardSecureEmbed": false,
887888
"v2.GetDashboardSecureEmbed": false,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
_context "context"
9+
_fmt "fmt"
10+
_log "log"
11+
_nethttp "net/http"
12+
_neturl "net/url"
13+
14+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
15+
)
16+
17+
// DashboardSharingApi service type
18+
type DashboardSharingApi datadog.Service
19+
20+
// ListSharedDashboardsByDashboardId List shared dashboards for a dashboard.
21+
// Retrieve shared dashboards associated with the specified dashboard.
22+
func (a *DashboardSharingApi) ListSharedDashboardsByDashboardId(ctx _context.Context, dashboardId string) (ListSharedDashboardsResponse, *_nethttp.Response, error) {
23+
var (
24+
localVarHTTPMethod = _nethttp.MethodGet
25+
localVarPostBody interface{}
26+
localVarReturnValue ListSharedDashboardsResponse
27+
)
28+
29+
operationId := "v2.ListSharedDashboardsByDashboardId"
30+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
31+
if !isOperationEnabled {
32+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
33+
}
34+
if isOperationEnabled && a.Client.Cfg.Debug {
35+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
36+
}
37+
38+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DashboardSharingApi.ListSharedDashboardsByDashboardId")
39+
if err != nil {
40+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
41+
}
42+
43+
localVarPath := localBasePath + "/api/v2/dashboard/{dashboard_id}/shared"
44+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{dashboard_id}", _neturl.PathEscape(datadog.ParameterToString(dashboardId, "")))
45+
46+
localVarHeaderParams := make(map[string]string)
47+
localVarQueryParams := _neturl.Values{}
48+
localVarFormParams := _neturl.Values{}
49+
localVarHeaderParams["Accept"] = "application/json"
50+
51+
if a.Client.Cfg.DelegatedTokenConfig != nil {
52+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
53+
if err != nil {
54+
return localVarReturnValue, nil, err
55+
}
56+
} else {
57+
datadog.SetAuthKeys(
58+
ctx,
59+
&localVarHeaderParams,
60+
[2]string{"apiKeyAuth", "DD-API-KEY"},
61+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
62+
)
63+
}
64+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
65+
if err != nil {
66+
return localVarReturnValue, nil, err
67+
}
68+
69+
localVarHTTPResponse, err := a.Client.CallAPI(req)
70+
if err != nil || localVarHTTPResponse == nil {
71+
return localVarReturnValue, localVarHTTPResponse, err
72+
}
73+
74+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
75+
if err != nil {
76+
return localVarReturnValue, localVarHTTPResponse, err
77+
}
78+
79+
if localVarHTTPResponse.StatusCode >= 300 {
80+
newErr := datadog.GenericOpenAPIError{
81+
ErrorBody: localVarBody,
82+
ErrorMessage: localVarHTTPResponse.Status,
83+
}
84+
if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 {
85+
var v JSONAPIErrorResponse
86+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
87+
if err != nil {
88+
return localVarReturnValue, localVarHTTPResponse, newErr
89+
}
90+
newErr.ErrorModel = v
91+
return localVarReturnValue, localVarHTTPResponse, newErr
92+
}
93+
if localVarHTTPResponse.StatusCode == 429 {
94+
var v APIErrorResponse
95+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
96+
if err != nil {
97+
return localVarReturnValue, localVarHTTPResponse, newErr
98+
}
99+
newErr.ErrorModel = v
100+
}
101+
return localVarReturnValue, localVarHTTPResponse, newErr
102+
}
103+
104+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
105+
if err != nil {
106+
newErr := datadog.GenericOpenAPIError{
107+
ErrorBody: localVarBody,
108+
ErrorMessage: err.Error(),
109+
}
110+
return localVarReturnValue, localVarHTTPResponse, newErr
111+
}
112+
113+
return localVarReturnValue, localVarHTTPResponse, nil
114+
}
115+
116+
// NewDashboardSharingApi Returns NewDashboardSharingApi.
117+
func NewDashboardSharingApi(client *datadog.APIClient) *DashboardSharingApi {
118+
return &DashboardSharingApi{
119+
Client: client,
120+
}
121+
}

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@
356356
// - [DashboardSecureEmbedApi.DeleteDashboardSecureEmbed]
357357
// - [DashboardSecureEmbedApi.GetDashboardSecureEmbed]
358358
// - [DashboardSecureEmbedApi.UpdateDashboardSecureEmbed]
359+
// - [DashboardSharingApi.ListSharedDashboardsByDashboardId]
359360
// - [DashboardsApi.GetDashboardUsage]
360361
// - [DashboardsApi.ListDashboardsUsage]
361362
// - [DataDeletionApi.CancelDataDeletionRequest]
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// ListSharedDashboardsResponse Response containing shared dashboards for a dashboard.
14+
type ListSharedDashboardsResponse struct {
15+
// Shared dashboards for the dashboard.
16+
Data []SharedDashboardResponse `json:"data"`
17+
// Users and dashboards related to the shared dashboards.
18+
Included []SharedDashboardIncluded `json:"included"`
19+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
20+
UnparsedObject map[string]interface{} `json:"-"`
21+
AdditionalProperties map[string]interface{} `json:"-"`
22+
}
23+
24+
// NewListSharedDashboardsResponse instantiates a new ListSharedDashboardsResponse object.
25+
// This constructor will assign default values to properties that have it defined,
26+
// and makes sure properties required by API are set, but the set of arguments
27+
// will change when the set of required properties is changed.
28+
func NewListSharedDashboardsResponse(data []SharedDashboardResponse, included []SharedDashboardIncluded) *ListSharedDashboardsResponse {
29+
this := ListSharedDashboardsResponse{}
30+
this.Data = data
31+
this.Included = included
32+
return &this
33+
}
34+
35+
// NewListSharedDashboardsResponseWithDefaults instantiates a new ListSharedDashboardsResponse object.
36+
// This constructor will only assign default values to properties that have it defined,
37+
// but it doesn't guarantee that properties required by API are set.
38+
func NewListSharedDashboardsResponseWithDefaults() *ListSharedDashboardsResponse {
39+
this := ListSharedDashboardsResponse{}
40+
return &this
41+
}
42+
43+
// GetData returns the Data field value.
44+
func (o *ListSharedDashboardsResponse) GetData() []SharedDashboardResponse {
45+
if o == nil {
46+
var ret []SharedDashboardResponse
47+
return ret
48+
}
49+
return o.Data
50+
}
51+
52+
// GetDataOk returns a tuple with the Data field value
53+
// and a boolean to check if the value has been set.
54+
func (o *ListSharedDashboardsResponse) GetDataOk() (*[]SharedDashboardResponse, bool) {
55+
if o == nil {
56+
return nil, false
57+
}
58+
return &o.Data, true
59+
}
60+
61+
// SetData sets field value.
62+
func (o *ListSharedDashboardsResponse) SetData(v []SharedDashboardResponse) {
63+
o.Data = v
64+
}
65+
66+
// GetIncluded returns the Included field value.
67+
func (o *ListSharedDashboardsResponse) GetIncluded() []SharedDashboardIncluded {
68+
if o == nil {
69+
var ret []SharedDashboardIncluded
70+
return ret
71+
}
72+
return o.Included
73+
}
74+
75+
// GetIncludedOk returns a tuple with the Included field value
76+
// and a boolean to check if the value has been set.
77+
func (o *ListSharedDashboardsResponse) GetIncludedOk() (*[]SharedDashboardIncluded, bool) {
78+
if o == nil {
79+
return nil, false
80+
}
81+
return &o.Included, true
82+
}
83+
84+
// SetIncluded sets field value.
85+
func (o *ListSharedDashboardsResponse) SetIncluded(v []SharedDashboardIncluded) {
86+
o.Included = v
87+
}
88+
89+
// MarshalJSON serializes the struct using spec logic.
90+
func (o ListSharedDashboardsResponse) MarshalJSON() ([]byte, error) {
91+
toSerialize := map[string]interface{}{}
92+
if o.UnparsedObject != nil {
93+
return datadog.Marshal(o.UnparsedObject)
94+
}
95+
toSerialize["data"] = o.Data
96+
toSerialize["included"] = o.Included
97+
98+
for key, value := range o.AdditionalProperties {
99+
toSerialize[key] = value
100+
}
101+
return datadog.Marshal(toSerialize)
102+
}
103+
104+
// UnmarshalJSON deserializes the given payload.
105+
func (o *ListSharedDashboardsResponse) UnmarshalJSON(bytes []byte) (err error) {
106+
all := struct {
107+
Data *[]SharedDashboardResponse `json:"data"`
108+
Included *[]SharedDashboardIncluded `json:"included"`
109+
}{}
110+
if err = datadog.Unmarshal(bytes, &all); err != nil {
111+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
112+
}
113+
if all.Data == nil {
114+
return fmt.Errorf("required field data missing")
115+
}
116+
if all.Included == nil {
117+
return fmt.Errorf("required field included missing")
118+
}
119+
additionalProperties := make(map[string]interface{})
120+
if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil {
121+
datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"})
122+
} else {
123+
return err
124+
}
125+
o.Data = *all.Data
126+
o.Included = *all.Included
127+
128+
if len(additionalProperties) > 0 {
129+
o.AdditionalProperties = additionalProperties
130+
}
131+
132+
return nil
133+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
9+
)
10+
11+
// SharedDashboardIncluded - Resource included with a shared dashboard.
12+
type SharedDashboardIncluded struct {
13+
SharedDashboardIncludedDashboard *SharedDashboardIncludedDashboard
14+
SharedDashboardIncludedUser *SharedDashboardIncludedUser
15+
16+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
17+
UnparsedObject interface{}
18+
}
19+
20+
// SharedDashboardIncludedDashboardAsSharedDashboardIncluded is a convenience function that returns SharedDashboardIncludedDashboard wrapped in SharedDashboardIncluded.
21+
func SharedDashboardIncludedDashboardAsSharedDashboardIncluded(v *SharedDashboardIncludedDashboard) SharedDashboardIncluded {
22+
return SharedDashboardIncluded{SharedDashboardIncludedDashboard: v}
23+
}
24+
25+
// SharedDashboardIncludedUserAsSharedDashboardIncluded is a convenience function that returns SharedDashboardIncludedUser wrapped in SharedDashboardIncluded.
26+
func SharedDashboardIncludedUserAsSharedDashboardIncluded(v *SharedDashboardIncludedUser) SharedDashboardIncluded {
27+
return SharedDashboardIncluded{SharedDashboardIncludedUser: v}
28+
}
29+
30+
// UnmarshalJSON turns data into one of the pointers in the struct.
31+
func (obj *SharedDashboardIncluded) UnmarshalJSON(data []byte) error {
32+
var err error
33+
match := 0
34+
// try to unmarshal data into SharedDashboardIncludedDashboard
35+
err = datadog.Unmarshal(data, &obj.SharedDashboardIncludedDashboard)
36+
if err == nil {
37+
if obj.SharedDashboardIncludedDashboard != nil && obj.SharedDashboardIncludedDashboard.UnparsedObject == nil {
38+
jsonSharedDashboardIncludedDashboard, _ := datadog.Marshal(obj.SharedDashboardIncludedDashboard)
39+
if string(jsonSharedDashboardIncludedDashboard) == "{}" { // empty struct
40+
obj.SharedDashboardIncludedDashboard = nil
41+
} else {
42+
match++
43+
}
44+
} else {
45+
obj.SharedDashboardIncludedDashboard = nil
46+
}
47+
} else {
48+
obj.SharedDashboardIncludedDashboard = nil
49+
}
50+
51+
// try to unmarshal data into SharedDashboardIncludedUser
52+
err = datadog.Unmarshal(data, &obj.SharedDashboardIncludedUser)
53+
if err == nil {
54+
if obj.SharedDashboardIncludedUser != nil && obj.SharedDashboardIncludedUser.UnparsedObject == nil {
55+
jsonSharedDashboardIncludedUser, _ := datadog.Marshal(obj.SharedDashboardIncludedUser)
56+
if string(jsonSharedDashboardIncludedUser) == "{}" { // empty struct
57+
obj.SharedDashboardIncludedUser = nil
58+
} else {
59+
match++
60+
}
61+
} else {
62+
obj.SharedDashboardIncludedUser = nil
63+
}
64+
} else {
65+
obj.SharedDashboardIncludedUser = nil
66+
}
67+
68+
if match != 1 { // more than 1 match
69+
// reset to nil
70+
obj.SharedDashboardIncludedDashboard = nil
71+
obj.SharedDashboardIncludedUser = nil
72+
return datadog.Unmarshal(data, &obj.UnparsedObject)
73+
}
74+
return nil // exactly one match
75+
}
76+
77+
// MarshalJSON turns data from the first non-nil pointers in the struct to JSON.
78+
func (obj SharedDashboardIncluded) MarshalJSON() ([]byte, error) {
79+
if obj.SharedDashboardIncludedDashboard != nil {
80+
return datadog.Marshal(&obj.SharedDashboardIncludedDashboard)
81+
}
82+
83+
if obj.SharedDashboardIncludedUser != nil {
84+
return datadog.Marshal(&obj.SharedDashboardIncludedUser)
85+
}
86+
87+
if obj.UnparsedObject != nil {
88+
return datadog.Marshal(obj.UnparsedObject)
89+
}
90+
return nil, nil // no data in oneOf schemas
91+
}
92+
93+
// GetActualInstance returns the actual instance.
94+
func (obj *SharedDashboardIncluded) GetActualInstance() interface{} {
95+
if obj.SharedDashboardIncludedDashboard != nil {
96+
return obj.SharedDashboardIncludedDashboard
97+
}
98+
99+
if obj.SharedDashboardIncludedUser != nil {
100+
return obj.SharedDashboardIncludedUser
101+
}
102+
103+
// all schemas are nil
104+
return nil
105+
}

0 commit comments

Comments
 (0)