From 7387a920b0bf931f16955581e01b26c6a23f9042 Mon Sep 17 00:00:00 2001 From: jpkalbacher Date: Wed, 17 Dec 2025 12:01:51 -0800 Subject: [PATCH 1/3] regen slate-sdk --- isp-slate/.openapi-generator/FILES | 3 +- isp-slate/.openapi-generator/VERSION | 2 +- isp-slate/api_slates_for_organization.go | 93 +-- isp-slate/configuration.go | 4 +- ..._errors_inner.go => model_error_detail.go} | 75 ++- isp-slate/model_error_model.go | 36 +- isp-slate/model_slate.go | 6 +- isp-slate/model_slate2.go | 173 ------ isp-slate/model_slate_without_id.go | 6 +- .../test/api_slates_for_organization_test.go | 24 +- isp-slate/utils.go | 16 +- run.sh | 4 +- spec/isp-slate.yaml | 582 +++++------------- 13 files changed, 301 insertions(+), 723 deletions(-) rename isp-slate/{model_error_model_errors_inner.go => model_error_detail.go} (59%) delete mode 100644 isp-slate/model_slate2.go diff --git a/isp-slate/.openapi-generator/FILES b/isp-slate/.openapi-generator/FILES index 71af8de..4f37842 100644 --- a/isp-slate/.openapi-generator/FILES +++ b/isp-slate/.openapi-generator/FILES @@ -1,9 +1,8 @@ api_slates_for_organization.go configuration.go +model_error_detail.go model_error_model.go -model_error_model_errors_inner.go model_slate.go -model_slate2.go model_slate_without_id.go response.go test/api_slates_for_organization_test.go diff --git a/isp-slate/.openapi-generator/VERSION b/isp-slate/.openapi-generator/VERSION index cd802a1..09a6d30 100644 --- a/isp-slate/.openapi-generator/VERSION +++ b/isp-slate/.openapi-generator/VERSION @@ -1 +1 @@ -6.6.0 \ No newline at end of file +7.8.0 diff --git a/isp-slate/api_slates_for_organization.go b/isp-slate/api_slates_for_organization.go index 0f25f8f..cde2d11 100644 --- a/isp-slate/api_slates_for_organization.go +++ b/isp-slate/api_slates_for_organization.go @@ -19,19 +19,20 @@ import ( ) -type SlatesForOrganizationApi interface { +type SlatesForOrganizationAPI interface { /* DeleteOrgSlate Delete Slate - Delete a slate by id. + Delete Slate +Delete a slate by id. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param org Organization name @param slateId Unique identifier for this slate + @param org Organization name @return ApiDeleteOrgSlateRequest */ - DeleteOrgSlate(ctx context.Context, org string, slateId string) ApiDeleteOrgSlateRequest + DeleteOrgSlate(ctx context.Context, slateId string, org string) ApiDeleteOrgSlateRequest // DeleteOrgSlateExecute executes the request DeleteOrgSlateExecute(r ApiDeleteOrgSlateRequest) (*http.Response, error) @@ -39,14 +40,15 @@ type SlatesForOrganizationApi interface { /* GetOrgSlate Get Slate - Get a slate by id. + Get Slate +Get a slate by id. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param org Organization name @param slateId Unique identifier for this slate + @param org Organization name @return ApiGetOrgSlateRequest */ - GetOrgSlate(ctx context.Context, org string, slateId string) ApiGetOrgSlateRequest + GetOrgSlate(ctx context.Context, slateId string, org string) ApiGetOrgSlateRequest // GetOrgSlateExecute executes the request // @return Slate @@ -55,7 +57,7 @@ type SlatesForOrganizationApi interface { /* ListOrgSlates List Slates - Returns a list of all slates. + List all slates @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param org Organization name @@ -64,13 +66,14 @@ type SlatesForOrganizationApi interface { ListOrgSlates(ctx context.Context, org string) ApiListOrgSlatesRequest // ListOrgSlatesExecute executes the request - // @return []Slate2 - ListOrgSlatesExecute(r ApiListOrgSlatesRequest) ([]Slate2, *http.Response, error) + // @return []Slate + ListOrgSlatesExecute(r ApiListOrgSlatesRequest) ([]Slate, *http.Response, error) /* PutOrgSlate Create/Update Slate - Create or update a slate by id. The URL of the slate must already exist. + Create/Update Slate +Create or update a slate by id. The URL of the slate must already exist. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param slateId Unique identifier for this slate @@ -84,14 +87,14 @@ type SlatesForOrganizationApi interface { PutOrgSlateExecute(r ApiPutOrgSlateRequest) (*Slate, *http.Response, error) } -// SlatesForOrganizationApiService SlatesForOrganizationApi service -type SlatesForOrganizationApiService service +// SlatesForOrganizationAPIService SlatesForOrganizationAPI service +type SlatesForOrganizationAPIService service type ApiDeleteOrgSlateRequest struct { ctx context.Context - ApiService SlatesForOrganizationApi - org string + ApiService SlatesForOrganizationAPI slateId string + org string } func (r ApiDeleteOrgSlateRequest) Execute() (*http.Response, error) { @@ -101,38 +104,39 @@ func (r ApiDeleteOrgSlateRequest) Execute() (*http.Response, error) { /* DeleteOrgSlate Delete Slate +Delete Slate Delete a slate by id. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param org Organization name @param slateId Unique identifier for this slate + @param org Organization name @return ApiDeleteOrgSlateRequest */ -func (a *SlatesForOrganizationApiService) DeleteOrgSlate(ctx context.Context, org string, slateId string) ApiDeleteOrgSlateRequest { +func (a *SlatesForOrganizationAPIService) DeleteOrgSlate(ctx context.Context, slateId string, org string) ApiDeleteOrgSlateRequest { return ApiDeleteOrgSlateRequest{ ApiService: a, ctx: ctx, - org: org, slateId: slateId, + org: org, } } // Execute executes the request -func (a *SlatesForOrganizationApiService) DeleteOrgSlateExecute(r ApiDeleteOrgSlateRequest) (*http.Response, error) { +func (a *SlatesForOrganizationAPIService) DeleteOrgSlateExecute(r ApiDeleteOrgSlateRequest) (*http.Response, error) { var ( localVarHTTPMethod = http.MethodDelete localVarPostBody interface{} formFiles []formFile ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationApiService.DeleteOrgSlate") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationAPIService.DeleteOrgSlate") if err != nil { return nil, &GenericOpenAPIError{error: err.Error()} } localVarPath := localBasePath + "/v2/{org}/slates/{slate-id}" - localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterToString(r.org, "")), -1) localVarPath = strings.Replace(localVarPath, "{"+"slate-id"+"}", url.PathEscape(parameterToString(r.slateId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterToString(r.org, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -264,9 +268,9 @@ func (a *SlatesForOrganizationApiService) DeleteOrgSlateExecute(r ApiDeleteOrgSl type ApiGetOrgSlateRequest struct { ctx context.Context - ApiService SlatesForOrganizationApi - org string + ApiService SlatesForOrganizationAPI slateId string + org string } func (r ApiGetOrgSlateRequest) Execute() (*Slate, *http.Response, error) { @@ -276,25 +280,26 @@ func (r ApiGetOrgSlateRequest) Execute() (*Slate, *http.Response, error) { /* GetOrgSlate Get Slate +Get Slate Get a slate by id. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param org Organization name @param slateId Unique identifier for this slate + @param org Organization name @return ApiGetOrgSlateRequest */ -func (a *SlatesForOrganizationApiService) GetOrgSlate(ctx context.Context, org string, slateId string) ApiGetOrgSlateRequest { +func (a *SlatesForOrganizationAPIService) GetOrgSlate(ctx context.Context, slateId string, org string) ApiGetOrgSlateRequest { return ApiGetOrgSlateRequest{ ApiService: a, ctx: ctx, - org: org, slateId: slateId, + org: org, } } // Execute executes the request // @return Slate -func (a *SlatesForOrganizationApiService) GetOrgSlateExecute(r ApiGetOrgSlateRequest) (*Slate, *http.Response, error) { +func (a *SlatesForOrganizationAPIService) GetOrgSlateExecute(r ApiGetOrgSlateRequest) (*Slate, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} @@ -302,14 +307,14 @@ func (a *SlatesForOrganizationApiService) GetOrgSlateExecute(r ApiGetOrgSlateReq localVarReturnValue *Slate ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationApiService.GetOrgSlate") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationAPIService.GetOrgSlate") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } localVarPath := localBasePath + "/v2/{org}/slates/{slate-id}" - localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterToString(r.org, "")), -1) localVarPath = strings.Replace(localVarPath, "{"+"slate-id"+"}", url.PathEscape(parameterToString(r.slateId, "")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", url.PathEscape(parameterToString(r.org, "")), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -452,7 +457,7 @@ func (a *SlatesForOrganizationApiService) GetOrgSlateExecute(r ApiGetOrgSlateReq type ApiListOrgSlatesRequest struct { ctx context.Context - ApiService SlatesForOrganizationApi + ApiService SlatesForOrganizationAPI org string cursor *string limit *int32 @@ -470,20 +475,20 @@ func (r ApiListOrgSlatesRequest) Limit(limit int32) ApiListOrgSlatesRequest { return r } -func (r ApiListOrgSlatesRequest) Execute() ([]Slate2, *http.Response, error) { +func (r ApiListOrgSlatesRequest) Execute() ([]Slate, *http.Response, error) { return r.ApiService.ListOrgSlatesExecute(r) } /* ListOrgSlates List Slates -Returns a list of all slates. +List all slates @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @param org Organization name @return ApiListOrgSlatesRequest */ -func (a *SlatesForOrganizationApiService) ListOrgSlates(ctx context.Context, org string) ApiListOrgSlatesRequest { +func (a *SlatesForOrganizationAPIService) ListOrgSlates(ctx context.Context, org string) ApiListOrgSlatesRequest { return ApiListOrgSlatesRequest{ ApiService: a, ctx: ctx, @@ -492,16 +497,16 @@ func (a *SlatesForOrganizationApiService) ListOrgSlates(ctx context.Context, org } // Execute executes the request -// @return []Slate2 -func (a *SlatesForOrganizationApiService) ListOrgSlatesExecute(r ApiListOrgSlatesRequest) ([]Slate2, *http.Response, error) { +// @return []Slate +func (a *SlatesForOrganizationAPIService) ListOrgSlatesExecute(r ApiListOrgSlatesRequest) ([]Slate, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet localVarPostBody interface{} formFiles []formFile - localVarReturnValue []Slate2 + localVarReturnValue []Slate ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationApiService.ListOrgSlates") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationAPIService.ListOrgSlates") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } @@ -636,7 +641,7 @@ func (a *SlatesForOrganizationApiService) ListOrgSlatesExecute(r ApiListOrgSlate if err.Error() != "" { return localVarReturnValue, localVarHTTPResponse, err } - localVarReturnValue = items.([]Slate2) + localVarReturnValue = items.([]Slate) localVarHTTPResponse = resp } } @@ -646,7 +651,7 @@ func (a *SlatesForOrganizationApiService) ListOrgSlatesExecute(r ApiListOrgSlate type ApiPutOrgSlateRequest struct { ctx context.Context - ApiService SlatesForOrganizationApi + ApiService SlatesForOrganizationAPI slateId string org string slateWithoutID *SlateWithoutID @@ -664,6 +669,7 @@ func (r ApiPutOrgSlateRequest) Execute() (*Slate, *http.Response, error) { /* PutOrgSlate Create/Update Slate +Create/Update Slate Create or update a slate by id. The URL of the slate must already exist. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @@ -671,7 +677,7 @@ Create or update a slate by id. The URL of the slate must already exist. @param org Organization name @return ApiPutOrgSlateRequest */ -func (a *SlatesForOrganizationApiService) PutOrgSlate(ctx context.Context, slateId string, org string) ApiPutOrgSlateRequest { +func (a *SlatesForOrganizationAPIService) PutOrgSlate(ctx context.Context, slateId string, org string) ApiPutOrgSlateRequest { return ApiPutOrgSlateRequest{ ApiService: a, ctx: ctx, @@ -682,7 +688,7 @@ func (a *SlatesForOrganizationApiService) PutOrgSlate(ctx context.Context, slate // Execute executes the request // @return Slate -func (a *SlatesForOrganizationApiService) PutOrgSlateExecute(r ApiPutOrgSlateRequest) (*Slate, *http.Response, error) { +func (a *SlatesForOrganizationAPIService) PutOrgSlateExecute(r ApiPutOrgSlateRequest) (*Slate, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPut localVarPostBody interface{} @@ -690,7 +696,7 @@ func (a *SlatesForOrganizationApiService) PutOrgSlateExecute(r ApiPutOrgSlateReq localVarReturnValue *Slate ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationApiService.PutOrgSlate") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SlatesForOrganizationAPIService.PutOrgSlate") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } @@ -702,6 +708,9 @@ func (a *SlatesForOrganizationApiService) PutOrgSlateExecute(r ApiPutOrgSlateReq localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} + if r.slateWithoutID == nil { + return localVarReturnValue, nil, reportError("slateWithoutID is required and must be specified") + } // to determine the Content-Type header localVarHTTPContentTypes := []string{"application/json"} diff --git a/isp-slate/configuration.go b/isp-slate/configuration.go index 0e8adb5..0a3ae3c 100644 --- a/isp-slate/configuration.go +++ b/isp-slate/configuration.go @@ -92,8 +92,8 @@ func NewConfiguration() *Configuration { Debug: false, Servers: ServerConfigurations{ { - URL: "https://api.istreamplanet.com", - Description: "prod", + URL: "https://int.api.istreamplanet.com", + Description: "int", }, }, OperationServers: map[string]ServerConfigurations{ diff --git a/isp-slate/model_error_model_errors_inner.go b/isp-slate/model_error_detail.go similarity index 59% rename from isp-slate/model_error_model_errors_inner.go rename to isp-slate/model_error_detail.go index a69dfdc..0806128 100644 --- a/isp-slate/model_error_model_errors_inner.go +++ b/isp-slate/model_error_detail.go @@ -13,38 +13,37 @@ import ( "encoding/json" ) -// checks if the ErrorModelErrorsInner type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ErrorModelErrorsInner{} +// checks if the ErrorDetail type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ErrorDetail{} -// ErrorModelErrorsInner struct for ErrorModelErrorsInner -type ErrorModelErrorsInner struct { - // Where the error occured, e.g. 'body.items[3].tags' or 'path.thing-id' - Location *string `json:"location,omitempty" doc:"Where the error occured, e.g. 'body.items[3].tags' or 'path.thing-id'"` +// 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"` + Value interface{} `json:"value,omitempty"` } -// NewErrorModelErrorsInner instantiates a new ErrorModelErrorsInner object +// 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 NewErrorModelErrorsInner() *ErrorModelErrorsInner { - this := ErrorModelErrorsInner{} +func NewErrorDetail() *ErrorDetail { + this := ErrorDetail{} return &this } -// NewErrorModelErrorsInnerWithDefaults instantiates a new ErrorModelErrorsInner object +// 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 NewErrorModelErrorsInnerWithDefaults() *ErrorModelErrorsInner { - this := ErrorModelErrorsInner{} +func NewErrorDetailWithDefaults() *ErrorDetail { + this := ErrorDetail{} return &this } // GetLocation returns the Location field value if set, zero value otherwise. -func (o *ErrorModelErrorsInner) GetLocation() string { +func (o *ErrorDetail) GetLocation() string { if o == nil || IsNil(o.Location) { var ret string return ret @@ -54,7 +53,7 @@ func (o *ErrorModelErrorsInner) GetLocation() string { // 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 *ErrorModelErrorsInner) GetLocationOk() (*string, bool) { +func (o *ErrorDetail) GetLocationOk() (*string, bool) { if o == nil || IsNil(o.Location) { return nil, false } @@ -62,7 +61,7 @@ func (o *ErrorModelErrorsInner) GetLocationOk() (*string, bool) { } // HasLocation returns a boolean if a field has been set. -func (o *ErrorModelErrorsInner) HasLocation() bool { +func (o *ErrorDetail) HasLocation() bool { if o != nil && !IsNil(o.Location) { return true } @@ -71,12 +70,12 @@ func (o *ErrorModelErrorsInner) HasLocation() bool { } // SetLocation gets a reference to the given string and assigns it to the Location field. -func (o *ErrorModelErrorsInner) SetLocation(v string) { +func (o *ErrorDetail) SetLocation(v string) { o.Location = &v } // GetMessage returns the Message field value if set, zero value otherwise. -func (o *ErrorModelErrorsInner) GetMessage() string { +func (o *ErrorDetail) GetMessage() string { if o == nil || IsNil(o.Message) { var ret string return ret @@ -86,7 +85,7 @@ func (o *ErrorModelErrorsInner) GetMessage() string { // 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 *ErrorModelErrorsInner) GetMessageOk() (*string, bool) { +func (o *ErrorDetail) GetMessageOk() (*string, bool) { if o == nil || IsNil(o.Message) { return nil, false } @@ -94,7 +93,7 @@ func (o *ErrorModelErrorsInner) GetMessageOk() (*string, bool) { } // HasMessage returns a boolean if a field has been set. -func (o *ErrorModelErrorsInner) HasMessage() bool { +func (o *ErrorDetail) HasMessage() bool { if o != nil && !IsNil(o.Message) { return true } @@ -103,12 +102,12 @@ func (o *ErrorModelErrorsInner) HasMessage() bool { } // SetMessage gets a reference to the given string and assigns it to the Message field. -func (o *ErrorModelErrorsInner) SetMessage(v string) { +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 *ErrorModelErrorsInner) GetValue() interface{} { +func (o *ErrorDetail) GetValue() interface{} { if o == nil { var ret interface{} return ret @@ -119,7 +118,7 @@ func (o *ErrorModelErrorsInner) 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 *ErrorModelErrorsInner) GetValueOk() (*interface{}, bool) { +func (o *ErrorDetail) GetValueOk() (*interface{}, bool) { if o == nil || IsNil(o.Value) { return nil, false } @@ -127,7 +126,7 @@ func (o *ErrorModelErrorsInner) GetValueOk() (*interface{}, bool) { } // HasValue returns a boolean if a field has been set. -func (o *ErrorModelErrorsInner) HasValue() bool { +func (o *ErrorDetail) HasValue() bool { if o != nil && IsNil(o.Value) { return true } @@ -136,11 +135,11 @@ func (o *ErrorModelErrorsInner) HasValue() bool { } // SetValue gets a reference to the given interface{} and assigns it to the Value field. -func (o *ErrorModelErrorsInner) SetValue(v interface{}) { +func (o *ErrorDetail) SetValue(v interface{}) { o.Value = v } -func (o ErrorModelErrorsInner) MarshalJSON() ([]byte, error) { +func (o ErrorDetail) MarshalJSON() ([]byte, error) { toSerialize,err := o.ToMap() if err != nil { return []byte{}, err @@ -148,7 +147,7 @@ func (o ErrorModelErrorsInner) MarshalJSON() ([]byte, error) { return json.Marshal(toSerialize) } -func (o ErrorModelErrorsInner) ToMap() (map[string]interface{}, error) { +func (o ErrorDetail) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} if !IsNil(o.Location) { toSerialize["location"] = o.Location @@ -162,38 +161,38 @@ func (o ErrorModelErrorsInner) ToMap() (map[string]interface{}, error) { return toSerialize, nil } -type NullableErrorModelErrorsInner struct { - value *ErrorModelErrorsInner +type NullableErrorDetail struct { + value *ErrorDetail isSet bool } -func (v NullableErrorModelErrorsInner) Get() *ErrorModelErrorsInner { +func (v NullableErrorDetail) Get() *ErrorDetail { return v.value } -func (v *NullableErrorModelErrorsInner) Set(val *ErrorModelErrorsInner) { +func (v *NullableErrorDetail) Set(val *ErrorDetail) { v.value = val v.isSet = true } -func (v NullableErrorModelErrorsInner) IsSet() bool { +func (v NullableErrorDetail) IsSet() bool { return v.isSet } -func (v *NullableErrorModelErrorsInner) Unset() { +func (v *NullableErrorDetail) Unset() { v.value = nil v.isSet = false } -func NewNullableErrorModelErrorsInner(val *ErrorModelErrorsInner) *NullableErrorModelErrorsInner { - return &NullableErrorModelErrorsInner{value: val, isSet: true} +func NewNullableErrorDetail(val *ErrorDetail) *NullableErrorDetail { + return &NullableErrorDetail{value: val, isSet: true} } -func (v NullableErrorModelErrorsInner) MarshalJSON() ([]byte, error) { +func (v NullableErrorDetail) MarshalJSON() ([]byte, error) { return json.Marshal(v.value) } -func (v *NullableErrorModelErrorsInner) UnmarshalJSON(src []byte) error { +func (v *NullableErrorDetail) UnmarshalJSON(src []byte) error { v.isSet = true return json.Unmarshal(src, &v.value) } diff --git a/isp-slate/model_error_model.go b/isp-slate/model_error_model.go index b6aa622..eef3c59 100644 --- a/isp-slate/model_error_model.go +++ b/isp-slate/model_error_model.go @@ -18,18 +18,18 @@ var _ MappedNullable = &ErrorModel{} // ErrorModel struct for ErrorModel type ErrorModel 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"` + // 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 []ErrorModelErrorsInner `json:"errors,omitempty" doc:"Optional list of individual error details"` - // A URI reference that identifies the specific occurence of the problem. - Instance *string `json:"instance,omitempty" format:"uri" doc:"A URI reference that identifies the specific occurence of the problem."` + 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 *int32 `json:"status,omitempty" format:"int32" doc:"HTTP status code"` - // A short, human-readable summary of the problem type. This value should not change between occurances of the error. - Title *string `json:"title,omitempty" doc:"A short, human-readable summary of the problem type. This value should not change between occurances of the error."` + 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."` } @@ -120,9 +120,9 @@ func (o *ErrorModel) SetDetail(v string) { } // GetErrors returns the Errors field value if set, zero value otherwise. -func (o *ErrorModel) GetErrors() []ErrorModelErrorsInner { +func (o *ErrorModel) GetErrors() []ErrorDetail { if o == nil || IsNil(o.Errors) { - var ret []ErrorModelErrorsInner + var ret []ErrorDetail return ret } return o.Errors @@ -130,7 +130,7 @@ func (o *ErrorModel) GetErrors() []ErrorModelErrorsInner { // GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *ErrorModel) GetErrorsOk() ([]ErrorModelErrorsInner, bool) { +func (o *ErrorModel) GetErrorsOk() ([]ErrorDetail, bool) { if o == nil || IsNil(o.Errors) { return nil, false } @@ -146,8 +146,8 @@ func (o *ErrorModel) HasErrors() bool { return false } -// SetErrors gets a reference to the given []ErrorModelErrorsInner and assigns it to the Errors field. -func (o *ErrorModel) SetErrors(v []ErrorModelErrorsInner) { +// SetErrors gets a reference to the given []ErrorDetail and assigns it to the Errors field. +func (o *ErrorModel) SetErrors(v []ErrorDetail) { o.Errors = v } @@ -184,9 +184,9 @@ func (o *ErrorModel) SetInstance(v string) { } // GetStatus returns the Status field value if set, zero value otherwise. -func (o *ErrorModel) GetStatus() int32 { +func (o *ErrorModel) GetStatus() int64 { if o == nil || IsNil(o.Status) { - var ret int32 + var ret int64 return ret } return *o.Status @@ -194,7 +194,7 @@ func (o *ErrorModel) GetStatus() int32 { // 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() (*int32, bool) { +func (o *ErrorModel) GetStatusOk() (*int64, bool) { if o == nil || IsNil(o.Status) { return nil, false } @@ -210,8 +210,8 @@ func (o *ErrorModel) HasStatus() bool { return false } -// SetStatus gets a reference to the given int32 and assigns it to the Status field. -func (o *ErrorModel) SetStatus(v int32) { +// SetStatus gets a reference to the given int64 and assigns it to the Status field. +func (o *ErrorModel) SetStatus(v int64) { o.Status = &v } diff --git a/isp-slate/model_slate.go b/isp-slate/model_slate.go index 553045e..0002f2c 100644 --- a/isp-slate/model_slate.go +++ b/isp-slate/model_slate.go @@ -11,6 +11,8 @@ package isp import ( "encoding/json" + "bytes" + "fmt" ) // checks if the Slate type satisfies the MappedNullable interface at compile time @@ -18,8 +20,8 @@ var _ MappedNullable = &Slate{} // Slate struct for Slate type Slate 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"` + // 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 friendly slate description. Description string `json:"description" doc:"A friendly slate description."` // Unique identifier for this slate diff --git a/isp-slate/model_slate2.go b/isp-slate/model_slate2.go deleted file mode 100644 index ff8b43a..0000000 --- a/isp-slate/model_slate2.go +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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 ( - "encoding/json" -) - -// checks if the Slate2 type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Slate2{} - -// Slate2 struct for Slate2 -type Slate2 struct { - // A friendly slate description. - Description string `json:"description" doc:"A friendly slate description."` - // Unique identifier for this slate - Id string `json:"id" doc:"Unique identifier for this slate"` - // The url where the slate can be accessed. - Url string `json:"url" doc:"The url where the slate can be accessed."` -} - -// NewSlate2 instantiates a new Slate2 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 NewSlate2(description string, id string, url string) *Slate2 { - this := Slate2{} - this.Description = description - this.Id = id - this.Url = url - return &this -} - -// NewSlate2WithDefaults instantiates a new Slate2 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 NewSlate2WithDefaults() *Slate2 { - this := Slate2{} - return &this -} - -// GetDescription returns the Description field value -func (o *Slate2) GetDescription() string { - if o == nil { - var ret string - return ret - } - - return o.Description -} - -// GetDescriptionOk returns a tuple with the Description field value -// and a boolean to check if the value has been set. -func (o *Slate2) GetDescriptionOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Description, true -} - -// SetDescription sets field value -func (o *Slate2) SetDescription(v string) { - o.Description = v -} - -// GetId returns the Id field value -func (o *Slate2) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *Slate2) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *Slate2) SetId(v string) { - o.Id = v -} - -// GetUrl returns the Url field value -func (o *Slate2) GetUrl() string { - if o == nil { - var ret string - return ret - } - - return o.Url -} - -// GetUrlOk returns a tuple with the Url field value -// and a boolean to check if the value has been set. -func (o *Slate2) GetUrlOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Url, true -} - -// SetUrl sets field value -func (o *Slate2) SetUrl(v string) { - o.Url = v -} - -func (o Slate2) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Slate2) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["description"] = o.Description - toSerialize["id"] = o.Id - toSerialize["url"] = o.Url - return toSerialize, nil -} - -type NullableSlate2 struct { - value *Slate2 - isSet bool -} - -func (v NullableSlate2) Get() *Slate2 { - return v.value -} - -func (v *NullableSlate2) Set(val *Slate2) { - v.value = val - v.isSet = true -} - -func (v NullableSlate2) IsSet() bool { - return v.isSet -} - -func (v *NullableSlate2) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableSlate2(val *Slate2) *NullableSlate2 { - return &NullableSlate2{value: val, isSet: true} -} - -func (v NullableSlate2) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableSlate2) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/isp-slate/model_slate_without_id.go b/isp-slate/model_slate_without_id.go index b6b6bc6..3712f07 100644 --- a/isp-slate/model_slate_without_id.go +++ b/isp-slate/model_slate_without_id.go @@ -11,6 +11,8 @@ package isp import ( "encoding/json" + "bytes" + "fmt" ) // checks if the SlateWithoutID type satisfies the MappedNullable interface at compile time @@ -18,8 +20,8 @@ var _ MappedNullable = &SlateWithoutID{} // SlateWithoutID struct for SlateWithoutID type SlateWithoutID 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"` + // 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 friendly slate description. Description string `json:"description" doc:"A friendly slate description."` // The url where the slate can be accessed. Must be a valid URL diff --git a/isp-slate/test/api_slates_for_organization_test.go b/isp-slate/test/api_slates_for_organization_test.go index 3bfeafd..fc4ed47 100644 --- a/isp-slate/test/api_slates_for_organization_test.go +++ b/isp-slate/test/api_slates_for_organization_test.go @@ -1,7 +1,7 @@ /* iStreamPlanet Slate Management API -Testing SlatesForOrganizationApiService +Testing SlatesForOrganizationAPIService */ @@ -17,33 +17,33 @@ import ( openapiclient "github.com/istreamlabs/go-sdk/isp-slate" ) -func Test_isp_SlatesForOrganizationApiService(t *testing.T) { +func Test_isp_SlatesForOrganizationAPIService(t *testing.T) { configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) - t.Run("Test SlatesForOrganizationApiService DeleteOrgSlate", func(t *testing.T) { + t.Run("Test SlatesForOrganizationAPIService DeleteOrgSlate", func(t *testing.T) { t.Skip("skip test") // remove to run test - var org string var slateId string + var org string - httpRes, err := apiClient.SlatesForOrganizationApi.DeleteOrgSlate(context.Background(), org, slateId).Execute() + httpRes, err := apiClient.SlatesForOrganizationAPI.DeleteOrgSlate(context.Background(), slateId, org).Execute() require.Nil(t, err) assert.Equal(t, 200, httpRes.StatusCode) }) - t.Run("Test SlatesForOrganizationApiService GetOrgSlate", func(t *testing.T) { + t.Run("Test SlatesForOrganizationAPIService GetOrgSlate", func(t *testing.T) { t.Skip("skip test") // remove to run test - var org string var slateId string + var org string - resp, httpRes, err := apiClient.SlatesForOrganizationApi.GetOrgSlate(context.Background(), org, slateId).Execute() + resp, httpRes, err := apiClient.SlatesForOrganizationAPI.GetOrgSlate(context.Background(), slateId, org).Execute() require.Nil(t, err) require.NotNil(t, resp) @@ -51,13 +51,13 @@ func Test_isp_SlatesForOrganizationApiService(t *testing.T) { }) - t.Run("Test SlatesForOrganizationApiService ListOrgSlates", func(t *testing.T) { + t.Run("Test SlatesForOrganizationAPIService ListOrgSlates", func(t *testing.T) { t.Skip("skip test") // remove to run test var org string - resp, httpRes, err := apiClient.SlatesForOrganizationApi.ListOrgSlates(context.Background(), org).Execute() + resp, httpRes, err := apiClient.SlatesForOrganizationAPI.ListOrgSlates(context.Background(), org).Execute() require.Nil(t, err) require.NotNil(t, resp) @@ -65,14 +65,14 @@ func Test_isp_SlatesForOrganizationApiService(t *testing.T) { }) - t.Run("Test SlatesForOrganizationApiService PutOrgSlate", func(t *testing.T) { + t.Run("Test SlatesForOrganizationAPIService PutOrgSlate", func(t *testing.T) { t.Skip("skip test") // remove to run test var slateId string var org string - resp, httpRes, err := apiClient.SlatesForOrganizationApi.PutOrgSlate(context.Background(), slateId, org).Execute() + resp, httpRes, err := apiClient.SlatesForOrganizationAPI.PutOrgSlate(context.Background(), slateId, org).Execute() require.Nil(t, err) require.NotNil(t, resp) diff --git a/isp-slate/utils.go b/isp-slate/utils.go index d496fde..a8d5eb6 100644 --- a/isp-slate/utils.go +++ b/isp-slate/utils.go @@ -10,7 +10,9 @@ package isp import ( + "bytes" "encoding/json" + "fmt" "reflect" "time" ) @@ -319,7 +321,7 @@ func NewNullableTime(val *time.Time) *NullableTime { } func (v NullableTime) MarshalJSON() ([]byte, error) { - return v.value.MarshalJSON() + return json.Marshal(v.value) } func (v *NullableTime) UnmarshalJSON(src []byte) error { @@ -344,3 +346,15 @@ func IsNil(i interface{}) bool { type MappedNullable interface { ToMap() (map[string]interface{}, error) } + +// A wrapper for strict JSON decoding +func newStrictDecoder(data []byte) *json.Decoder { + dec := json.NewDecoder(bytes.NewBuffer(data)) + dec.DisallowUnknownFields() + return dec +} + +// Prevent trying to import "fmt" +func reportError(format string, a ...interface{}) error { + return fmt.Errorf(format, a...) +} \ No newline at end of file diff --git a/run.sh b/run.sh index c804cbd..f5404a3 100755 --- a/run.sh +++ b/run.sh @@ -1,6 +1,6 @@ #!/bin/bash -GENERATOR_IMAGE="openapitools/openapi-generator-cli:v6.6.0" +GENERATOR_IMAGE="openapitools/openapi-generator-cli:v7.8.0" API="${1-isp}" ENV="${2-prod}" @@ -15,6 +15,8 @@ elif [[ "$API" == "isp-slate" ]]; then OPENAPI_SPEC="https://api.istreamplanet.com/docs/slates/openapi.json" if [[ $ENV == "stage" ]]; then OPENAPI_SPEC="https://stage.api.istreamplanet.com/docs/slates/openapi.json" + elif [[ $ENV == "int" ]]; then + OPENAPI_SPEC="https://int.api.istreamplanet.com/docs/slates/openapi.json" fi elif [[ "$API" == "isp-lifecycle" ]]; then OPENAPI_SPEC="https://api.istreamplanet.com/state/openapi-3.0.json" diff --git a/spec/isp-slate.yaml b/spec/isp-slate.yaml index e6341ae..67be15c 100644 --- a/spec/isp-slate.yaml +++ b/spec/isp-slate.yaml @@ -1,185 +1,188 @@ components: schemas: - ErrorModel: + ErrorDetail: + additionalProperties: false + properties: + location: + description: Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id' + type: string + message: + description: Error message text + type: string + value: + description: The value at the given location type: object + ErrorModel: + additionalProperties: false properties: $schema: - type: string - description: An optional URL to a JSON Schema document describing this resource + description: A URL to the JSON Schema for this object. + examples: + - https://int.api.istreamplanet.com/docs/slates/schemas/ErrorModel.json format: uri - detail: + readOnly: true type: string + detail: description: A human-readable explanation specific to this occurrence of the problem. - example: Property foo is required but is missing. + examples: + - Property foo is required but is missing. + type: string errors: - type: array description: Optional list of individual error details items: - type: object - properties: - location: - type: string - description: Where the error occured, e.g. 'body.items[3].tags' or 'path.thing-id' - message: - type: string - description: Error message text - value: - description: The value at the given location - additionalProperties: false + $ref: '#/components/schemas/ErrorDetail' + type: + - array + - "null" instance: - type: string - description: A URI reference that identifies the specific occurence of the problem. + description: A URI reference that identifies the specific occurrence of the problem. + examples: + - https://example.com/error-log/abc123 format: uri - example: https://example.com/error-log/abc123 + type: string status: - type: integer description: HTTP status code - format: int32 - example: 400 + examples: + - 400 + format: int64 + type: integer title: + description: A short, human-readable summary of the problem type. This value should not change between occurrences of the error. + examples: + - Bad Request type: string - description: A short, human-readable summary of the problem type. This value should not change between occurances of the error. - example: Bad Request type: - type: string + default: about:blank description: A URI reference to human-readable documentation for the error. + examples: + - https://example.com/errors/example format: uri - default: about:blank - example: https://example.com/errors/example - additionalProperties: false - Slate: + type: string type: object + Slate: + additionalProperties: false properties: $schema: - type: string - description: An optional URL to a JSON Schema document describing this resource + description: A URL to the JSON Schema for this object. + examples: + - https://int.api.istreamplanet.com/docs/slates/schemas/Slate.json format: uri - description: + readOnly: true type: string - description: A friendly slate description. - example: slate for event 1 - id: - type: string - description: Unique identifier for this slate - example: slate-id-1 - url: - type: string - description: The url where the slate can be accessed. - example: https://example.com/path/to/image.jpg - additionalProperties: false - required: - - id - - description - - url - Slate2: - type: object - properties: description: - type: string description: A friendly slate description. - example: slate for event 1 - id: + examples: + - slate for event 1 type: string + id: description: Unique identifier for this slate - example: slate-id-1 - url: + examples: + - slate-id-1 type: string + url: description: The url where the slate can be accessed. - example: https://example.com/path/to/image.jpg - additionalProperties: false + examples: + - https://example.com/path/to/image.jpg + type: string required: - id - description - url - SlateList: - type: array - items: - $ref: '#/components/schemas/Slate2' - SlateWithoutID: type: object + SlateWithoutID: + additionalProperties: false properties: $schema: - type: string - description: An optional URL to a JSON Schema document describing this resource + description: A URL to the JSON Schema for this object. + examples: + - https://int.api.istreamplanet.com/docs/slates/schemas/SlateWithoutID.json format: uri - description: + readOnly: true type: string + description: description: A friendly slate description. - example: slate for event 1 - url: + examples: + - slate for event 1 type: string + url: description: The url where the slate can be accessed. Must be a valid URL - example: https://example.com/path/to/image.jpg - additionalProperties: false + examples: + - https://example.com/path/to/image.jpg + type: string required: - description - url + type: object securitySchemes: authcode: - type: oauth2 flows: authorizationCode: - authorizationUrl: https://istreamplanet.auth0.com/authorize - tokenUrl: https://istreamplanet.auth0.com/oauth/token - m2m: + scopes: null + tokenUrl: "" type: oauth2 + m2m: flows: clientCredentials: - tokenUrl: https://istreamplanet.auth0.com/oauth/token + scopes: null + tokenUrl: "" + type: oauth2 info: contact: + email: support@istreamplanet.com name: Slate Management url: https://istreamplanet.com/contact/ - email: support@istreamplanet.com title: iStreamPlanet Slate Management API version: 1.0.0 -openapi: 3.0.3 +openapi: 3.1.0 paths: /v2/{org}/slates: get: - description: Returns a list of all slates. + description: List all slates operationId: list-org-slates parameters: - - name: org - description: Organization name + - description: Organization name in: path + name: org required: true schema: - type: string description: Organization name - - name: cursor - description: Current page cursor + type: string + - description: Current page cursor + explode: false in: query + name: cursor schema: - type: string description: Current page cursor + type: string + - description: Number of items to return explode: false - - name: limit - description: Number of items to return in: query + name: limit schema: - type: integer + default: 100 description: Number of items to return format: int32 - default: 100 - minimum: 1 maximum: 100 - explode: false + minimum: 1 + type: integer responses: "200": content: application/json: schema: - $ref: '#/components/schemas/SlateList' + items: + $ref: '#/components/schemas/Slate' + type: + - array + - "null" description: OK headers: Content-Type: - description: Content-Type schema: type: string Link: - description: Link schema: + description: HTTP links for pagination type: string "400": content: @@ -187,113 +190,62 @@ paths: schema: $ref: '#/components/schemas/ErrorModel' description: Bad Request - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "401": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unauthorized - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "422": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unprocessable Entity - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "499": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' - description: "" - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "500": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Internal Server Error - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "503": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Service Unavailable - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string summary: List Slates tags: - Slates for Organization /v2/{org}/slates/{slate-id}: delete: - description: Delete a slate by id. + description: |- + Delete Slate + Delete a slate by id. operationId: delete-org-slate parameters: - - name: org - description: Organization name + - description: Unique identifier for this slate + example: slate-id-1 in: path + name: slate-id required: true schema: + description: Unique identifier for this slate + examples: + - slate-id-1 type: string - description: Organization name - - name: slate-id - description: Unique identifier for this slate + - description: Organization name in: path + name: org required: true schema: + description: Organization name type: string - description: Unique identifier for this slate - example: slate-id-1 responses: "204": description: No Content @@ -303,142 +255,73 @@ paths: schema: $ref: '#/components/schemas/ErrorModel' description: Bad Request - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "401": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unauthorized - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "409": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Conflict - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "412": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Precondition Failed - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "422": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unprocessable Entity - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "499": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' - description: "" - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "500": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Internal Server Error - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "503": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Service Unavailable - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string summary: Delete Slate tags: - Slates for Organization get: - description: Get a slate by id. + description: |- + Get Slate + Get a slate by id. operationId: get-org-slate parameters: - - name: org - description: Organization name + - description: Unique identifier for this slate + example: slate-id-1 in: path + name: slate-id required: true schema: + description: Unique identifier for this slate + examples: + - slate-id-1 type: string - description: Organization name - - name: slate-id - description: Unique identifier for this slate + - description: Organization name in: path + name: org required: true schema: + description: Organization name type: string - description: Unique identifier for this slate - example: slate-id-1 responses: "200": content: @@ -448,18 +331,15 @@ paths: description: OK headers: Content-Type: - description: Content-Type schema: type: string Link: - description: Link schema: type: string "304": description: Not Modified headers: Managed-By: - description: Managed-By schema: type: string "400": @@ -468,146 +348,95 @@ paths: schema: $ref: '#/components/schemas/ErrorModel' description: Bad Request - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "401": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unauthorized - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "404": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Not Found - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "422": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unprocessable Entity - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "499": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' - description: "" - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "500": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Internal Server Error - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "503": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Service Unavailable - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string summary: Get Slate tags: - Slates for Organization put: - description: Create or update a slate by id. The URL of the slate must already exist. + description: |- + Create/Update Slate + Create or update a slate by id. The URL of the slate must already exist. operationId: put-org-slate parameters: - - name: slate-id - description: Unique identifier for this slate + - description: Unique identifier for this slate + example: slate-id-1 in: path + name: slate-id required: true schema: - type: string description: Unique identifier for this slate - example: slate-id-1 - - name: org - description: Organization name + examples: + - slate-id-1 + type: string + - description: Organization name in: path + name: org required: true schema: - type: string description: Organization name + type: string requestBody: content: application/json: schema: $ref: '#/components/schemas/SlateWithoutID' + description: Slate Request Body + required: true responses: - "201": + "200": content: application/json: schema: $ref: '#/components/schemas/Slate' + description: OK + headers: + Content-Type: + schema: + type: string + Link: + schema: + type: string + "201": description: Created headers: Content-Type: - description: Content-Type schema: type: string Link: - description: Link schema: type: string "204": @@ -620,180 +449,71 @@ paths: schema: $ref: '#/components/schemas/ErrorModel' description: Bad Request - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "401": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unauthorized - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "403": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Forbidden - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "404": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Not Found - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "408": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Request Timeout - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "409": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Conflict - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "412": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Precondition Failed - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "413": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Request Entity Too Large - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "422": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Unprocessable Entity - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "499": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' - description: "" - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "500": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Internal Server Error - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string "503": content: application/problem+json: schema: $ref: '#/components/schemas/ErrorModel' description: Service Unavailable - headers: - Content-Type: - description: Content-Type - schema: - type: string - Link: - description: Link - schema: - type: string summary: Create/Update Slate tags: - Slates for Organization @@ -801,8 +521,8 @@ security: - authcode: [] - m2m: [] servers: - - url: https://api.istreamplanet.com - description: prod + - description: int + url: https://int.api.istreamplanet.com tags: - name: Slates for Organization - name: Slate Operations @@ -814,6 +534,10 @@ x-cli-config: example: isp exclude: true params: - audience: https://platform.dtc.istreamplanet.net/{org} - client_id: 9joico3xz7UKKSn3HiCcI2RJWkqs1INQ - scopes: offline_access + audience: https://platform.dev.dtc.istreamplanet.net/{org} + authorize_url: "" + client_id: TMEt4ihzsGtgHd335WcFXjp5mJ1lS6qP + redirect_url: http://auth.rest.sh:8484 + scopes: offline_access,Groups + state: non-empty + token_url: "" From c5e527bd864e563c4fa91e3aa947fc82e87b9527 Mon Sep 17 00:00:00 2001 From: jpkalbacher Date: Wed, 17 Dec 2025 12:18:19 -0800 Subject: [PATCH 2/3] testing --- go.mod | 16 +- go.sum | 48 +- isp-slate/client.go | 667 ---------------------------- isp-slate/convenience.go | 250 ----------- isp-slate/model_slate.go | 2 - isp-slate/model_slate_without_id.go | 2 - run.sh | 27 +- spec/isp-slate.yaml | 7 + 8 files changed, 86 insertions(+), 933 deletions(-) delete mode 100644 isp-slate/client.go delete mode 100644 isp-slate/convenience.go diff --git a/go.mod b/go.mod index 04d6012..84aefb5 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,19 @@ module github.com/istreamlabs/go-sdk -go 1.13 +go 1.24.0 require ( - github.com/stretchr/testify v1.8.4 // indirect + github.com/stretchr/testify v1.8.4 github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9 - golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 + golang.org/x/oauth2 v0.34.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/net v0.48.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect ) diff --git a/go.sum b/go.sum index cada52f..a221f48 100644 --- a/go.sum +++ b/go.sum @@ -1,31 +1,65 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9 h1:/Bsw4C+DEdqPjt8vAqaC9LAqpAQnaCQQqmolqq3S1T4= github.com/tent/http-link-go v0.0.0-20130702225549-ac974c61c2f9/go.mod h1:RHkNRtSLfOK7qBTHaeSX1D6BNpI3qw7NTxsmNr4RvN8= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= +golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54= +launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM= diff --git a/isp-slate/client.go b/isp-slate/client.go deleted file mode 100644 index 3022202..0000000 --- a/isp-slate/client.go +++ /dev/null @@ -1,667 +0,0 @@ -/* - * 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 - - SlatesForOrganizationApi SlatesForOrganizationApi -} - -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.SlatesForOrganizationApi = (*SlatesForOrganizationApiService)(&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-slate/convenience.go b/isp-slate/convenience.go deleted file mode 100644 index f326e87..0000000 --- a/isp-slate/convenience.go +++ /dev/null @@ -1,250 +0,0 @@ -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-slate/model_slate.go b/isp-slate/model_slate.go index 0002f2c..6c6d044 100644 --- a/isp-slate/model_slate.go +++ b/isp-slate/model_slate.go @@ -11,8 +11,6 @@ package isp import ( "encoding/json" - "bytes" - "fmt" ) // checks if the Slate type satisfies the MappedNullable interface at compile time diff --git a/isp-slate/model_slate_without_id.go b/isp-slate/model_slate_without_id.go index 3712f07..838ec34 100644 --- a/isp-slate/model_slate_without_id.go +++ b/isp-slate/model_slate_without_id.go @@ -11,8 +11,6 @@ package isp import ( "encoding/json" - "bytes" - "fmt" ) // checks if the SlateWithoutID type satisfies the MappedNullable interface at compile time diff --git a/run.sh b/run.sh index f5404a3..ebe19c7 100755 --- a/run.sh +++ b/run.sh @@ -46,14 +46,28 @@ else fi +# Force correct Go types for isp-slate path params when using OAS 3.1 +if [[ "$API" == "isp-slate" ]]; then + # Ensure org and slate-id are generated as string (not interface{}) + yq -i ' + (.paths."/v2/{org}/slates".get.parameters[] | select(.name=="org").schema."x-go-type") = "string" | + (.paths."/v2/{org}/slates/{slate-id}".get.parameters[] | select(.name=="org").schema."x-go-type") = "string" | + (.paths."/v2/{org}/slates/{slate-id}".get.parameters[] | select(.name=="slate-id").schema."x-go-type") = "string" | + (.paths."/v2/{org}/slates/{slate-id}".put.parameters[] | select(.name=="org").schema."x-go-type") = "string" | + (.paths."/v2/{org}/slates/{slate-id}".put.parameters[] | select(.name=="slate-id").schema."x-go-type") = "string" | + (.paths."/v2/{org}/slates/{slate-id}".delete.parameters[] | select(.name=="org").schema."x-go-type") = "string" | + (.paths."/v2/{org}/slates/{slate-id}".delete.parameters[] | select(.name=="slate-id").schema."x-go-type") = "string" + ' "$SCRIPT_DIR/$SPEC_FILE" +fi + # Recreate directory to ensure clean build rm -rf "${API}" mkdir "${API}" # Copy required files to directory cp ./prerequisites/.openapi-generator-ignore ./${API}/.openapi-generator-ignore -cp ./prerequisites/convenience._go ./${API}/convenience.go -cp ./prerequisites/${API}_client._go ./${API}/client.go +# cp ./prerequisites/convenience._go ./${API}/convenience.go +# cp ./prerequisites/${API}_client._go ./${API}/client.go # Generate the SDK docker run --rm \ @@ -74,6 +88,15 @@ sed -i.bak -E 's/@@@@"([^"]+)"@@@@/\1/g' ./${API}/*.go # got to remove those. sed -i.bak -E 's/ example:"null"//g' ./${API}/*.go +# Remove duplicate helpers added by newer generator versions (keep utils.go versions) +# - Delete newStrictDecoder and reportError from client.go +sed -i.bak -E '/^\/\/ A wrapper for strict JSON decoding/,/^}/d' ./${API}/client.go +sed -i.bak -E '/^\/\/ Prevent trying to import "fmt"/,/^}/d' ./${API}/client.go + +# Clean up unused imports that appear in some simple models +sed -i.bak -E '/^\t"bytes"$/d' ./${API}/model_*.go +sed -i.bak -E '/^\t"fmt"$/d' ./${API}/model_*.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 diff --git a/spec/isp-slate.yaml b/spec/isp-slate.yaml index 67be15c..3ddfce0 100644 --- a/spec/isp-slate.yaml +++ b/spec/isp-slate.yaml @@ -147,6 +147,7 @@ paths: schema: description: Organization name type: string + x-go-type: string - description: Current page cursor explode: false in: query @@ -239,6 +240,7 @@ paths: examples: - slate-id-1 type: string + x-go-type: string - description: Organization name in: path name: org @@ -246,6 +248,7 @@ paths: schema: description: Organization name type: string + x-go-type: string responses: "204": description: No Content @@ -315,6 +318,7 @@ paths: examples: - slate-id-1 type: string + x-go-type: string - description: Organization name in: path name: org @@ -322,6 +326,7 @@ paths: schema: description: Organization name type: string + x-go-type: string responses: "200": content: @@ -402,6 +407,7 @@ paths: examples: - slate-id-1 type: string + x-go-type: string - description: Organization name in: path name: org @@ -409,6 +415,7 @@ paths: schema: description: Organization name type: string + x-go-type: string requestBody: content: application/json: From 57f640267761641f5542551430158c40229757d8 Mon Sep 17 00:00:00 2001 From: jpkalbacher Date: Wed, 17 Dec 2025 12:26:07 -0800 Subject: [PATCH 3/3] test again --- isp-slate/.gitignore | 24 + isp-slate/.openapi-generator-ignore | 20 +- isp-slate/.openapi-generator/FILES | 13 + isp-slate/.travis.yml | 8 + isp-slate/README.md | 175 ++++++ isp-slate/api/openapi.yaml | 556 +++++++++++++++++ isp-slate/client.go | 663 +++++++++++++++++++++ isp-slate/docs/ErrorDetail.md | 118 ++++ isp-slate/docs/ErrorModel.md | 212 +++++++ isp-slate/docs/Slate.md | 119 ++++ isp-slate/docs/SlateWithoutID.md | 98 +++ isp-slate/docs/SlatesForOrganizationAPI.md | 305 ++++++++++ isp-slate/git_push.sh | 57 ++ isp-slate/go.mod | 7 + isp-slate/go.sum | 13 + prerequisites/.openapi-generator-ignore | 20 +- 16 files changed, 2388 insertions(+), 20 deletions(-) create mode 100644 isp-slate/.gitignore create mode 100644 isp-slate/.travis.yml create mode 100644 isp-slate/README.md create mode 100644 isp-slate/api/openapi.yaml create mode 100644 isp-slate/client.go create mode 100644 isp-slate/docs/ErrorDetail.md create mode 100644 isp-slate/docs/ErrorModel.md create mode 100644 isp-slate/docs/Slate.md create mode 100644 isp-slate/docs/SlateWithoutID.md create mode 100644 isp-slate/docs/SlatesForOrganizationAPI.md create mode 100644 isp-slate/git_push.sh create mode 100644 isp-slate/go.mod create mode 100644 isp-slate/go.sum diff --git a/isp-slate/.gitignore b/isp-slate/.gitignore new file mode 100644 index 0000000..daf913b --- /dev/null +++ b/isp-slate/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/isp-slate/.openapi-generator-ignore b/isp-slate/.openapi-generator-ignore index 6db43e9..42251ca 100644 --- a/isp-slate/.openapi-generator-ignore +++ b/isp-slate/.openapi-generator-ignore @@ -22,14 +22,14 @@ # 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 +# api/* +# docs/* +# .gitignore +# .travis.yml +# README.md +# go.mod +# go.sum +# git_push.sh -convenience.go -client.go +# convenience.go +# client.go diff --git a/isp-slate/.openapi-generator/FILES b/isp-slate/.openapi-generator/FILES index 4f37842..f1c9676 100644 --- a/isp-slate/.openapi-generator/FILES +++ b/isp-slate/.openapi-generator/FILES @@ -1,5 +1,18 @@ +.gitignore +.travis.yml +README.md +api/openapi.yaml api_slates_for_organization.go +client.go configuration.go +docs/ErrorDetail.md +docs/ErrorModel.md +docs/Slate.md +docs/SlateWithoutID.md +docs/SlatesForOrganizationAPI.md +git_push.sh +go.mod +go.sum model_error_detail.go model_error_model.go model_slate.go diff --git a/isp-slate/.travis.yml b/isp-slate/.travis.yml new file mode 100644 index 0000000..f5cb2ce --- /dev/null +++ b/isp-slate/.travis.yml @@ -0,0 +1,8 @@ +language: go + +install: + - go get -d -v . + +script: + - go build -v ./ + diff --git a/isp-slate/README.md b/isp-slate/README.md new file mode 100644 index 0000000..4b11b49 --- /dev/null +++ b/isp-slate/README.md @@ -0,0 +1,175 @@ +# Go API client for isp + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +## Overview +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. + +- API version: 1.0.0 +- Package version: 1.0.0 +- Generator version: 7.8.0 +- Build package: org.openapitools.codegen.languages.GoClientCodegen +For more information, please visit [https://istreamplanet.com/contact/](https://istreamplanet.com/contact/) + +## Installation + +Install the following dependencies: + +```sh +go get github.com/stretchr/testify/assert +go get golang.org/x/oauth2 +go get golang.org/x/net/context +``` + +Put the package under your project folder and add the following in import: + +```go +import isp "github.com/istreamlabs/go-sdk/isp" +``` + +To use a proxy, set the environment variable `HTTP_PROXY`: + +```go +os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") +``` + +## Configuration of Server URL + +Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. + +### Select Server Configuration + +For using other server than the one defined on index 0 set context value `isp.ContextServerIndex` of type `int`. + +```go +ctx := context.WithValue(context.Background(), isp.ContextServerIndex, 1) +``` + +### Templated Server URL + +Templated server URL is formatted using default variables from configuration or from context value `isp.ContextServerVariables` of type `map[string]string`. + +```go +ctx := context.WithValue(context.Background(), isp.ContextServerVariables, map[string]string{ + "basePath": "v2", +}) +``` + +Note, enum values are always validated and all unused variables are silently ignored. + +### URLs Configuration per Operation + +Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. +An operation is uniquely identified by `"{classname}Service.{nickname}"` string. +Similar rules for overriding default operation server index and variables applies by using `isp.ContextOperationServerIndices` and `isp.ContextOperationServerVariables` context maps. + +```go +ctx := context.WithValue(context.Background(), isp.ContextOperationServerIndices, map[string]int{ + "{classname}Service.{nickname}": 2, +}) +ctx = context.WithValue(context.Background(), isp.ContextOperationServerVariables, map[string]map[string]string{ + "{classname}Service.{nickname}": { + "port": "8443", + }, +}) +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://int.api.istreamplanet.com* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*SlatesForOrganizationAPI* | [**DeleteOrgSlate**](docs/SlatesForOrganizationAPI.md#deleteorgslate) | **Delete** /v2/{org}/slates/{slate-id} | Delete Slate +*SlatesForOrganizationAPI* | [**GetOrgSlate**](docs/SlatesForOrganizationAPI.md#getorgslate) | **Get** /v2/{org}/slates/{slate-id} | Get Slate +*SlatesForOrganizationAPI* | [**ListOrgSlates**](docs/SlatesForOrganizationAPI.md#listorgslates) | **Get** /v2/{org}/slates | List Slates +*SlatesForOrganizationAPI* | [**PutOrgSlate**](docs/SlatesForOrganizationAPI.md#putorgslate) | **Put** /v2/{org}/slates/{slate-id} | Create/Update Slate + + +## Documentation For Models + + - [ErrorDetail](docs/ErrorDetail.md) + - [ErrorModel](docs/ErrorModel.md) + - [Slate](docs/Slate.md) + - [SlateWithoutID](docs/SlateWithoutID.md) + + +## Documentation For Authorization + + +Authentication schemes defined for the API: +### authcode + + +- **Type**: OAuth +- **Flow**: accessCode +- **Authorization URL**: +- **Scopes**: N/A + +Example + +```go +auth := context.WithValue(context.Background(), isp.ContextAccessToken, "ACCESSTOKENSTRING") +r, err := client.Service.Operation(auth, args) +``` + +Or via OAuth2 module to automatically refresh tokens and perform user authentication. + +```go +import "golang.org/x/oauth2" + +/* Perform OAuth2 round trip request and obtain a token */ + +tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) +auth := context.WithValue(oauth2.NoContext, isp.ContextOAuth2, tokenSource) +r, err := client.Service.Operation(auth, args) +``` + +### m2m + + +- **Type**: OAuth +- **Flow**: application +- **Authorization URL**: +- **Scopes**: N/A + +Example + +```go +auth := context.WithValue(context.Background(), isp.ContextAccessToken, "ACCESSTOKENSTRING") +r, err := client.Service.Operation(auth, args) +``` + +Or via OAuth2 module to automatically refresh tokens and perform user authentication. + +```go +import "golang.org/x/oauth2" + +/* Perform OAuth2 round trip request and obtain a token */ + +tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) +auth := context.WithValue(oauth2.NoContext, isp.ContextOAuth2, tokenSource) +r, err := client.Service.Operation(auth, args) +``` + + +## Documentation for Utility Methods + +Due to the fact that model structure members are all pointers, this package contains +a number of utility functions to easily obtain pointers to values of basic types. +Each of these functions takes a value of the given basic type and returns a pointer to it: + +* `PtrBool` +* `PtrInt` +* `PtrInt32` +* `PtrInt64` +* `PtrFloat` +* `PtrFloat32` +* `PtrFloat64` +* `PtrString` +* `PtrTime` + +## Author + +support@istreamplanet.com + diff --git a/isp-slate/api/openapi.yaml b/isp-slate/api/openapi.yaml new file mode 100644 index 0000000..e31bd18 --- /dev/null +++ b/isp-slate/api/openapi.yaml @@ -0,0 +1,556 @@ +openapi: 3.1.0 +info: + contact: + email: support@istreamplanet.com + name: Slate Management + url: https://istreamplanet.com/contact/ + title: iStreamPlanet Slate Management API + version: 1.0.0 +servers: +- description: int + url: https://int.api.istreamplanet.com +security: +- authcode: [] +- m2m: [] +tags: +- name: Slates for Organization +- name: Slate Operations +paths: + /v2/{org}/slates: + get: + description: List all slates + operationId: list-org-slates + parameters: + - description: Organization name + explode: false + in: path + name: org + required: true + schema: + description: Organization name + type: string + x-go-type: string + style: simple + - description: Current page cursor + explode: false + in: query + name: cursor + required: false + schema: + description: Current page cursor + type: string + style: form + - description: Number of items to return + explode: false + in: query + name: limit + required: false + schema: + default: 100 + description: Number of items to return + format: int32 + maximum: 100 + minimum: 1 + type: integer + style: form + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/Slate' + type: array + description: OK + headers: + Content-Type: + explode: false + schema: + type: string + style: simple + Link: + explode: false + schema: + description: HTTP links for pagination + type: string + style: simple + "400": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Bad Request + "401": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unauthorized + "422": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unprocessable Entity + "499": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + "500": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Internal Server Error + "503": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Service Unavailable + summary: List Slates + tags: + - Slates for Organization + /v2/{org}/slates/{slate-id}: + delete: + description: |- + Delete Slate + Delete a slate by id. + operationId: delete-org-slate + parameters: + - description: Unique identifier for this slate + example: slate-id-1 + explode: false + in: path + name: slate-id + required: true + schema: + description: Unique identifier for this slate + type: string + x-go-type: string + style: simple + - description: Organization name + explode: false + in: path + name: org + required: true + schema: + description: Organization name + type: string + x-go-type: string + style: simple + responses: + "204": + description: No Content + "400": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Bad Request + "401": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unauthorized + "409": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Conflict + "412": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Precondition Failed + "422": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unprocessable Entity + "499": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + "500": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Internal Server Error + "503": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Service Unavailable + summary: Delete Slate + tags: + - Slates for Organization + get: + description: |- + Get Slate + Get a slate by id. + operationId: get-org-slate + parameters: + - description: Unique identifier for this slate + example: slate-id-1 + explode: false + in: path + name: slate-id + required: true + schema: + description: Unique identifier for this slate + type: string + x-go-type: string + style: simple + - description: Organization name + explode: false + in: path + name: org + required: true + schema: + description: Organization name + type: string + x-go-type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Slate' + description: OK + headers: + Content-Type: + explode: false + schema: + type: string + style: simple + Link: + explode: false + schema: + type: string + style: simple + "304": + description: Not Modified + headers: + Managed-By: + explode: false + schema: + type: string + style: simple + "400": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Bad Request + "401": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unauthorized + "404": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Not Found + "422": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unprocessable Entity + "499": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + "500": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Internal Server Error + "503": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Service Unavailable + summary: Get Slate + tags: + - Slates for Organization + put: + description: |- + Create/Update Slate + Create or update a slate by id. The URL of the slate must already exist. + operationId: put-org-slate + parameters: + - description: Unique identifier for this slate + example: slate-id-1 + explode: false + in: path + name: slate-id + required: true + schema: + description: Unique identifier for this slate + type: string + x-go-type: string + style: simple + - description: Organization name + explode: false + in: path + name: org + required: true + schema: + description: Organization name + type: string + x-go-type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SlateWithoutID' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Slate' + description: OK + headers: + Content-Type: + explode: false + schema: + type: string + style: simple + Link: + explode: false + schema: + type: string + style: simple + "201": + description: Created + headers: + Content-Type: + explode: false + schema: + type: string + style: simple + Link: + explode: false + schema: + type: string + style: simple + "204": + description: No Content + "304": + description: Not Modified + "400": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Bad Request + "401": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unauthorized + "403": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Forbidden + "404": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Not Found + "408": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Request Timeout + "409": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Conflict + "412": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Precondition Failed + "413": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Request Entity Too Large + "422": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Unprocessable Entity + "499": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + "500": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Internal Server Error + "503": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/ErrorModel' + description: Service Unavailable + summary: Create/Update Slate + tags: + - Slates for Organization +components: + schemas: + ErrorDetail: + additionalProperties: false + properties: + location: + description: "Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id'" + type: string + message: + description: Error message text + type: string + value: {} + ErrorModel: + additionalProperties: false + properties: + $schema: + description: A URL to the JSON Schema for this object. + format: uri + readOnly: true + type: string + detail: + description: A human-readable explanation specific to this occurrence of + the problem. + type: string + errors: + description: Optional list of individual error details + items: + $ref: '#/components/schemas/ErrorDetail' + type: array + instance: + description: A URI reference that identifies the specific occurrence of + the problem. + format: uri + type: string + status: + description: HTTP status code + format: int64 + type: integer + title: + description: "A short, human-readable summary of the problem type. This\ + \ value should not change between occurrences of the error." + type: string + type: + default: about:blank + description: A URI reference to human-readable documentation for the error. + format: uri + type: string + Slate: + additionalProperties: false + example: + $schema: https://openapi-generator.tech + description: description + id: id + url: url + properties: + $schema: + description: A URL to the JSON Schema for this object. + format: uri + readOnly: true + type: string + description: + description: A friendly slate description. + type: string + id: + description: Unique identifier for this slate + type: string + url: + description: The url where the slate can be accessed. + type: string + required: + - description + - id + - url + SlateWithoutID: + additionalProperties: false + example: + $schema: https://openapi-generator.tech + description: description + url: url + properties: + $schema: + description: A URL to the JSON Schema for this object. + format: uri + readOnly: true + type: string + description: + description: A friendly slate description. + type: string + url: + description: The url where the slate can be accessed. Must be a valid URL + type: string + required: + - description + - url + securitySchemes: + authcode: + flows: + authorizationCode: + scopes: {} + tokenUrl: "" + type: oauth2 + m2m: + flows: + clientCredentials: + scopes: {} + tokenUrl: "" + type: oauth2 +x-cli-config: + security: authcode + prompt: + org: + description: Organization ID + example: isp + exclude: true + params: + audience: "https://platform.dev.dtc.istreamplanet.net/{org}" + authorize_url: "" + client_id: TMEt4ihzsGtgHd335WcFXjp5mJ1lS6qP + redirect_url: http://auth.rest.sh:8484 + scopes: "offline_access,Groups" + state: non-empty + token_url: "" diff --git a/isp-slate/client.go b/isp-slate/client.go new file mode 100644 index 0000000..878e093 --- /dev/null +++ b/isp-slate/client.go @@ -0,0 +1,663 @@ +/* + * 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)/(?:[^;]+\+)?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 + + SlatesForOrganizationAPI SlatesForOrganizationAPI +} + +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.SlatesForOrganizationAPI = (*SlatesForOrganizationAPIService)(&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{}, style string, 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, style, collectionType) + return + } + if t, ok := obj.(time.Time); ok { + parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, 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 +} + +// 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) { + var bs []byte + bs, err = xml.Marshal(body) + if err == nil { + bodyBuf.Write(bs) + } + } + + 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-slate/docs/ErrorDetail.md b/isp-slate/docs/ErrorDetail.md new file mode 100644 index 0000000..c8d757e --- /dev/null +++ b/isp-slate/docs/ErrorDetail.md @@ -0,0 +1,118 @@ +# ErrorDetail + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Location** | Pointer to **string** | Where the error occurred, e.g. 'body.items[3].tags' or 'path.thing-id' | [optional] +**Message** | Pointer to **string** | Error message text | [optional] +**Value** | Pointer to **interface{}** | | [optional] + +## Methods + +### NewErrorDetail + +`func NewErrorDetail() *ErrorDetail` + +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 + +### NewErrorDetailWithDefaults + +`func NewErrorDetailWithDefaults() *ErrorDetail` + +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 + +### GetLocation + +`func (o *ErrorDetail) GetLocation() string` + +GetLocation returns the Location field if non-nil, zero value otherwise. + +### GetLocationOk + +`func (o *ErrorDetail) GetLocationOk() (*string, bool)` + +GetLocationOk returns a tuple with the Location field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetLocation + +`func (o *ErrorDetail) SetLocation(v string)` + +SetLocation sets Location field to given value. + +### HasLocation + +`func (o *ErrorDetail) HasLocation() bool` + +HasLocation returns a boolean if a field has been set. + +### GetMessage + +`func (o *ErrorDetail) GetMessage() string` + +GetMessage returns the Message field if non-nil, zero value otherwise. + +### GetMessageOk + +`func (o *ErrorDetail) GetMessageOk() (*string, bool)` + +GetMessageOk returns a tuple with the Message field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetMessage + +`func (o *ErrorDetail) SetMessage(v string)` + +SetMessage sets Message field to given value. + +### HasMessage + +`func (o *ErrorDetail) HasMessage() bool` + +HasMessage returns a boolean if a field has been set. + +### GetValue + +`func (o *ErrorDetail) GetValue() interface{}` + +GetValue returns the Value field if non-nil, zero value otherwise. + +### GetValueOk + +`func (o *ErrorDetail) GetValueOk() (*interface{}, bool)` + +GetValueOk returns a tuple with the Value field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetValue + +`func (o *ErrorDetail) SetValue(v interface{})` + +SetValue sets Value field to given value. + +### HasValue + +`func (o *ErrorDetail) HasValue() bool` + +HasValue returns a boolean if a field has been set. + +### SetValueNil + +`func (o *ErrorDetail) SetValueNil(b bool)` + + SetValueNil sets the value for Value to be an explicit nil + +### UnsetValue +`func (o *ErrorDetail) UnsetValue()` + +UnsetValue ensures that no value is present for Value, not even an explicit nil + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/isp-slate/docs/ErrorModel.md b/isp-slate/docs/ErrorModel.md new file mode 100644 index 0000000..dfae829 --- /dev/null +++ b/isp-slate/docs/ErrorModel.md @@ -0,0 +1,212 @@ +# ErrorModel + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | Pointer to **string** | A URL to the JSON Schema for this object. | [optional] [readonly] +**Detail** | Pointer to **string** | A human-readable explanation specific to this occurrence of the problem. | [optional] +**Errors** | Pointer to [**[]ErrorDetail**](ErrorDetail.md) | Optional list of individual error details | [optional] +**Instance** | Pointer to **string** | A URI reference that identifies the specific occurrence of the problem. | [optional] +**Status** | Pointer to **int64** | HTTP status code | [optional] +**Title** | Pointer to **string** | A short, human-readable summary of the problem type. This value should not change between occurrences of the error. | [optional] +**Type** | Pointer to **string** | A URI reference to human-readable documentation for the error. | [optional] [default to "about:blank"] + +## Methods + +### NewErrorModel + +`func NewErrorModel() *ErrorModel` + +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 + +### NewErrorModelWithDefaults + +`func NewErrorModelWithDefaults() *ErrorModel` + +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 + +### GetSchema + +`func (o *ErrorModel) GetSchema() string` + +GetSchema returns the Schema field if non-nil, zero value otherwise. + +### GetSchemaOk + +`func (o *ErrorModel) GetSchemaOk() (*string, bool)` + +GetSchemaOk returns a tuple with the Schema field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSchema + +`func (o *ErrorModel) SetSchema(v string)` + +SetSchema sets Schema field to given value. + +### HasSchema + +`func (o *ErrorModel) HasSchema() bool` + +HasSchema returns a boolean if a field has been set. + +### GetDetail + +`func (o *ErrorModel) GetDetail() string` + +GetDetail returns the Detail field if non-nil, zero value otherwise. + +### GetDetailOk + +`func (o *ErrorModel) GetDetailOk() (*string, bool)` + +GetDetailOk returns a tuple with the Detail field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDetail + +`func (o *ErrorModel) SetDetail(v string)` + +SetDetail sets Detail field to given value. + +### HasDetail + +`func (o *ErrorModel) HasDetail() bool` + +HasDetail returns a boolean if a field has been set. + +### GetErrors + +`func (o *ErrorModel) GetErrors() []ErrorDetail` + +GetErrors returns the Errors field if non-nil, zero value otherwise. + +### GetErrorsOk + +`func (o *ErrorModel) GetErrorsOk() (*[]ErrorDetail, bool)` + +GetErrorsOk returns a tuple with the Errors field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetErrors + +`func (o *ErrorModel) SetErrors(v []ErrorDetail)` + +SetErrors sets Errors field to given value. + +### HasErrors + +`func (o *ErrorModel) HasErrors() bool` + +HasErrors returns a boolean if a field has been set. + +### GetInstance + +`func (o *ErrorModel) GetInstance() string` + +GetInstance returns the Instance field if non-nil, zero value otherwise. + +### GetInstanceOk + +`func (o *ErrorModel) GetInstanceOk() (*string, bool)` + +GetInstanceOk returns a tuple with the Instance field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetInstance + +`func (o *ErrorModel) SetInstance(v string)` + +SetInstance sets Instance field to given value. + +### HasInstance + +`func (o *ErrorModel) HasInstance() bool` + +HasInstance returns a boolean if a field has been set. + +### GetStatus + +`func (o *ErrorModel) GetStatus() int64` + +GetStatus returns the Status field if non-nil, zero value otherwise. + +### GetStatusOk + +`func (o *ErrorModel) GetStatusOk() (*int64, bool)` + +GetStatusOk returns a tuple with the Status field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetStatus + +`func (o *ErrorModel) SetStatus(v int64)` + +SetStatus sets Status field to given value. + +### HasStatus + +`func (o *ErrorModel) HasStatus() bool` + +HasStatus returns a boolean if a field has been set. + +### GetTitle + +`func (o *ErrorModel) GetTitle() string` + +GetTitle returns the Title field if non-nil, zero value otherwise. + +### GetTitleOk + +`func (o *ErrorModel) GetTitleOk() (*string, bool)` + +GetTitleOk returns a tuple with the Title field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTitle + +`func (o *ErrorModel) SetTitle(v string)` + +SetTitle sets Title field to given value. + +### HasTitle + +`func (o *ErrorModel) HasTitle() bool` + +HasTitle returns a boolean if a field has been set. + +### GetType + +`func (o *ErrorModel) GetType() string` + +GetType returns the Type field if non-nil, zero value otherwise. + +### GetTypeOk + +`func (o *ErrorModel) GetTypeOk() (*string, bool)` + +GetTypeOk returns a tuple with the Type field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetType + +`func (o *ErrorModel) SetType(v string)` + +SetType sets Type field to given value. + +### HasType + +`func (o *ErrorModel) HasType() bool` + +HasType returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/isp-slate/docs/Slate.md b/isp-slate/docs/Slate.md new file mode 100644 index 0000000..743d278 --- /dev/null +++ b/isp-slate/docs/Slate.md @@ -0,0 +1,119 @@ +# Slate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | Pointer to **string** | A URL to the JSON Schema for this object. | [optional] [readonly] +**Description** | **string** | A friendly slate description. | +**Id** | **string** | Unique identifier for this slate | +**Url** | **string** | The url where the slate can be accessed. | + +## Methods + +### NewSlate + +`func NewSlate(description string, id string, url string, ) *Slate` + +NewSlate instantiates a new Slate 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 + +### NewSlateWithDefaults + +`func NewSlateWithDefaults() *Slate` + +NewSlateWithDefaults instantiates a new Slate 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 + +### GetSchema + +`func (o *Slate) GetSchema() string` + +GetSchema returns the Schema field if non-nil, zero value otherwise. + +### GetSchemaOk + +`func (o *Slate) GetSchemaOk() (*string, bool)` + +GetSchemaOk returns a tuple with the Schema field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSchema + +`func (o *Slate) SetSchema(v string)` + +SetSchema sets Schema field to given value. + +### HasSchema + +`func (o *Slate) HasSchema() bool` + +HasSchema returns a boolean if a field has been set. + +### GetDescription + +`func (o *Slate) GetDescription() string` + +GetDescription returns the Description field if non-nil, zero value otherwise. + +### GetDescriptionOk + +`func (o *Slate) GetDescriptionOk() (*string, bool)` + +GetDescriptionOk returns a tuple with the Description field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDescription + +`func (o *Slate) SetDescription(v string)` + +SetDescription sets Description field to given value. + + +### GetId + +`func (o *Slate) GetId() string` + +GetId returns the Id field if non-nil, zero value otherwise. + +### GetIdOk + +`func (o *Slate) GetIdOk() (*string, bool)` + +GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetId + +`func (o *Slate) SetId(v string)` + +SetId sets Id field to given value. + + +### GetUrl + +`func (o *Slate) GetUrl() string` + +GetUrl returns the Url field if non-nil, zero value otherwise. + +### GetUrlOk + +`func (o *Slate) GetUrlOk() (*string, bool)` + +GetUrlOk returns a tuple with the Url field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUrl + +`func (o *Slate) SetUrl(v string)` + +SetUrl sets Url field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/isp-slate/docs/SlateWithoutID.md b/isp-slate/docs/SlateWithoutID.md new file mode 100644 index 0000000..7e97a82 --- /dev/null +++ b/isp-slate/docs/SlateWithoutID.md @@ -0,0 +1,98 @@ +# SlateWithoutID + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**Schema** | Pointer to **string** | A URL to the JSON Schema for this object. | [optional] [readonly] +**Description** | **string** | A friendly slate description. | +**Url** | **string** | The url where the slate can be accessed. Must be a valid URL | + +## Methods + +### NewSlateWithoutID + +`func NewSlateWithoutID(description string, url string, ) *SlateWithoutID` + +NewSlateWithoutID instantiates a new SlateWithoutID 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 + +### NewSlateWithoutIDWithDefaults + +`func NewSlateWithoutIDWithDefaults() *SlateWithoutID` + +NewSlateWithoutIDWithDefaults instantiates a new SlateWithoutID 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 + +### GetSchema + +`func (o *SlateWithoutID) GetSchema() string` + +GetSchema returns the Schema field if non-nil, zero value otherwise. + +### GetSchemaOk + +`func (o *SlateWithoutID) GetSchemaOk() (*string, bool)` + +GetSchemaOk returns a tuple with the Schema field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetSchema + +`func (o *SlateWithoutID) SetSchema(v string)` + +SetSchema sets Schema field to given value. + +### HasSchema + +`func (o *SlateWithoutID) HasSchema() bool` + +HasSchema returns a boolean if a field has been set. + +### GetDescription + +`func (o *SlateWithoutID) GetDescription() string` + +GetDescription returns the Description field if non-nil, zero value otherwise. + +### GetDescriptionOk + +`func (o *SlateWithoutID) GetDescriptionOk() (*string, bool)` + +GetDescriptionOk returns a tuple with the Description field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetDescription + +`func (o *SlateWithoutID) SetDescription(v string)` + +SetDescription sets Description field to given value. + + +### GetUrl + +`func (o *SlateWithoutID) GetUrl() string` + +GetUrl returns the Url field if non-nil, zero value otherwise. + +### GetUrlOk + +`func (o *SlateWithoutID) GetUrlOk() (*string, bool)` + +GetUrlOk returns a tuple with the Url field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUrl + +`func (o *SlateWithoutID) SetUrl(v string)` + +SetUrl sets Url field to given value. + + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/isp-slate/docs/SlatesForOrganizationAPI.md b/isp-slate/docs/SlatesForOrganizationAPI.md new file mode 100644 index 0000000..669b01c --- /dev/null +++ b/isp-slate/docs/SlatesForOrganizationAPI.md @@ -0,0 +1,305 @@ +# \SlatesForOrganizationAPI + +All URIs are relative to *https://int.api.istreamplanet.com* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**DeleteOrgSlate**](SlatesForOrganizationAPI.md#DeleteOrgSlate) | **Delete** /v2/{org}/slates/{slate-id} | Delete Slate +[**GetOrgSlate**](SlatesForOrganizationAPI.md#GetOrgSlate) | **Get** /v2/{org}/slates/{slate-id} | Get Slate +[**ListOrgSlates**](SlatesForOrganizationAPI.md#ListOrgSlates) | **Get** /v2/{org}/slates | List Slates +[**PutOrgSlate**](SlatesForOrganizationAPI.md#PutOrgSlate) | **Put** /v2/{org}/slates/{slate-id} | Create/Update Slate + + + +## DeleteOrgSlate + +> DeleteOrgSlate(ctx, slateId, org).Execute() + +Delete Slate + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/istreamlabs/go-sdk/isp" +) + +func main() { + slateId := "slate-id-1" // string | Unique identifier for this slate + org := "org_example" // string | Organization name + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + r, err := apiClient.SlatesForOrganizationAPI.DeleteOrgSlate(context.Background(), slateId, org).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SlatesForOrganizationAPI.DeleteOrgSlate``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**slateId** | **string** | Unique identifier for this slate | +**org** | **string** | Organization name | + +### Other Parameters + +Other parameters are passed through a pointer to a apiDeleteOrgSlateRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + + +### Return type + + (empty response body) + +### Authorization + +[authcode](../README.md#authcode), [m2m](../README.md#m2m) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/problem+json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## GetOrgSlate + +> Slate GetOrgSlate(ctx, slateId, org).Execute() + +Get Slate + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/istreamlabs/go-sdk/isp" +) + +func main() { + slateId := "slate-id-1" // string | Unique identifier for this slate + org := "org_example" // string | Organization name + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.SlatesForOrganizationAPI.GetOrgSlate(context.Background(), slateId, org).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SlatesForOrganizationAPI.GetOrgSlate``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `GetOrgSlate`: Slate + fmt.Fprintf(os.Stdout, "Response from `SlatesForOrganizationAPI.GetOrgSlate`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**slateId** | **string** | Unique identifier for this slate | +**org** | **string** | Organization name | + +### Other Parameters + +Other parameters are passed through a pointer to a apiGetOrgSlateRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + + +### Return type + +[**Slate**](Slate.md) + +### Authorization + +[authcode](../README.md#authcode), [m2m](../README.md#m2m) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json, application/problem+json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## ListOrgSlates + +> []Slate ListOrgSlates(ctx, org).Cursor(cursor).Limit(limit).Execute() + +List Slates + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/istreamlabs/go-sdk/isp" +) + +func main() { + org := "org_example" // string | Organization name + cursor := "cursor_example" // string | Current page cursor (optional) + limit := int32(56) // int32 | Number of items to return (optional) (default to 100) + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.SlatesForOrganizationAPI.ListOrgSlates(context.Background(), org).Cursor(cursor).Limit(limit).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SlatesForOrganizationAPI.ListOrgSlates``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `ListOrgSlates`: []Slate + fmt.Fprintf(os.Stdout, "Response from `SlatesForOrganizationAPI.ListOrgSlates`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**org** | **string** | Organization name | + +### Other Parameters + +Other parameters are passed through a pointer to a apiListOrgSlatesRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + **cursor** | **string** | Current page cursor | + **limit** | **int32** | Number of items to return | [default to 100] + +### Return type + +[**[]Slate**](Slate.md) + +### Authorization + +[authcode](../README.md#authcode), [m2m](../README.md#m2m) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json, application/problem+json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + +## PutOrgSlate + +> Slate PutOrgSlate(ctx, slateId, org).SlateWithoutID(slateWithoutID).Execute() + +Create/Update Slate + + + +### Example + +```go +package main + +import ( + "context" + "fmt" + "os" + openapiclient "github.com/istreamlabs/go-sdk/isp" +) + +func main() { + slateId := "slate-id-1" // string | Unique identifier for this slate + org := "org_example" // string | Organization name + slateWithoutID := *openapiclient.NewSlateWithoutID("Description_example", "Url_example") // SlateWithoutID | + + configuration := openapiclient.NewConfiguration() + apiClient := openapiclient.NewAPIClient(configuration) + resp, r, err := apiClient.SlatesForOrganizationAPI.PutOrgSlate(context.Background(), slateId, org).SlateWithoutID(slateWithoutID).Execute() + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `SlatesForOrganizationAPI.PutOrgSlate``: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `PutOrgSlate`: Slate + fmt.Fprintf(os.Stdout, "Response from `SlatesForOrganizationAPI.PutOrgSlate`: %v\n", resp) +} +``` + +### Path Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc. +**slateId** | **string** | Unique identifier for this slate | +**org** | **string** | Organization name | + +### Other Parameters + +Other parameters are passed through a pointer to a apiPutOrgSlateRequest struct via the builder pattern + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + + + **slateWithoutID** | [**SlateWithoutID**](SlateWithoutID.md) | | + +### Return type + +[**Slate**](Slate.md) + +### Authorization + +[authcode](../README.md#authcode), [m2m](../README.md#m2m) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json, application/problem+json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + diff --git a/isp-slate/git_push.sh b/isp-slate/git_push.sh new file mode 100644 index 0000000..56348c5 --- /dev/null +++ b/isp-slate/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="istreamlabs" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="go-sdk" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/isp-slate/go.mod b/isp-slate/go.mod new file mode 100644 index 0000000..2147799 --- /dev/null +++ b/isp-slate/go.mod @@ -0,0 +1,7 @@ +module github.com/istreamlabs/go-sdk/isp + +go 1.18 + +require ( + golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 +) diff --git a/isp-slate/go.sum b/isp-slate/go.sum new file mode 100644 index 0000000..734252e --- /dev/null +++ b/isp-slate/go.sum @@ -0,0 +1,13 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/prerequisites/.openapi-generator-ignore b/prerequisites/.openapi-generator-ignore index 6db43e9..42251ca 100644 --- a/prerequisites/.openapi-generator-ignore +++ b/prerequisites/.openapi-generator-ignore @@ -22,14 +22,14 @@ # 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 +# api/* +# docs/* +# .gitignore +# .travis.yml +# README.md +# go.mod +# go.sum +# git_push.sh -convenience.go -client.go +# convenience.go +# client.go