Files
sailpoint-cli/vendor/github.com/sailpoint-oss/golang-sdk/beta/api_lifecycle_states.go
2023-03-06 13:51:30 -06:00

365 lines
14 KiB
Go

/*
IdentityNow Beta API
Use these APIs to interact with the IdentityNow platform to achieve repeatable, automated processes with greater scalability. These APIs are in beta and are subject to change. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.
API version: 3.1.0-beta
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package beta
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
// LifecycleStatesApiService LifecycleStatesApi service
type LifecycleStatesApiService service
type ApiListLifecycleStatesRequest struct {
ctx context.Context
ApiService *LifecycleStatesApiService
identityProfileId string
lifecycleStateId string
}
func (r ApiListLifecycleStatesRequest) Execute() (*LifecycleState, *http.Response, error) {
return r.ApiService.ListLifecycleStatesExecute(r)
}
/*
ListLifecycleStates Lifecycle State
This endpoint returns a lifecycle state.
A token with ORG_ADMIN or API authority is required to call this API.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param identityProfileId Identity Profile ID
@param lifecycleStateId Lifecycle State ID
@return ApiListLifecycleStatesRequest
*/
func (a *LifecycleStatesApiService) ListLifecycleStates(ctx context.Context, identityProfileId string, lifecycleStateId string) ApiListLifecycleStatesRequest {
return ApiListLifecycleStatesRequest{
ApiService: a,
ctx: ctx,
identityProfileId: identityProfileId,
lifecycleStateId: lifecycleStateId,
}
}
// Execute executes the request
// @return LifecycleState
func (a *LifecycleStatesApiService) ListLifecycleStatesExecute(r ApiListLifecycleStatesRequest) (*LifecycleState, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LifecycleState
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LifecycleStatesApiService.ListLifecycleStates")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/identity-profiles/{identity-profile-id}/lifecycle-states/{lifecycle-state-id}"
localVarPath = strings.Replace(localVarPath, "{"+"identity-profile-id"+"}", url.PathEscape(parameterToString(r.identityProfileId, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"lifecycle-state-id"+"}", url.PathEscape(parameterToString(r.lifecycleStateId, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorResponseDto
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v ListAccessProfiles401Response
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ErrorResponseDto
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 429 {
var v ListAccessProfiles429Response
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorResponseDto
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type ApiUpdateLifecycleStatesRequest struct {
ctx context.Context
ApiService *LifecycleStatesApiService
identityProfileId string
lifecycleStateId string
jsonPatchOperation *[]JsonPatchOperation
}
// A list of lifecycle state update operations according to the [JSON Patch](https://tools.ietf.org/html/rfc6902) standard. The following fields can be updated: * enabled * description * accountActions * accessProfileIds * emailNotificationOption
func (r ApiUpdateLifecycleStatesRequest) JsonPatchOperation(jsonPatchOperation []JsonPatchOperation) ApiUpdateLifecycleStatesRequest {
r.jsonPatchOperation = &jsonPatchOperation
return r
}
func (r ApiUpdateLifecycleStatesRequest) Execute() (*LifecycleState, *http.Response, error) {
return r.ApiService.UpdateLifecycleStatesExecute(r)
}
/*
UpdateLifecycleStates Update Lifecycle State
This API updates individual lifecycle state fields using the [JSON Patch](https://tools.ietf.org/html/rfc6902) standard.
A token with ORG_ADMIN or API authority is required to call this API.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param identityProfileId Identity Profile ID
@param lifecycleStateId Lifecycle State ID
@return ApiUpdateLifecycleStatesRequest
*/
func (a *LifecycleStatesApiService) UpdateLifecycleStates(ctx context.Context, identityProfileId string, lifecycleStateId string) ApiUpdateLifecycleStatesRequest {
return ApiUpdateLifecycleStatesRequest{
ApiService: a,
ctx: ctx,
identityProfileId: identityProfileId,
lifecycleStateId: lifecycleStateId,
}
}
// Execute executes the request
// @return LifecycleState
func (a *LifecycleStatesApiService) UpdateLifecycleStatesExecute(r ApiUpdateLifecycleStatesRequest) (*LifecycleState, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPatch
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *LifecycleState
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LifecycleStatesApiService.UpdateLifecycleStates")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/identity-profiles/{identity-profile-id}/lifecycle-states/{lifecycle-state-id}"
localVarPath = strings.Replace(localVarPath, "{"+"identity-profile-id"+"}", url.PathEscape(parameterToString(r.identityProfileId, "")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"lifecycle-state-id"+"}", url.PathEscape(parameterToString(r.lifecycleStateId, "")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.jsonPatchOperation == nil {
return localVarReturnValue, nil, reportError("jsonPatchOperation is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json-patch+json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.jsonPatchOperation
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 {
var v ErrorResponseDto
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 401 {
var v ListAccessProfiles401Response
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 403 {
var v ErrorResponseDto
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 429 {
var v ListAccessProfiles429Response
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
if localVarHTTPResponse.StatusCode == 500 {
var v ErrorResponseDto
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}