diff --git a/sdk/client/api_application_resource.go b/sdk/client/api_application_resource.go new file mode 100644 index 00000000..b0c31588 --- /dev/null +++ b/sdk/client/api_application_resource.go @@ -0,0 +1,1274 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package client + +import ( + "context" + "fmt" + "github.com/conductor-sdk/conductor-go/sdk/model" + "github.com/conductor-sdk/conductor-go/sdk/model/rbac" + "net/http" + "net/url" + "strings" +) + +type ApplicationResourceApiService struct { + *APIClient +} + +/* +ApplicationResourceApiService +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param applicationId + - @param role + @return interface{} +*/ +func (a *ApplicationResourceApiService) AddRoleToApplicationUser(ctx context.Context, applicationId string, role string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Post") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{applicationId}/roles/{role}" + path = strings.Replace(path, "{"+"applicationId"+"}", fmt.Sprintf("%v", applicationId), -1) + path = strings.Replace(path, "{"+"role"+"}", fmt.Sprintf("%v", role), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Create an access key for an application +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return interface{} +*/ +func (a *ApplicationResourceApiService) CreateAccessKey(ctx context.Context, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Post") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{id}/accessKeys" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Create an application +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + @return interface{} +*/ +func (a *ApplicationResourceApiService) CreateApplication(ctx context.Context, body rbac.CreateOrUpdateApplicationRequest) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Post") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Delete an access key +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param applicationId + - @param keyId + @return interface{} +*/ +func (a *ApplicationResourceApiService) DeleteAccessKey(ctx context.Context, applicationId string, keyId string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{applicationId}/accessKeys/{keyId}" + path = strings.Replace(path, "{"+"applicationId"+"}", fmt.Sprintf("%v", applicationId), -1) + path = strings.Replace(path, "{"+"keyId"+"}", fmt.Sprintf("%v", keyId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Delete an application +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return interface{} +*/ +func (a *ApplicationResourceApiService) DeleteApplication(ctx context.Context, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Delete a tag for application +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param id +*/ +func (a *ApplicationResourceApiService) DeleteTagForApplication(ctx context.Context, body []model.Tag, id string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/applications/{id}/tags" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +ApplicationResourceApiService Get application's access keys +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return interface{} +*/ +func (a *ApplicationResourceApiService) GetAccessKeys(ctx context.Context, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{id}/accessKeys" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Get application id by access key id +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param accessKeyId + @return interface{} +*/ +func (a *ApplicationResourceApiService) GetAppByAccessKeyId(ctx context.Context, accessKeyId string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/key/{accessKeyId}" + path = strings.Replace(path, "{"+"accessKeyId"+"}", fmt.Sprintf("%v", accessKeyId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Get an application by id +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return interface{} +*/ +func (a *ApplicationResourceApiService) GetApplication(ctx context.Context, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Get tags by application +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return []model.Tag +*/ +func (a *ApplicationResourceApiService) GetTagsForApplication(ctx context.Context, id string) ([]model.Tag, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue []model.Tag + ) + + // create path and map variables + path := "/api/applications/{id}/tags" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []model.Tag + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Get all applications + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return []rbac.ConductorApplication +*/ +func (a *ApplicationResourceApiService) ListApplications(ctx context.Context) ([]rbac.ConductorApplication, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue []rbac.ConductorApplication + ) + + // create path and map variables + path := "/api/applications" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []rbac.ConductorApplication + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Put a tag to application +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param id +*/ +func (a *ApplicationResourceApiService) PutTagForApplication(ctx context.Context, body []model.Tag, id string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Put") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/applications/{id}/tags" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +ApplicationResourceApiService +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param applicationId + - @param role + @return interface{} +*/ +func (a *ApplicationResourceApiService) RemoveRoleFromApplicationUser(ctx context.Context, applicationId string, role string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{applicationId}/roles/{role}" + path = strings.Replace(path, "{"+"applicationId"+"}", fmt.Sprintf("%v", applicationId), -1) + path = strings.Replace(path, "{"+"role"+"}", fmt.Sprintf("%v", role), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Toggle the status of an access key +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param applicationId + - @param keyId + @return interface{} +*/ +func (a *ApplicationResourceApiService) ToggleAccessKeyStatus(ctx context.Context, applicationId string, keyId string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Post") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{applicationId}/accessKeys/{keyId}/status" + path = strings.Replace(path, "{"+"applicationId"+"}", fmt.Sprintf("%v", applicationId), -1) + path = strings.Replace(path, "{"+"keyId"+"}", fmt.Sprintf("%v", keyId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +ApplicationResourceApiService Update an application +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param id + @return interface{} +*/ +func (a *ApplicationResourceApiService) UpdateApplication(ctx context.Context, body rbac.CreateOrUpdateApplicationRequest, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Put") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/applications/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} diff --git a/sdk/client/api_group_resource.go b/sdk/client/api_group_resource.go new file mode 100644 index 00000000..9d08a0dc --- /dev/null +++ b/sdk/client/api_group_resource.go @@ -0,0 +1,828 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package client + +import ( + "context" + "fmt" + "github.com/conductor-sdk/conductor-go/sdk/model/rbac" + "net/http" + "net/url" + "strings" +) + +type GroupResourceApiService struct { + *APIClient +} + +/* +GroupResourceApiService Add user to group +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param groupId + - @param userId + @return interface{} +*/ +func (a *GroupResourceApiService) AddUserToGroup(ctx context.Context, groupId string, userId string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Post") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/groups/{groupId}/users/{userId}" + path = strings.Replace(path, "{"+"groupId"+"}", fmt.Sprintf("%v", groupId), -1) + path = strings.Replace(path, "{"+"userId"+"}", fmt.Sprintf("%v", userId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +GroupResourceApiService Add users to group +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param groupId +*/ +func (a *GroupResourceApiService) AddUsersToGroup(ctx context.Context, body []string, groupId string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Post") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/groups/{groupId}/users" + path = strings.Replace(path, "{"+"groupId"+"}", fmt.Sprintf("%v", groupId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +GroupResourceApiService Delete a group +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return Response +*/ +func (a *GroupResourceApiService) DeleteGroup(ctx context.Context, id string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/groups/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode < 300 { + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +GroupResourceApiService Get the permissions this group has over workflows and tasks +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param groupId + @return rbac.GrantedAccessResponse +*/ +func (a *GroupResourceApiService) GetGrantedPermissions1(ctx context.Context, groupId string) (rbac.GrantedAccessResponse, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue rbac.GrantedAccessResponse + ) + + // create path and map variables + path := "/api/groups/{groupId}/permissions" + path = strings.Replace(path, "{"+"groupId"+"}", fmt.Sprintf("%v", groupId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v rbac.GrantedAccessResponse + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +GroupResourceApiService Get a group by id +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return interface{} +*/ +func (a *GroupResourceApiService) GetGroup(ctx context.Context, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/groups/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +GroupResourceApiService Get all users in group +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return interface{} +*/ +func (a *GroupResourceApiService) GetUsersInGroup(ctx context.Context, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/groups/{id}/users" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +GroupResourceApiService Get all groups + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return []rbac.Group +*/ +func (a *GroupResourceApiService) ListGroups(ctx context.Context) ([]rbac.Group, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue []rbac.Group + ) + + // create path and map variables + path := "/api/groups" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []rbac.Group + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +GroupResourceApiService Remove user from group +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param groupId + - @param userId + @return interface{} +*/ +func (a *GroupResourceApiService) RemoveUserFromGroup(ctx context.Context, groupId string, userId string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/groups/{groupId}/users/{userId}" + path = strings.Replace(path, "{"+"groupId"+"}", fmt.Sprintf("%v", groupId), -1) + path = strings.Replace(path, "{"+"userId"+"}", fmt.Sprintf("%v", userId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +GroupResourceApiService Remove users from group +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param groupId +*/ +func (a *GroupResourceApiService) RemoveUsersFromGroup(ctx context.Context, body []string, groupId string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/groups/{groupId}/users" + path = strings.Replace(path, "{"+"groupId"+"}", fmt.Sprintf("%v", groupId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +GroupResourceApiService Create or update a group +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param id + @return interface{} +*/ +func (a *GroupResourceApiService) UpsertGroup(ctx context.Context, body rbac.UpsertGroupRequest, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Put") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/groups/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} diff --git a/sdk/client/api_secret_resource.go b/sdk/client/api_secret_resource.go new file mode 100644 index 00000000..2e9aebf8 --- /dev/null +++ b/sdk/client/api_secret_resource.go @@ -0,0 +1,1001 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package client + +import ( + "context" + "fmt" + "github.com/conductor-sdk/conductor-go/sdk/model" + "net/http" + "net/url" + "strings" +) + +type SecretResourceApiService struct { + *APIClient +} + +/* +SecretResourceApiService Clear local cache + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return map[string]string +*/ +func (a *SecretResourceApiService) ClearLocalCache(ctx context.Context) (map[string]string, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue map[string]string + ) + + // create path and map variables + path := "/api/secrets/clearLocalCache" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v map[string]string + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService Clear redis cache + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return map[string]string +*/ +func (a *SecretResourceApiService) ClearRedisCache(ctx context.Context) (map[string]string, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue map[string]string + ) + + // create path and map variables + path := "/api/secrets/clearRedisCache" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v map[string]string + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService Delete a secret value by key +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param key + @return interface{} +*/ +func (a *SecretResourceApiService) DeleteSecret(ctx context.Context, key string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/secrets/{key}" + path = strings.Replace(path, "{"+"key"+"}", fmt.Sprintf("%v", key), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService Delete tags of the secret +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param key +*/ +func (a *SecretResourceApiService) DeleteTagForSecret(ctx context.Context, body []model.Tag, key string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/secrets/{key}/tags" + path = strings.Replace(path, "{"+"key"+"}", fmt.Sprintf("%v", key), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +SecretResourceApiService Get secret value by key +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param key + @return string +*/ +func (a *SecretResourceApiService) GetSecret(ctx context.Context, key string) (string, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue string + ) + + // create path and map variables + path := "/api/secrets/{key}" + path = strings.Replace(path, "{"+"key"+"}", fmt.Sprintf("%v", key), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v string + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService Get tags by secret +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param key + @return []model.Tag +*/ +func (a *SecretResourceApiService) GetTags(ctx context.Context, key string) ([]model.Tag, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue []model.Tag + ) + + // create path and map variables + path := "/api/secrets/{key}/tags" + path = strings.Replace(path, "{"+"key"+"}", fmt.Sprintf("%v", key), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []model.Tag + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService List all secret names + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return []string +*/ +func (a *SecretResourceApiService) ListAllSecretNames(ctx context.Context) ([]string, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Post") + postBody interface{} + fileName string + fileBytes []byte + returnValue []string + ) + + // create path and map variables + path := "/api/secrets" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []string + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService List all secret names user can grant access to + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return []string +*/ +func (a *SecretResourceApiService) ListSecretsThatUserCanGrantAccessTo(ctx context.Context) ([]string, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue []string + ) + + // create path and map variables + path := "/api/secrets" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []string + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService List all secret names along with tags user can grant access to + - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return []model.Secret +*/ +func (a *SecretResourceApiService) ListSecretsWithTagsThatUserCanGrantAccessTo(ctx context.Context) ([]model.Secret, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue []model.Secret + ) + + // create path and map variables + path := "/api/secrets-v2" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []model.Secret + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService Put a secret value by key +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param key + @return interface{} +*/ +func (a *SecretResourceApiService) PutSecret(ctx context.Context, body string, key string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Put") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/secrets/{key}" + path = strings.Replace(path, "{"+"key"+"}", fmt.Sprintf("%v", key), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +SecretResourceApiService Tag a secret +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param key +*/ +func (a *SecretResourceApiService) PutTagForSecret(ctx context.Context, body []model.Tag, key string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Put") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/secrets/{key}/tags" + path = strings.Replace(path, "{"+"key"+"}", fmt.Sprintf("%v", key), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +SecretResourceApiService Check if secret exists +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param key + @return interface{} +*/ +func (a *SecretResourceApiService) SecretExists(ctx context.Context, key string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/secrets/{key}/exists" + path = strings.Replace(path, "{"+"key"+"}", fmt.Sprintf("%v", key), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} diff --git a/sdk/client/api_user_resource.go b/sdk/client/api_user_resource.go new file mode 100644 index 00000000..ce2847f5 --- /dev/null +++ b/sdk/client/api_user_resource.go @@ -0,0 +1,534 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package client + +import ( + "context" + "fmt" + "github.com/antihax/optional" + "github.com/conductor-sdk/conductor-go/sdk/model/rbac" + "net/http" + "net/url" + "strings" +) + +type UserResourceApiService struct { + *APIClient +} + +/* +UserResourceApiService Get the permissions this user has over workflows and tasks +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param userId + - @param type_ + - @param id + @return interface{} +*/ +func (a *UserResourceApiService) CheckPermissions(ctx context.Context, userId string, type_ string, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/users/{userId}/checkPermissions" + path = strings.Replace(path, "{"+"userId"+"}", fmt.Sprintf("%v", userId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + queryParams.Add("type", parameterToString(type_, "")) + queryParams.Add("id", parameterToString(id, "")) + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +UserResourceApiService Delete a user +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return Response +*/ +func (a *UserResourceApiService) DeleteUser(ctx context.Context, id string) (*http.Response, error) { + var ( + httpMethod = strings.ToUpper("Delete") + postBody interface{} + fileName string + fileBytes []byte + ) + + // create path and map variables + path := "/api/users/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + return httpResponse, err + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + return httpResponse, newErr + } + + return httpResponse, nil +} + +/* +UserResourceApiService Get the permissions this user has over workflows and tasks +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param userId + @return interface{} +*/ +func (a *UserResourceApiService) GetGrantedPermissions(ctx context.Context, userId string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/users/{userId}/permissions" + path = strings.Replace(path, "{"+"userId"+"}", fmt.Sprintf("%v", userId), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +UserResourceApiService Get a user by id +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param id + @return interface{} +*/ +func (a *UserResourceApiService) GetUser(ctx context.Context, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/users/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* + UserResourceApiService Get all users + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *UserResourceApiListUsersOpts - Optional Parameters: + * @param "Apps" (optional.Bool) - + @return []ConductorUser +*/ + +type UserResourceApiListUsersOpts struct { + Apps optional.Bool +} + +func (a *UserResourceApiService) ListUsers(ctx context.Context, optionals *UserResourceApiListUsersOpts) ([]rbac.ConductorUser, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Get") + postBody interface{} + fileName string + fileBytes []byte + returnValue []rbac.ConductorUser + ) + + // create path and map variables + path := "/api/users" + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + if optionals != nil && optionals.Apps.IsSet() { + queryParams.Add("apps", parameterToString(optionals.Apps.Value(), "")) + } + // to determine the Content-Type header + contentTypes := []string{} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v []rbac.ConductorUser + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} + +/* +UserResourceApiService Create or update a user +* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + - @param body + - @param id + @return interface{} +*/ +func (a *UserResourceApiService) UpsertUser(ctx context.Context, body rbac.UpsertUserRequest, id string) (interface{}, *http.Response, error) { + var ( + httpMethod = strings.ToUpper("Put") + postBody interface{} + fileName string + fileBytes []byte + returnValue interface{} + ) + + // create path and map variables + path := "/api/users/{id}" + path = strings.Replace(path, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + + headerParams := make(map[string]string) + queryParams := url.Values{} + formParams := url.Values{} + + // to determine the Content-Type header + contentTypes := []string{"application/json"} + + // set Content-Type header + contentType := selectHeaderContentType(contentTypes) + if contentType != "" { + headerParams["Content-Type"] = contentType + } + + // to determine the Accept header + headerAccepts := []string{"application/json"} + + // set Accept header + headerAccept := selectHeaderAccept(headerAccepts) + if headerAccept != "" { + headerParams["Accept"] = headerAccept + } + // body params + postBody = &body + r, err := a.prepareRequest(ctx, path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return returnValue, nil, err + } + + httpResponse, err := a.callAPI(r) + if err != nil || httpResponse == nil { + return returnValue, httpResponse, err + } + + responseBody, err := getDecompressedBody(httpResponse) + httpResponse.Body.Close() + if err != nil { + return returnValue, httpResponse, err + } + + if httpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.decode(&returnValue, responseBody, httpResponse.Header.Get("Content-Type")) + if err == nil { + return returnValue, httpResponse, err + } + } + + if httpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: responseBody, + error: httpResponse.Status, + } + if httpResponse.StatusCode == 200 { + var v interface{} + err = a.decode(&v, responseBody, httpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return returnValue, httpResponse, newErr + } + newErr.model = v + return returnValue, httpResponse, newErr + } + return returnValue, httpResponse, newErr + } + + return returnValue, httpResponse, nil +} diff --git a/sdk/model/rbac/conductor_user.go b/sdk/model/rbac/conductor_user.go new file mode 100644 index 00000000..b94f0d6d --- /dev/null +++ b/sdk/model/rbac/conductor_user.go @@ -0,0 +1,20 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type ConductorUser struct { + ApplicationUser bool `json:"applicationUser,omitempty"` + EncryptedId bool `json:"encryptedId,omitempty"` + EncryptedIdDisplayValue string `json:"encryptedIdDisplayValue,omitempty"` + Groups []Group `json:"groups,omitempty"` + Id string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Roles []Role `json:"roles,omitempty"` + Uuid string `json:"uuid,omitempty"` +} diff --git a/sdk/model/rbac/create_or_update_application_request.go b/sdk/model/rbac/create_or_update_application_request.go new file mode 100644 index 00000000..fe6128a6 --- /dev/null +++ b/sdk/model/rbac/create_or_update_application_request.go @@ -0,0 +1,14 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type CreateOrUpdateApplicationRequest struct { + // Application's name e.g.: Payment Processors + Name string `json:"name"` +} diff --git a/sdk/model/rbac/extended_conductor_application.go b/sdk/model/rbac/extended_conductor_application.go new file mode 100644 index 00000000..a8f53b15 --- /dev/null +++ b/sdk/model/rbac/extended_conductor_application.go @@ -0,0 +1,21 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +import "github.com/conductor-sdk/conductor-go/sdk/model" + +type ConductorApplication struct { + CreateTime int64 `json:"createTime,omitempty"` + CreatedBy string `json:"createdBy,omitempty"` + Id string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Tags []model.Tag `json:"tags,omitempty"` + UpdateTime int64 `json:"updateTime,omitempty"` + UpdatedBy string `json:"updatedBy,omitempty"` +} diff --git a/sdk/model/rbac/granted_access.go b/sdk/model/rbac/granted_access.go new file mode 100644 index 00000000..2b139a62 --- /dev/null +++ b/sdk/model/rbac/granted_access.go @@ -0,0 +1,15 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type GrantedAccess struct { + Access []string `json:"access,omitempty"` + Tag string `json:"tag,omitempty"` + Target *TargetRef `json:"target,omitempty"` +} diff --git a/sdk/model/rbac/granted_access_response.go b/sdk/model/rbac/granted_access_response.go new file mode 100644 index 00000000..00c7dede --- /dev/null +++ b/sdk/model/rbac/granted_access_response.go @@ -0,0 +1,13 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type GrantedAccessResponse struct { + GrantedAccess []GrantedAccess `json:"grantedAccess,omitempty"` +} diff --git a/sdk/model/rbac/group.go b/sdk/model/rbac/group.go new file mode 100644 index 00000000..1934b6e7 --- /dev/null +++ b/sdk/model/rbac/group.go @@ -0,0 +1,16 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type Group struct { + DefaultAccess map[string][]string `json:"defaultAccess,omitempty"` + Description string `json:"description,omitempty"` + Id string `json:"id,omitempty"` + Roles []Role `json:"roles,omitempty"` +} diff --git a/sdk/model/rbac/permission.go b/sdk/model/rbac/permission.go new file mode 100644 index 00000000..45076cda --- /dev/null +++ b/sdk/model/rbac/permission.go @@ -0,0 +1,13 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type Permission struct { + Name string `json:"name,omitempty"` +} diff --git a/sdk/model/rbac/role.go b/sdk/model/rbac/role.go new file mode 100644 index 00000000..1122b57a --- /dev/null +++ b/sdk/model/rbac/role.go @@ -0,0 +1,14 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type Role struct { + Name string `json:"name,omitempty"` + Permissions []Permission `json:"permissions,omitempty"` +} diff --git a/sdk/model/rbac/upsert_group_request.go b/sdk/model/rbac/upsert_group_request.go new file mode 100644 index 00000000..1d6832eb --- /dev/null +++ b/sdk/model/rbac/upsert_group_request.go @@ -0,0 +1,17 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type UpsertGroupRequest struct { + // a default Map to share permissions, allowed target types: WORKFLOW_DEF, TASK_DEF, WORKFLOW_SCHEDULE + DefaultAccess map[string][]string `json:"defaultAccess,omitempty"` + // A general description of the group + Description string `json:"description"` + Roles []string `json:"roles,omitempty"` +} diff --git a/sdk/model/rbac/upsert_user_request.go b/sdk/model/rbac/upsert_user_request.go new file mode 100644 index 00000000..9ace6a14 --- /dev/null +++ b/sdk/model/rbac/upsert_user_request.go @@ -0,0 +1,17 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package rbac + +type UpsertUserRequest struct { + // Ids of the groups this user belongs to + Groups []string `json:"groups,omitempty"` + // User's full name + Name string `json:"name"` + Roles []string `json:"roles,omitempty"` +} diff --git a/sdk/model/secret.go b/sdk/model/secret.go new file mode 100644 index 00000000..03536204 --- /dev/null +++ b/sdk/model/secret.go @@ -0,0 +1,14 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. +package model + +type Secret struct { + Name string `json:"name,omitempty"` + Tags []Tag `json:"tags,omitempty"` +}