diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 6cbe24d..c9589f3 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -60,10 +60,13 @@ jobs: - name: Re-generate isp-slate run: ./run.sh isp-slate + - name: Re-generate isp-lifecycle + run: ./run.sh isp-lifecycle + - name: Detect generated changes id: changes run: | - git add isp isp-slate + git add isp isp-slate isp-lifecycle git status if [ -n "$(git status -s)" ]; then diff --git a/isp-lifecycle/.openapi-generator-ignore b/isp-lifecycle/.openapi-generator-ignore new file mode 100644 index 0000000..6db43e9 --- /dev/null +++ b/isp-lifecycle/.openapi-generator-ignore @@ -0,0 +1,35 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md + +api/* +docs/* +.gitignore +.travis.yml +README.md +go.mod +go.sum +git_push.sh + +convenience.go +client.go diff --git a/isp-lifecycle/.openapi-generator/FILES b/isp-lifecycle/.openapi-generator/FILES new file mode 100644 index 0000000..75088c1 --- /dev/null +++ b/isp-lifecycle/.openapi-generator/FILES @@ -0,0 +1,12 @@ +api_lifecycle.go +configuration.go +model_error_detail.go +model_error_model.go +model_get_component_state_response_body.go +model_get_state_response_body.go +model_list_component_states_response_body.go +model_list_component_states_response_entry.go +model_put_component_body.go +response.go +test/api_lifecycle_test.go +utils.go diff --git a/isp-lifecycle/.openapi-generator/VERSION b/isp-lifecycle/.openapi-generator/VERSION new file mode 100644 index 0000000..cd802a1 --- /dev/null +++ b/isp-lifecycle/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0 \ No newline at end of file diff --git a/isp-lifecycle/api_lifecycle.go b/isp-lifecycle/api_lifecycle.go new file mode 100644 index 0000000..0aadea1 --- /dev/null +++ b/isp-lifecycle/api_lifecycle.go @@ -0,0 +1,606 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "bytes" + "context" + "io/ioutil" + "net/http" + "net/url" + "strings" +) + + +type LifecycleApi interface { + + /* + CalculateLifecycleState Calculates channel lifecycle state + + Calculates the current lifecycle state of the given channel. The Channel Lifecycle State is determined by evaluating the state of individual components. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param org The organization that owns the channel. + @param channelId The name of the channel. + @return ApiCalculateLifecycleStateRequest + */ + CalculateLifecycleState(ctx context.Context, org string, channelId string) ApiCalculateLifecycleStateRequest + + // CalculateLifecycleStateExecute executes the request + // @return GetStateResponseBody + CalculateLifecycleStateExecute(r ApiCalculateLifecycleStateRequest) (*GetStateResponseBody, *http.Response, error) + + /* + GetLifecycleComponentState Get component state + + Retrieve the current state of a component for a given channel. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param org The organization that owns the channel. + @param channelId The name of the channel. + @param component A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with). + @return ApiGetLifecycleComponentStateRequest + */ + GetLifecycleComponentState(ctx context.Context, org string, channelId string, component string) ApiGetLifecycleComponentStateRequest + + // GetLifecycleComponentStateExecute executes the request + // @return GetComponentStateResponseBody + GetLifecycleComponentStateExecute(r ApiGetLifecycleComponentStateRequest) (*GetComponentStateResponseBody, *http.Response, error) + + /* + ListLifecycleComponentStates List component states + + List the states of every component for the given channel ID. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param org The organization that owns the channel. + @param channelId The name of the channel. + @return ApiListLifecycleComponentStatesRequest + */ + ListLifecycleComponentStates(ctx context.Context, org string, channelId string) ApiListLifecycleComponentStatesRequest + + // ListLifecycleComponentStatesExecute executes the request + // @return ListComponentStatesResponseBody + ListLifecycleComponentStatesExecute(r ApiListLifecycleComponentStatesRequest) (*ListComponentStatesResponseBody, *http.Response, error) + + /* + PutLifecycleComponentState Put component state + + Update the state of a component associated with the given channel. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param channelUrn The channel_urn (channeldoc identifier). + @param component A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with). + @return ApiPutLifecycleComponentStateRequest + */ + PutLifecycleComponentState(ctx context.Context, channelUrn string, component string) ApiPutLifecycleComponentStateRequest + + // PutLifecycleComponentStateExecute executes the request + PutLifecycleComponentStateExecute(r ApiPutLifecycleComponentStateRequest) (*http.Response, error) +} + +// LifecycleApiService LifecycleApi service +type LifecycleApiService service + +type ApiCalculateLifecycleStateRequest struct { + ctx context.Context + ApiService LifecycleApi + org string + channelId string +} + +func (r ApiCalculateLifecycleStateRequest) Execute() (*GetStateResponseBody, *http.Response, error) { + return r.ApiService.CalculateLifecycleStateExecute(r) +} + +/* +CalculateLifecycleState Calculates channel lifecycle state + +Calculates the current lifecycle state of the given channel. The Channel Lifecycle State is determined by evaluating the state of individual components. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param org The organization that owns the channel. + @param channelId The name of the channel. + @return ApiCalculateLifecycleStateRequest +*/ +func (a *LifecycleApiService) CalculateLifecycleState(ctx context.Context, org string, channelId string) ApiCalculateLifecycleStateRequest { + return ApiCalculateLifecycleStateRequest{ + ApiService: a, + ctx: ctx, + org: org, + channelId: channelId, + } +} + +// Execute executes the request +// @return GetStateResponseBody +func (a *LifecycleApiService) CalculateLifecycleStateExecute(r ApiCalculateLifecycleStateRequest) (*GetStateResponseBody, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetStateResponseBody + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LifecycleApiService.CalculateLifecycleState") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v2/{org}/channels/{channel_id}/state" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterToString(r.org, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"channel_id"+"}", url.PathEscape(parameterToString(r.channelId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.org) < 1 { + return localVarReturnValue, nil, reportError("org must have at least 1 elements") + } + if strlen(r.channelId) < 1 { + return localVarReturnValue, nil, reportError("channelId must have at least 1 elements") + } + + // 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", "application/problem+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, + } + var v ErrorModel + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + 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 + } + + if disablePaging := r.ctx.Value(ContextDisablePaging); disablePaging == nil { + if uri := GetLink(localVarHTTPResponse, RelNext); uri != nil { + // This response is paginated. Read all the pages and append the items. + items, resp, err := getAllPages(a.client, localVarReturnValue, localVarHTTPResponse) + if err.Error() != "" { + return localVarReturnValue, localVarHTTPResponse, err + } + localVarReturnValue = items.(*GetStateResponseBody) + localVarHTTPResponse = resp + } + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiGetLifecycleComponentStateRequest struct { + ctx context.Context + ApiService LifecycleApi + org string + channelId string + component string +} + +func (r ApiGetLifecycleComponentStateRequest) Execute() (*GetComponentStateResponseBody, *http.Response, error) { + return r.ApiService.GetLifecycleComponentStateExecute(r) +} + +/* +GetLifecycleComponentState Get component state + +Retrieve the current state of a component for a given channel. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param org The organization that owns the channel. + @param channelId The name of the channel. + @param component A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with). + @return ApiGetLifecycleComponentStateRequest +*/ +func (a *LifecycleApiService) GetLifecycleComponentState(ctx context.Context, org string, channelId string, component string) ApiGetLifecycleComponentStateRequest { + return ApiGetLifecycleComponentStateRequest{ + ApiService: a, + ctx: ctx, + org: org, + channelId: channelId, + component: component, + } +} + +// Execute executes the request +// @return GetComponentStateResponseBody +func (a *LifecycleApiService) GetLifecycleComponentStateExecute(r ApiGetLifecycleComponentStateRequest) (*GetComponentStateResponseBody, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *GetComponentStateResponseBody + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LifecycleApiService.GetLifecycleComponentState") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v2/{org}/channels/{channel_id}/state/components/{component}" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterToString(r.org, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"channel_id"+"}", url.PathEscape(parameterToString(r.channelId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"component"+"}", url.PathEscape(parameterToString(r.component, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.org) < 1 { + return localVarReturnValue, nil, reportError("org must have at least 1 elements") + } + if strlen(r.channelId) < 1 { + return localVarReturnValue, nil, reportError("channelId must have at least 1 elements") + } + + // 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", "application/problem+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, + } + var v ErrorModel + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + 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 + } + + if disablePaging := r.ctx.Value(ContextDisablePaging); disablePaging == nil { + if uri := GetLink(localVarHTTPResponse, RelNext); uri != nil { + // This response is paginated. Read all the pages and append the items. + items, resp, err := getAllPages(a.client, localVarReturnValue, localVarHTTPResponse) + if err.Error() != "" { + return localVarReturnValue, localVarHTTPResponse, err + } + localVarReturnValue = items.(*GetComponentStateResponseBody) + localVarHTTPResponse = resp + } + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiListLifecycleComponentStatesRequest struct { + ctx context.Context + ApiService LifecycleApi + org string + channelId string +} + +func (r ApiListLifecycleComponentStatesRequest) Execute() (*ListComponentStatesResponseBody, *http.Response, error) { + return r.ApiService.ListLifecycleComponentStatesExecute(r) +} + +/* +ListLifecycleComponentStates List component states + +List the states of every component for the given channel ID. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param org The organization that owns the channel. + @param channelId The name of the channel. + @return ApiListLifecycleComponentStatesRequest +*/ +func (a *LifecycleApiService) ListLifecycleComponentStates(ctx context.Context, org string, channelId string) ApiListLifecycleComponentStatesRequest { + return ApiListLifecycleComponentStatesRequest{ + ApiService: a, + ctx: ctx, + org: org, + channelId: channelId, + } +} + +// Execute executes the request +// @return ListComponentStatesResponseBody +func (a *LifecycleApiService) ListLifecycleComponentStatesExecute(r ApiListLifecycleComponentStatesRequest) (*ListComponentStatesResponseBody, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListComponentStatesResponseBody + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LifecycleApiService.ListLifecycleComponentStates") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v2/{org}/channels/{channel_id}/state/components" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterToString(r.org, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"channel_id"+"}", url.PathEscape(parameterToString(r.channelId, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.org) < 1 { + return localVarReturnValue, nil, reportError("org must have at least 1 elements") + } + if strlen(r.channelId) < 1 { + return localVarReturnValue, nil, reportError("channelId must have at least 1 elements") + } + + // 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", "application/problem+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, + } + var v ErrorModel + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + 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 + } + + if disablePaging := r.ctx.Value(ContextDisablePaging); disablePaging == nil { + if uri := GetLink(localVarHTTPResponse, RelNext); uri != nil { + // This response is paginated. Read all the pages and append the items. + items, resp, err := getAllPages(a.client, localVarReturnValue, localVarHTTPResponse) + if err.Error() != "" { + return localVarReturnValue, localVarHTTPResponse, err + } + localVarReturnValue = items.(*ListComponentStatesResponseBody) + localVarHTTPResponse = resp + } + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type ApiPutLifecycleComponentStateRequest struct { + ctx context.Context + ApiService LifecycleApi + channelUrn string + component string + putComponentBody *PutComponentBody +} + +func (r ApiPutLifecycleComponentStateRequest) PutComponentBody(putComponentBody PutComponentBody) ApiPutLifecycleComponentStateRequest { + r.putComponentBody = &putComponentBody + return r +} + +func (r ApiPutLifecycleComponentStateRequest) Execute() (*http.Response, error) { + return r.ApiService.PutLifecycleComponentStateExecute(r) +} + +/* +PutLifecycleComponentState Put component state + +Update the state of a component associated with the given channel. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param channelUrn The channel_urn (channeldoc identifier). + @param component A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with). + @return ApiPutLifecycleComponentStateRequest +*/ +func (a *LifecycleApiService) PutLifecycleComponentState(ctx context.Context, channelUrn string, component string) ApiPutLifecycleComponentStateRequest { + return ApiPutLifecycleComponentStateRequest{ + ApiService: a, + ctx: ctx, + channelUrn: channelUrn, + component: component, + } +} + +// Execute executes the request +func (a *LifecycleApiService) PutLifecycleComponentStateExecute(r ApiPutLifecycleComponentStateRequest) (*http.Response, error) { + var ( + localVarHTTPMethod = http.MethodPut + localVarPostBody interface{} + formFiles []formFile + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "LifecycleApiService.PutLifecycleComponentState") + if err != nil { + return nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/v2/channels/{channel_urn}/state/components/{component}" + localVarPath = strings.Replace(localVarPath, "{"+"channel_urn"+"}", url.PathEscape(parameterToString(r.channelUrn, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"component"+"}", url.PathEscape(parameterToString(r.component, "")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + if strlen(r.channelUrn) < 1 { + return nil, reportError("channelUrn must have at least 1 elements") + } + if r.putComponentBody == nil { + return nil, reportError("putComponentBody is required and must be specified") + } + + // to determine the Content-Type header + localVarHTTPContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/problem+json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + // body params + localVarPostBody = r.putComponentBody + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + var v ErrorModel + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarHTTPResponse, newErr + } + newErr.model = v + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} diff --git a/isp-lifecycle/client.go b/isp-lifecycle/client.go new file mode 100644 index 0000000..07ef1d3 --- /dev/null +++ b/isp-lifecycle/client.go @@ -0,0 +1,667 @@ +/* + * iStreamPlanet Slate Management API + * + * API version: 1.0.0 + * Contact: support@istreamplanet.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/oauth2" +) + +var ( + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" ) +) + +// APIClient manages communication with the iStreamPlanet Slate Management API API v1.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + LifecycleApi LifecycleApi +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.LifecycleApi = (*LifecycleApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString( obj interface{}, key string ) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return fmt.Sprintf("%v", obj) + } + var param,ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap,err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t,ok := obj.(MappedNullable); ok { + dataMap,err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i:=0;i 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + return + } + if xmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if jsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + err = file.Close() + if err != nil { + return err + } + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + err = xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericOpenAPIError Provides access to the body, error and model on returned errors. +type GenericOpenAPIError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/isp-lifecycle/configuration.go b/isp-lifecycle/configuration.go new file mode 100644 index 0000000..eaba465 --- /dev/null +++ b/isp-lifecycle/configuration.go @@ -0,0 +1,216 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "context" + "fmt" + "net/http" + "strings" +) + +// contextKeys are used to identify the type of value in the context. +// Since these are string, it is possible to get a short description of the +// context key for logging and debugging using key.String(). + +type contextKey string + +func (c contextKey) String() string { + return "auth " + string(c) +} + +var ( + // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. + ContextOAuth2 = contextKey("token") + + // ContextServerIndex uses a server configuration from the index. + ContextServerIndex = contextKey("serverIndex") + + // ContextOperationServerIndices uses a server configuration from the index mapping. + ContextOperationServerIndices = contextKey("serverOperationIndices") + + // ContextServerVariables overrides a server configuration variables. + ContextServerVariables = contextKey("serverVariables") + + // ContextOperationServerVariables overrides a server configuration variables using operation specific values. + ContextOperationServerVariables = contextKey("serverOperationVariables") +) + +// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth +type BasicAuth struct { + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` +} + +// APIKey provides API key based authentication to a request passed via context using ContextAPIKey +type APIKey struct { + Key string + Prefix string +} + +// ServerVariable stores the information about a server variable +type ServerVariable struct { + Description string + DefaultValue string + EnumValues []string +} + +// ServerConfiguration stores the information about a server +type ServerConfiguration struct { + URL string + Description string + Variables map[string]ServerVariable +} + +// ServerConfigurations stores multiple ServerConfiguration items +type ServerConfigurations []ServerConfiguration + +// Configuration stores the configuration of the API client +type Configuration struct { + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` + DefaultHeader map[string]string `json:"defaultHeader,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Debug bool `json:"debug,omitempty"` + Servers ServerConfigurations + OperationServers map[string]ServerConfigurations + HTTPClient *http.Client +} + +// NewConfiguration returns a new Configuration object +func NewConfiguration() *Configuration { + cfg := &Configuration{ + DefaultHeader: make(map[string]string), + UserAgent: "OpenAPI-Generator/1.0.0/go", + Debug: false, + Servers: ServerConfigurations{ + { + URL: "", + Description: "No description provided", + }, + }, + OperationServers: map[string]ServerConfigurations{ + }, + } + return cfg +} + +// AddDefaultHeader adds a new HTTP header to the default header in the request +func (c *Configuration) AddDefaultHeader(key string, value string) { + c.DefaultHeader[key] = value +} + +// URL formats template on a index using given variables +func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { + if index < 0 || len(sc) <= index { + return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1) + } + server := sc[index] + url := server.URL + + // go through variables and replace placeholders + for name, variable := range server.Variables { + if value, ok := variables[name]; ok { + found := bool(len(variable.EnumValues) == 0) + for _, enumValue := range variable.EnumValues { + if value == enumValue { + found = true + } + } + if !found { + return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) + } + url = strings.Replace(url, "{"+name+"}", value, -1) + } else { + url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) + } + } + return url, nil +} + +// ServerURL returns URL based on server settings +func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { + return c.Servers.URL(index, variables) +} + +func getServerIndex(ctx context.Context) (int, error) { + si := ctx.Value(ContextServerIndex) + if si != nil { + if index, ok := si.(int); ok { + return index, nil + } + return 0, reportError("Invalid type %T should be int", si) + } + return 0, nil +} + +func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { + osi := ctx.Value(ContextOperationServerIndices) + if osi != nil { + if operationIndices, ok := osi.(map[string]int); !ok { + return 0, reportError("Invalid type %T should be map[string]int", osi) + } else { + index, ok := operationIndices[endpoint] + if ok { + return index, nil + } + } + } + return getServerIndex(ctx) +} + +func getServerVariables(ctx context.Context) (map[string]string, error) { + sv := ctx.Value(ContextServerVariables) + if sv != nil { + if variables, ok := sv.(map[string]string); ok { + return variables, nil + } + return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) + } + return nil, nil +} + +func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { + osv := ctx.Value(ContextOperationServerVariables) + if osv != nil { + if operationVariables, ok := osv.(map[string]map[string]string); !ok { + return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) + } else { + variables, ok := operationVariables[endpoint] + if ok { + return variables, nil + } + } + } + return getServerVariables(ctx) +} + +// ServerURLWithContext returns a new server URL given an endpoint +func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { + sc, ok := c.OperationServers[endpoint] + if !ok { + sc = c.Servers + } + + if ctx == nil { + return sc.URL(0, nil) + } + + index, err := getServerOperationIndex(ctx, endpoint) + if err != nil { + return "", err + } + + variables, err := getServerOperationVariables(ctx, endpoint) + if err != nil { + return "", err + } + + return sc.URL(index, variables) +} diff --git a/isp-lifecycle/convenience.go b/isp-lifecycle/convenience.go new file mode 100644 index 0000000..f326e87 --- /dev/null +++ b/isp-lifecycle/convenience.go @@ -0,0 +1,250 @@ +package isp + +import ( + "context" + "fmt" + "io" + "log" + "net/http" + "net/http/httputil" + "net/url" + "reflect" + + link "github.com/tent/http-link-go" + "golang.org/x/oauth2/clientcredentials" +) + +// RelNext is the `next` link relationship, used for pagination. +const RelNext = "next" + +var ( + // ContextDisablePaging disable automatic pagination handling for a request. + ContextDisablePaging = contextKey("paging") +) + +// GetLink returns the URI of the first HTTP Link header with the requested +// relationship value, nil otherwise. +func GetLink(resp *http.Response, rel string) *url.URL { + // Multiple Link headers may be present. + for _, header := range resp.Header["Link"] { + // Each Link header may have multiple links in it. + if links, err := link.Parse(header); err == nil { + for _, parsed := range links { + if parsed.Rel == rel { + // Link URIs may be relative, so resolve them. + loc, _ := url.Parse(parsed.URI) + return resp.Request.URL.ResolveReference(loc) + } + } + } + } + + return nil +} + +// getAllPages fetches all pages in a paginated response and appends the +// results of each call to the parsed slice. Returns the total combined slice +// and the *last* response. If any request in the chain has an error, then +// processing is stopped and the error is returned. +func getAllPages(client *APIClient, parsed interface{}, resp *http.Response) (interface{}, *http.Response, GenericOpenAPIError) { + items := reflect.ValueOf(parsed) + + // Check for a `next` link relation header for pagination. If present, we + // must follow it, append the data, and repeat until no more `next` link + // is available (signaling the end of the list). + for { + if uri := GetLink(resp, RelNext); uri != nil { + req, err := http.NewRequest(http.MethodGet, uri.String(), nil) + if err != nil { + return nil, nil, GenericOpenAPIError{ + error: err.Error(), + } + } + for k, v := range client.cfg.DefaultHeader { + req.Header.Set(k, v) + } + // Response gets set to the next response in the series. + resp, err = client.cfg.HTTPClient.Do(req) + if err != nil { + return nil, resp, GenericOpenAPIError{ + error: err.Error(), + } + } + + data, err := io.ReadAll(resp.Body) + if err != nil { + return nil, resp, GenericOpenAPIError{ + error: err.Error(), + } + } + + // Since we don't know the return type, use reflection to create a new + // instance of it to store the current response's data, which we'll + // decode and append to the existing items list. + additional := reflect.New(items.Type()) + addIface := additional.Interface() + err = client.decode(&addIface, data, resp.Header.Get("Content-Type")) + if err != nil { + return nil, resp, GenericOpenAPIError{ + body: data, + error: err.Error(), + } + } + + // Append the new items and then pop back up top to process the + // headers in this latest response. + items = reflect.AppendSlice(items, additional.Elem()) + continue + } + break + } + + return items.Interface(), resp, GenericOpenAPIError{} +} + +// HighLevelClient wraps an APIClient and http.Client, as well as providing +// custom high-level functionality. +type HighLevelClient struct { + *APIClient + *http.Client +} + +// Decode a response body based on the content type. +func (c *HighLevelClient) Decode(v interface{}, body []byte, contentType string) error { + return c.decode(v, body, contentType) +} + +// GetModel performs an HTTP GET on the given URI and loads the model from the +// response if successful. +func (c *HighLevelClient) GetModel(uri string, model interface{}) (*http.Response, error) { + req, _ := http.NewRequest(http.MethodGet, uri, nil) + return c.DoModel(req, model) +} + +// DoModel takes an HTTP request like http.Client.Do and makes the request. If +// successful, it also loads the model from the response. +func (c *HighLevelClient) DoModel(req *http.Request, model interface{}) (*http.Response, error) { + resp, err := c.Do(req) + if err != nil { + return nil, err + } + + if resp.StatusCode >= 300 { + return nil, fmt.Errorf("unable to get model: status code %d", resp.StatusCode) + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + err = c.decode(model, body, resp.Header.Get("Content-Type")) + if err != nil { + return nil, err + } + + return resp, nil +} + +// Do the request, logging the request/response if debugging is enabled. +func (c *HighLevelClient) Do(req *http.Request) (*http.Response, error) { + if req.Header == nil { + req.Header = http.Header{} + } + for k, v := range c.cfg.DefaultHeader { + if req.Header.Get(k) == "" { + req.Header.Set(k, v) + } + } + + if c.cfg.Debug { + dump, err := httputil.DumpRequestOut(req, true) + if err != nil { + return nil, err + } + log.Printf("\n%s\n", string(dump)) + } + + res, err := c.Client.Do(req) + + if c.cfg.Debug { + dump, err := httputil.DumpResponse(res, true) + if err != nil { + return res, err + } + log.Printf("\n%s\n", string(dump)) + } + + return res, err +} + +// NewWithClientCredentials creates a new authenticated client using the OAuth +// 2.0 client credentials flow, caching and refreshing the access token as +// needed whenever requests to the API are made. Leave the organization blank +// if using multi-org tokens. +func NewWithClientCredentials(clientID, clientSecret, organization string) *HighLevelClient { + var aud string + if organization == "" { + aud = "https://api.istreamplanet.com" + } else { + aud = "https://platform.dtc.istreamplanet.net/" + organization + } + + auth := &clientcredentials.Config{ + ClientID: clientID, + ClientSecret: clientSecret, + TokenURL: "https://istreamplanet.auth0.com/oauth/token", + EndpointParams: url.Values{ + "audience": []string{aud}, + }, + } + + config := NewConfiguration() + config.HTTPClient = auth.Client(context.Background()) + + client := NewAPIClient(config) + return &HighLevelClient{ + APIClient: client, + Client: config.HTTPClient, + } +} + +// NewWithOktaClientCredentials creates a new authenticated client using the OAuth +// 2.0 client credentials flow, caching and refreshing the access token as +// needed whenever requests to the API are made. Leave the organization blank +// if using multi-org tokens. It is specific to WBD-Okta and replaces NewWithClientCredentials. +func NewWithOktaClientCredentials(clientID, clientSecret string) *HighLevelClient { + auth := &clientcredentials.Config{ + ClientID: clientID, + ClientSecret: clientSecret, + TokenURL: "https://tw.okta.com/oauth2/aus125bl6q770za4g0x8/v1/token", + } + + config := NewConfiguration() + config.HTTPClient = auth.Client(context.Background()) + + client := NewAPIClient(config) + return &HighLevelClient{ + APIClient: client, + Client: config.HTTPClient, + } +} + +// NewWithAuthHeader creates a new authenticated client using the given +// authorization header. The header format should be `Bearer `, where +// `` is replaced by the contents of the encoded & signed JWT. +func NewWithAuthHeader(header string) *HighLevelClient { + config := NewConfiguration() + config.AddDefaultHeader("Authorization", header) + client := NewAPIClient(config) + return &HighLevelClient{ + APIClient: client, + Client: config.HTTPClient, + } +} + +// TODO: remove this... for some reason it is missing in the generated output. +// At some point we need to switch to a less wonky code generator. +func parameterToString(v interface{}, s string) string { + return fmt.Sprintf("%v", v) +} diff --git a/isp-lifecycle/model_error_detail.go b/isp-lifecycle/model_error_detail.go new file mode 100644 index 0000000..0057d6f --- /dev/null +++ b/isp-lifecycle/model_error_detail.go @@ -0,0 +1,200 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" +) + +// checks if the ErrorDetail type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ErrorDetail{} + +// ErrorDetail struct for ErrorDetail +type ErrorDetail struct { + // Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id' + Location *string `json:"location,omitempty" doc:"Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'"` + // Error message text + Message *string `json:"message,omitempty" doc:"Error message text"` + // The value at the given location + Value interface{} `json:"value,omitempty" doc:"The value at the given location"` +} + +// NewErrorDetail instantiates a new ErrorDetail object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewErrorDetail() *ErrorDetail { + this := ErrorDetail{} + return &this +} + +// NewErrorDetailWithDefaults instantiates a new ErrorDetail object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewErrorDetailWithDefaults() *ErrorDetail { + this := ErrorDetail{} + return &this +} + +// GetLocation returns the Location field value if set, zero value otherwise. +func (o *ErrorDetail) GetLocation() string { + if o == nil || IsNil(o.Location) { + var ret string + return ret + } + return *o.Location +} + +// GetLocationOk returns a tuple with the Location field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorDetail) GetLocationOk() (*string, bool) { + if o == nil || IsNil(o.Location) { + return nil, false + } + return o.Location, true +} + +// HasLocation returns a boolean if a field has been set. +func (o *ErrorDetail) HasLocation() bool { + if o != nil && !IsNil(o.Location) { + return true + } + + return false +} + +// SetLocation gets a reference to the given string and assigns it to the Location field. +func (o *ErrorDetail) SetLocation(v string) { + o.Location = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *ErrorDetail) GetMessage() string { + if o == nil || IsNil(o.Message) { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorDetail) GetMessageOk() (*string, bool) { + if o == nil || IsNil(o.Message) { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *ErrorDetail) HasMessage() bool { + if o != nil && !IsNil(o.Message) { + return true + } + + return false +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *ErrorDetail) SetMessage(v string) { + o.Message = &v +} + +// GetValue returns the Value field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ErrorDetail) GetValue() interface{} { + if o == nil { + var ret interface{} + return ret + } + return o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *ErrorDetail) GetValueOk() (*interface{}, bool) { + if o == nil || IsNil(o.Value) { + return nil, false + } + return &o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *ErrorDetail) HasValue() bool { + if o != nil && IsNil(o.Value) { + return true + } + + return false +} + +// SetValue gets a reference to the given interface{} and assigns it to the Value field. +func (o *ErrorDetail) SetValue(v interface{}) { + o.Value = v +} + +func (o ErrorDetail) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ErrorDetail) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Location) { + toSerialize["location"] = o.Location + } + if !IsNil(o.Message) { + toSerialize["message"] = o.Message + } + if o.Value != nil { + toSerialize["value"] = o.Value + } + return toSerialize, nil +} + +type NullableErrorDetail struct { + value *ErrorDetail + isSet bool +} + +func (v NullableErrorDetail) Get() *ErrorDetail { + return v.value +} + +func (v *NullableErrorDetail) Set(val *ErrorDetail) { + v.value = val + v.isSet = true +} + +func (v NullableErrorDetail) IsSet() bool { + return v.isSet +} + +func (v *NullableErrorDetail) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableErrorDetail(val *ErrorDetail) *NullableErrorDetail { + return &NullableErrorDetail{value: val, isSet: true} +} + +func (v NullableErrorDetail) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableErrorDetail) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/isp-lifecycle/model_error_model.go b/isp-lifecycle/model_error_model.go new file mode 100644 index 0000000..61a61b5 --- /dev/null +++ b/isp-lifecycle/model_error_model.go @@ -0,0 +1,352 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" +) + +// checks if the ErrorModel type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ErrorModel{} + +// ErrorModel struct for ErrorModel +type ErrorModel struct { + // A URL to the JSON Schema for this object. + Schema *string `json:"$schema,omitempty" format:"uri" doc:"A URL to the JSON Schema for this object."` + // A human-readable explanation specific to this occurrence of the problem. + Detail *string `json:"detail,omitempty" doc:"A human-readable explanation specific to this occurrence of the problem."` + // Optional list of individual error details + Errors []ErrorDetail `json:"errors,omitempty" doc:"Optional list of individual error details"` + // A URI reference that identifies the specific occurrence of the problem. + Instance *string `json:"instance,omitempty" format:"uri" doc:"A URI reference that identifies the specific occurrence of the problem."` + // HTTP status code + Status *int64 `json:"status,omitempty" format:"int64" doc:"HTTP status code"` + // A short, human-readable summary of the problem type. This value should not change between occurrences of the error. + Title *string `json:"title,omitempty" doc:"A short, human-readable summary of the problem type. This value should not change between occurrences of the error."` + // A URI reference to human-readable documentation for the error. + Type *string `json:"type,omitempty" format:"uri" default:""about:blank"" doc:"A URI reference to human-readable documentation for the error."` +} + +// NewErrorModel instantiates a new ErrorModel object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewErrorModel() *ErrorModel { + this := ErrorModel{} + var type_ string = "about:blank" + this.Type = &type_ + return &this +} + +// NewErrorModelWithDefaults instantiates a new ErrorModel object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewErrorModelWithDefaults() *ErrorModel { + this := ErrorModel{} + var type_ string = "about:blank" + this.Type = &type_ + return &this +} + +// GetSchema returns the Schema field value if set, zero value otherwise. +func (o *ErrorModel) GetSchema() string { + if o == nil || IsNil(o.Schema) { + var ret string + return ret + } + return *o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorModel) GetSchemaOk() (*string, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *ErrorModel) HasSchema() bool { + if o != nil && !IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given string and assigns it to the Schema field. +func (o *ErrorModel) SetSchema(v string) { + o.Schema = &v +} + +// GetDetail returns the Detail field value if set, zero value otherwise. +func (o *ErrorModel) GetDetail() string { + if o == nil || IsNil(o.Detail) { + var ret string + return ret + } + return *o.Detail +} + +// GetDetailOk returns a tuple with the Detail field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorModel) GetDetailOk() (*string, bool) { + if o == nil || IsNil(o.Detail) { + return nil, false + } + return o.Detail, true +} + +// HasDetail returns a boolean if a field has been set. +func (o *ErrorModel) HasDetail() bool { + if o != nil && !IsNil(o.Detail) { + return true + } + + return false +} + +// SetDetail gets a reference to the given string and assigns it to the Detail field. +func (o *ErrorModel) SetDetail(v string) { + o.Detail = &v +} + +// GetErrors returns the Errors field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *ErrorModel) GetErrors() []ErrorDetail { + if o == nil { + var ret []ErrorDetail + return ret + } + return o.Errors +} + +// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *ErrorModel) GetErrorsOk() ([]ErrorDetail, bool) { + if o == nil || IsNil(o.Errors) { + return nil, false + } + return o.Errors, true +} + +// HasErrors returns a boolean if a field has been set. +func (o *ErrorModel) HasErrors() bool { + if o != nil && IsNil(o.Errors) { + return true + } + + return false +} + +// SetErrors gets a reference to the given []ErrorDetail and assigns it to the Errors field. +func (o *ErrorModel) SetErrors(v []ErrorDetail) { + o.Errors = v +} + +// GetInstance returns the Instance field value if set, zero value otherwise. +func (o *ErrorModel) GetInstance() string { + if o == nil || IsNil(o.Instance) { + var ret string + return ret + } + return *o.Instance +} + +// GetInstanceOk returns a tuple with the Instance field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorModel) GetInstanceOk() (*string, bool) { + if o == nil || IsNil(o.Instance) { + return nil, false + } + return o.Instance, true +} + +// HasInstance returns a boolean if a field has been set. +func (o *ErrorModel) HasInstance() bool { + if o != nil && !IsNil(o.Instance) { + return true + } + + return false +} + +// SetInstance gets a reference to the given string and assigns it to the Instance field. +func (o *ErrorModel) SetInstance(v string) { + o.Instance = &v +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *ErrorModel) GetStatus() int64 { + if o == nil || IsNil(o.Status) { + var ret int64 + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorModel) GetStatusOk() (*int64, bool) { + if o == nil || IsNil(o.Status) { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *ErrorModel) HasStatus() bool { + if o != nil && !IsNil(o.Status) { + return true + } + + return false +} + +// SetStatus gets a reference to the given int64 and assigns it to the Status field. +func (o *ErrorModel) SetStatus(v int64) { + o.Status = &v +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *ErrorModel) GetTitle() string { + if o == nil || IsNil(o.Title) { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorModel) GetTitleOk() (*string, bool) { + if o == nil || IsNil(o.Title) { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *ErrorModel) HasTitle() bool { + if o != nil && !IsNil(o.Title) { + return true + } + + return false +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *ErrorModel) SetTitle(v string) { + o.Title = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ErrorModel) GetType() string { + if o == nil || IsNil(o.Type) { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ErrorModel) GetTypeOk() (*string, bool) { + if o == nil || IsNil(o.Type) { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ErrorModel) HasType() bool { + if o != nil && !IsNil(o.Type) { + return true + } + + return false +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *ErrorModel) SetType(v string) { + o.Type = &v +} + +func (o ErrorModel) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ErrorModel) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Schema) { + toSerialize["$schema"] = o.Schema + } + if !IsNil(o.Detail) { + toSerialize["detail"] = o.Detail + } + if o.Errors != nil { + toSerialize["errors"] = o.Errors + } + if !IsNil(o.Instance) { + toSerialize["instance"] = o.Instance + } + if !IsNil(o.Status) { + toSerialize["status"] = o.Status + } + if !IsNil(o.Title) { + toSerialize["title"] = o.Title + } + if !IsNil(o.Type) { + toSerialize["type"] = o.Type + } + return toSerialize, nil +} + +type NullableErrorModel struct { + value *ErrorModel + isSet bool +} + +func (v NullableErrorModel) Get() *ErrorModel { + return v.value +} + +func (v *NullableErrorModel) Set(val *ErrorModel) { + v.value = val + v.isSet = true +} + +func (v NullableErrorModel) IsSet() bool { + return v.isSet +} + +func (v *NullableErrorModel) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableErrorModel(val *ErrorModel) *NullableErrorModel { + return &NullableErrorModel{value: val, isSet: true} +} + +func (v NullableErrorModel) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableErrorModel) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/isp-lifecycle/model_get_component_state_response_body.go b/isp-lifecycle/model_get_component_state_response_body.go new file mode 100644 index 0000000..ffcc1cc --- /dev/null +++ b/isp-lifecycle/model_get_component_state_response_body.go @@ -0,0 +1,292 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" + "time" +) + +// checks if the GetComponentStateResponseBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetComponentStateResponseBody{} + +// GetComponentStateResponseBody struct for GetComponentStateResponseBody +type GetComponentStateResponseBody struct { + // A URL to the JSON Schema for this object. + Schema *string `json:"$schema,omitempty" format:"uri" doc:"A URL to the JSON Schema for this object."` + ChannelId string `json:"channel_id"` + // The ChannelDoc's revision + ChannelRevision int32 `json:"channel_revision" format:"int32" doc:"The ChannelDoc's revision"` + // A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with). + Component string `json:"component" enum:"CHANNEL_CONFIG,TRANSCODER,PUBLISHING" doc:"A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with)."` + // The current state of the component. + ComponentState string `json:"component_state" enum:"OFF,PROVISIONING,STREAMING,TERMINATING,ERROR" doc:"The current state of the component."` + Org string `json:"org"` + // ISO 8601 timestamp when the component state was updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time" doc:"ISO 8601 timestamp when the component state was updated."` +} + +// NewGetComponentStateResponseBody instantiates a new GetComponentStateResponseBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGetComponentStateResponseBody(channelId string, channelRevision int32, component string, componentState string, org string, updatedAt time.Time) *GetComponentStateResponseBody { + this := GetComponentStateResponseBody{} + this.ChannelId = channelId + this.ChannelRevision = channelRevision + this.Component = component + this.ComponentState = componentState + this.Org = org + this.UpdatedAt = updatedAt + return &this +} + +// NewGetComponentStateResponseBodyWithDefaults instantiates a new GetComponentStateResponseBody object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGetComponentStateResponseBodyWithDefaults() *GetComponentStateResponseBody { + this := GetComponentStateResponseBody{} + return &this +} + +// GetSchema returns the Schema field value if set, zero value otherwise. +func (o *GetComponentStateResponseBody) GetSchema() string { + if o == nil || IsNil(o.Schema) { + var ret string + return ret + } + return *o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetComponentStateResponseBody) GetSchemaOk() (*string, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *GetComponentStateResponseBody) HasSchema() bool { + if o != nil && !IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given string and assigns it to the Schema field. +func (o *GetComponentStateResponseBody) SetSchema(v string) { + o.Schema = &v +} + +// GetChannelId returns the ChannelId field value +func (o *GetComponentStateResponseBody) GetChannelId() string { + if o == nil { + var ret string + return ret + } + + return o.ChannelId +} + +// GetChannelIdOk returns a tuple with the ChannelId field value +// and a boolean to check if the value has been set. +func (o *GetComponentStateResponseBody) GetChannelIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ChannelId, true +} + +// SetChannelId sets field value +func (o *GetComponentStateResponseBody) SetChannelId(v string) { + o.ChannelId = v +} + +// GetChannelRevision returns the ChannelRevision field value +func (o *GetComponentStateResponseBody) GetChannelRevision() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.ChannelRevision +} + +// GetChannelRevisionOk returns a tuple with the ChannelRevision field value +// and a boolean to check if the value has been set. +func (o *GetComponentStateResponseBody) GetChannelRevisionOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.ChannelRevision, true +} + +// SetChannelRevision sets field value +func (o *GetComponentStateResponseBody) SetChannelRevision(v int32) { + o.ChannelRevision = v +} + +// GetComponent returns the Component field value +func (o *GetComponentStateResponseBody) GetComponent() string { + if o == nil { + var ret string + return ret + } + + return o.Component +} + +// GetComponentOk returns a tuple with the Component field value +// and a boolean to check if the value has been set. +func (o *GetComponentStateResponseBody) GetComponentOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Component, true +} + +// SetComponent sets field value +func (o *GetComponentStateResponseBody) SetComponent(v string) { + o.Component = v +} + +// GetComponentState returns the ComponentState field value +func (o *GetComponentStateResponseBody) GetComponentState() string { + if o == nil { + var ret string + return ret + } + + return o.ComponentState +} + +// GetComponentStateOk returns a tuple with the ComponentState field value +// and a boolean to check if the value has been set. +func (o *GetComponentStateResponseBody) GetComponentStateOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ComponentState, true +} + +// SetComponentState sets field value +func (o *GetComponentStateResponseBody) SetComponentState(v string) { + o.ComponentState = v +} + +// GetOrg returns the Org field value +func (o *GetComponentStateResponseBody) GetOrg() string { + if o == nil { + var ret string + return ret + } + + return o.Org +} + +// GetOrgOk returns a tuple with the Org field value +// and a boolean to check if the value has been set. +func (o *GetComponentStateResponseBody) GetOrgOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Org, true +} + +// SetOrg sets field value +func (o *GetComponentStateResponseBody) SetOrg(v string) { + o.Org = v +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *GetComponentStateResponseBody) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *GetComponentStateResponseBody) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value +func (o *GetComponentStateResponseBody) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +func (o GetComponentStateResponseBody) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetComponentStateResponseBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Schema) { + toSerialize["$schema"] = o.Schema + } + toSerialize["channel_id"] = o.ChannelId + toSerialize["channel_revision"] = o.ChannelRevision + toSerialize["component"] = o.Component + toSerialize["component_state"] = o.ComponentState + toSerialize["org"] = o.Org + toSerialize["updated_at"] = o.UpdatedAt + return toSerialize, nil +} + +type NullableGetComponentStateResponseBody struct { + value *GetComponentStateResponseBody + isSet bool +} + +func (v NullableGetComponentStateResponseBody) Get() *GetComponentStateResponseBody { + return v.value +} + +func (v *NullableGetComponentStateResponseBody) Set(val *GetComponentStateResponseBody) { + v.value = val + v.isSet = true +} + +func (v NullableGetComponentStateResponseBody) IsSet() bool { + return v.isSet +} + +func (v *NullableGetComponentStateResponseBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetComponentStateResponseBody(val *GetComponentStateResponseBody) *NullableGetComponentStateResponseBody { + return &NullableGetComponentStateResponseBody{value: val, isSet: true} +} + +func (v NullableGetComponentStateResponseBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetComponentStateResponseBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/isp-lifecycle/model_get_state_response_body.go b/isp-lifecycle/model_get_state_response_body.go new file mode 100644 index 0000000..854f736 --- /dev/null +++ b/isp-lifecycle/model_get_state_response_body.go @@ -0,0 +1,266 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" + "time" +) + +// checks if the GetStateResponseBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &GetStateResponseBody{} + +// GetStateResponseBody struct for GetStateResponseBody +type GetStateResponseBody struct { + // A URL to the JSON Schema for this object. + Schema *string `json:"$schema,omitempty" format:"uri" doc:"A URL to the JSON Schema for this object."` + // The name of the channel. + ChannelId string `json:"channel_id" minLength:"1" doc:"The name of the channel."` + // Current revision of the channel. + ChannelRevision int32 `json:"channel_revision" format:"int32" doc:"Current revision of the channel."` + // Current state of the channel + ChannelState string `json:"channel_state" enum:"OFF,PROVISIONING,STREAMING,TERMINATING,ERROR" doc:"Current state of the channel"` + // The organization that owns the channel. + Org string `json:"org" minLength:"1" doc:"The organization that owns the channel."` + // Timestamp when the lifecycle state was updated. Timestamps are in ISO 8601. + UpdatedAt time.Time `json:"updated_at" format:"date-time" doc:"Timestamp when the lifecycle state was updated. Timestamps are in ISO 8601."` +} + +// NewGetStateResponseBody instantiates a new GetStateResponseBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewGetStateResponseBody(channelId string, channelRevision int32, channelState string, org string, updatedAt time.Time) *GetStateResponseBody { + this := GetStateResponseBody{} + this.ChannelId = channelId + this.ChannelRevision = channelRevision + this.ChannelState = channelState + this.Org = org + this.UpdatedAt = updatedAt + return &this +} + +// NewGetStateResponseBodyWithDefaults instantiates a new GetStateResponseBody object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewGetStateResponseBodyWithDefaults() *GetStateResponseBody { + this := GetStateResponseBody{} + return &this +} + +// GetSchema returns the Schema field value if set, zero value otherwise. +func (o *GetStateResponseBody) GetSchema() string { + if o == nil || IsNil(o.Schema) { + var ret string + return ret + } + return *o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GetStateResponseBody) GetSchemaOk() (*string, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *GetStateResponseBody) HasSchema() bool { + if o != nil && !IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given string and assigns it to the Schema field. +func (o *GetStateResponseBody) SetSchema(v string) { + o.Schema = &v +} + +// GetChannelId returns the ChannelId field value +func (o *GetStateResponseBody) GetChannelId() string { + if o == nil { + var ret string + return ret + } + + return o.ChannelId +} + +// GetChannelIdOk returns a tuple with the ChannelId field value +// and a boolean to check if the value has been set. +func (o *GetStateResponseBody) GetChannelIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ChannelId, true +} + +// SetChannelId sets field value +func (o *GetStateResponseBody) SetChannelId(v string) { + o.ChannelId = v +} + +// GetChannelRevision returns the ChannelRevision field value +func (o *GetStateResponseBody) GetChannelRevision() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.ChannelRevision +} + +// GetChannelRevisionOk returns a tuple with the ChannelRevision field value +// and a boolean to check if the value has been set. +func (o *GetStateResponseBody) GetChannelRevisionOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.ChannelRevision, true +} + +// SetChannelRevision sets field value +func (o *GetStateResponseBody) SetChannelRevision(v int32) { + o.ChannelRevision = v +} + +// GetChannelState returns the ChannelState field value +func (o *GetStateResponseBody) GetChannelState() string { + if o == nil { + var ret string + return ret + } + + return o.ChannelState +} + +// GetChannelStateOk returns a tuple with the ChannelState field value +// and a boolean to check if the value has been set. +func (o *GetStateResponseBody) GetChannelStateOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ChannelState, true +} + +// SetChannelState sets field value +func (o *GetStateResponseBody) SetChannelState(v string) { + o.ChannelState = v +} + +// GetOrg returns the Org field value +func (o *GetStateResponseBody) GetOrg() string { + if o == nil { + var ret string + return ret + } + + return o.Org +} + +// GetOrgOk returns a tuple with the Org field value +// and a boolean to check if the value has been set. +func (o *GetStateResponseBody) GetOrgOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Org, true +} + +// SetOrg sets field value +func (o *GetStateResponseBody) SetOrg(v string) { + o.Org = v +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *GetStateResponseBody) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *GetStateResponseBody) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value +func (o *GetStateResponseBody) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +func (o GetStateResponseBody) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o GetStateResponseBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Schema) { + toSerialize["$schema"] = o.Schema + } + toSerialize["channel_id"] = o.ChannelId + toSerialize["channel_revision"] = o.ChannelRevision + toSerialize["channel_state"] = o.ChannelState + toSerialize["org"] = o.Org + toSerialize["updated_at"] = o.UpdatedAt + return toSerialize, nil +} + +type NullableGetStateResponseBody struct { + value *GetStateResponseBody + isSet bool +} + +func (v NullableGetStateResponseBody) Get() *GetStateResponseBody { + return v.value +} + +func (v *NullableGetStateResponseBody) Set(val *GetStateResponseBody) { + v.value = val + v.isSet = true +} + +func (v NullableGetStateResponseBody) IsSet() bool { + return v.isSet +} + +func (v *NullableGetStateResponseBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableGetStateResponseBody(val *GetStateResponseBody) *NullableGetStateResponseBody { + return &NullableGetStateResponseBody{value: val, isSet: true} +} + +func (v NullableGetStateResponseBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableGetStateResponseBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/isp-lifecycle/model_list_component_states_response_body.go b/isp-lifecycle/model_list_component_states_response_body.go new file mode 100644 index 0000000..239c600 --- /dev/null +++ b/isp-lifecycle/model_list_component_states_response_body.go @@ -0,0 +1,157 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" +) + +// checks if the ListComponentStatesResponseBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListComponentStatesResponseBody{} + +// ListComponentStatesResponseBody struct for ListComponentStatesResponseBody +type ListComponentStatesResponseBody struct { + // A URL to the JSON Schema for this object. + Schema *string `json:"$schema,omitempty" format:"uri" doc:"A URL to the JSON Schema for this object."` + // The list of components states. + Components []ListComponentStatesResponseEntry `json:"components" doc:"The list of components states."` +} + +// NewListComponentStatesResponseBody instantiates a new ListComponentStatesResponseBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListComponentStatesResponseBody(components []ListComponentStatesResponseEntry) *ListComponentStatesResponseBody { + this := ListComponentStatesResponseBody{} + this.Components = components + return &this +} + +// NewListComponentStatesResponseBodyWithDefaults instantiates a new ListComponentStatesResponseBody object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListComponentStatesResponseBodyWithDefaults() *ListComponentStatesResponseBody { + this := ListComponentStatesResponseBody{} + return &this +} + +// GetSchema returns the Schema field value if set, zero value otherwise. +func (o *ListComponentStatesResponseBody) GetSchema() string { + if o == nil || IsNil(o.Schema) { + var ret string + return ret + } + return *o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ListComponentStatesResponseBody) GetSchemaOk() (*string, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *ListComponentStatesResponseBody) HasSchema() bool { + if o != nil && !IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given string and assigns it to the Schema field. +func (o *ListComponentStatesResponseBody) SetSchema(v string) { + o.Schema = &v +} + +// GetComponents returns the Components field value +// If the value is explicit nil, the zero value for []ListComponentStatesResponseEntry will be returned +func (o *ListComponentStatesResponseBody) GetComponents() []ListComponentStatesResponseEntry { + if o == nil { + var ret []ListComponentStatesResponseEntry + return ret + } + + return o.Components +} + +// GetComponentsOk returns a tuple with the Components field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *ListComponentStatesResponseBody) GetComponentsOk() ([]ListComponentStatesResponseEntry, bool) { + if o == nil || IsNil(o.Components) { + return nil, false + } + return o.Components, true +} + +// SetComponents sets field value +func (o *ListComponentStatesResponseBody) SetComponents(v []ListComponentStatesResponseEntry) { + o.Components = v +} + +func (o ListComponentStatesResponseBody) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListComponentStatesResponseBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Schema) { + toSerialize["$schema"] = o.Schema + } + if o.Components != nil { + toSerialize["components"] = o.Components + } + return toSerialize, nil +} + +type NullableListComponentStatesResponseBody struct { + value *ListComponentStatesResponseBody + isSet bool +} + +func (v NullableListComponentStatesResponseBody) Get() *ListComponentStatesResponseBody { + return v.value +} + +func (v *NullableListComponentStatesResponseBody) Set(val *ListComponentStatesResponseBody) { + v.value = val + v.isSet = true +} + +func (v NullableListComponentStatesResponseBody) IsSet() bool { + return v.isSet +} + +func (v *NullableListComponentStatesResponseBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListComponentStatesResponseBody(val *ListComponentStatesResponseBody) *NullableListComponentStatesResponseBody { + return &NullableListComponentStatesResponseBody{value: val, isSet: true} +} + +func (v NullableListComponentStatesResponseBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListComponentStatesResponseBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/isp-lifecycle/model_list_component_states_response_entry.go b/isp-lifecycle/model_list_component_states_response_entry.go new file mode 100644 index 0000000..f5e392e --- /dev/null +++ b/isp-lifecycle/model_list_component_states_response_entry.go @@ -0,0 +1,255 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" + "time" +) + +// checks if the ListComponentStatesResponseEntry type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListComponentStatesResponseEntry{} + +// ListComponentStatesResponseEntry struct for ListComponentStatesResponseEntry +type ListComponentStatesResponseEntry struct { + ChannelId string `json:"channel_id"` + // The ChannelDoc's revision + ChannelRevision int32 `json:"channel_revision" format:"int32" doc:"The ChannelDoc's revision"` + // A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with). + Component string `json:"component" enum:"CHANNEL_CONFIG,TRANSCODER,PUBLISHING" doc:"A service or feature involved in a channel workflow/operations (ie. \"what\" the lifecycle system is concerned with)."` + // The current state of the component. + ComponentState string `json:"component_state" enum:"OFF,PROVISIONING,STREAMING,TERMINATING,ERROR" doc:"The current state of the component."` + Org string `json:"org"` + // ISO 8601 timestamp when the component state was updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time" doc:"ISO 8601 timestamp when the component state was updated."` +} + +// NewListComponentStatesResponseEntry instantiates a new ListComponentStatesResponseEntry object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListComponentStatesResponseEntry(channelId string, channelRevision int32, component string, componentState string, org string, updatedAt time.Time) *ListComponentStatesResponseEntry { + this := ListComponentStatesResponseEntry{} + this.ChannelId = channelId + this.ChannelRevision = channelRevision + this.Component = component + this.ComponentState = componentState + this.Org = org + this.UpdatedAt = updatedAt + return &this +} + +// NewListComponentStatesResponseEntryWithDefaults instantiates a new ListComponentStatesResponseEntry object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListComponentStatesResponseEntryWithDefaults() *ListComponentStatesResponseEntry { + this := ListComponentStatesResponseEntry{} + return &this +} + +// GetChannelId returns the ChannelId field value +func (o *ListComponentStatesResponseEntry) GetChannelId() string { + if o == nil { + var ret string + return ret + } + + return o.ChannelId +} + +// GetChannelIdOk returns a tuple with the ChannelId field value +// and a boolean to check if the value has been set. +func (o *ListComponentStatesResponseEntry) GetChannelIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ChannelId, true +} + +// SetChannelId sets field value +func (o *ListComponentStatesResponseEntry) SetChannelId(v string) { + o.ChannelId = v +} + +// GetChannelRevision returns the ChannelRevision field value +func (o *ListComponentStatesResponseEntry) GetChannelRevision() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.ChannelRevision +} + +// GetChannelRevisionOk returns a tuple with the ChannelRevision field value +// and a boolean to check if the value has been set. +func (o *ListComponentStatesResponseEntry) GetChannelRevisionOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.ChannelRevision, true +} + +// SetChannelRevision sets field value +func (o *ListComponentStatesResponseEntry) SetChannelRevision(v int32) { + o.ChannelRevision = v +} + +// GetComponent returns the Component field value +func (o *ListComponentStatesResponseEntry) GetComponent() string { + if o == nil { + var ret string + return ret + } + + return o.Component +} + +// GetComponentOk returns a tuple with the Component field value +// and a boolean to check if the value has been set. +func (o *ListComponentStatesResponseEntry) GetComponentOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Component, true +} + +// SetComponent sets field value +func (o *ListComponentStatesResponseEntry) SetComponent(v string) { + o.Component = v +} + +// GetComponentState returns the ComponentState field value +func (o *ListComponentStatesResponseEntry) GetComponentState() string { + if o == nil { + var ret string + return ret + } + + return o.ComponentState +} + +// GetComponentStateOk returns a tuple with the ComponentState field value +// and a boolean to check if the value has been set. +func (o *ListComponentStatesResponseEntry) GetComponentStateOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ComponentState, true +} + +// SetComponentState sets field value +func (o *ListComponentStatesResponseEntry) SetComponentState(v string) { + o.ComponentState = v +} + +// GetOrg returns the Org field value +func (o *ListComponentStatesResponseEntry) GetOrg() string { + if o == nil { + var ret string + return ret + } + + return o.Org +} + +// GetOrgOk returns a tuple with the Org field value +// and a boolean to check if the value has been set. +func (o *ListComponentStatesResponseEntry) GetOrgOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Org, true +} + +// SetOrg sets field value +func (o *ListComponentStatesResponseEntry) SetOrg(v string) { + o.Org = v +} + +// GetUpdatedAt returns the UpdatedAt field value +func (o *ListComponentStatesResponseEntry) GetUpdatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + + return o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value +// and a boolean to check if the value has been set. +func (o *ListComponentStatesResponseEntry) GetUpdatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.UpdatedAt, true +} + +// SetUpdatedAt sets field value +func (o *ListComponentStatesResponseEntry) SetUpdatedAt(v time.Time) { + o.UpdatedAt = v +} + +func (o ListComponentStatesResponseEntry) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListComponentStatesResponseEntry) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["channel_id"] = o.ChannelId + toSerialize["channel_revision"] = o.ChannelRevision + toSerialize["component"] = o.Component + toSerialize["component_state"] = o.ComponentState + toSerialize["org"] = o.Org + toSerialize["updated_at"] = o.UpdatedAt + return toSerialize, nil +} + +type NullableListComponentStatesResponseEntry struct { + value *ListComponentStatesResponseEntry + isSet bool +} + +func (v NullableListComponentStatesResponseEntry) Get() *ListComponentStatesResponseEntry { + return v.value +} + +func (v *NullableListComponentStatesResponseEntry) Set(val *ListComponentStatesResponseEntry) { + v.value = val + v.isSet = true +} + +func (v NullableListComponentStatesResponseEntry) IsSet() bool { + return v.isSet +} + +func (v *NullableListComponentStatesResponseEntry) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListComponentStatesResponseEntry(val *ListComponentStatesResponseEntry) *NullableListComponentStatesResponseEntry { + return &NullableListComponentStatesResponseEntry{value: val, isSet: true} +} + +func (v NullableListComponentStatesResponseEntry) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListComponentStatesResponseEntry) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/isp-lifecycle/model_put_component_body.go b/isp-lifecycle/model_put_component_body.go new file mode 100644 index 0000000..837cd93 --- /dev/null +++ b/isp-lifecycle/model_put_component_body.go @@ -0,0 +1,181 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" +) + +// checks if the PutComponentBody type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PutComponentBody{} + +// PutComponentBody struct for PutComponentBody +type PutComponentBody struct { + // A URL to the JSON Schema for this object. + Schema *string `json:"$schema,omitempty" format:"uri" doc:"A URL to the JSON Schema for this object."` + // The ChannelDoc's revision + ChannelRevision int32 `json:"channel_revision" format:"int32" doc:"The ChannelDoc's revision"` + // The current state of the component. + ComponentState string `json:"component_state" enum:"OFF,PROVISIONING,STREAMING,TERMINATING,ERROR" doc:"The current state of the component."` +} + +// NewPutComponentBody instantiates a new PutComponentBody object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPutComponentBody(channelRevision int32, componentState string) *PutComponentBody { + this := PutComponentBody{} + this.ChannelRevision = channelRevision + this.ComponentState = componentState + return &this +} + +// NewPutComponentBodyWithDefaults instantiates a new PutComponentBody object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPutComponentBodyWithDefaults() *PutComponentBody { + this := PutComponentBody{} + return &this +} + +// GetSchema returns the Schema field value if set, zero value otherwise. +func (o *PutComponentBody) GetSchema() string { + if o == nil || IsNil(o.Schema) { + var ret string + return ret + } + return *o.Schema +} + +// GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PutComponentBody) GetSchemaOk() (*string, bool) { + if o == nil || IsNil(o.Schema) { + return nil, false + } + return o.Schema, true +} + +// HasSchema returns a boolean if a field has been set. +func (o *PutComponentBody) HasSchema() bool { + if o != nil && !IsNil(o.Schema) { + return true + } + + return false +} + +// SetSchema gets a reference to the given string and assigns it to the Schema field. +func (o *PutComponentBody) SetSchema(v string) { + o.Schema = &v +} + +// GetChannelRevision returns the ChannelRevision field value +func (o *PutComponentBody) GetChannelRevision() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.ChannelRevision +} + +// GetChannelRevisionOk returns a tuple with the ChannelRevision field value +// and a boolean to check if the value has been set. +func (o *PutComponentBody) GetChannelRevisionOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.ChannelRevision, true +} + +// SetChannelRevision sets field value +func (o *PutComponentBody) SetChannelRevision(v int32) { + o.ChannelRevision = v +} + +// GetComponentState returns the ComponentState field value +func (o *PutComponentBody) GetComponentState() string { + if o == nil { + var ret string + return ret + } + + return o.ComponentState +} + +// GetComponentStateOk returns a tuple with the ComponentState field value +// and a boolean to check if the value has been set. +func (o *PutComponentBody) GetComponentStateOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ComponentState, true +} + +// SetComponentState sets field value +func (o *PutComponentBody) SetComponentState(v string) { + o.ComponentState = v +} + +func (o PutComponentBody) MarshalJSON() ([]byte, error) { + toSerialize,err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o PutComponentBody) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.Schema) { + toSerialize["$schema"] = o.Schema + } + toSerialize["channel_revision"] = o.ChannelRevision + toSerialize["component_state"] = o.ComponentState + return toSerialize, nil +} + +type NullablePutComponentBody struct { + value *PutComponentBody + isSet bool +} + +func (v NullablePutComponentBody) Get() *PutComponentBody { + return v.value +} + +func (v *NullablePutComponentBody) Set(val *PutComponentBody) { + v.value = val + v.isSet = true +} + +func (v NullablePutComponentBody) IsSet() bool { + return v.isSet +} + +func (v *NullablePutComponentBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePutComponentBody(val *PutComponentBody) *NullablePutComponentBody { + return &NullablePutComponentBody{value: val, isSet: true} +} + +func (v NullablePutComponentBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePutComponentBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + + diff --git a/isp-lifecycle/response.go b/isp-lifecycle/response.go new file mode 100644 index 0000000..fc55863 --- /dev/null +++ b/isp-lifecycle/response.go @@ -0,0 +1,45 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "net/http" +) + +// APIResponse stores the API response returned by the server. +type APIResponse struct { + *http.Response `json:"-"` + Message string `json:"message,omitempty"` + // Operation is the name of the OpenAPI operation. + Operation string `json:"operation,omitempty"` + // RequestURL is the request URL. This value is always available, even if the + // embedded *http.Response is nil. + RequestURL string `json:"url,omitempty"` + // Method is the HTTP method used for the request. This value is always + // available, even if the embedded *http.Response is nil. + Method string `json:"method,omitempty"` + // Payload holds the contents of the response body (which may be nil or empty). + // This is provided here as the raw response.Body() reader will have already + // been drained. + Payload []byte `json:"-"` +} + +// NewAPIResponse returns a new APIResponse object. +func NewAPIResponse(r *http.Response) *APIResponse { + + response := &APIResponse{Response: r} + return response +} + +// NewAPIResponseWithError returns a new APIResponse object with the provided error message. +func NewAPIResponseWithError(errorMessage string) *APIResponse { + + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/isp-lifecycle/test/api_lifecycle_test.go b/isp-lifecycle/test/api_lifecycle_test.go new file mode 100644 index 0000000..2b3aad4 --- /dev/null +++ b/isp-lifecycle/test/api_lifecycle_test.go @@ -0,0 +1,85 @@ +/* +Channel Lifecycle State API + +Testing LifecycleApiService + +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); + +package isp + +import ( + "context" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "testing" + openapiclient "github.com/istreamlabs/go-sdk/isp-lifecycle" +) + +func Test_isp_LifecycleApiService(t *testing.T) { + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + + t.Run("Test LifecycleApiService CalculateLifecycleState", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var org string + var channelId string + + resp, httpRes, err := apiClient.LifecycleApi.CalculateLifecycleState(context.Background(), org, channelId).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + + t.Run("Test LifecycleApiService GetLifecycleComponentState", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var org string + var channelId string + var component string + + resp, httpRes, err := apiClient.LifecycleApi.GetLifecycleComponentState(context.Background(), org, channelId, component).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + + t.Run("Test LifecycleApiService ListLifecycleComponentStates", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var org string + var channelId string + + resp, httpRes, err := apiClient.LifecycleApi.ListLifecycleComponentStates(context.Background(), org, channelId).Execute() + + require.Nil(t, err) + require.NotNil(t, resp) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + + t.Run("Test LifecycleApiService PutLifecycleComponentState", func(t *testing.T) { + + t.Skip("skip test") // remove to run test + + var channelUrn string + var component string + + httpRes, err := apiClient.LifecycleApi.PutLifecycleComponentState(context.Background(), channelUrn, component).Execute() + + require.Nil(t, err) + assert.Equal(t, 200, httpRes.StatusCode) + + }) + +} diff --git a/isp-lifecycle/utils.go b/isp-lifecycle/utils.go new file mode 100644 index 0000000..b8e1eb0 --- /dev/null +++ b/isp-lifecycle/utils.go @@ -0,0 +1,345 @@ +/* + * Channel Lifecycle State API + * + * API version: 1.0.0 + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "encoding/json" + "reflect" + "time" +) + +// PtrBool is a helper routine that returns a pointer to given boolean value. +func PtrBool(v bool) *bool { return &v } + +// PtrInt is a helper routine that returns a pointer to given integer value. +func PtrInt(v int) *int { return &v } + +// PtrInt32 is a helper routine that returns a pointer to given integer value. +func PtrInt32(v int32) *int32 { return &v } + +// PtrInt64 is a helper routine that returns a pointer to given integer value. +func PtrInt64(v int64) *int64 { return &v } + +// PtrFloat32 is a helper routine that returns a pointer to given float value. +func PtrFloat32(v float32) *float32 { return &v } + +// PtrFloat64 is a helper routine that returns a pointer to given float value. +func PtrFloat64(v float64) *float64 { return &v } + +// PtrString is a helper routine that returns a pointer to given string value. +func PtrString(v string) *string { return &v } + +// PtrTime is helper routine that returns a pointer to given Time value. +func PtrTime(v time.Time) *time.Time { return &v } + +type NullableBool struct { + value *bool + isSet bool +} + +func (v NullableBool) Get() *bool { + return v.value +} + +func (v *NullableBool) Set(val *bool) { + v.value = val + v.isSet = true +} + +func (v NullableBool) IsSet() bool { + return v.isSet +} + +func (v *NullableBool) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableBool(val *bool) *NullableBool { + return &NullableBool{value: val, isSet: true} +} + +func (v NullableBool) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableBool) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt struct { + value *int + isSet bool +} + +func (v NullableInt) Get() *int { + return v.value +} + +func (v *NullableInt) Set(val *int) { + v.value = val + v.isSet = true +} + +func (v NullableInt) IsSet() bool { + return v.isSet +} + +func (v *NullableInt) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt(val *int) *NullableInt { + return &NullableInt{value: val, isSet: true} +} + +func (v NullableInt) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt32 struct { + value *int32 + isSet bool +} + +func (v NullableInt32) Get() *int32 { + return v.value +} + +func (v *NullableInt32) Set(val *int32) { + v.value = val + v.isSet = true +} + +func (v NullableInt32) IsSet() bool { + return v.isSet +} + +func (v *NullableInt32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt32(val *int32) *NullableInt32 { + return &NullableInt32{value: val, isSet: true} +} + +func (v NullableInt32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableInt64 struct { + value *int64 + isSet bool +} + +func (v NullableInt64) Get() *int64 { + return v.value +} + +func (v *NullableInt64) Set(val *int64) { + v.value = val + v.isSet = true +} + +func (v NullableInt64) IsSet() bool { + return v.isSet +} + +func (v *NullableInt64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableInt64(val *int64) *NullableInt64 { + return &NullableInt64{value: val, isSet: true} +} + +func (v NullableInt64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableInt64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat32 struct { + value *float32 + isSet bool +} + +func (v NullableFloat32) Get() *float32 { + return v.value +} + +func (v *NullableFloat32) Set(val *float32) { + v.value = val + v.isSet = true +} + +func (v NullableFloat32) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat32) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat32(val *float32) *NullableFloat32 { + return &NullableFloat32{value: val, isSet: true} +} + +func (v NullableFloat32) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat32) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableFloat64 struct { + value *float64 + isSet bool +} + +func (v NullableFloat64) Get() *float64 { + return v.value +} + +func (v *NullableFloat64) Set(val *float64) { + v.value = val + v.isSet = true +} + +func (v NullableFloat64) IsSet() bool { + return v.isSet +} + +func (v *NullableFloat64) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableFloat64(val *float64) *NullableFloat64 { + return &NullableFloat64{value: val, isSet: true} +} + +func (v NullableFloat64) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableFloat64) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableString struct { + value *string + isSet bool +} + +func (v NullableString) Get() *string { + return v.value +} + +func (v *NullableString) Set(val *string) { + v.value = val + v.isSet = true +} + +func (v NullableString) IsSet() bool { + return v.isSet +} + +func (v *NullableString) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableString(val *string) *NullableString { + return &NullableString{value: val, isSet: true} +} + +func (v NullableString) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableString) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +type NullableTime struct { + value *time.Time + isSet bool +} + +func (v NullableTime) Get() *time.Time { + return v.value +} + +func (v *NullableTime) Set(val *time.Time) { + v.value = val + v.isSet = true +} + +func (v NullableTime) IsSet() bool { + return v.isSet +} + +func (v *NullableTime) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableTime(val *time.Time) *NullableTime { + return &NullableTime{value: val, isSet: true} +} + +func (v NullableTime) MarshalJSON() ([]byte, error) { + return v.value.MarshalJSON() +} + +func (v *NullableTime) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} + +// IsNil checks if an input is nil +func IsNil(i interface{}) bool { + if i == nil { + return true + } + switch reflect.TypeOf(i).Kind() { + case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: + return reflect.ValueOf(i).IsNil() + case reflect.Array: + return reflect.ValueOf(i).IsZero() + } + return false +} + +type MappedNullable interface { + ToMap() (map[string]interface{}, error) +} diff --git a/isp/.openapi-generator/FILES b/isp/.openapi-generator/FILES index 2c4acf8..41f8c08 100644 --- a/isp/.openapi-generator/FILES +++ b/isp/.openapi-generator/FILES @@ -166,9 +166,9 @@ model_make_clip_response.go model_make_mp4_response.go model_mp4_url_response.go model_org_summary.go -model_patch_org_channel_request2.go -model_patch_org_channel_request2_ingest.go -model_patch_org_channel_request_inner.go +model_patch_org_channel_request.go +model_patch_org_channel_request2_inner.go +model_patch_org_channel_request_ingest.go model_pin_source_request.go model_play_url_response.go model_post_clip_archive_request.go diff --git a/isp/api_channels_for_organization.go b/isp/api_channels_for_organization.go index 7563ebc..84fb6da 100644 --- a/isp/api_channels_for_organization.go +++ b/isp/api_channels_for_organization.go @@ -1005,7 +1005,7 @@ type ApiPatchOrgChannelRequest struct { ifNoneMatch *[]string ifModifiedSince *time.Time ifUnmodifiedSince *time.Time - patchOrgChannelRequestInner *[]PatchOrgChannelRequestInner + patchOrgChannelRequest2Inner *[]PatchOrgChannelRequest2Inner } // Validate request but do not otherwise process it @@ -1038,8 +1038,8 @@ func (r ApiPatchOrgChannelRequest) IfUnmodifiedSince(ifUnmodifiedSince time.Time return r } -func (r ApiPatchOrgChannelRequest) PatchOrgChannelRequestInner(patchOrgChannelRequestInner []PatchOrgChannelRequestInner) ApiPatchOrgChannelRequest { - r.patchOrgChannelRequestInner = &patchOrgChannelRequestInner +func (r ApiPatchOrgChannelRequest) PatchOrgChannelRequest2Inner(patchOrgChannelRequest2Inner []PatchOrgChannelRequest2Inner) ApiPatchOrgChannelRequest { + r.patchOrgChannelRequest2Inner = &patchOrgChannelRequest2Inner return r } @@ -1123,7 +1123,7 @@ func (a *ChannelsForOrganizationApiService) PatchOrgChannelExecute(r ApiPatchOrg localVarHeaderParams["If-Unmodified-Since"] = parameterToString(*r.ifUnmodifiedSince, "") } // body params - localVarPostBody = r.patchOrgChannelRequestInner + localVarPostBody = r.patchOrgChannelRequest2Inner req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) if err != nil { return nil, err diff --git a/isp/model_patch_org_channel_request2.go b/isp/model_patch_org_channel_request.go similarity index 73% rename from isp/model_patch_org_channel_request2.go rename to isp/model_patch_org_channel_request.go index b72d3d7..940c51a 100644 --- a/isp/model_patch_org_channel_request2.go +++ b/isp/model_patch_org_channel_request.go @@ -14,11 +14,11 @@ import ( "time" ) -// checks if the PatchOrgChannelRequest2 type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PatchOrgChannelRequest2{} +// checks if the PatchOrgChannelRequest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchOrgChannelRequest{} -// PatchOrgChannelRequest2 struct for PatchOrgChannelRequest2 -type PatchOrgChannelRequest2 struct { +// PatchOrgChannelRequest struct for PatchOrgChannelRequest +type PatchOrgChannelRequest struct { // An optional URL to a JSON Schema document describing this resource Schema *string `json:"$schema,omitempty" format:"uri" doc:"An optional URL to a JSON Schema document describing this resource"` // Date and time the channel was created. @@ -29,7 +29,7 @@ type PatchOrgChannelRequest2 struct { EnableByoip *bool `json:"enable_byoip,omitempty" doc:"Indicates whether the channel's transcoder needs to run in a designated IP range."` // External Channel ID provided at channel creation time Id *string `json:"id,omitempty" minLength:"1" pattern:"/^([a-z0-9]+(-*[a-z0-9]+)*)$/" doc:"External Channel ID provided at channel creation time"` - Ingest *PatchOrgChannelRequest2Ingest `json:"ingest,omitempty"` + Ingest *PatchOrgChannelRequestIngest `json:"ingest,omitempty"` // Optional labels for a channel. Any included labels must be at least 1 character long, but no greater than 256 characters. The maximum number of labels is 10. Labels []string `json:"labels,omitempty" maxItems:"10" doc:"Optional labels for a channel. Any included labels must be at least 1 character long, but no greater than 256 characters. The maximum number of labels is 10."` // Date and time the channel was last modified. @@ -50,25 +50,25 @@ type PatchOrgChannelRequest2 struct { Transcode *ChannelTranscode `json:"transcode,omitempty"` } -// NewPatchOrgChannelRequest2 instantiates a new PatchOrgChannelRequest2 object +// NewPatchOrgChannelRequest instantiates a new PatchOrgChannelRequest object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewPatchOrgChannelRequest2() *PatchOrgChannelRequest2 { - this := PatchOrgChannelRequest2{} +func NewPatchOrgChannelRequest() *PatchOrgChannelRequest { + this := PatchOrgChannelRequest{} return &this } -// NewPatchOrgChannelRequest2WithDefaults instantiates a new PatchOrgChannelRequest2 object +// NewPatchOrgChannelRequestWithDefaults instantiates a new PatchOrgChannelRequest object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set -func NewPatchOrgChannelRequest2WithDefaults() *PatchOrgChannelRequest2 { - this := PatchOrgChannelRequest2{} +func NewPatchOrgChannelRequestWithDefaults() *PatchOrgChannelRequest { + this := PatchOrgChannelRequest{} return &this } // GetSchema returns the Schema field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetSchema() string { +func (o *PatchOrgChannelRequest) GetSchema() string { if o == nil || IsNil(o.Schema) { var ret string return ret @@ -78,7 +78,7 @@ func (o *PatchOrgChannelRequest2) GetSchema() string { // GetSchemaOk returns a tuple with the Schema field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetSchemaOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetSchemaOk() (*string, bool) { if o == nil || IsNil(o.Schema) { return nil, false } @@ -86,7 +86,7 @@ func (o *PatchOrgChannelRequest2) GetSchemaOk() (*string, bool) { } // HasSchema returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasSchema() bool { +func (o *PatchOrgChannelRequest) HasSchema() bool { if o != nil && !IsNil(o.Schema) { return true } @@ -95,12 +95,12 @@ func (o *PatchOrgChannelRequest2) HasSchema() bool { } // SetSchema gets a reference to the given string and assigns it to the Schema field. -func (o *PatchOrgChannelRequest2) SetSchema(v string) { +func (o *PatchOrgChannelRequest) SetSchema(v string) { o.Schema = &v } // GetCreated returns the Created field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetCreated() time.Time { +func (o *PatchOrgChannelRequest) GetCreated() time.Time { if o == nil || IsNil(o.Created) { var ret time.Time return ret @@ -110,7 +110,7 @@ func (o *PatchOrgChannelRequest2) GetCreated() time.Time { // GetCreatedOk returns a tuple with the Created field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetCreatedOk() (*time.Time, bool) { +func (o *PatchOrgChannelRequest) GetCreatedOk() (*time.Time, bool) { if o == nil || IsNil(o.Created) { return nil, false } @@ -118,7 +118,7 @@ func (o *PatchOrgChannelRequest2) GetCreatedOk() (*time.Time, bool) { } // HasCreated returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasCreated() bool { +func (o *PatchOrgChannelRequest) HasCreated() bool { if o != nil && !IsNil(o.Created) { return true } @@ -127,12 +127,12 @@ func (o *PatchOrgChannelRequest2) HasCreated() bool { } // SetCreated gets a reference to the given time.Time and assigns it to the Created field. -func (o *PatchOrgChannelRequest2) SetCreated(v time.Time) { +func (o *PatchOrgChannelRequest) SetCreated(v time.Time) { o.Created = &v } // GetDesiredState returns the DesiredState field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetDesiredState() string { +func (o *PatchOrgChannelRequest) GetDesiredState() string { if o == nil || IsNil(o.DesiredState) { var ret string return ret @@ -142,7 +142,7 @@ func (o *PatchOrgChannelRequest2) GetDesiredState() string { // GetDesiredStateOk returns a tuple with the DesiredState field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetDesiredStateOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetDesiredStateOk() (*string, bool) { if o == nil || IsNil(o.DesiredState) { return nil, false } @@ -150,7 +150,7 @@ func (o *PatchOrgChannelRequest2) GetDesiredStateOk() (*string, bool) { } // HasDesiredState returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasDesiredState() bool { +func (o *PatchOrgChannelRequest) HasDesiredState() bool { if o != nil && !IsNil(o.DesiredState) { return true } @@ -159,12 +159,12 @@ func (o *PatchOrgChannelRequest2) HasDesiredState() bool { } // SetDesiredState gets a reference to the given string and assigns it to the DesiredState field. -func (o *PatchOrgChannelRequest2) SetDesiredState(v string) { +func (o *PatchOrgChannelRequest) SetDesiredState(v string) { o.DesiredState = &v } // GetEnableByoip returns the EnableByoip field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetEnableByoip() bool { +func (o *PatchOrgChannelRequest) GetEnableByoip() bool { if o == nil || IsNil(o.EnableByoip) { var ret bool return ret @@ -174,7 +174,7 @@ func (o *PatchOrgChannelRequest2) GetEnableByoip() bool { // GetEnableByoipOk returns a tuple with the EnableByoip field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetEnableByoipOk() (*bool, bool) { +func (o *PatchOrgChannelRequest) GetEnableByoipOk() (*bool, bool) { if o == nil || IsNil(o.EnableByoip) { return nil, false } @@ -182,7 +182,7 @@ func (o *PatchOrgChannelRequest2) GetEnableByoipOk() (*bool, bool) { } // HasEnableByoip returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasEnableByoip() bool { +func (o *PatchOrgChannelRequest) HasEnableByoip() bool { if o != nil && !IsNil(o.EnableByoip) { return true } @@ -191,12 +191,12 @@ func (o *PatchOrgChannelRequest2) HasEnableByoip() bool { } // SetEnableByoip gets a reference to the given bool and assigns it to the EnableByoip field. -func (o *PatchOrgChannelRequest2) SetEnableByoip(v bool) { +func (o *PatchOrgChannelRequest) SetEnableByoip(v bool) { o.EnableByoip = &v } // GetId returns the Id field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetId() string { +func (o *PatchOrgChannelRequest) GetId() string { if o == nil || IsNil(o.Id) { var ret string return ret @@ -206,7 +206,7 @@ func (o *PatchOrgChannelRequest2) GetId() string { // GetIdOk returns a tuple with the Id field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetIdOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetIdOk() (*string, bool) { if o == nil || IsNil(o.Id) { return nil, false } @@ -214,7 +214,7 @@ func (o *PatchOrgChannelRequest2) GetIdOk() (*string, bool) { } // HasId returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasId() bool { +func (o *PatchOrgChannelRequest) HasId() bool { if o != nil && !IsNil(o.Id) { return true } @@ -223,14 +223,14 @@ func (o *PatchOrgChannelRequest2) HasId() bool { } // SetId gets a reference to the given string and assigns it to the Id field. -func (o *PatchOrgChannelRequest2) SetId(v string) { +func (o *PatchOrgChannelRequest) SetId(v string) { o.Id = &v } // GetIngest returns the Ingest field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetIngest() PatchOrgChannelRequest2Ingest { +func (o *PatchOrgChannelRequest) GetIngest() PatchOrgChannelRequestIngest { if o == nil || IsNil(o.Ingest) { - var ret PatchOrgChannelRequest2Ingest + var ret PatchOrgChannelRequestIngest return ret } return *o.Ingest @@ -238,7 +238,7 @@ func (o *PatchOrgChannelRequest2) GetIngest() PatchOrgChannelRequest2Ingest { // GetIngestOk returns a tuple with the Ingest field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetIngestOk() (*PatchOrgChannelRequest2Ingest, bool) { +func (o *PatchOrgChannelRequest) GetIngestOk() (*PatchOrgChannelRequestIngest, bool) { if o == nil || IsNil(o.Ingest) { return nil, false } @@ -246,7 +246,7 @@ func (o *PatchOrgChannelRequest2) GetIngestOk() (*PatchOrgChannelRequest2Ingest, } // HasIngest returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasIngest() bool { +func (o *PatchOrgChannelRequest) HasIngest() bool { if o != nil && !IsNil(o.Ingest) { return true } @@ -254,13 +254,13 @@ func (o *PatchOrgChannelRequest2) HasIngest() bool { return false } -// SetIngest gets a reference to the given PatchOrgChannelRequest2Ingest and assigns it to the Ingest field. -func (o *PatchOrgChannelRequest2) SetIngest(v PatchOrgChannelRequest2Ingest) { +// SetIngest gets a reference to the given PatchOrgChannelRequestIngest and assigns it to the Ingest field. +func (o *PatchOrgChannelRequest) SetIngest(v PatchOrgChannelRequestIngest) { o.Ingest = &v } // GetLabels returns the Labels field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetLabels() []string { +func (o *PatchOrgChannelRequest) GetLabels() []string { if o == nil || IsNil(o.Labels) { var ret []string return ret @@ -270,7 +270,7 @@ func (o *PatchOrgChannelRequest2) GetLabels() []string { // GetLabelsOk returns a tuple with the Labels field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetLabelsOk() ([]string, bool) { +func (o *PatchOrgChannelRequest) GetLabelsOk() ([]string, bool) { if o == nil || IsNil(o.Labels) { return nil, false } @@ -278,7 +278,7 @@ func (o *PatchOrgChannelRequest2) GetLabelsOk() ([]string, bool) { } // HasLabels returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasLabels() bool { +func (o *PatchOrgChannelRequest) HasLabels() bool { if o != nil && !IsNil(o.Labels) { return true } @@ -287,12 +287,12 @@ func (o *PatchOrgChannelRequest2) HasLabels() bool { } // SetLabels gets a reference to the given []string and assigns it to the Labels field. -func (o *PatchOrgChannelRequest2) SetLabels(v []string) { +func (o *PatchOrgChannelRequest) SetLabels(v []string) { o.Labels = v } // GetModified returns the Modified field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetModified() time.Time { +func (o *PatchOrgChannelRequest) GetModified() time.Time { if o == nil || IsNil(o.Modified) { var ret time.Time return ret @@ -302,7 +302,7 @@ func (o *PatchOrgChannelRequest2) GetModified() time.Time { // GetModifiedOk returns a tuple with the Modified field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetModifiedOk() (*time.Time, bool) { +func (o *PatchOrgChannelRequest) GetModifiedOk() (*time.Time, bool) { if o == nil || IsNil(o.Modified) { return nil, false } @@ -310,7 +310,7 @@ func (o *PatchOrgChannelRequest2) GetModifiedOk() (*time.Time, bool) { } // HasModified returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasModified() bool { +func (o *PatchOrgChannelRequest) HasModified() bool { if o != nil && !IsNil(o.Modified) { return true } @@ -319,12 +319,12 @@ func (o *PatchOrgChannelRequest2) HasModified() bool { } // SetModified gets a reference to the given time.Time and assigns it to the Modified field. -func (o *PatchOrgChannelRequest2) SetModified(v time.Time) { +func (o *PatchOrgChannelRequest) SetModified(v time.Time) { o.Modified = &v } // GetName returns the Name field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetName() string { +func (o *PatchOrgChannelRequest) GetName() string { if o == nil || IsNil(o.Name) { var ret string return ret @@ -334,7 +334,7 @@ func (o *PatchOrgChannelRequest2) GetName() string { // GetNameOk returns a tuple with the Name field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetNameOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetNameOk() (*string, bool) { if o == nil || IsNil(o.Name) { return nil, false } @@ -342,7 +342,7 @@ func (o *PatchOrgChannelRequest2) GetNameOk() (*string, bool) { } // HasName returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasName() bool { +func (o *PatchOrgChannelRequest) HasName() bool { if o != nil && !IsNil(o.Name) { return true } @@ -351,12 +351,12 @@ func (o *PatchOrgChannelRequest2) HasName() bool { } // SetName gets a reference to the given string and assigns it to the Name field. -func (o *PatchOrgChannelRequest2) SetName(v string) { +func (o *PatchOrgChannelRequest) SetName(v string) { o.Name = &v } // GetOrganization returns the Organization field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetOrganization() string { +func (o *PatchOrgChannelRequest) GetOrganization() string { if o == nil || IsNil(o.Organization) { var ret string return ret @@ -366,7 +366,7 @@ func (o *PatchOrgChannelRequest2) GetOrganization() string { // GetOrganizationOk returns a tuple with the Organization field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetOrganizationOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetOrganizationOk() (*string, bool) { if o == nil || IsNil(o.Organization) { return nil, false } @@ -374,7 +374,7 @@ func (o *PatchOrgChannelRequest2) GetOrganizationOk() (*string, bool) { } // HasOrganization returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasOrganization() bool { +func (o *PatchOrgChannelRequest) HasOrganization() bool { if o != nil && !IsNil(o.Organization) { return true } @@ -383,12 +383,12 @@ func (o *PatchOrgChannelRequest2) HasOrganization() bool { } // SetOrganization gets a reference to the given string and assigns it to the Organization field. -func (o *PatchOrgChannelRequest2) SetOrganization(v string) { +func (o *PatchOrgChannelRequest) SetOrganization(v string) { o.Organization = &v } // GetPackaging returns the Packaging field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetPackaging() ChannelPackaging { +func (o *PatchOrgChannelRequest) GetPackaging() ChannelPackaging { if o == nil || IsNil(o.Packaging) { var ret ChannelPackaging return ret @@ -398,7 +398,7 @@ func (o *PatchOrgChannelRequest2) GetPackaging() ChannelPackaging { // GetPackagingOk returns a tuple with the Packaging field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetPackagingOk() (*ChannelPackaging, bool) { +func (o *PatchOrgChannelRequest) GetPackagingOk() (*ChannelPackaging, bool) { if o == nil || IsNil(o.Packaging) { return nil, false } @@ -406,7 +406,7 @@ func (o *PatchOrgChannelRequest2) GetPackagingOk() (*ChannelPackaging, bool) { } // HasPackaging returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasPackaging() bool { +func (o *PatchOrgChannelRequest) HasPackaging() bool { if o != nil && !IsNil(o.Packaging) { return true } @@ -415,12 +415,12 @@ func (o *PatchOrgChannelRequest2) HasPackaging() bool { } // SetPackaging gets a reference to the given ChannelPackaging and assigns it to the Packaging field. -func (o *PatchOrgChannelRequest2) SetPackaging(v ChannelPackaging) { +func (o *PatchOrgChannelRequest) SetPackaging(v ChannelPackaging) { o.Packaging = &v } // GetPublishing returns the Publishing field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetPublishing() ChannelPublishing { +func (o *PatchOrgChannelRequest) GetPublishing() ChannelPublishing { if o == nil || IsNil(o.Publishing) { var ret ChannelPublishing return ret @@ -430,7 +430,7 @@ func (o *PatchOrgChannelRequest2) GetPublishing() ChannelPublishing { // GetPublishingOk returns a tuple with the Publishing field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetPublishingOk() (*ChannelPublishing, bool) { +func (o *PatchOrgChannelRequest) GetPublishingOk() (*ChannelPublishing, bool) { if o == nil || IsNil(o.Publishing) { return nil, false } @@ -438,7 +438,7 @@ func (o *PatchOrgChannelRequest2) GetPublishingOk() (*ChannelPublishing, bool) { } // HasPublishing returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasPublishing() bool { +func (o *PatchOrgChannelRequest) HasPublishing() bool { if o != nil && !IsNil(o.Publishing) { return true } @@ -447,12 +447,12 @@ func (o *PatchOrgChannelRequest2) HasPublishing() bool { } // SetPublishing gets a reference to the given ChannelPublishing and assigns it to the Publishing field. -func (o *PatchOrgChannelRequest2) SetPublishing(v ChannelPublishing) { +func (o *PatchOrgChannelRequest) SetPublishing(v ChannelPublishing) { o.Publishing = &v } // GetRegion returns the Region field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetRegion() string { +func (o *PatchOrgChannelRequest) GetRegion() string { if o == nil || IsNil(o.Region) { var ret string return ret @@ -462,7 +462,7 @@ func (o *PatchOrgChannelRequest2) GetRegion() string { // GetRegionOk returns a tuple with the Region field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetRegionOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetRegionOk() (*string, bool) { if o == nil || IsNil(o.Region) { return nil, false } @@ -470,7 +470,7 @@ func (o *PatchOrgChannelRequest2) GetRegionOk() (*string, bool) { } // HasRegion returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasRegion() bool { +func (o *PatchOrgChannelRequest) HasRegion() bool { if o != nil && !IsNil(o.Region) { return true } @@ -479,12 +479,12 @@ func (o *PatchOrgChannelRequest2) HasRegion() bool { } // SetRegion gets a reference to the given string and assigns it to the Region field. -func (o *PatchOrgChannelRequest2) SetRegion(v string) { +func (o *PatchOrgChannelRequest) SetRegion(v string) { o.Region = &v } // GetResourceClass returns the ResourceClass field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetResourceClass() string { +func (o *PatchOrgChannelRequest) GetResourceClass() string { if o == nil || IsNil(o.ResourceClass) { var ret string return ret @@ -494,7 +494,7 @@ func (o *PatchOrgChannelRequest2) GetResourceClass() string { // GetResourceClassOk returns a tuple with the ResourceClass field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetResourceClassOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetResourceClassOk() (*string, bool) { if o == nil || IsNil(o.ResourceClass) { return nil, false } @@ -502,7 +502,7 @@ func (o *PatchOrgChannelRequest2) GetResourceClassOk() (*string, bool) { } // HasResourceClass returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasResourceClass() bool { +func (o *PatchOrgChannelRequest) HasResourceClass() bool { if o != nil && !IsNil(o.ResourceClass) { return true } @@ -511,12 +511,12 @@ func (o *PatchOrgChannelRequest2) HasResourceClass() bool { } // SetResourceClass gets a reference to the given string and assigns it to the ResourceClass field. -func (o *PatchOrgChannelRequest2) SetResourceClass(v string) { +func (o *PatchOrgChannelRequest) SetResourceClass(v string) { o.ResourceClass = &v } // GetSelf returns the Self field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetSelf() string { +func (o *PatchOrgChannelRequest) GetSelf() string { if o == nil || IsNil(o.Self) { var ret string return ret @@ -526,7 +526,7 @@ func (o *PatchOrgChannelRequest2) GetSelf() string { // GetSelfOk returns a tuple with the Self field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetSelfOk() (*string, bool) { +func (o *PatchOrgChannelRequest) GetSelfOk() (*string, bool) { if o == nil || IsNil(o.Self) { return nil, false } @@ -534,7 +534,7 @@ func (o *PatchOrgChannelRequest2) GetSelfOk() (*string, bool) { } // HasSelf returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasSelf() bool { +func (o *PatchOrgChannelRequest) HasSelf() bool { if o != nil && !IsNil(o.Self) { return true } @@ -543,12 +543,12 @@ func (o *PatchOrgChannelRequest2) HasSelf() bool { } // SetSelf gets a reference to the given string and assigns it to the Self field. -func (o *PatchOrgChannelRequest2) SetSelf(v string) { +func (o *PatchOrgChannelRequest) SetSelf(v string) { o.Self = &v } // GetSignaling returns the Signaling field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetSignaling() ChannelSignaling { +func (o *PatchOrgChannelRequest) GetSignaling() ChannelSignaling { if o == nil || IsNil(o.Signaling) { var ret ChannelSignaling return ret @@ -558,7 +558,7 @@ func (o *PatchOrgChannelRequest2) GetSignaling() ChannelSignaling { // GetSignalingOk returns a tuple with the Signaling field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetSignalingOk() (*ChannelSignaling, bool) { +func (o *PatchOrgChannelRequest) GetSignalingOk() (*ChannelSignaling, bool) { if o == nil || IsNil(o.Signaling) { return nil, false } @@ -566,7 +566,7 @@ func (o *PatchOrgChannelRequest2) GetSignalingOk() (*ChannelSignaling, bool) { } // HasSignaling returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasSignaling() bool { +func (o *PatchOrgChannelRequest) HasSignaling() bool { if o != nil && !IsNil(o.Signaling) { return true } @@ -575,12 +575,12 @@ func (o *PatchOrgChannelRequest2) HasSignaling() bool { } // SetSignaling gets a reference to the given ChannelSignaling and assigns it to the Signaling field. -func (o *PatchOrgChannelRequest2) SetSignaling(v ChannelSignaling) { +func (o *PatchOrgChannelRequest) SetSignaling(v ChannelSignaling) { o.Signaling = &v } // GetTags returns the Tags field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetTags() ChannelTags { +func (o *PatchOrgChannelRequest) GetTags() ChannelTags { if o == nil || IsNil(o.Tags) { var ret ChannelTags return ret @@ -590,7 +590,7 @@ func (o *PatchOrgChannelRequest2) GetTags() ChannelTags { // GetTagsOk returns a tuple with the Tags field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetTagsOk() (*ChannelTags, bool) { +func (o *PatchOrgChannelRequest) GetTagsOk() (*ChannelTags, bool) { if o == nil || IsNil(o.Tags) { return nil, false } @@ -598,7 +598,7 @@ func (o *PatchOrgChannelRequest2) GetTagsOk() (*ChannelTags, bool) { } // HasTags returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasTags() bool { +func (o *PatchOrgChannelRequest) HasTags() bool { if o != nil && !IsNil(o.Tags) { return true } @@ -607,12 +607,12 @@ func (o *PatchOrgChannelRequest2) HasTags() bool { } // SetTags gets a reference to the given ChannelTags and assigns it to the Tags field. -func (o *PatchOrgChannelRequest2) SetTags(v ChannelTags) { +func (o *PatchOrgChannelRequest) SetTags(v ChannelTags) { o.Tags = &v } // GetTranscode returns the Transcode field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2) GetTranscode() ChannelTranscode { +func (o *PatchOrgChannelRequest) GetTranscode() ChannelTranscode { if o == nil || IsNil(o.Transcode) { var ret ChannelTranscode return ret @@ -622,7 +622,7 @@ func (o *PatchOrgChannelRequest2) GetTranscode() ChannelTranscode { // GetTranscodeOk returns a tuple with the Transcode field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2) GetTranscodeOk() (*ChannelTranscode, bool) { +func (o *PatchOrgChannelRequest) GetTranscodeOk() (*ChannelTranscode, bool) { if o == nil || IsNil(o.Transcode) { return nil, false } @@ -630,7 +630,7 @@ func (o *PatchOrgChannelRequest2) GetTranscodeOk() (*ChannelTranscode, bool) { } // HasTranscode returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2) HasTranscode() bool { +func (o *PatchOrgChannelRequest) HasTranscode() bool { if o != nil && !IsNil(o.Transcode) { return true } @@ -639,11 +639,11 @@ func (o *PatchOrgChannelRequest2) HasTranscode() bool { } // SetTranscode gets a reference to the given ChannelTranscode and assigns it to the Transcode field. -func (o *PatchOrgChannelRequest2) SetTranscode(v ChannelTranscode) { +func (o *PatchOrgChannelRequest) SetTranscode(v ChannelTranscode) { o.Transcode = &v } -func (o PatchOrgChannelRequest2) MarshalJSON() ([]byte, error) { +func (o PatchOrgChannelRequest) MarshalJSON() ([]byte, error) { toSerialize,err := o.ToMap() if err != nil { return []byte{}, err @@ -651,7 +651,7 @@ func (o PatchOrgChannelRequest2) MarshalJSON() ([]byte, error) { return json.Marshal(toSerialize) } -func (o PatchOrgChannelRequest2) ToMap() (map[string]interface{}, error) { +func (o PatchOrgChannelRequest) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if !IsNil(o.Schema) { toSerialize["$schema"] = o.Schema @@ -710,38 +710,38 @@ func (o PatchOrgChannelRequest2) ToMap() (map[string]interface{}, error) { return toSerialize, nil } -type NullablePatchOrgChannelRequest2 struct { - value *PatchOrgChannelRequest2 +type NullablePatchOrgChannelRequest struct { + value *PatchOrgChannelRequest isSet bool } -func (v NullablePatchOrgChannelRequest2) Get() *PatchOrgChannelRequest2 { +func (v NullablePatchOrgChannelRequest) Get() *PatchOrgChannelRequest { return v.value } -func (v *NullablePatchOrgChannelRequest2) Set(val *PatchOrgChannelRequest2) { +func (v *NullablePatchOrgChannelRequest) Set(val *PatchOrgChannelRequest) { v.value = val v.isSet = true } -func (v NullablePatchOrgChannelRequest2) IsSet() bool { +func (v NullablePatchOrgChannelRequest) IsSet() bool { return v.isSet } -func (v *NullablePatchOrgChannelRequest2) Unset() { +func (v *NullablePatchOrgChannelRequest) Unset() { v.value = nil v.isSet = false } -func NewNullablePatchOrgChannelRequest2(val *PatchOrgChannelRequest2) *NullablePatchOrgChannelRequest2 { - return &NullablePatchOrgChannelRequest2{value: val, isSet: true} +func NewNullablePatchOrgChannelRequest(val *PatchOrgChannelRequest) *NullablePatchOrgChannelRequest { + return &NullablePatchOrgChannelRequest{value: val, isSet: true} } -func (v NullablePatchOrgChannelRequest2) MarshalJSON() ([]byte, error) { +func (v NullablePatchOrgChannelRequest) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } -func (v *NullablePatchOrgChannelRequest2) UnmarshalJSON(src []byte) error { +func (v *NullablePatchOrgChannelRequest) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) } diff --git a/isp/model_patch_org_channel_request_inner.go b/isp/model_patch_org_channel_request2_inner.go similarity index 59% rename from isp/model_patch_org_channel_request_inner.go rename to isp/model_patch_org_channel_request2_inner.go index 6d7c0c7..1c2caae 100644 --- a/isp/model_patch_org_channel_request_inner.go +++ b/isp/model_patch_org_channel_request2_inner.go @@ -13,11 +13,11 @@ import ( "encoding/json" ) -// checks if the PatchOrgChannelRequestInner type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PatchOrgChannelRequestInner{} +// checks if the PatchOrgChannelRequest2Inner type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchOrgChannelRequest2Inner{} -// PatchOrgChannelRequestInner struct for PatchOrgChannelRequestInner -type PatchOrgChannelRequestInner struct { +// PatchOrgChannelRequest2Inner struct for PatchOrgChannelRequest2Inner +type PatchOrgChannelRequest2Inner struct { // JSON Pointer for the source of a move or copy From *string `json:"from,omitempty" doc:"JSON Pointer for the source of a move or copy"` // Operation name @@ -28,27 +28,27 @@ type PatchOrgChannelRequestInner struct { Value interface{} `json:"value,omitempty" doc:"The value to set"` } -// NewPatchOrgChannelRequestInner instantiates a new PatchOrgChannelRequestInner object +// NewPatchOrgChannelRequest2Inner instantiates a new PatchOrgChannelRequest2Inner object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewPatchOrgChannelRequestInner(op string, path string) *PatchOrgChannelRequestInner { - this := PatchOrgChannelRequestInner{} +func NewPatchOrgChannelRequest2Inner(op string, path string) *PatchOrgChannelRequest2Inner { + this := PatchOrgChannelRequest2Inner{} this.Op = op this.Path = path return &this } -// NewPatchOrgChannelRequestInnerWithDefaults instantiates a new PatchOrgChannelRequestInner object +// NewPatchOrgChannelRequest2InnerWithDefaults instantiates a new PatchOrgChannelRequest2Inner object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set -func NewPatchOrgChannelRequestInnerWithDefaults() *PatchOrgChannelRequestInner { - this := PatchOrgChannelRequestInner{} +func NewPatchOrgChannelRequest2InnerWithDefaults() *PatchOrgChannelRequest2Inner { + this := PatchOrgChannelRequest2Inner{} return &this } // GetFrom returns the From field value if set, zero value otherwise. -func (o *PatchOrgChannelRequestInner) GetFrom() string { +func (o *PatchOrgChannelRequest2Inner) GetFrom() string { if o == nil || IsNil(o.From) { var ret string return ret @@ -58,7 +58,7 @@ func (o *PatchOrgChannelRequestInner) GetFrom() string { // GetFromOk returns a tuple with the From field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequestInner) GetFromOk() (*string, bool) { +func (o *PatchOrgChannelRequest2Inner) GetFromOk() (*string, bool) { if o == nil || IsNil(o.From) { return nil, false } @@ -66,7 +66,7 @@ func (o *PatchOrgChannelRequestInner) GetFromOk() (*string, bool) { } // HasFrom returns a boolean if a field has been set. -func (o *PatchOrgChannelRequestInner) HasFrom() bool { +func (o *PatchOrgChannelRequest2Inner) HasFrom() bool { if o != nil && !IsNil(o.From) { return true } @@ -75,12 +75,12 @@ func (o *PatchOrgChannelRequestInner) HasFrom() bool { } // SetFrom gets a reference to the given string and assigns it to the From field. -func (o *PatchOrgChannelRequestInner) SetFrom(v string) { +func (o *PatchOrgChannelRequest2Inner) SetFrom(v string) { o.From = &v } // GetOp returns the Op field value -func (o *PatchOrgChannelRequestInner) GetOp() string { +func (o *PatchOrgChannelRequest2Inner) GetOp() string { if o == nil { var ret string return ret @@ -91,7 +91,7 @@ func (o *PatchOrgChannelRequestInner) GetOp() string { // GetOpOk returns a tuple with the Op field value // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequestInner) GetOpOk() (*string, bool) { +func (o *PatchOrgChannelRequest2Inner) GetOpOk() (*string, bool) { if o == nil { return nil, false } @@ -99,12 +99,12 @@ func (o *PatchOrgChannelRequestInner) GetOpOk() (*string, bool) { } // SetOp sets field value -func (o *PatchOrgChannelRequestInner) SetOp(v string) { +func (o *PatchOrgChannelRequest2Inner) SetOp(v string) { o.Op = v } // GetPath returns the Path field value -func (o *PatchOrgChannelRequestInner) GetPath() string { +func (o *PatchOrgChannelRequest2Inner) GetPath() string { if o == nil { var ret string return ret @@ -115,7 +115,7 @@ func (o *PatchOrgChannelRequestInner) GetPath() string { // GetPathOk returns a tuple with the Path field value // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequestInner) GetPathOk() (*string, bool) { +func (o *PatchOrgChannelRequest2Inner) GetPathOk() (*string, bool) { if o == nil { return nil, false } @@ -123,12 +123,12 @@ func (o *PatchOrgChannelRequestInner) GetPathOk() (*string, bool) { } // SetPath sets field value -func (o *PatchOrgChannelRequestInner) SetPath(v string) { +func (o *PatchOrgChannelRequest2Inner) SetPath(v string) { o.Path = v } // GetValue returns the Value field value if set, zero value otherwise (both if not set or set to explicit null). -func (o *PatchOrgChannelRequestInner) GetValue() interface{} { +func (o *PatchOrgChannelRequest2Inner) GetValue() interface{} { if o == nil { var ret interface{} return ret @@ -139,7 +139,7 @@ func (o *PatchOrgChannelRequestInner) GetValue() interface{} { // GetValueOk returns a tuple with the Value field value if set, nil otherwise // and a boolean to check if the value has been set. // NOTE: If the value is an explicit nil, `nil, true` will be returned -func (o *PatchOrgChannelRequestInner) GetValueOk() (*interface{}, bool) { +func (o *PatchOrgChannelRequest2Inner) GetValueOk() (*interface{}, bool) { if o == nil || IsNil(o.Value) { return nil, false } @@ -147,7 +147,7 @@ func (o *PatchOrgChannelRequestInner) GetValueOk() (*interface{}, bool) { } // HasValue returns a boolean if a field has been set. -func (o *PatchOrgChannelRequestInner) HasValue() bool { +func (o *PatchOrgChannelRequest2Inner) HasValue() bool { if o != nil && IsNil(o.Value) { return true } @@ -156,11 +156,11 @@ func (o *PatchOrgChannelRequestInner) HasValue() bool { } // SetValue gets a reference to the given interface{} and assigns it to the Value field. -func (o *PatchOrgChannelRequestInner) SetValue(v interface{}) { +func (o *PatchOrgChannelRequest2Inner) SetValue(v interface{}) { o.Value = v } -func (o PatchOrgChannelRequestInner) MarshalJSON() ([]byte, error) { +func (o PatchOrgChannelRequest2Inner) MarshalJSON() ([]byte, error) { toSerialize,err := o.ToMap() if err != nil { return []byte{}, err @@ -168,7 +168,7 @@ func (o PatchOrgChannelRequestInner) MarshalJSON() ([]byte, error) { return json.Marshal(toSerialize) } -func (o PatchOrgChannelRequestInner) ToMap() (map[string]interface{}, error) { +func (o PatchOrgChannelRequest2Inner) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if !IsNil(o.From) { toSerialize["from"] = o.From @@ -181,38 +181,38 @@ func (o PatchOrgChannelRequestInner) ToMap() (map[string]interface{}, error) { return toSerialize, nil } -type NullablePatchOrgChannelRequestInner struct { - value *PatchOrgChannelRequestInner +type NullablePatchOrgChannelRequest2Inner struct { + value *PatchOrgChannelRequest2Inner isSet bool } -func (v NullablePatchOrgChannelRequestInner) Get() *PatchOrgChannelRequestInner { +func (v NullablePatchOrgChannelRequest2Inner) Get() *PatchOrgChannelRequest2Inner { return v.value } -func (v *NullablePatchOrgChannelRequestInner) Set(val *PatchOrgChannelRequestInner) { +func (v *NullablePatchOrgChannelRequest2Inner) Set(val *PatchOrgChannelRequest2Inner) { v.value = val v.isSet = true } -func (v NullablePatchOrgChannelRequestInner) IsSet() bool { +func (v NullablePatchOrgChannelRequest2Inner) IsSet() bool { return v.isSet } -func (v *NullablePatchOrgChannelRequestInner) Unset() { +func (v *NullablePatchOrgChannelRequest2Inner) Unset() { v.value = nil v.isSet = false } -func NewNullablePatchOrgChannelRequestInner(val *PatchOrgChannelRequestInner) *NullablePatchOrgChannelRequestInner { - return &NullablePatchOrgChannelRequestInner{value: val, isSet: true} +func NewNullablePatchOrgChannelRequest2Inner(val *PatchOrgChannelRequest2Inner) *NullablePatchOrgChannelRequest2Inner { + return &NullablePatchOrgChannelRequest2Inner{value: val, isSet: true} } -func (v NullablePatchOrgChannelRequestInner) MarshalJSON() ([]byte, error) { +func (v NullablePatchOrgChannelRequest2Inner) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } -func (v *NullablePatchOrgChannelRequestInner) UnmarshalJSON(src []byte) error { +func (v *NullablePatchOrgChannelRequest2Inner) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) } diff --git a/isp/model_patch_org_channel_request2_ingest.go b/isp/model_patch_org_channel_request_ingest.go similarity index 53% rename from isp/model_patch_org_channel_request2_ingest.go rename to isp/model_patch_org_channel_request_ingest.go index 808c7b1..70b8ae1 100644 --- a/isp/model_patch_org_channel_request2_ingest.go +++ b/isp/model_patch_org_channel_request_ingest.go @@ -13,34 +13,34 @@ import ( "encoding/json" ) -// checks if the PatchOrgChannelRequest2Ingest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PatchOrgChannelRequest2Ingest{} +// checks if the PatchOrgChannelRequestIngest type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &PatchOrgChannelRequestIngest{} -// PatchOrgChannelRequest2Ingest Ingest configures inputs for the transcoder. -type PatchOrgChannelRequest2Ingest struct { +// PatchOrgChannelRequestIngest Ingest configures inputs for the transcoder. +type PatchOrgChannelRequestIngest struct { Slate *ChannelIngestSlate `json:"slate,omitempty"` Source *ChannelIngestSource `json:"source,omitempty"` } -// NewPatchOrgChannelRequest2Ingest instantiates a new PatchOrgChannelRequest2Ingest object +// NewPatchOrgChannelRequestIngest instantiates a new PatchOrgChannelRequestIngest object // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewPatchOrgChannelRequest2Ingest() *PatchOrgChannelRequest2Ingest { - this := PatchOrgChannelRequest2Ingest{} +func NewPatchOrgChannelRequestIngest() *PatchOrgChannelRequestIngest { + this := PatchOrgChannelRequestIngest{} return &this } -// NewPatchOrgChannelRequest2IngestWithDefaults instantiates a new PatchOrgChannelRequest2Ingest object +// NewPatchOrgChannelRequestIngestWithDefaults instantiates a new PatchOrgChannelRequestIngest object // This constructor will only assign default values to properties that have it defined, // but it doesn't guarantee that properties required by API are set -func NewPatchOrgChannelRequest2IngestWithDefaults() *PatchOrgChannelRequest2Ingest { - this := PatchOrgChannelRequest2Ingest{} +func NewPatchOrgChannelRequestIngestWithDefaults() *PatchOrgChannelRequestIngest { + this := PatchOrgChannelRequestIngest{} return &this } // GetSlate returns the Slate field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2Ingest) GetSlate() ChannelIngestSlate { +func (o *PatchOrgChannelRequestIngest) GetSlate() ChannelIngestSlate { if o == nil || IsNil(o.Slate) { var ret ChannelIngestSlate return ret @@ -50,7 +50,7 @@ func (o *PatchOrgChannelRequest2Ingest) GetSlate() ChannelIngestSlate { // GetSlateOk returns a tuple with the Slate field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2Ingest) GetSlateOk() (*ChannelIngestSlate, bool) { +func (o *PatchOrgChannelRequestIngest) GetSlateOk() (*ChannelIngestSlate, bool) { if o == nil || IsNil(o.Slate) { return nil, false } @@ -58,7 +58,7 @@ func (o *PatchOrgChannelRequest2Ingest) GetSlateOk() (*ChannelIngestSlate, bool) } // HasSlate returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2Ingest) HasSlate() bool { +func (o *PatchOrgChannelRequestIngest) HasSlate() bool { if o != nil && !IsNil(o.Slate) { return true } @@ -67,12 +67,12 @@ func (o *PatchOrgChannelRequest2Ingest) HasSlate() bool { } // SetSlate gets a reference to the given ChannelIngestSlate and assigns it to the Slate field. -func (o *PatchOrgChannelRequest2Ingest) SetSlate(v ChannelIngestSlate) { +func (o *PatchOrgChannelRequestIngest) SetSlate(v ChannelIngestSlate) { o.Slate = &v } // GetSource returns the Source field value if set, zero value otherwise. -func (o *PatchOrgChannelRequest2Ingest) GetSource() ChannelIngestSource { +func (o *PatchOrgChannelRequestIngest) GetSource() ChannelIngestSource { if o == nil || IsNil(o.Source) { var ret ChannelIngestSource return ret @@ -82,7 +82,7 @@ func (o *PatchOrgChannelRequest2Ingest) GetSource() ChannelIngestSource { // GetSourceOk returns a tuple with the Source field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *PatchOrgChannelRequest2Ingest) GetSourceOk() (*ChannelIngestSource, bool) { +func (o *PatchOrgChannelRequestIngest) GetSourceOk() (*ChannelIngestSource, bool) { if o == nil || IsNil(o.Source) { return nil, false } @@ -90,7 +90,7 @@ func (o *PatchOrgChannelRequest2Ingest) GetSourceOk() (*ChannelIngestSource, boo } // HasSource returns a boolean if a field has been set. -func (o *PatchOrgChannelRequest2Ingest) HasSource() bool { +func (o *PatchOrgChannelRequestIngest) HasSource() bool { if o != nil && !IsNil(o.Source) { return true } @@ -99,11 +99,11 @@ func (o *PatchOrgChannelRequest2Ingest) HasSource() bool { } // SetSource gets a reference to the given ChannelIngestSource and assigns it to the Source field. -func (o *PatchOrgChannelRequest2Ingest) SetSource(v ChannelIngestSource) { +func (o *PatchOrgChannelRequestIngest) SetSource(v ChannelIngestSource) { o.Source = &v } -func (o PatchOrgChannelRequest2Ingest) MarshalJSON() ([]byte, error) { +func (o PatchOrgChannelRequestIngest) MarshalJSON() ([]byte, error) { toSerialize,err := o.ToMap() if err != nil { return []byte{}, err @@ -111,7 +111,7 @@ func (o PatchOrgChannelRequest2Ingest) MarshalJSON() ([]byte, error) { return json.Marshal(toSerialize) } -func (o PatchOrgChannelRequest2Ingest) ToMap() (map[string]interface{}, error) { +func (o PatchOrgChannelRequestIngest) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if !IsNil(o.Slate) { toSerialize["slate"] = o.Slate @@ -122,38 +122,38 @@ func (o PatchOrgChannelRequest2Ingest) ToMap() (map[string]interface{}, error) { return toSerialize, nil } -type NullablePatchOrgChannelRequest2Ingest struct { - value *PatchOrgChannelRequest2Ingest +type NullablePatchOrgChannelRequestIngest struct { + value *PatchOrgChannelRequestIngest isSet bool } -func (v NullablePatchOrgChannelRequest2Ingest) Get() *PatchOrgChannelRequest2Ingest { +func (v NullablePatchOrgChannelRequestIngest) Get() *PatchOrgChannelRequestIngest { return v.value } -func (v *NullablePatchOrgChannelRequest2Ingest) Set(val *PatchOrgChannelRequest2Ingest) { +func (v *NullablePatchOrgChannelRequestIngest) Set(val *PatchOrgChannelRequestIngest) { v.value = val v.isSet = true } -func (v NullablePatchOrgChannelRequest2Ingest) IsSet() bool { +func (v NullablePatchOrgChannelRequestIngest) IsSet() bool { return v.isSet } -func (v *NullablePatchOrgChannelRequest2Ingest) Unset() { +func (v *NullablePatchOrgChannelRequestIngest) Unset() { v.value = nil v.isSet = false } -func NewNullablePatchOrgChannelRequest2Ingest(val *PatchOrgChannelRequest2Ingest) *NullablePatchOrgChannelRequest2Ingest { - return &NullablePatchOrgChannelRequest2Ingest{value: val, isSet: true} +func NewNullablePatchOrgChannelRequestIngest(val *PatchOrgChannelRequestIngest) *NullablePatchOrgChannelRequestIngest { + return &NullablePatchOrgChannelRequestIngest{value: val, isSet: true} } -func (v NullablePatchOrgChannelRequest2Ingest) MarshalJSON() ([]byte, error) { +func (v NullablePatchOrgChannelRequestIngest) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } -func (v *NullablePatchOrgChannelRequest2Ingest) UnmarshalJSON(src []byte) error { +func (v *NullablePatchOrgChannelRequestIngest) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) } diff --git a/prerequisites/isp-lifecycle_client._go b/prerequisites/isp-lifecycle_client._go new file mode 100644 index 0000000..07ef1d3 --- /dev/null +++ b/prerequisites/isp-lifecycle_client._go @@ -0,0 +1,667 @@ +/* + * iStreamPlanet Slate Management API + * + * API version: 1.0.0 + * Contact: support@istreamplanet.com + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package isp + +import ( + "bytes" + "context" + "encoding/json" + "encoding/xml" + "errors" + "fmt" + "io" + "log" + "mime/multipart" + "net/http" + "net/http/httputil" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" + + "golang.org/x/oauth2" +) + +var ( + jsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:vnd\.[^;]+\+)?json)`) + xmlCheck = regexp.MustCompile(`(?i:(?:application|text)/xml)`) + queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) + queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" ) +) + +// APIClient manages communication with the iStreamPlanet Slate Management API API v1.0.0 +// In most cases there should be only one, shared, APIClient. +type APIClient struct { + cfg *Configuration + common service // Reuse a single struct instead of allocating one for each service on the heap. + + // API Services + + LifecycleApi LifecycleApi +} + +type service struct { + client *APIClient +} + +// NewAPIClient creates a new API client. Requires a userAgent string describing your application. +// optionally a custom http.Client to allow for advanced features such as caching. +func NewAPIClient(cfg *Configuration) *APIClient { + if cfg.HTTPClient == nil { + cfg.HTTPClient = http.DefaultClient + } + + c := &APIClient{} + c.cfg = cfg + c.common.client = c + + // API Services + c.LifecycleApi = (*LifecycleApiService)(&c.common) + + return c +} + +func atoi(in string) (int, error) { + return strconv.Atoi(in) +} + +// selectHeaderContentType select a content type from the available list. +func selectHeaderContentType(contentTypes []string) string { + if len(contentTypes) == 0 { + return "" + } + if contains(contentTypes, "application/json") { + return "application/json" + } + return contentTypes[0] // use the first content type specified in 'consumes' +} + +// selectHeaderAccept join all accept types and return +func selectHeaderAccept(accepts []string) string { + if len(accepts) == 0 { + return "" + } + + if contains(accepts, "application/json") { + return "application/json" + } + + return strings.Join(accepts, ",") +} + +// contains is a case insensitive match, finding needle in a haystack +func contains(haystack []string, needle string) bool { + for _, a := range haystack { + if strings.EqualFold(a, needle) { + return true + } + } + return false +} + +// Verify optional parameters are of the correct type. +func typeCheckParameter(obj interface{}, expected string, name string) error { + // Make sure there is an object. + if obj == nil { + return nil + } + + // Check the type is as expected. + if reflect.TypeOf(obj).String() != expected { + return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) + } + return nil +} + +func parameterValueToString( obj interface{}, key string ) string { + if reflect.TypeOf(obj).Kind() != reflect.Ptr { + return fmt.Sprintf("%v", obj) + } + var param,ok = obj.(MappedNullable) + if !ok { + return "" + } + dataMap,err := param.ToMap() + if err != nil { + return "" + } + return fmt.Sprintf("%v", dataMap[key]) +} + +// parameterAddToHeaderOrQuery adds the provided object to the request header or url query +// supporting deep object syntax +func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) { + var v = reflect.ValueOf(obj) + var value = "" + if v == reflect.ValueOf(nil) { + value = "null" + } else { + switch v.Kind() { + case reflect.Invalid: + value = "invalid" + + case reflect.Struct: + if t,ok := obj.(MappedNullable); ok { + dataMap,err := t.ToMap() + if err != nil { + return + } + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339), collectionType) + return + } + value = v.Type().String() + " value" + case reflect.Slice: + var indValue = reflect.ValueOf(obj) + if indValue == reflect.ValueOf(nil) { + return + } + var lenIndValue = indValue.Len() + for i:=0;i 0 || (len(formFiles) > 0) { + if body != nil { + return nil, errors.New("Cannot specify postBody and multipart form at the same time.") + } + body = &bytes.Buffer{} + w := multipart.NewWriter(body) + + for k, v := range formParams { + for _, iv := range v { + if strings.HasPrefix(k, "@") { // file + err = addFile(w, k[1:], iv) + if err != nil { + return nil, err + } + } else { // form value + w.WriteField(k, iv) + } + } + } + for _, formFile := range formFiles { + if len(formFile.fileBytes) > 0 && formFile.fileName != "" { + w.Boundary() + part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) + if err != nil { + return nil, err + } + _, err = part.Write(formFile.fileBytes) + if err != nil { + return nil, err + } + } + } + + // Set the Boundary in the Content-Type + headerParams["Content-Type"] = w.FormDataContentType() + + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + w.Close() + } + + if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { + if body != nil { + return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") + } + body = &bytes.Buffer{} + body.WriteString(formParams.Encode()) + // Set Content-Length + headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) + } + + // Setup path and query parameters + url, err := url.Parse(path) + if err != nil { + return nil, err + } + + // Override request host, if applicable + if c.cfg.Host != "" { + url.Host = c.cfg.Host + } + + // Override request scheme, if applicable + if c.cfg.Scheme != "" { + url.Scheme = c.cfg.Scheme + } + + // Adding Query Param + query := url.Query() + for k, v := range queryParams { + for _, iv := range v { + query.Add(k, iv) + } + } + + // Encode the parameters. + url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { + pieces := strings.Split(s, "=") + pieces[0] = queryDescape.Replace(pieces[0]) + return strings.Join(pieces, "=") + }) + + // Generate a new request + if body != nil { + localVarRequest, err = http.NewRequest(method, url.String(), body) + } else { + localVarRequest, err = http.NewRequest(method, url.String(), nil) + } + if err != nil { + return nil, err + } + + // add header parameters, if any + if len(headerParams) > 0 { + headers := http.Header{} + for h, v := range headerParams { + headers[h] = []string{v} + } + localVarRequest.Header = headers + } + + // Add the user agent to the request. + localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) + + if ctx != nil { + // add context to the request + localVarRequest = localVarRequest.WithContext(ctx) + + // Walk through any authentication. + + // OAuth2 authentication + if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { + // We were able to grab an oauth2 token from the context + var latestToken *oauth2.Token + if latestToken, err = tok.Token(); err != nil { + return nil, err + } + + latestToken.SetAuthHeader(localVarRequest) + } + + } + + for header, value := range c.cfg.DefaultHeader { + localVarRequest.Header.Add(header, value) + } + return localVarRequest, nil +} + +func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { + if len(b) == 0 { + return nil + } + if s, ok := v.(*string); ok { + *s = string(b) + return nil + } + if f, ok := v.(*os.File); ok { + f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = f.Write(b) + if err != nil { + return + } + _, err = f.Seek(0, io.SeekStart) + return + } + if f, ok := v.(**os.File); ok { + *f, err = os.CreateTemp("", "HttpClientFile") + if err != nil { + return + } + _, err = (*f).Write(b) + if err != nil { + return + } + _, err = (*f).Seek(0, io.SeekStart) + return + } + if xmlCheck.MatchString(contentType) { + if err = xml.Unmarshal(b, v); err != nil { + return err + } + return nil + } + if jsonCheck.MatchString(contentType) { + if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas + if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined + if err = unmarshalObj.UnmarshalJSON(b); err != nil { + return err + } + } else { + return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") + } + } else if err = json.Unmarshal(b, v); err != nil { // simple model + return err + } + return nil + } + return errors.New("undefined response type") +} + +// Add a file to the multipart request +func addFile(w *multipart.Writer, fieldName, path string) error { + file, err := os.Open(filepath.Clean(path)) + if err != nil { + return err + } + err = file.Close() + if err != nil { + return err + } + + part, err := w.CreateFormFile(fieldName, filepath.Base(path)) + if err != nil { + return err + } + _, err = io.Copy(part, file) + + return err +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Set request body from an interface{} +func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { + if bodyBuf == nil { + bodyBuf = &bytes.Buffer{} + } + + if reader, ok := body.(io.Reader); ok { + _, err = bodyBuf.ReadFrom(reader) + } else if fp, ok := body.(*os.File); ok { + _, err = bodyBuf.ReadFrom(fp) + } else if b, ok := body.([]byte); ok { + _, err = bodyBuf.Write(b) + } else if s, ok := body.(string); ok { + _, err = bodyBuf.WriteString(s) + } else if s, ok := body.(*string); ok { + _, err = bodyBuf.WriteString(*s) + } else if jsonCheck.MatchString(contentType) { + err = json.NewEncoder(bodyBuf).Encode(body) + } else if xmlCheck.MatchString(contentType) { + err = xml.NewEncoder(bodyBuf).Encode(body) + } + + if err != nil { + return nil, err + } + + if bodyBuf.Len() == 0 { + err = fmt.Errorf("invalid body type %s\n", contentType) + return nil, err + } + return bodyBuf, nil +} + +// detectContentType method is used to figure out `Request.Body` content type for request header +func detectContentType(body interface{}) string { + contentType := "text/plain; charset=utf-8" + kind := reflect.TypeOf(body).Kind() + + switch kind { + case reflect.Struct, reflect.Map, reflect.Ptr: + contentType = "application/json; charset=utf-8" + case reflect.String: + contentType = "text/plain; charset=utf-8" + default: + if b, ok := body.([]byte); ok { + contentType = http.DetectContentType(b) + } else if kind == reflect.Slice { + contentType = "application/json; charset=utf-8" + } + } + + return contentType +} + +// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go +type cacheControl map[string]string + +func parseCacheControl(headers http.Header) cacheControl { + cc := cacheControl{} + ccHeader := headers.Get("Cache-Control") + for _, part := range strings.Split(ccHeader, ",") { + part = strings.Trim(part, " ") + if part == "" { + continue + } + if strings.ContainsRune(part, '=') { + keyval := strings.Split(part, "=") + cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") + } else { + cc[part] = "" + } + } + return cc +} + +// CacheExpires helper function to determine remaining time before repeating a request. +func CacheExpires(r *http.Response) time.Time { + // Figure out when the cache expires. + var expires time.Time + now, err := time.Parse(time.RFC1123, r.Header.Get("date")) + if err != nil { + return time.Now() + } + respCacheControl := parseCacheControl(r.Header) + + if maxAge, ok := respCacheControl["max-age"]; ok { + lifetime, err := time.ParseDuration(maxAge + "s") + if err != nil { + expires = now + } else { + expires = now.Add(lifetime) + } + } else { + expiresHeader := r.Header.Get("Expires") + if expiresHeader != "" { + expires, err = time.Parse(time.RFC1123, expiresHeader) + if err != nil { + expires = now + } + } + } + return expires +} + +func strlen(s string) int { + return utf8.RuneCountInString(s) +} + +// GenericOpenAPIError Provides access to the body, error and model on returned errors. +type GenericOpenAPIError struct { + body []byte + error string + model interface{} +} + +// Error returns non-empty string if there was an error. +func (e GenericOpenAPIError) Error() string { + return e.error +} + +// Body returns the raw bytes of the response +func (e GenericOpenAPIError) Body() []byte { + return e.body +} + +// Model returns the unpacked model of the error +func (e GenericOpenAPIError) Model() interface{} { + return e.model +} + +// format error message using title and detail when model implements rfc7807 +func formatErrorMessage(status string, v interface{}) string { + str := "" + metaValue := reflect.ValueOf(v).Elem() + + if metaValue.Kind() == reflect.Struct { + field := metaValue.FieldByName("Title") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s", field.Interface()) + } + + field = metaValue.FieldByName("Detail") + if field != (reflect.Value{}) { + str = fmt.Sprintf("%s (%s)", str, field.Interface()) + } + } + + return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) +} diff --git a/run.sh b/run.sh index c9a859b..9545c73 100755 --- a/run.sh +++ b/run.sh @@ -16,8 +16,13 @@ elif [[ "$API" == "isp-slate" ]]; then if [[ $ENV == "stage" ]]; then OPENAPI_SPEC="http://stage.api.istreamplanet.com/docs/slates/openapi.json" fi +elif [[ "$API" == "isp-lifecycle" ]]; then + OPENAPI_SPEC="https://api.istreamplanet.com/state/openapi-3.0.json" + if [[ $ENV == "stage" ]]; then + OPENAPI_SPEC="http://stage.api.istreamplanet.com/state/openapi-3.0.json" + fi else - >&2 echo "Unrecognized api $API. Valid options are: isp, isp-slate" + >&2 echo "Unrecognized api $API. Valid options are: isp, isp-slate, isp-lifecycle" >&2 echo "" exit 1 fi @@ -56,6 +61,7 @@ sed -i.bak -E 's/ example:"null"//g' ./${API}/*.go # Correct an error in the unit tests sed -i.bak -E 's,"github.com/istreamlabs/go-sdk/isp","github.com/istreamlabs/go-sdk/isp-slate",g' ./isp-slate/**/*.go +sed -i.bak -E 's,"github.com/istreamlabs/go-sdk/isp","github.com/istreamlabs/go-sdk/isp-lifecycle",g' ./isp-lifecycle/**/*.go # Cleanup all sed backups find . -name '*.bak' -delete