Skip to content

Commit d4202d5

Browse files
fix: [PL-48875]: CDB - Request header and model type updates (#668)
* fix: [PL-48875]: Added support for x-api-key headers. Fix type for dashboard update * feat: [PL-48875]: Refactored header code * feat: [PL-48875]: Refactored header code for dashbaord filter
1 parent 4bcace6 commit d4202d5

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

harness/nextgen/api_dashboards.go

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ var (
2727

2828
type DashboardsApiService service
2929

30+
// addAPIKeyToHeaders adds the API key from context to the header parameters if available
31+
func addAPIKeyToHeaders(ctx context.Context, headerParams map[string]string) {
32+
if ctx != nil {
33+
// API Key Authentication
34+
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
35+
var key string
36+
if auth.Prefix != "" {
37+
key = auth.Prefix + " " + auth.Key
38+
} else {
39+
key = auth.Key
40+
}
41+
headerParams["x-api-key"] = key
42+
}
43+
}
44+
}
45+
3046
/*
3147
DashboardsApiService
3248
Clone a dashboard.
@@ -79,19 +95,9 @@ func (a *DashboardsApiService) CloneDashboard(ctx context.Context, body CloneDas
7995
}
8096
// body params
8197
localVarPostBody = &body
82-
if ctx != nil {
83-
// API Key Authentication
84-
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
85-
var key string
86-
if auth.Prefix != "" {
87-
key = auth.Prefix + " " + auth.Key
88-
} else {
89-
key = auth.Key
90-
}
91-
localVarHeaderParams["x-api-key"] = key
9298

93-
}
94-
}
99+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
100+
95101
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
96102
if err != nil {
97103
return localVarReturnValue, nil, err
@@ -201,6 +207,9 @@ func (a *DashboardsApiService) DeleteDashboard(ctx context.Context, body DeleteD
201207
}
202208
// body params
203209
localVarPostBody = &body
210+
211+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
212+
204213
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
205214
if err != nil {
206215
return localVarReturnValue, nil, err
@@ -297,6 +306,9 @@ func (a *DashboardsApiService) GetDashboard(ctx context.Context, dashboardId str
297306
if localVarHttpHeaderAccept != "" {
298307
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
299308
}
309+
310+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
311+
300312
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
301313
if err != nil {
302314
return localVarReturnValue, nil, err
@@ -404,6 +416,9 @@ func (a *DashboardsApiService) UpdateDashboard(ctx context.Context, body CreateD
404416
}
405417
// body params
406418
localVarPostBody = &body
419+
420+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
421+
407422
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
408423
if err != nil {
409424
return localVarReturnValue, nil, err

harness/nextgen/api_dashboards_filter.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (a *DashboardsFilterApiService) GetDashboardFilters(ctx context.Context, da
9191

9292
}
9393
}
94+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
9495
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
9596
if err != nil {
9697
return localVarReturnValue, nil, err
@@ -216,6 +217,7 @@ func (a *DashboardsFilterApiService) UpdateDashboardFilter(ctx context.Context,
216217

217218
}
218219
}
220+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
219221
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
220222
if err != nil {
221223
return localVarReturnValue, nil, err

harness/nextgen/api_dashboards_folder.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,7 @@ func (a *DashboardsFolderApiService) CreateFolder(ctx context.Context, body Crea
7979
}
8080
// body params
8181
localVarPostBody = &body
82-
if ctx != nil {
83-
// API Key Authentication
84-
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
85-
var key string
86-
if auth.Prefix != "" {
87-
key = auth.Prefix + " " + auth.Key
88-
} else {
89-
key = auth.Key
90-
}
91-
localVarHeaderParams["x-api-key"] = key
92-
93-
}
94-
}
82+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
9583
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
9684
if err != nil {
9785
return localVarReturnValue, nil, err
@@ -198,6 +186,7 @@ func (a *DashboardsFolderApiService) DeleteFolder(ctx context.Context, folderId
198186
if localVarHttpHeaderAccept != "" {
199187
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
200188
}
189+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
201190
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
202191
if err != nil {
203192
return localVarReturnValue, nil, err
@@ -304,6 +293,7 @@ func (a *DashboardsFolderApiService) GetFolder(ctx context.Context, folderId str
304293
if localVarHttpHeaderAccept != "" {
305294
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
306295
}
296+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
307297
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
308298
if err != nil {
309299
return localVarReturnValue, nil, err
@@ -413,6 +403,7 @@ func (a *DashboardsFolderApiService) UpdateFolder(ctx context.Context, body Upda
413403
}
414404
// body params
415405
localVarPostBody = &body
406+
addAPIKeyToHeaders(ctx, localVarHeaderParams)
416407
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
417408
if err != nil {
418409
return localVarReturnValue, nil, err

harness/nextgen/docs/UpdateDashboardResponseResource.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**Id** | **int32** | | [default to null]
6+
**Id** | **string** | | [default to null]
77
**Title** | **string** | | [default to null]
88
**ResourceIdentifier** | **string** | | [default to null]
99
**Description** | **string** | | [default to null]

harness/nextgen/model_update_dashboard_response_resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
package nextgen
1111

1212
type UpdateDashboardResponseResource struct {
13-
Id int32 `json:"id"`
13+
Id string `json:"id"`
1414
Title string `json:"title"`
1515
ResourceIdentifier string `json:"resourceIdentifier"`
1616
Description string `json:"description"`

0 commit comments

Comments
 (0)