-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Extend client so that it is possible to follow links on ge… (#65)
…neric work job artefact managers <!-- Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. SPDX-License-Identifier: Proprietary --> ### Description extend the API to allow automatic collection browsing ### Test Coverage <!-- Please put an `x` in the correct box e.g. `[x]` to indicate the testing coverage of this change. --> - [ ] This change is covered by existing or additional automated tests. - [ ] Manual testing has been performed (and evidence provided) as automated testing was not feasible. - [x] Additional tests are not required for this change (e.g. documentation update).
- Loading branch information
1 parent
a1a8cd0
commit a6e7460
Showing
3 changed files
with
359 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:sparkles: Extend client so that it is possible to follow links on generic work job artefact managers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* | ||
* Copyright (C) 2020-2024 Arm Limited or its affiliates and Contributors. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// Package client defines an HTTP client for communicating with the web services. | ||
// It includes the definition of request/response types as well as provides helpers for calling specific helpers. | ||
package client | ||
|
||
// ************************************************************************************* | ||
// NOTE: this file is not generated. | ||
// ************************************************************************************* | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"net/http" | ||
"net/url" | ||
) | ||
|
||
func (r *ApiListGenericWorkJobsRequest) FollowGenericWorkJobArtefactsLink(link string) (*ArtefactManagerCollection, *http.Response, error) { | ||
return r.ApiService.FollowGenericWorkJobArtefactsLink(r, link) | ||
} | ||
|
||
func (a *GenericWorkJobsAPIService) FollowGenericWorkJobArtefactsLink(r *ApiListGenericWorkJobsRequest, link string) (*ArtefactManagerCollection, *http.Response, error) { | ||
|
||
var ( | ||
localVarHTTPMethod = http.MethodGet | ||
localVarPostBody interface{} | ||
formFiles []formFile | ||
localVarReturnValue *ArtefactManagerCollection | ||
) | ||
|
||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "GenericWorkJobsAPIService.ListGenericWorkJobArtefactManagers") | ||
if err != nil { | ||
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} | ||
} | ||
|
||
// NOTE: | ||
// These lines are the only differences from the `ListGenericWorkJobArtefactManagersExecute` function, | ||
// we specify the destination of the call by appending the link that is to be followed | ||
localVarPath := localBasePath + link | ||
// ************************************************************************************************************** | ||
|
||
localVarHeaderParams := make(map[string]string) | ||
localVarQueryParams := url.Values{} | ||
localVarFormParams := url.Values{} | ||
|
||
if r.embed != nil { | ||
parameterAddToHeaderOrQuery(localVarQueryParams, "embed", r.embed, "form", "") | ||
} else { | ||
var defaultValue = false | ||
r.embed = &defaultValue | ||
} | ||
if r.limit != nil { | ||
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "") | ||
} else { | ||
var defaultValue int32 = 20 | ||
r.limit = &defaultValue | ||
} | ||
if r.offset != nil { | ||
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "") | ||
} else { | ||
var defaultValue int32 = 0 | ||
r.offset = &defaultValue | ||
} | ||
// to determine the Content-Type header | ||
localVarHTTPContentTypes := []string{} | ||
|
||
// set Content-Type header | ||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) | ||
if localVarHTTPContentType != "" { | ||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType | ||
} | ||
|
||
// to determine the Accept header | ||
localVarHTTPHeaderAccepts := []string{"application/json"} | ||
|
||
// set Accept header | ||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) | ||
if localVarHTTPHeaderAccept != "" { | ||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept | ||
} | ||
if r.acceptVersion != nil { | ||
parameterAddToHeaderOrQuery(localVarHeaderParams, "Accept-Version", r.acceptVersion, "simple", "") | ||
} | ||
if r.ifNoneMatch != nil { | ||
parameterAddToHeaderOrQuery(localVarHeaderParams, "if-none-match", r.ifNoneMatch, "simple", "") | ||
} | ||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) | ||
if err != nil { | ||
return localVarReturnValue, nil, err | ||
} | ||
|
||
localVarHTTPResponse, err := a.client.callAPI(req) | ||
if err != nil || localVarHTTPResponse == nil { | ||
return localVarReturnValue, localVarHTTPResponse, err | ||
} | ||
|
||
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) | ||
localVarHTTPResponse.Body.Close() | ||
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) | ||
if err != nil { | ||
return localVarReturnValue, localVarHTTPResponse, err | ||
} | ||
|
||
if localVarHTTPResponse.StatusCode >= 300 { | ||
newErr := &GenericOpenAPIError{ | ||
body: localVarBody, | ||
error: localVarHTTPResponse.Status, | ||
} | ||
if localVarHTTPResponse.StatusCode == 400 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 401 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 404 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 406 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 429 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
} | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
|
||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr := &GenericOpenAPIError{ | ||
body: localVarBody, | ||
error: err.Error(), | ||
} | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
|
||
return localVarReturnValue, localVarHTTPResponse, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/* | ||
* Copyright (C) 2020-2024 Arm Limited or its affiliates and Contributors. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// Package client defines an HTTP client for communicating with the web services. | ||
// It includes the definition of request/response types as well as provides helpers for calling specific helpers. | ||
package client | ||
|
||
// ************************************************************************************* | ||
// NOTE: this file is not generated. | ||
// ************************************************************************************* | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"net/http" | ||
"net/url" | ||
) | ||
|
||
func (r *ApiListGenericWorkJobsRequest) FollowGenericWorkJobArtefactsLink(link string) (*ArtefactManagerCollection, *http.Response, error) { | ||
return r.ApiService.FollowGenericWorkJobArtefactsLink(r, link) | ||
} | ||
|
||
func (a *GenericWorkJobsAPIService) FollowGenericWorkJobArtefactsLink(r *ApiListGenericWorkJobsRequest, link string) (*ArtefactManagerCollection, *http.Response, error) { | ||
|
||
var ( | ||
localVarHTTPMethod = http.MethodGet | ||
localVarPostBody interface{} | ||
formFiles []formFile | ||
localVarReturnValue *ArtefactManagerCollection | ||
) | ||
|
||
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "GenericWorkJobsAPIService.ListGenericWorkJobArtefactManagers") | ||
if err != nil { | ||
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} | ||
} | ||
|
||
// NOTE: | ||
// These lines are the only differences from the `ListGenericWorkJobArtefactManagersExecute` function, | ||
// we specify the destination of the call by appending the link that is to be followed | ||
localVarPath := localBasePath + link | ||
// ************************************************************************************************************** | ||
|
||
localVarHeaderParams := make(map[string]string) | ||
localVarQueryParams := url.Values{} | ||
localVarFormParams := url.Values{} | ||
|
||
if r.embed != nil { | ||
parameterAddToHeaderOrQuery(localVarQueryParams, "embed", r.embed, "form", "") | ||
} else { | ||
var defaultValue = false | ||
r.embed = &defaultValue | ||
} | ||
if r.limit != nil { | ||
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "") | ||
} else { | ||
var defaultValue int32 = 20 | ||
r.limit = &defaultValue | ||
} | ||
if r.offset != nil { | ||
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "") | ||
} else { | ||
var defaultValue int32 = 0 | ||
r.offset = &defaultValue | ||
} | ||
// to determine the Content-Type header | ||
localVarHTTPContentTypes := []string{} | ||
|
||
// set Content-Type header | ||
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) | ||
if localVarHTTPContentType != "" { | ||
localVarHeaderParams["Content-Type"] = localVarHTTPContentType | ||
} | ||
|
||
// to determine the Accept header | ||
localVarHTTPHeaderAccepts := []string{"application/json"} | ||
|
||
// set Accept header | ||
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) | ||
if localVarHTTPHeaderAccept != "" { | ||
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept | ||
} | ||
if r.acceptVersion != nil { | ||
parameterAddToHeaderOrQuery(localVarHeaderParams, "Accept-Version", r.acceptVersion, "simple", "") | ||
} | ||
if r.ifNoneMatch != nil { | ||
parameterAddToHeaderOrQuery(localVarHeaderParams, "if-none-match", r.ifNoneMatch, "simple", "") | ||
} | ||
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) | ||
if err != nil { | ||
return localVarReturnValue, nil, err | ||
} | ||
|
||
localVarHTTPResponse, err := a.client.callAPI(req) | ||
if err != nil || localVarHTTPResponse == nil { | ||
return localVarReturnValue, localVarHTTPResponse, err | ||
} | ||
|
||
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) | ||
localVarHTTPResponse.Body.Close() | ||
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) | ||
if err != nil { | ||
return localVarReturnValue, localVarHTTPResponse, err | ||
} | ||
|
||
if localVarHTTPResponse.StatusCode >= 300 { | ||
newErr := &GenericOpenAPIError{ | ||
body: localVarBody, | ||
error: localVarHTTPResponse.Status, | ||
} | ||
if localVarHTTPResponse.StatusCode == 400 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 401 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 404 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 406 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
if localVarHTTPResponse.StatusCode == 429 { | ||
var v ErrorResponse | ||
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr.error = err.Error() | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) | ||
newErr.model = v | ||
} | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
|
||
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) | ||
if err != nil { | ||
newErr := &GenericOpenAPIError{ | ||
body: localVarBody, | ||
error: err.Error(), | ||
} | ||
return localVarReturnValue, localVarHTTPResponse, newErr | ||
} | ||
|
||
return localVarReturnValue, localVarHTTPResponse, nil | ||
} |