|
27 | 27 |
|
28 | 28 | type DashboardsApiService service |
29 | 29 |
|
| 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 | + |
30 | 46 | /* |
31 | 47 | DashboardsApiService |
32 | 48 | Clone a dashboard. |
@@ -79,19 +95,9 @@ func (a *DashboardsApiService) CloneDashboard(ctx context.Context, body CloneDas |
79 | 95 | } |
80 | 96 | // body params |
81 | 97 | 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 | 98 |
|
93 | | - } |
94 | | - } |
| 99 | + addAPIKeyToHeaders(ctx, localVarHeaderParams) |
| 100 | + |
95 | 101 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) |
96 | 102 | if err != nil { |
97 | 103 | return localVarReturnValue, nil, err |
@@ -201,6 +207,9 @@ func (a *DashboardsApiService) DeleteDashboard(ctx context.Context, body DeleteD |
201 | 207 | } |
202 | 208 | // body params |
203 | 209 | localVarPostBody = &body |
| 210 | + |
| 211 | + addAPIKeyToHeaders(ctx, localVarHeaderParams) |
| 212 | + |
204 | 213 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) |
205 | 214 | if err != nil { |
206 | 215 | return localVarReturnValue, nil, err |
@@ -297,6 +306,9 @@ func (a *DashboardsApiService) GetDashboard(ctx context.Context, dashboardId str |
297 | 306 | if localVarHttpHeaderAccept != "" { |
298 | 307 | localVarHeaderParams["Accept"] = localVarHttpHeaderAccept |
299 | 308 | } |
| 309 | + |
| 310 | + addAPIKeyToHeaders(ctx, localVarHeaderParams) |
| 311 | + |
300 | 312 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) |
301 | 313 | if err != nil { |
302 | 314 | return localVarReturnValue, nil, err |
@@ -404,6 +416,9 @@ func (a *DashboardsApiService) UpdateDashboard(ctx context.Context, body CreateD |
404 | 416 | } |
405 | 417 | // body params |
406 | 418 | localVarPostBody = &body |
| 419 | + |
| 420 | + addAPIKeyToHeaders(ctx, localVarHeaderParams) |
| 421 | + |
407 | 422 | r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) |
408 | 423 | if err != nil { |
409 | 424 | return localVarReturnValue, nil, err |
|
0 commit comments