diff --git a/schematicsv1/schematics_v1.go b/schematicsv1/schematics_v1.go
index bb8eb39..ca4bed1 100644
--- a/schematicsv1/schematics_v1.go
+++ b/schematicsv1/schematics_v1.go
@@ -15,7 +15,7 @@
*/
/*
- * IBM OpenAPI SDK Code Generator Version: 3.36.0-6f5b0381-20210716-180747
+ * IBM OpenAPI SDK Code Generator Version: 3.37.0-a85661cd-20210802-190136
*/
// Package schematicsv1 : Operations and models for the SchematicsV1 service
@@ -275,7 +275,8 @@ func (schematics *SchematicsV1) ListResourceGroupWithContext(ctx context.Context
// that the API uses.
//
Authorization Schematics support generic authorization such as service access or platform access to the
// workspace ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
-// service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
+// service access roles and required
+// permissions](https://cloud.ibm.com/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) GetSchematicsVersion(getSchematicsVersionOptions *GetSchematicsVersionOptions) (result *VersionResponse, response *core.DetailedResponse, err error) {
return schematics.GetSchematicsVersionWithContext(context.Background(), getSchematicsVersionOptions)
}
@@ -378,6 +379,84 @@ func (schematics *SchematicsV1) ListLocationsWithContext(ctx context.Context, li
return
}
+// ProcessTemplateMetaData : Create metadata by processing the template
+// Create a Template metadata definition.
+func (schematics *SchematicsV1) ProcessTemplateMetaData(processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions) (result *TemplateMetaDataResponse, response *core.DetailedResponse, err error) {
+ return schematics.ProcessTemplateMetaDataWithContext(context.Background(), processTemplateMetaDataOptions)
+}
+
+// ProcessTemplateMetaDataWithContext is an alternate form of the ProcessTemplateMetaData method which supports a Context parameter
+func (schematics *SchematicsV1) ProcessTemplateMetaDataWithContext(ctx context.Context, processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions) (result *TemplateMetaDataResponse, response *core.DetailedResponse, err error) {
+ err = core.ValidateNotNil(processTemplateMetaDataOptions, "processTemplateMetaDataOptions cannot be nil")
+ if err != nil {
+ return
+ }
+ err = core.ValidateStruct(processTemplateMetaDataOptions, "processTemplateMetaDataOptions")
+ if err != nil {
+ return
+ }
+
+ builder := core.NewRequestBuilder(core.POST)
+ builder = builder.WithContext(ctx)
+ builder.EnableGzipCompression = schematics.GetEnableGzipCompression()
+ _, err = builder.ResolveRequestURL(schematics.Service.Options.URL, `/v2/template_metadata_processor`, nil)
+ if err != nil {
+ return
+ }
+
+ for headerName, headerValue := range processTemplateMetaDataOptions.Headers {
+ builder.AddHeader(headerName, headerValue)
+ }
+
+ sdkHeaders := common.GetSdkHeaders("schematics", "V1", "ProcessTemplateMetaData")
+ for headerName, headerValue := range sdkHeaders {
+ builder.AddHeader(headerName, headerValue)
+ }
+ builder.AddHeader("Accept", "application/json")
+ builder.AddHeader("Content-Type", "application/json")
+ if processTemplateMetaDataOptions.XGithubToken != nil {
+ builder.AddHeader("X-Github-token", fmt.Sprint(*processTemplateMetaDataOptions.XGithubToken))
+ }
+
+ body := make(map[string]interface{})
+ if processTemplateMetaDataOptions.TemplateType != nil {
+ body["template_type"] = processTemplateMetaDataOptions.TemplateType
+ }
+ if processTemplateMetaDataOptions.Source != nil {
+ body["source"] = processTemplateMetaDataOptions.Source
+ }
+ if processTemplateMetaDataOptions.Region != nil {
+ body["region"] = processTemplateMetaDataOptions.Region
+ }
+ if processTemplateMetaDataOptions.SourceType != nil {
+ body["source_type"] = processTemplateMetaDataOptions.SourceType
+ }
+ _, err = builder.SetBodyContentJSON(body)
+ if err != nil {
+ return
+ }
+
+ request, err := builder.Build()
+ if err != nil {
+ return
+ }
+
+ var rawResponse map[string]json.RawMessage
+ response, err = schematics.Service.Request(request, &rawResponse)
+ if err != nil {
+ return
+ }
+ if rawResponse != nil {
+ err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateMetaDataResponse)
+ if err != nil {
+ return
+ }
+ response.Result = result
+ }
+
+ return
+}
+
// ListWorkspaces : List workspaces
// Retrieve a list of Schematics workspaces from your IBM Cloud account that you have access to. The list of workspaces
// that is returned depends on the API endpoint that you use. For example, if you use an API endpoint for a geography,
@@ -1154,7 +1233,7 @@ func (schematics *SchematicsV1) GetWorkspaceInputsWithContext(ctx context.Contex
}
// ReplaceWorkspaceInputs : Replace workspace input variables
-// Replace the input variables for the template that your workspace points to.
+// Replace or Update the input variables for the template that your workspace points to.
func (schematics *SchematicsV1) ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions *ReplaceWorkspaceInputsOptions) (result *UserValues, response *core.DetailedResponse, err error) {
return schematics.ReplaceWorkspaceInputsWithContext(context.Background(), replaceWorkspaceInputsOptions)
}
@@ -1591,9 +1670,15 @@ func (schematics *SchematicsV1) GetWorkspaceTemplateStateWithContext(ctx context
return
}
-// GetWorkspaceActivityLogs : Get the workspace activity log urls
-// View an activity log for Terraform actions that ran against your workspace. You can view logs for plan, apply, and
-// destroy actions. operationId: get_activity_log_urls.
+// GetWorkspaceActivityLogs : Get workspace job log URL
+// Get the Terraform log file URL for a workspace job. You can retrieve the log URL for jobs that were created with the
+// `PUT /v1/workspaces/{id}/apply`, `POST /v1/workspaces/{id}/plan`, or `DELETE /v1/workspaces/{id}/destroy` API.
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or platform access to the workspace ID and the
+// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
+// and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptions *GetWorkspaceActivityLogsOptions) (result *WorkspaceActivityLogs, response *core.DetailedResponse, err error) {
return schematics.GetWorkspaceActivityLogsWithContext(context.Background(), getWorkspaceActivityLogsOptions)
}
@@ -1653,8 +1738,9 @@ func (schematics *SchematicsV1) GetWorkspaceActivityLogsWithContext(ctx context.
return
}
-// GetWorkspaceLogUrls : Get all workspace log urls
-// Get all workspace log urls.
+// GetWorkspaceLogUrls : Get latest workspace job log URL for all workspace templates
+// Retrieve the log file URL for the latest job of a template that ran against your workspace. You use this URL to
+// retrieve detailed logs for the latest job.
func (schematics *SchematicsV1) GetWorkspaceLogUrls(getWorkspaceLogUrlsOptions *GetWorkspaceLogUrlsOptions) (result *LogStoreResponseList, response *core.DetailedResponse, err error) {
return schematics.GetWorkspaceLogUrlsWithContext(context.Background(), getWorkspaceLogUrlsOptions)
}
@@ -1713,8 +1799,14 @@ func (schematics *SchematicsV1) GetWorkspaceLogUrlsWithContext(ctx context.Conte
return
}
-// GetTemplateLogs : Get all template logs
-// Get all template logs.
+// GetTemplateLogs : Show logs for the latest action for a workspace template
+// Show the Terraform logs for the most recent job of a template that ran against your workspace.
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or platform access to the workspace ID and the
+// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
+// and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) GetTemplateLogs(getTemplateLogsOptions *GetTemplateLogsOptions) (result *string, response *core.DetailedResponse, err error) {
return schematics.GetTemplateLogsWithContext(context.Background(), getTemplateLogsOptions)
}
@@ -1776,9 +1868,8 @@ func (schematics *SchematicsV1) GetTemplateLogsWithContext(ctx context.Context,
return
}
-// GetTemplateActivityLog : Get the template activity logs
-// View an activity log for Terraform actions that ran for a template against your workspace. You can view logs for
-// plan, apply, and destroy actions.
+// GetTemplateActivityLog : Show logs for a workspace job
+// Show the Terraform logs for an job that ran against your workspace.
func (schematics *SchematicsV1) GetTemplateActivityLog(getTemplateActivityLogOptions *GetTemplateActivityLogOptions) (result *string, response *core.DetailedResponse, err error) {
return schematics.GetTemplateActivityLogWithContext(context.Background(), getTemplateActivityLogOptions)
}
@@ -1841,8 +1932,21 @@ func (schematics *SchematicsV1) GetTemplateActivityLogWithContext(ctx context.Co
return
}
-// ListActions : Get all the Action definitions
-// Get all the Action definitions.
+// ListActions : List actions
+// Retrieve a list of all Schematics actions that depends on the API endpoint that you have access. For example, if you
+// use an API endpoint for a geography, such as North America, only actions that are created in `us-south` or `us-east`
+// are retrieved.
+//
+// For more information, about supported API endpoints, see
+// [API endpoints](/apidocs/schematics#api-endpoints).
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or
+// platform access to an action ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required
+// permissions](/docs/schematics?topic=schematics-access#action-permissions.
func (schematics *SchematicsV1) ListActions(listActionsOptions *ListActionsOptions) (result *ActionList, response *core.DetailedResponse, err error) {
return schematics.ListActionsWithContext(context.Background(), listActionsOptions)
}
@@ -1906,8 +2010,26 @@ func (schematics *SchematicsV1) ListActionsWithContext(ctx context.Context, list
return
}
-// CreateAction : Create an Action definition
-// Create a new Action definition.
+// CreateAction : Create an action
+// Create an IBM Cloud Schematics action to run on a single target or groups of target hosts, roles, policies, or steps
+// to deploy your resources in the target hosts. You can run the IBM Cloud resources the order in which you want to
+// execute them. **Note** If your Git repository already contains a host file. Schematics does not overwrite the host
+// file already present in your Git repository. For sample templates, see IBM Cloud Automation
+// [templates](https://github.com/Cloud-Schematics).
+//
+// For more information, about the Schematics create action,
+// see [ibmcloud schematics action
+// create](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-create-action).
+// **Note** you cannot update the location and region once an action is created.
+// Also, make sure your IP addresses are in the [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses).
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or
+// platform access to an action ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required
+// permissions](/docs/schematics?topic=schematics-access#action-permissions.
func (schematics *SchematicsV1) CreateAction(createActionOptions *CreateActionOptions) (result *Action, response *core.DetailedResponse, err error) {
return schematics.CreateActionWithContext(context.Background(), createActionOptions)
}
@@ -1976,17 +2098,20 @@ func (schematics *SchematicsV1) CreateActionWithContext(ctx context.Context, cre
if createActionOptions.CommandParameter != nil {
body["command_parameter"] = createActionOptions.CommandParameter
}
- if createActionOptions.Bastion != nil {
- body["bastion"] = createActionOptions.Bastion
- }
if createActionOptions.Inventory != nil {
body["inventory"] = createActionOptions.Inventory
}
+ if createActionOptions.Credentials != nil {
+ body["credentials"] = createActionOptions.Credentials
+ }
+ if createActionOptions.Bastion != nil {
+ body["bastion"] = createActionOptions.Bastion
+ }
if createActionOptions.BastionCredential != nil {
body["bastion_credential"] = createActionOptions.BastionCredential
}
- if createActionOptions.Credentials != nil {
- body["credentials"] = createActionOptions.Credentials
+ if createActionOptions.TargetsIni != nil {
+ body["targets_ini"] = createActionOptions.TargetsIni
}
if createActionOptions.Inputs != nil {
body["inputs"] = createActionOptions.Inputs
@@ -2029,8 +2154,17 @@ func (schematics *SchematicsV1) CreateActionWithContext(ctx context.Context, cre
return
}
-// GetAction : Get the Action definition
-// Get the Action definition.
+// GetAction : Get action details
+// Retrieve the detailed information of an actions from your IBM Cloud account. This API returns a URL to the log file
+// that you can retrieve by using the\_ `GET /v2/actions/{action_id}/logs` API.
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or
+// platform access to an action ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required
+// permissions](/docs/schematics?topic=schematics-access#action-permissions.
func (schematics *SchematicsV1) GetAction(getActionOptions *GetActionOptions) (result *Action, response *core.DetailedResponse, err error) {
return schematics.GetActionWithContext(context.Background(), getActionOptions)
}
@@ -2093,8 +2227,20 @@ func (schematics *SchematicsV1) GetActionWithContext(ctx context.Context, getAct
return
}
-// DeleteAction : Delete the Action
-// Delete the Action definition.
+// DeleteAction : Delete an action
+// Delete a Schematics action and specify the Ansible playbook that you want to run against your IBM Cloud resources.
+// **Note** you cannot delete or stop the job activity from an ongoing execution of an action defined in the playbook.
+// You can repeat the execution of same job, whenever you patch the actions. For more information, about the Schematics
+// action state, see [Schematics action state
+// diagram](/docs/schematics?topic=schematics-action-setup#action-state-diagram).
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or
+// platform access to an action ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required
+// permissions](/docs/schematics?topic=schematics-access#action-permissions.
func (schematics *SchematicsV1) DeleteAction(deleteActionOptions *DeleteActionOptions) (response *core.DetailedResponse, err error) {
return schematics.DeleteActionWithContext(context.Background(), deleteActionOptions)
}
@@ -2147,8 +2293,21 @@ func (schematics *SchematicsV1) DeleteActionWithContext(ctx context.Context, del
return
}
-// UpdateAction : Update the Action definition
-// Update the Action definition.
+// UpdateAction : Update an action
+// Update or replace an action to change the action state from the critical state to normal state, or pending state to
+// the normal state for a successful execution. For more information, about the Schematics action state, see
+// [Schematics action state diagram](/docs/schematics?topic=schematics-action-setup#action-state-diagram).
+//
+// **Note** you cannot update the location and region once an action is created.
+// Also, make sure your IP addresses are in the [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses].
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or
+// platform access to an action ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required
+// permissions](/docs/schematics?topic=schematics-access#action-permissions.
func (schematics *SchematicsV1) UpdateAction(updateActionOptions *UpdateActionOptions) (result *Action, response *core.DetailedResponse, err error) {
return schematics.UpdateActionWithContext(context.Background(), updateActionOptions)
}
@@ -2221,17 +2380,20 @@ func (schematics *SchematicsV1) UpdateActionWithContext(ctx context.Context, upd
if updateActionOptions.CommandParameter != nil {
body["command_parameter"] = updateActionOptions.CommandParameter
}
- if updateActionOptions.Bastion != nil {
- body["bastion"] = updateActionOptions.Bastion
- }
if updateActionOptions.Inventory != nil {
body["inventory"] = updateActionOptions.Inventory
}
+ if updateActionOptions.Credentials != nil {
+ body["credentials"] = updateActionOptions.Credentials
+ }
+ if updateActionOptions.Bastion != nil {
+ body["bastion"] = updateActionOptions.Bastion
+ }
if updateActionOptions.BastionCredential != nil {
body["bastion_credential"] = updateActionOptions.BastionCredential
}
- if updateActionOptions.Credentials != nil {
- body["credentials"] = updateActionOptions.Credentials
+ if updateActionOptions.TargetsIni != nil {
+ body["targets_ini"] = updateActionOptions.TargetsIni
}
if updateActionOptions.Inputs != nil {
body["inputs"] = updateActionOptions.Inputs
@@ -2274,8 +2436,14 @@ func (schematics *SchematicsV1) UpdateActionWithContext(ctx context.Context, upd
return
}
-// UploadTemplateTarAction : Upload template tar file for the action
-// Upload template tar file for the action.
+// UploadTemplateTarAction : Replace a TAR file to an action
+// Replace your template by uploading tape archive file (.tar) file from your local machine. Before you use this API,
+// you must create an action without a link to a GitHub or GitLab repository with the\_POST /v2/actions\_API.
+//
+// Authorization
+// Schematics support generic authorization such as service access or platform access to an action ID and the
+// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
+// and required permissions](/docs/schematics?topic=schematics-access#action-permissions.
func (schematics *SchematicsV1) UploadTemplateTarAction(uploadTemplateTarActionOptions *UploadTemplateTarActionOptions) (result *TemplateRepoTarUploadResponse, response *core.DetailedResponse, err error) {
return schematics.UploadTemplateTarActionWithContext(context.Background(), uploadTemplateTarActionOptions)
}
@@ -2474,11 +2642,11 @@ func (schematics *SchematicsV1) GetWorkspaceActivityWithContext(ctx context.Cont
}
// DeleteWorkspaceActivity : Stop the workspace job
-// Stop an ongoing schematics job that runs against your workspace. **Note**: If you remove the Schematics apply job
-// that runs against your workspace, any changes to your IBM Cloud resources that are already applied are not reverted.
-// If a creation, update, or deletion is currently in progress, Schematics waits for the job to be completed first.
-// Then, any other resource creations, updates, or deletions that are included in your Terraform template file are
-// ignored.
+// Stop an ongoing schematics job that runs against your workspace.
+// **Note**: If you remove the Schematics apply job that runs against your workspace, any changes to your IBM Cloud
+// resources that are already applied are not reverted. If a creation, update, or deletion is currently in progress,
+// Schematics waits for the job to be completed first. Then, any other resource creations, updates, or deletions that
+// are included in your Terraform template file are ignored.
// Authorization Schematics supports generic authorization such as service access or platform access to the
// workspace ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
// service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
@@ -2541,14 +2709,16 @@ func (schematics *SchematicsV1) DeleteWorkspaceActivityWithContext(ctx context.C
return
}
-// RunWorkspaceCommands : Run terraform Commands
+// RunWorkspaceCommands : Run Terraform Commands
// Run Terraform state commands to modify the workspace state file, by using the IBM Cloud Schematics API.
//
// Authorization
//
-// Schematics support generic authorization such as service access or platform access to the workspace ID and the
-// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
-// and required permissions](/docs/schematics?topic=schematics-access#access-roles).
+// Schematics support generic authorization such as service access or platform access
+// to the workspace ID and the resource group. For more information, about Schematics
+// access and permissions,
+// see [Schematics service access roles and required
+// permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) RunWorkspaceCommands(runWorkspaceCommandsOptions *RunWorkspaceCommandsOptions) (result *WorkspaceActivityCommandResult, response *core.DetailedResponse, err error) {
return schematics.RunWorkspaceCommandsWithContext(context.Background(), runWorkspaceCommandsOptions)
}
@@ -2626,8 +2796,34 @@ func (schematics *SchematicsV1) RunWorkspaceCommandsWithContext(ctx context.Cont
return
}
-// ApplyWorkspaceCommand : Run schematics workspace 'apply' activity
-// Run schematics workspace 'apply' activity.
+// ApplyWorkspaceCommand : Perform a Schematics `apply` job
+// Run a Schematics `apply` job against your workspace. An `apply` job provisions, modifies, or removes the IBM Cloud
+// resources that you described in the Terraform template that your workspace points to. Depending on the type and
+// number of resources that you want to provision or modify, this process might take a few minutes, or even up to hours
+// to complete. During this time, you cannot make changes to your workspace. After all updates are applied, the state of
+// the files is [persisted](/docs/schematics?topic=schematics-persist-files) to determine what resources exist in your
+// IBM Cloud account.
+//
+//
+// **Important**: Your workspace must be in an `Inactive`, `Active`, `Failed`, or `Stopped` state to perform a
+// Schematics `apply` job. After all updates are applied, the state of the files is
+// [persisted](/docs/schematics?topic=schematics-persist-files) to determine what resources exist in your IBM Cloud
+// account.
+//
+//
+// **Note**: This API returns an activity or job ID that you use to retrieve the log URL with the `GET
+// /v1/workspaces/{id}/actions/{action_id}/logs` API.
+//
+//
+// **Important:** Applying a template might incur costs. Make sure to review the pricing information for the resources
+// that you specified in your templates before you apply the template in IBM Cloud. To find a summary of job that
+// Schematics is about to perform, create a Terraform execution plan with the `POST /v1/workspaces/{id}/plan` API.
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or platform access to the workspace ID and the
+// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
+// and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) ApplyWorkspaceCommand(applyWorkspaceCommandOptions *ApplyWorkspaceCommandOptions) (result *WorkspaceActivityApplyResult, response *core.DetailedResponse, err error) {
return schematics.ApplyWorkspaceCommandWithContext(context.Background(), applyWorkspaceCommandOptions)
}
@@ -2668,6 +2864,9 @@ func (schematics *SchematicsV1) ApplyWorkspaceCommandWithContext(ctx context.Con
if applyWorkspaceCommandOptions.RefreshToken != nil {
builder.AddHeader("refresh_token", fmt.Sprint(*applyWorkspaceCommandOptions.RefreshToken))
}
+ if applyWorkspaceCommandOptions.DelegatedToken != nil {
+ builder.AddHeader("delegated_token", fmt.Sprint(*applyWorkspaceCommandOptions.DelegatedToken))
+ }
body := make(map[string]interface{})
if applyWorkspaceCommandOptions.ActionOptions != nil {
@@ -2699,9 +2898,25 @@ func (schematics *SchematicsV1) ApplyWorkspaceCommandWithContext(ctx context.Con
return
}
-// DestroyWorkspaceCommand : Run workspace 'destroy' activity
-// Run workspace 'destroy' activity, to destroy all the resources associated with the workspace. WARNING: This action
-// cannot be reversed.
+// DestroyWorkspaceCommand : Perform a Schematics `destroy` job
+// Run a Schematics `destroy` job against your workspace. A `destroy` job removes all IBM Cloud resources that are
+// associated with your workspace. Removing your resources does not delete the Schematics workspace. To delete the
+// workspace, use the `DELETE /v1/workspaces/{id}` API. This API returns an activity or job ID that you use to retrieve
+// the URL to the log file with the `GET /v1/workspaces/{id}/actions/{action_id}/logs` API.
+//
+//
+// **Important**: Your workspace must be in an `Active`, `Failed`, or `Stopped` state to perform a Schematics `destroy`
+// job.
+//
+//
+// **Note**: Deleting IBM Cloud resources cannot be undone. Make sure that you back up any required data before you
+// remove your resources.
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or platform access to the workspace ID and the
+// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
+// and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) DestroyWorkspaceCommand(destroyWorkspaceCommandOptions *DestroyWorkspaceCommandOptions) (result *WorkspaceActivityDestroyResult, response *core.DetailedResponse, err error) {
return schematics.DestroyWorkspaceCommandWithContext(context.Background(), destroyWorkspaceCommandOptions)
}
@@ -2742,6 +2957,9 @@ func (schematics *SchematicsV1) DestroyWorkspaceCommandWithContext(ctx context.C
if destroyWorkspaceCommandOptions.RefreshToken != nil {
builder.AddHeader("refresh_token", fmt.Sprint(*destroyWorkspaceCommandOptions.RefreshToken))
}
+ if destroyWorkspaceCommandOptions.DelegatedToken != nil {
+ builder.AddHeader("delegated_token", fmt.Sprint(*destroyWorkspaceCommandOptions.DelegatedToken))
+ }
body := make(map[string]interface{})
if destroyWorkspaceCommandOptions.ActionOptions != nil {
@@ -2773,8 +2991,25 @@ func (schematics *SchematicsV1) DestroyWorkspaceCommandWithContext(ctx context.C
return
}
-// PlanWorkspaceCommand : Run workspace 'plan' activity,
-// Run schematics workspace 'plan' activity, to preview the change before running an 'apply' activity.
+// PlanWorkspaceCommand : Perform a Schematics `plan` job
+// Run a Schematics `plan` job against your workspace. The `plan` job creates a summary of IBM Cloud resources that must
+// be created, modified, or deleted to achieve the state that is described in the Terraform or IBM Cloud catalog
+// template that your workspace points to. During this time, you cannot make changes to your workspace. You can use the
+// summary to verify your changes before you apply the template in IBM Cloud.
+//
+//
+// **Important**: Your workspace must be in an `Inactive`, `Active`, `Failed`, or `Stopped` state to perform a
+// Schematics `plan` job.
+//
+//
+// **Note**: This API returns an activity or job ID that you use to retrieve the URL to the log file with the `GET
+// /v1/workspaces/{id}/actions/{action_id}/logs` API.
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or platform access to the workspace ID and the
+// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
+// and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) PlanWorkspaceCommand(planWorkspaceCommandOptions *PlanWorkspaceCommandOptions) (result *WorkspaceActivityPlanResult, response *core.DetailedResponse, err error) {
return schematics.PlanWorkspaceCommandWithContext(context.Background(), planWorkspaceCommandOptions)
}
@@ -2814,6 +3049,9 @@ func (schematics *SchematicsV1) PlanWorkspaceCommandWithContext(ctx context.Cont
if planWorkspaceCommandOptions.RefreshToken != nil {
builder.AddHeader("refresh_token", fmt.Sprint(*planWorkspaceCommandOptions.RefreshToken))
}
+ if planWorkspaceCommandOptions.DelegatedToken != nil {
+ builder.AddHeader("delegated_token", fmt.Sprint(*planWorkspaceCommandOptions.DelegatedToken))
+ }
request, err := builder.Build()
if err != nil {
@@ -2836,8 +3074,17 @@ func (schematics *SchematicsV1) PlanWorkspaceCommandWithContext(ctx context.Cont
return
}
-// RefreshWorkspaceCommand : Run workspace 'refresh' activity
-// Run workspace 'refresh' activity.
+// RefreshWorkspaceCommand : Perform a Schematics `refresh` job
+// Run a Schematics `refresh` job against your workspace. A `refresh` job validates the IBM Cloud resources in your
+// account against the state that is stored in the Terraform statefile of your workspace. If differences are found, the
+// Terraform statefile is updated accordingly. This API returns an activity or job ID that you use to retrieve the URL
+// to the log file with the `GET /v1/workspaces/{id}/actions/{action_id}/logs` API.
+//
+// Authorization
+//
+// Schematics support generic authorization such as service access or platform access to the workspace ID and the
+// resource group. For more information, about Schematics access and permissions, see [Schematics service access roles
+// and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) RefreshWorkspaceCommand(refreshWorkspaceCommandOptions *RefreshWorkspaceCommandOptions) (result *WorkspaceActivityRefreshResult, response *core.DetailedResponse, err error) {
return schematics.RefreshWorkspaceCommandWithContext(context.Background(), refreshWorkspaceCommandOptions)
}
@@ -2877,6 +3124,9 @@ func (schematics *SchematicsV1) RefreshWorkspaceCommandWithContext(ctx context.C
if refreshWorkspaceCommandOptions.RefreshToken != nil {
builder.AddHeader("refresh_token", fmt.Sprint(*refreshWorkspaceCommandOptions.RefreshToken))
}
+ if refreshWorkspaceCommandOptions.DelegatedToken != nil {
+ builder.AddHeader("delegated_token", fmt.Sprint(*refreshWorkspaceCommandOptions.DelegatedToken))
+ }
request, err := builder.Build()
if err != nil {
@@ -2899,8 +3149,16 @@ func (schematics *SchematicsV1) RefreshWorkspaceCommandWithContext(ctx context.C
return
}
-// ListJobs : Get all the Job records
-// Get all the Job records.
+// ListJobs : List jobs
+// Retrieve a list of all Schematics jobs. The job displays a list of jobs with the status as `in_progess`, `success`,
+// or `failed`. Jobs are generated when you use the `POST /v2/jobs`, `PUT /v2/jobs/{job_id}`, or `DELETE
+// /v2/jobs/{job_id}`.
+//
+// Authorization
+// Schematics support generic authorization such as service access or
+// platform access to the job ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) ListJobs(listJobsOptions *ListJobsOptions) (result *JobList, response *core.DetailedResponse, err error) {
return schematics.ListJobsWithContext(context.Background(), listJobsOptions)
}
@@ -2976,8 +3234,8 @@ func (schematics *SchematicsV1) ListJobsWithContext(ctx context.Context, listJob
return
}
-// CreateJob : Create a Job record and launch the Job
-// Creare a Job record and launch the Job.
+// CreateJob : Create a job
+// Create a job and launch the job.
func (schematics *SchematicsV1) CreateJob(createJobOptions *CreateJobOptions) (result *Job, response *core.DetailedResponse, err error) {
return schematics.CreateJobWithContext(context.Background(), createJobOptions)
}
@@ -3081,8 +3339,14 @@ func (schematics *SchematicsV1) CreateJobWithContext(ctx context.Context, create
return
}
-// GetJob : Get the Job record
-// Get the Job record.
+// GetJob : Get a job
+// Retrieve the detailed information of Job
+//
+// Authorization
+// Schematics support generic authorization such as service access or
+// platform access to the job ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) GetJob(getJobOptions *GetJobOptions) (result *Job, response *core.DetailedResponse, err error) {
return schematics.GetJobWithContext(context.Background(), getJobOptions)
}
@@ -3145,25 +3409,32 @@ func (schematics *SchematicsV1) GetJobWithContext(ctx context.Context, getJobOpt
return
}
-// ReplaceJob : Clone the Job-record, and relaunch the Job
-// Clone the Job-record, and relaunch the Job.
-func (schematics *SchematicsV1) ReplaceJob(replaceJobOptions *ReplaceJobOptions) (result *Job, response *core.DetailedResponse, err error) {
- return schematics.ReplaceJobWithContext(context.Background(), replaceJobOptions)
+// UpdateJob : Clone the Job, and relaunch the Job
+// Update or replace a job creates a copy of the job and relaunches an existing job by updating the information of an
+// existing Schematics job.
+//
+// Authorization
+// Schematics support generic authorization such as service access or
+// platform access to the job ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
+func (schematics *SchematicsV1) UpdateJob(updateJobOptions *UpdateJobOptions) (result *Job, response *core.DetailedResponse, err error) {
+ return schematics.UpdateJobWithContext(context.Background(), updateJobOptions)
}
-// ReplaceJobWithContext is an alternate form of the ReplaceJob method which supports a Context parameter
-func (schematics *SchematicsV1) ReplaceJobWithContext(ctx context.Context, replaceJobOptions *ReplaceJobOptions) (result *Job, response *core.DetailedResponse, err error) {
- err = core.ValidateNotNil(replaceJobOptions, "replaceJobOptions cannot be nil")
+// UpdateJobWithContext is an alternate form of the UpdateJob method which supports a Context parameter
+func (schematics *SchematicsV1) UpdateJobWithContext(ctx context.Context, updateJobOptions *UpdateJobOptions) (result *Job, response *core.DetailedResponse, err error) {
+ err = core.ValidateNotNil(updateJobOptions, "updateJobOptions cannot be nil")
if err != nil {
return
}
- err = core.ValidateStruct(replaceJobOptions, "replaceJobOptions")
+ err = core.ValidateStruct(updateJobOptions, "updateJobOptions")
if err != nil {
return
}
pathParamsMap := map[string]string{
- "job_id": *replaceJobOptions.JobID,
+ "job_id": *updateJobOptions.JobID,
}
builder := core.NewRequestBuilder(core.PUT)
@@ -3174,59 +3445,59 @@ func (schematics *SchematicsV1) ReplaceJobWithContext(ctx context.Context, repla
return
}
- for headerName, headerValue := range replaceJobOptions.Headers {
+ for headerName, headerValue := range updateJobOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
- sdkHeaders := common.GetSdkHeaders("schematics", "V1", "ReplaceJob")
+ sdkHeaders := common.GetSdkHeaders("schematics", "V1", "UpdateJob")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
builder.AddHeader("Content-Type", "application/json")
- if replaceJobOptions.RefreshToken != nil {
- builder.AddHeader("refresh_token", fmt.Sprint(*replaceJobOptions.RefreshToken))
+ if updateJobOptions.RefreshToken != nil {
+ builder.AddHeader("refresh_token", fmt.Sprint(*updateJobOptions.RefreshToken))
}
body := make(map[string]interface{})
- if replaceJobOptions.CommandObject != nil {
- body["command_object"] = replaceJobOptions.CommandObject
+ if updateJobOptions.CommandObject != nil {
+ body["command_object"] = updateJobOptions.CommandObject
}
- if replaceJobOptions.CommandObjectID != nil {
- body["command_object_id"] = replaceJobOptions.CommandObjectID
+ if updateJobOptions.CommandObjectID != nil {
+ body["command_object_id"] = updateJobOptions.CommandObjectID
}
- if replaceJobOptions.CommandName != nil {
- body["command_name"] = replaceJobOptions.CommandName
+ if updateJobOptions.CommandName != nil {
+ body["command_name"] = updateJobOptions.CommandName
}
- if replaceJobOptions.CommandParameter != nil {
- body["command_parameter"] = replaceJobOptions.CommandParameter
+ if updateJobOptions.CommandParameter != nil {
+ body["command_parameter"] = updateJobOptions.CommandParameter
}
- if replaceJobOptions.CommandOptions != nil {
- body["command_options"] = replaceJobOptions.CommandOptions
+ if updateJobOptions.CommandOptions != nil {
+ body["command_options"] = updateJobOptions.CommandOptions
}
- if replaceJobOptions.Inputs != nil {
- body["inputs"] = replaceJobOptions.Inputs
+ if updateJobOptions.Inputs != nil {
+ body["inputs"] = updateJobOptions.Inputs
}
- if replaceJobOptions.Settings != nil {
- body["settings"] = replaceJobOptions.Settings
+ if updateJobOptions.Settings != nil {
+ body["settings"] = updateJobOptions.Settings
}
- if replaceJobOptions.Tags != nil {
- body["tags"] = replaceJobOptions.Tags
+ if updateJobOptions.Tags != nil {
+ body["tags"] = updateJobOptions.Tags
}
- if replaceJobOptions.Location != nil {
- body["location"] = replaceJobOptions.Location
+ if updateJobOptions.Location != nil {
+ body["location"] = updateJobOptions.Location
}
- if replaceJobOptions.Status != nil {
- body["status"] = replaceJobOptions.Status
+ if updateJobOptions.Status != nil {
+ body["status"] = updateJobOptions.Status
}
- if replaceJobOptions.Data != nil {
- body["data"] = replaceJobOptions.Data
+ if updateJobOptions.Data != nil {
+ body["data"] = updateJobOptions.Data
}
- if replaceJobOptions.Bastion != nil {
- body["bastion"] = replaceJobOptions.Bastion
+ if updateJobOptions.Bastion != nil {
+ body["bastion"] = updateJobOptions.Bastion
}
- if replaceJobOptions.LogSummary != nil {
- body["log_summary"] = replaceJobOptions.LogSummary
+ if updateJobOptions.LogSummary != nil {
+ body["log_summary"] = updateJobOptions.LogSummary
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
@@ -3254,8 +3525,16 @@ func (schematics *SchematicsV1) ReplaceJobWithContext(ctx context.Context, repla
return
}
-// DeleteJob : Stop the running Job, and delete the Job-record
-// Stop the running Job, and delete the Job-record.
+// DeleteJob : Stop the running Job, and delete the Job
+// Stop the running Job, and delete the Job. **Note** You cannot delete or stop the job activity from an ongoing
+// execution of an action defined in the playbook. You can repeat the execution of same job, whenever you patch or
+// update the action or workspace.
+//
+// Authorization
+// Schematics support generic authorization such as service access or
+// platform access to the job ID and the resource group.
+// For more information, about Schematics access and permissions, see
+// [Schematics service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) DeleteJob(deleteJobOptions *DeleteJobOptions) (response *core.DetailedResponse, err error) {
return schematics.DeleteJobWithContext(context.Background(), deleteJobOptions)
}
@@ -3311,8 +3590,11 @@ func (schematics *SchematicsV1) DeleteJobWithContext(ctx context.Context, delete
return
}
-// ListJobLogs : Get log-file from the Job record
-// Get log-file from the Job record.
+// ListJobLogs : Get job logs
+// Retrieve the job logs
+// Authorization Schematics support generic authorization such as service access or platform access to the
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) ListJobLogs(listJobLogsOptions *ListJobLogsOptions) (result *JobLog, response *core.DetailedResponse, err error) {
return schematics.ListJobLogsWithContext(context.Background(), listJobLogsOptions)
}
@@ -3517,8 +3799,14 @@ func (schematics *SchematicsV1) GetWorkspaceDeletionJobStatusWithContext(ctx con
return
}
-// ListInventories : Get all resource inventory definitions
-// Get all resource inventory definition.
+// ListInventories : List inventories
+// Retrieve a list of all Schematics inventories that depends on the API endpoint that you have access. For example, if
+// you use an API endpoint for a geography, such as North America, only inventories that are created in `us-south` or
+// `us-east` are retrieved. For more information, about supported API endpoints, see [API
+// endpoints](/apidocs/schematics#api-endpoints).
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) ListInventories(listInventoriesOptions *ListInventoriesOptions) (result *InventoryResourceRecordList, response *core.DetailedResponse, err error) {
return schematics.ListInventoriesWithContext(context.Background(), listInventoriesOptions)
}
@@ -3582,8 +3870,16 @@ func (schematics *SchematicsV1) ListInventoriesWithContext(ctx context.Context,
return
}
-// CreateInventory : Create a resource inventory definition, used to target Actions or Controls
-// Create a resource inventory definition.
+// CreateInventory : Create an inventory
+// Create an IBM Cloud Schematics inventory as a single IBM Cloud resource where you want to run Ansible playbook by
+// using Schematics actions. For more information, about inventory host groups, refer to [creating static and dynamic
+// inventory for Schematics actions](/docs/schematics?topic=schematics-inventories-setup). **Note** you cannot update
+// the location and region, resource group once an action is created. Also, make sure your IP addresses are in the
+// [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses). If your Git repository already contains a host
+// file. Schematics does not overwrite the host file already present in your Git repository.
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) CreateInventory(createInventoryOptions *CreateInventoryOptions) (result *InventoryResourceRecord, response *core.DetailedResponse, err error) {
return schematics.CreateInventoryWithContext(context.Background(), createInventoryOptions)
}
@@ -3663,8 +3959,16 @@ func (schematics *SchematicsV1) CreateInventoryWithContext(ctx context.Context,
return
}
-// GetInventory : Get the resource inventory definition, used to target Actions or Controls
-// Get the resource inventory definition.
+// GetInventory : Get inventory definition resource
+// Use this API to retrieve the detailed information for a resource inventory definition used to target an action in
+// your IBM Cloud account. For more information, about inventory get, refer to [ibmcloud schematics inventory
+// get](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-get-inv).
+// **Note** you can fetch only the location and region, resource group from where your inventory is created.
+// Also, make sure your IP addresses are in the [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses).
+//
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) GetInventory(getInventoryOptions *GetInventoryOptions) (result *InventoryResourceRecord, response *core.DetailedResponse, err error) {
return schematics.GetInventoryWithContext(context.Background(), getInventoryOptions)
}
@@ -3723,8 +4027,16 @@ func (schematics *SchematicsV1) GetInventoryWithContext(ctx context.Context, get
return
}
-// ReplaceInventory : Replace the resource inventory definition, used to target Actions or Controls
-// Replace the resource inventory definition.
+// ReplaceInventory : Replace an inventory
+// Use this API to update the inventory definition resource used to target an action. For more information, about
+// inventory update, refer to [ibmcloud schematics inventory
+// update](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-update-inv).
+// **Note** you cannot update the location and region, resource group once an action is created.
+// Also, make sure your IP addresses are in the [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses).
+//
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) ReplaceInventory(replaceInventoryOptions *ReplaceInventoryOptions) (result *InventoryResourceRecord, response *core.DetailedResponse, err error) {
return schematics.ReplaceInventoryWithContext(context.Background(), replaceInventoryOptions)
}
@@ -3808,8 +4120,16 @@ func (schematics *SchematicsV1) ReplaceInventoryWithContext(ctx context.Context,
return
}
-// DeleteInventory : Delete the resource inventory definition
-// Delete the resource inventory definition.
+// DeleteInventory : Delete inventory definition resource
+// Use this API to delete the resource inventory definition by using the inventory ID that you want to run against. For
+// more information, about inventory delete, refer to [ibmcloud schematics inventory
+// delete](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-delete-inventory).
+// **Note** you cannot delete the location and region, resource group from where your inventory is created.
+// Also, make sure your IP addresses are in the [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses).
+//
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) DeleteInventory(deleteInventoryOptions *DeleteInventoryOptions) (response *core.DetailedResponse, err error) {
return schematics.DeleteInventoryWithContext(context.Background(), deleteInventoryOptions)
}
@@ -3862,7 +4182,7 @@ func (schematics *SchematicsV1) DeleteInventoryWithContext(ctx context.Context,
return
}
-// UpdateInventory : Update the resource inventory definition, used to target Actions or Controls
+// UpdateInventory : Update the inventory definition resource
// Update the resource inventory definition.
func (schematics *SchematicsV1) UpdateInventory(updateInventoryOptions *UpdateInventoryOptions) (result *InventoryResourceRecord, response *core.DetailedResponse, err error) {
return schematics.UpdateInventoryWithContext(context.Background(), updateInventoryOptions)
@@ -3947,8 +4267,8 @@ func (schematics *SchematicsV1) UpdateInventoryWithContext(ctx context.Context,
return
}
-// ListInventoryValues : Get all the resource inventory values
-// Get all the resource inventory values.
+// ListInventoryValues : Get all the inventory resource values
+// Get all the inventory resource values.
func (schematics *SchematicsV1) ListInventoryValues(listInventoryValuesOptions *ListInventoryValuesOptions) (result *InventoryResourceRecordList, response *core.DetailedResponse, err error) {
return schematics.ListInventoryValuesWithContext(context.Background(), listInventoryValuesOptions)
}
@@ -4007,8 +4327,8 @@ func (schematics *SchematicsV1) ListInventoryValuesWithContext(ctx context.Conte
return
}
-// GetInventoryValue : Get the resource inventory value
-// Get the resource inventory value.
+// GetInventoryValue : Get the inventory resource value
+// Get the inventory resource value.
func (schematics *SchematicsV1) GetInventoryValue(getInventoryValueOptions *GetInventoryValueOptions) (result *InventoryResourceRecord, response *core.DetailedResponse, err error) {
return schematics.GetInventoryValueWithContext(context.Background(), getInventoryValueOptions)
}
@@ -4068,8 +4388,14 @@ func (schematics *SchematicsV1) GetInventoryValueWithContext(ctx context.Context
return
}
-// ListResourceQuery : Get all resource query definitions
-// Get all resource query definition.
+// ListResourceQuery : List resource queries
+// Retrieve the list of resource query definitions that you have access to. The list of resource queries that is
+// returned depends on the API endpoint that you use. For example, if you use an API endpoint for a geography, such as
+// North America, only resource query definitions that are created in `us-south` or `us-east` are retrieved. For more
+// information, about supported API endpoints, see [API endpoints](/apidocs/schematics#api-endpoints).
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) ListResourceQuery(listResourceQueryOptions *ListResourceQueryOptions) (result *ResourceQueryRecordList, response *core.DetailedResponse, err error) {
return schematics.ListResourceQueryWithContext(context.Background(), listResourceQueryOptions)
}
@@ -4133,8 +4459,17 @@ func (schematics *SchematicsV1) ListResourceQueryWithContext(ctx context.Context
return
}
-// CreateResourceQuery : Create a resource query definition
-// Create a resource query definition.
+// CreateResourceQuery : Create resource query
+// Use this API to create a resource query definition that will be used to select an IBM Cloud resource or a group of
+// resources as the dynamic inventory for the Schematics Actions. For more information, about resource query commands,
+// refer to [ibmcloud schematics resource query
+// create](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-create-rq). **Note** you cannot update
+// the location and region, resource group once an action is created. Also, make sure your IP addresses are in the
+// [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses). If your Git repository already contains a host
+// file. Schematics does not overwrite the host file already present in your Git repository.
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) CreateResourceQuery(createResourceQueryOptions *CreateResourceQueryOptions) (result *ResourceQueryRecord, response *core.DetailedResponse, err error) {
return schematics.CreateResourceQueryWithContext(context.Background(), createResourceQueryOptions)
}
@@ -4205,8 +4540,13 @@ func (schematics *SchematicsV1) CreateResourceQueryWithContext(ctx context.Conte
return
}
-// GetResourcesQuery : Get the resources query definition
-// Get the resources query definition.
+// GetResourcesQuery : Get resources query
+// Use this API to retrieve the information resource query by Id. For more information, about resource query commands,
+// refer to [ibmcloud schematics resource query
+// get](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-get-rq).
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) GetResourcesQuery(getResourcesQueryOptions *GetResourcesQueryOptions) (result *ResourceQueryRecord, response *core.DetailedResponse, err error) {
return schematics.GetResourcesQueryWithContext(context.Background(), getResourcesQueryOptions)
}
@@ -4265,8 +4605,15 @@ func (schematics *SchematicsV1) GetResourcesQueryWithContext(ctx context.Context
return
}
-// ReplaceResourcesQuery : Replace the resources query definition
-// Replace the resources query definition.
+// ReplaceResourcesQuery : Replace resources query definition
+// Use this API to replace the resource query definition used to build the dynamic inventory for the Schematics Action.
+// For more information, about resource query commands, refer to [ibmcloud schematics resource query
+// update](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-update-rq).
+// **Note** you cannot update the location and region, resource group once a resource query is created. Also, make sure
+// your IP addresses are in the [allowlist](/docs/schematics?topic=schematics-allowed-ipaddresses).
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) ReplaceResourcesQuery(replaceResourcesQueryOptions *ReplaceResourcesQueryOptions) (result *ResourceQueryRecord, response *core.DetailedResponse, err error) {
return schematics.ReplaceResourcesQueryWithContext(context.Background(), replaceResourcesQueryOptions)
}
@@ -4342,7 +4689,7 @@ func (schematics *SchematicsV1) ReplaceResourcesQueryWithContext(ctx context.Con
}
// ExecuteResourceQuery : Run the resource query
-// Execute a resource query definition.
+// Run the resource query.
func (schematics *SchematicsV1) ExecuteResourceQuery(executeResourceQueryOptions *ExecuteResourceQueryOptions) (result *ResourceQueryResponseRecord, response *core.DetailedResponse, err error) {
return schematics.ExecuteResourceQueryWithContext(context.Background(), executeResourceQueryOptions)
}
@@ -4401,8 +4748,13 @@ func (schematics *SchematicsV1) ExecuteResourceQueryWithContext(ctx context.Cont
return
}
-// DeleteResourcesQuery : Delete the resources query definition
-// Delete the resources query definition.
+// DeleteResourcesQuery : Delete resources query
+// Use this API to delete the resource query definition by Id. For more information, about resource query commands,
+// refer to [ibmcloud schematics resource query
+// delete](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-delete-resource-query).
+// Authorization Schematics support generic authorization such as service access or platform access to an
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#action-permissions).
func (schematics *SchematicsV1) DeleteResourcesQuery(deleteResourcesQueryOptions *DeleteResourcesQueryOptions) (response *core.DetailedResponse, err error) {
return schematics.DeleteResourcesQueryWithContext(context.Background(), deleteResourcesQueryOptions)
}
@@ -4455,8 +4807,12 @@ func (schematics *SchematicsV1) DeleteResourcesQueryWithContext(ctx context.Cont
return
}
-// GetKmsSettings : Get the KMS settings for customer account
-// Get the KMS settings for customer account.
+// GetKmsSettings : Get the KMS settings
+// Retrieve the KMS on the API endpoint that you have access. For example, if you use an API endpoint for a geography,
+// such as North America, only Schematics resource that are created in `us-south` or `us-east` are retrieved.
+// Authorization Schematics support generic authorization such as service access or platform access to the
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
func (schematics *SchematicsV1) GetKmsSettings(getKmsSettingsOptions *GetKmsSettingsOptions) (result *KMSSettings, response *core.DetailedResponse, err error) {
return schematics.GetKmsSettingsWithContext(context.Background(), getKmsSettingsOptions)
}
@@ -4513,19 +4869,25 @@ func (schematics *SchematicsV1) GetKmsSettingsWithContext(ctx context.Context, g
return
}
-// ReplaceKmsSettings : Set the KMS settings for customer account
-// Set the KMS settings for customer account.
-func (schematics *SchematicsV1) ReplaceKmsSettings(replaceKmsSettingsOptions *ReplaceKmsSettingsOptions) (result *KMSSettings, response *core.DetailedResponse, err error) {
- return schematics.ReplaceKmsSettingsWithContext(context.Background(), replaceKmsSettingsOptions)
+// UpdateKmsSettings : Replace the KMS settings
+// Replace or Update the KMS setting for your location, by using your private endpoint, `CRN`, primary `CRK`, and
+// secondary `CRK`. **Note** you can update the KMS settings only once. For example, if you use an API endpoint for a
+// geography, such as North America, only Schematics resource that are created in `us-south` or `us-east` are retrieved.
+//
+// Authorization Schematics support generic authorization such as service access or platform access to the
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
+func (schematics *SchematicsV1) UpdateKmsSettings(updateKmsSettingsOptions *UpdateKmsSettingsOptions) (result *KMSSettings, response *core.DetailedResponse, err error) {
+ return schematics.UpdateKmsSettingsWithContext(context.Background(), updateKmsSettingsOptions)
}
-// ReplaceKmsSettingsWithContext is an alternate form of the ReplaceKmsSettings method which supports a Context parameter
-func (schematics *SchematicsV1) ReplaceKmsSettingsWithContext(ctx context.Context, replaceKmsSettingsOptions *ReplaceKmsSettingsOptions) (result *KMSSettings, response *core.DetailedResponse, err error) {
- err = core.ValidateNotNil(replaceKmsSettingsOptions, "replaceKmsSettingsOptions cannot be nil")
+// UpdateKmsSettingsWithContext is an alternate form of the UpdateKmsSettings method which supports a Context parameter
+func (schematics *SchematicsV1) UpdateKmsSettingsWithContext(ctx context.Context, updateKmsSettingsOptions *UpdateKmsSettingsOptions) (result *KMSSettings, response *core.DetailedResponse, err error) {
+ err = core.ValidateNotNil(updateKmsSettingsOptions, "updateKmsSettingsOptions cannot be nil")
if err != nil {
return
}
- err = core.ValidateStruct(replaceKmsSettingsOptions, "replaceKmsSettingsOptions")
+ err = core.ValidateStruct(updateKmsSettingsOptions, "updateKmsSettingsOptions")
if err != nil {
return
}
@@ -4538,11 +4900,11 @@ func (schematics *SchematicsV1) ReplaceKmsSettingsWithContext(ctx context.Contex
return
}
- for headerName, headerValue := range replaceKmsSettingsOptions.Headers {
+ for headerName, headerValue := range updateKmsSettingsOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
- sdkHeaders := common.GetSdkHeaders("schematics", "V1", "ReplaceKmsSettings")
+ sdkHeaders := common.GetSdkHeaders("schematics", "V1", "UpdateKmsSettings")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
@@ -4550,20 +4912,20 @@ func (schematics *SchematicsV1) ReplaceKmsSettingsWithContext(ctx context.Contex
builder.AddHeader("Content-Type", "application/json")
body := make(map[string]interface{})
- if replaceKmsSettingsOptions.Location != nil {
- body["location"] = replaceKmsSettingsOptions.Location
+ if updateKmsSettingsOptions.Location != nil {
+ body["location"] = updateKmsSettingsOptions.Location
}
- if replaceKmsSettingsOptions.EncryptionScheme != nil {
- body["encryption_scheme"] = replaceKmsSettingsOptions.EncryptionScheme
+ if updateKmsSettingsOptions.EncryptionScheme != nil {
+ body["encryption_scheme"] = updateKmsSettingsOptions.EncryptionScheme
}
- if replaceKmsSettingsOptions.ResourceGroup != nil {
- body["resource_group"] = replaceKmsSettingsOptions.ResourceGroup
+ if updateKmsSettingsOptions.ResourceGroup != nil {
+ body["resource_group"] = updateKmsSettingsOptions.ResourceGroup
}
- if replaceKmsSettingsOptions.PrimaryCrk != nil {
- body["primary_crk"] = replaceKmsSettingsOptions.PrimaryCrk
+ if updateKmsSettingsOptions.PrimaryCrk != nil {
+ body["primary_crk"] = updateKmsSettingsOptions.PrimaryCrk
}
- if replaceKmsSettingsOptions.SecondaryCrk != nil {
- body["secondary_crk"] = replaceKmsSettingsOptions.SecondaryCrk
+ if updateKmsSettingsOptions.SecondaryCrk != nil {
+ body["secondary_crk"] = updateKmsSettingsOptions.SecondaryCrk
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
@@ -4591,19 +4953,23 @@ func (schematics *SchematicsV1) ReplaceKmsSettingsWithContext(ctx context.Contex
return
}
-// GetDiscoveredKmsInstances : Discover the KMS instances in the account
-// Discover the KMS instances in the account.
-func (schematics *SchematicsV1) GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptions *GetDiscoveredKmsInstancesOptions) (result *KMSDiscovery, response *core.DetailedResponse, err error) {
- return schematics.GetDiscoveredKmsInstancesWithContext(context.Background(), getDiscoveredKmsInstancesOptions)
+// ListKms : Discover the KMS instances
+// Lists the KMS instances of your IBM Cloud account to find your Key Protect or Hyper Protect Crypto Services by using
+// the location and encrypted scheme such as KYOK or BYOK.
+// Authorization Schematics support generic authorization such as service access or platform access to the
+// action ID and the resource group. For more information, about Schematics access and permissions, see [Schematics
+// service access roles and required permissions](/docs/schematics?topic=schematics-access#access-roles).
+func (schematics *SchematicsV1) ListKms(listKmsOptions *ListKmsOptions) (result *KMSDiscovery, response *core.DetailedResponse, err error) {
+ return schematics.ListKmsWithContext(context.Background(), listKmsOptions)
}
-// GetDiscoveredKmsInstancesWithContext is an alternate form of the GetDiscoveredKmsInstances method which supports a Context parameter
-func (schematics *SchematicsV1) GetDiscoveredKmsInstancesWithContext(ctx context.Context, getDiscoveredKmsInstancesOptions *GetDiscoveredKmsInstancesOptions) (result *KMSDiscovery, response *core.DetailedResponse, err error) {
- err = core.ValidateNotNil(getDiscoveredKmsInstancesOptions, "getDiscoveredKmsInstancesOptions cannot be nil")
+// ListKmsWithContext is an alternate form of the ListKms method which supports a Context parameter
+func (schematics *SchematicsV1) ListKmsWithContext(ctx context.Context, listKmsOptions *ListKmsOptions) (result *KMSDiscovery, response *core.DetailedResponse, err error) {
+ err = core.ValidateNotNil(listKmsOptions, "listKmsOptions cannot be nil")
if err != nil {
return
}
- err = core.ValidateStruct(getDiscoveredKmsInstancesOptions, "getDiscoveredKmsInstancesOptions")
+ err = core.ValidateStruct(listKmsOptions, "listKmsOptions")
if err != nil {
return
}
@@ -4616,26 +4982,26 @@ func (schematics *SchematicsV1) GetDiscoveredKmsInstancesWithContext(ctx context
return
}
- for headerName, headerValue := range getDiscoveredKmsInstancesOptions.Headers {
+ for headerName, headerValue := range listKmsOptions.Headers {
builder.AddHeader(headerName, headerValue)
}
- sdkHeaders := common.GetSdkHeaders("schematics", "V1", "GetDiscoveredKmsInstances")
+ sdkHeaders := common.GetSdkHeaders("schematics", "V1", "ListKms")
for headerName, headerValue := range sdkHeaders {
builder.AddHeader(headerName, headerValue)
}
builder.AddHeader("Accept", "application/json")
- builder.AddQuery("encryption_scheme", fmt.Sprint(*getDiscoveredKmsInstancesOptions.EncryptionScheme))
- builder.AddQuery("location", fmt.Sprint(*getDiscoveredKmsInstancesOptions.Location))
- if getDiscoveredKmsInstancesOptions.ResourceGroup != nil {
- builder.AddQuery("resource_group", fmt.Sprint(*getDiscoveredKmsInstancesOptions.ResourceGroup))
+ builder.AddQuery("encryption_scheme", fmt.Sprint(*listKmsOptions.EncryptionScheme))
+ builder.AddQuery("location", fmt.Sprint(*listKmsOptions.Location))
+ if listKmsOptions.ResourceGroup != nil {
+ builder.AddQuery("resource_group", fmt.Sprint(*listKmsOptions.ResourceGroup))
}
- if getDiscoveredKmsInstancesOptions.Limit != nil {
- builder.AddQuery("limit", fmt.Sprint(*getDiscoveredKmsInstancesOptions.Limit))
+ if listKmsOptions.Limit != nil {
+ builder.AddQuery("limit", fmt.Sprint(*listKmsOptions.Limit))
}
- if getDiscoveredKmsInstancesOptions.Sort != nil {
- builder.AddQuery("sort", fmt.Sprint(*getDiscoveredKmsInstancesOptions.Sort))
+ if listKmsOptions.Sort != nil {
+ builder.AddQuery("sort", fmt.Sprint(*listKmsOptions.Sort))
}
request, err := builder.Build()
@@ -4659,106 +5025,30 @@ func (schematics *SchematicsV1) GetDiscoveredKmsInstancesWithContext(ctx context
return
}
-// ProcessTemplateMetaData : Create metadata by processing the template
-// Create a Template metadata definition.
-func (schematics *SchematicsV1) ProcessTemplateMetaData(processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions) (result *TemplateMetaDataResponse, response *core.DetailedResponse, err error) {
- return schematics.ProcessTemplateMetaDataWithContext(context.Background(), processTemplateMetaDataOptions)
-}
+// Action : Complete Action details with user inputs and system generated data.
+type Action struct {
+ // The unique name of your action. The name can be up to 128 characters long and can include alphanumeric characters,
+ // spaces, dashes, and underscores. **Example** you can use the name to stop action.
+ Name *string `json:"name,omitempty"`
-// ProcessTemplateMetaDataWithContext is an alternate form of the ProcessTemplateMetaData method which supports a Context parameter
-func (schematics *SchematicsV1) ProcessTemplateMetaDataWithContext(ctx context.Context, processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions) (result *TemplateMetaDataResponse, response *core.DetailedResponse, err error) {
- err = core.ValidateNotNil(processTemplateMetaDataOptions, "processTemplateMetaDataOptions cannot be nil")
- if err != nil {
- return
- }
- err = core.ValidateStruct(processTemplateMetaDataOptions, "processTemplateMetaDataOptions")
- if err != nil {
- return
- }
+ // Action description.
+ Description *string `json:"description,omitempty"`
- builder := core.NewRequestBuilder(core.POST)
- builder = builder.WithContext(ctx)
- builder.EnableGzipCompression = schematics.GetEnableGzipCompression()
- _, err = builder.ResolveRequestURL(schematics.Service.Options.URL, `/v2/template_metadata_processor`, nil)
- if err != nil {
- return
- }
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
- for headerName, headerValue := range processTemplateMetaDataOptions.Headers {
- builder.AddHeader(headerName, headerValue)
- }
+ // Resource-group name for an action. By default, action is created in default resource group.
+ ResourceGroup *string `json:"resource_group,omitempty"`
- sdkHeaders := common.GetSdkHeaders("schematics", "V1", "ProcessTemplateMetaData")
- for headerName, headerValue := range sdkHeaders {
- builder.AddHeader(headerName, headerValue)
- }
- builder.AddHeader("Accept", "application/json")
- builder.AddHeader("Content-Type", "application/json")
- if processTemplateMetaDataOptions.XGithubToken != nil {
- builder.AddHeader("X-Github-token", fmt.Sprint(*processTemplateMetaDataOptions.XGithubToken))
- }
-
- body := make(map[string]interface{})
- if processTemplateMetaDataOptions.TemplateType != nil {
- body["template_type"] = processTemplateMetaDataOptions.TemplateType
- }
- if processTemplateMetaDataOptions.Source != nil {
- body["source"] = processTemplateMetaDataOptions.Source
- }
- if processTemplateMetaDataOptions.Region != nil {
- body["region"] = processTemplateMetaDataOptions.Region
- }
- if processTemplateMetaDataOptions.SourceType != nil {
- body["source_type"] = processTemplateMetaDataOptions.SourceType
- }
- _, err = builder.SetBodyContentJSON(body)
- if err != nil {
- return
- }
-
- request, err := builder.Build()
- if err != nil {
- return
- }
-
- var rawResponse map[string]json.RawMessage
- response, err = schematics.Service.Request(request, &rawResponse)
- if err != nil {
- return
- }
- if rawResponse != nil {
- err = core.UnmarshalModel(rawResponse, "", &result, UnmarshalTemplateMetaDataResponse)
- if err != nil {
- return
- }
- response.Result = result
- }
-
- return
-}
-
-// Action : Complete Action details with user inputs and system generated data.
-type Action struct {
- // Action name (unique for an account).
- Name *string `json:"name,omitempty"`
-
- // Action description.
- Description *string `json:"description,omitempty"`
-
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string `json:"location,omitempty"`
-
- // Resource-group name for the Action. By default, Action will be created in Default Resource Group.
- ResourceGroup *string `json:"resource_group,omitempty"`
-
- // Action tags.
- Tags []string `json:"tags,omitempty"`
+ // Action tags.
+ Tags []string `json:"tags,omitempty"`
// User defined status of the Schematics object.
UserState *UserState `json:"user_state,omitempty"`
- // URL of the README file, for the source.
+ // URL of the `README` file, for the source URL.
SourceReadmeURL *string `json:"source_readme_url,omitempty"`
// Source of templates, playbooks, or controls.
@@ -4770,17 +5060,25 @@ type Action struct {
// Schematics job command parameter (playbook-name).
CommandParameter *string `json:"command_parameter,omitempty"`
- // Describes a bastion resource.
- Bastion *BastionResourceDefinition `json:"bastion,omitempty"`
-
// Target inventory record ID, used by the action or ansible playbook.
Inventory *string `json:"inventory,omitempty"`
+ // credentials of the Action.
+ Credentials []VariableData `json:"credentials,omitempty"`
+
+ // Describes a bastion resource.
+ Bastion *BastionResourceDefinition `json:"bastion,omitempty"`
+
// User editable variable data & system generated reference to value.
BastionCredential *VariableData `json:"bastion_credential,omitempty"`
- // credentials of the Action.
- Credentials []VariableData `json:"credentials,omitempty"`
+ // Inventory of host and host group for the playbook in `INI` file format. For example, `"targets_ini":
+ // "[webserverhost]
+ // 172.22.192.6
+ // [dbhost]
+ // 172.22.192.5"`. For more information, about an inventory host group syntax, see [Inventory host
+ // groups](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-inventory-host-grps).
+ TargetsIni *string `json:"targets_ini,omitempty"`
// Input variables for the Action.
Inputs []VariableData `json:"inputs,omitempty"`
@@ -4791,43 +5089,43 @@ type Action struct {
// Environment variables for the Action.
Settings []VariableData `json:"settings,omitempty"`
- // Action Id.
+ // Action ID.
ID *string `json:"id,omitempty"`
// Action Cloud Resource Name.
Crn *string `json:"crn,omitempty"`
- // Action account id.
+ // Action account ID.
Account *string `json:"account,omitempty"`
// Action Playbook Source creation time.
SourceCreatedAt *strfmt.DateTime `json:"source_created_at,omitempty"`
- // Email address of user who created the Action Playbook Source.
+ // E-mail address of user who created the Action Playbook Source.
SourceCreatedBy *string `json:"source_created_by,omitempty"`
- // Action Playbook updation time.
+ // The action playbook updation time.
SourceUpdatedAt *strfmt.DateTime `json:"source_updated_at,omitempty"`
- // Email address of user who updated the Action Playbook Source.
+ // E-mail address of user who updated the action playbook source.
SourceUpdatedBy *string `json:"source_updated_by,omitempty"`
// Action creation time.
CreatedAt *strfmt.DateTime `json:"created_at,omitempty"`
- // Email address of user who created the action.
+ // E-mail address of the user who created an action.
CreatedBy *string `json:"created_by,omitempty"`
// Action updation time.
UpdatedAt *strfmt.DateTime `json:"updated_at,omitempty"`
- // Email address of user who updated the action.
+ // E-mail address of the user who updated an action.
UpdatedBy *string `json:"updated_by,omitempty"`
// Computed state of the Action.
State *ActionState `json:"state,omitempty"`
- // Playbook names retrieved from repo.
+ // Playbook names retrieved from the respository.
PlaybookNames []string `json:"playbook_names,omitempty"`
// System lock status.
@@ -4835,8 +5133,9 @@ type Action struct {
}
// Constants associated with the Action.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
Action_Location_EuDe = "eu-de"
Action_Location_EuGb = "eu-gb"
@@ -4847,6 +5146,7 @@ const (
// Constants associated with the Action.SourceType property.
// Type of source for the Template.
const (
+ Action_SourceType_CosBucket = "cos_bucket"
Action_SourceType_ExternalScm = "external_scm"
Action_SourceType_GitHub = "git_hub"
Action_SourceType_GitHubEnterprise = "git_hub_enterprise"
@@ -4899,11 +5199,15 @@ func UnmarshalAction(m map[string]json.RawMessage, result interface{}) (err erro
if err != nil {
return
}
- err = core.UnmarshalModel(m, "bastion", &obj.Bastion, UnmarshalBastionResourceDefinition)
+ err = core.UnmarshalPrimitive(m, "inventory", &obj.Inventory)
if err != nil {
return
}
- err = core.UnmarshalPrimitive(m, "inventory", &obj.Inventory)
+ err = core.UnmarshalModel(m, "credentials", &obj.Credentials, UnmarshalVariableData)
+ if err != nil {
+ return
+ }
+ err = core.UnmarshalModel(m, "bastion", &obj.Bastion, UnmarshalBastionResourceDefinition)
if err != nil {
return
}
@@ -4911,7 +5215,7 @@ func UnmarshalAction(m map[string]json.RawMessage, result interface{}) (err erro
if err != nil {
return
}
- err = core.UnmarshalModel(m, "credentials", &obj.Credentials, UnmarshalVariableData)
+ err = core.UnmarshalPrimitive(m, "targets_ini", &obj.TargetsIni)
if err != nil {
return
}
@@ -5039,8 +5343,9 @@ type ActionLite struct {
// Action Cloud Resource Name.
Crn *string `json:"crn,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
Location *string `json:"location,omitempty"`
// Resource-group name for the Action. By default, Action will be created in Default Resource Group.
@@ -5078,8 +5383,9 @@ type ActionLite struct {
}
// Constants associated with the ActionLite.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
ActionLite_Location_EuDe = "eu-de"
ActionLite_Location_EuGb = "eu-gb"
@@ -5233,15 +5539,34 @@ func UnmarshalActionState(m map[string]json.RawMessage, result interface{}) (err
// ApplyWorkspaceCommandOptions : The ApplyWorkspaceCommand options.
type ApplyWorkspaceCommandOptions struct {
- // The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
- // API.
- WID *string `validate:"required,ne="`
+ // The ID of the workspace for which you want to run a Schematics `apply` job. To find the workspace ID, use the `GET
+ // /workspaces` API.
+ WID *string `json:"-" validate:"required,ne="`
- // The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ // The IAM refresh token is required only if you want to delete all the Terraform resources before deleting the
+ // Schematics workspace. If you want to delete the workspace only and keep all your Terraform resources, refresh token
+ // is not required.
+ //
+ // **Retrieving refresh token**:
+ // * Use `export IBMCLOUD_API_KEY=`, and execute `curl -X POST
+ // "https://iam.cloud.ibm.com/identity/token" -H "Content-Type: application/x-www-form-urlencoded" -d
+ // "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBMCLOUD_API_KEY" -u bx:bx`.
+ // * For more information, about creating IAM access token and API Docs, refer, [IAM access
+ // token](/apidocs/iam-identity-token-api#gettoken-password) and [Create API
+ // key](/apidocs/iam-identity-token-api#create-api-key).
+ //
+ // **Limitation**:
+ // * If the token is expired, you can use `refresh token` to get a new IAM access token.
+ // * The `refresh_token` parameter cannot be used to retrieve a new IAM access token.
+ // * When the IAM access token is about to expire, use the API key to create a new access token.
+ RefreshToken *string `json:"-" validate:"required"`
- // Workspace Activity Options Template.
- ActionOptions *WorkspaceActivityOptionsTemplate
+ // Workspace job options template.
+ ActionOptions *WorkspaceActivityOptionsTemplate `json:"action_options,omitempty"`
+
+ // The IAM delegated token for your IBM Cloud account. This token is required for requests that are sent via the UI
+ // only.
+ DelegatedToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -5273,6 +5598,12 @@ func (_options *ApplyWorkspaceCommandOptions) SetActionOptions(actionOptions *Wo
return _options
}
+// SetDelegatedToken : Allow user to set DelegatedToken
+func (_options *ApplyWorkspaceCommandOptions) SetDelegatedToken(delegatedToken string) *ApplyWorkspaceCommandOptions {
+ _options.DelegatedToken = core.StringPtr(delegatedToken)
+ return _options
+}
+
// SetHeaders : Allow user to set Headers
func (options *ApplyWorkspaceCommandOptions) SetHeaders(param map[string]string) *ApplyWorkspaceCommandOptions {
options.Headers = param
@@ -5380,74 +5711,85 @@ func UnmarshalCatalogRef(m map[string]json.RawMessage, result interface{}) (err
// CreateActionOptions : The CreateAction options.
type CreateActionOptions struct {
- // Action name (unique for an account).
- Name *string
+ // The unique name of your action. The name can be up to 128 characters long and can include alphanumeric characters,
+ // spaces, dashes, and underscores. **Example** you can use the name to stop action.
+ Name *string `json:"name,omitempty"`
// Action description.
- Description *string
+ Description *string `json:"description,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
- // Resource-group name for the Action. By default, Action will be created in Default Resource Group.
- ResourceGroup *string
+ // Resource-group name for an action. By default, action is created in default resource group.
+ ResourceGroup *string `json:"resource_group,omitempty"`
// Action tags.
- Tags []string
+ Tags []string `json:"tags,omitempty"`
// User defined status of the Schematics object.
- UserState *UserState
+ UserState *UserState `json:"user_state,omitempty"`
- // URL of the README file, for the source.
- SourceReadmeURL *string
+ // URL of the `README` file, for the source URL.
+ SourceReadmeURL *string `json:"source_readme_url,omitempty"`
// Source of templates, playbooks, or controls.
- Source *ExternalSource
+ Source *ExternalSource `json:"source,omitempty"`
// Type of source for the Template.
- SourceType *string
+ SourceType *string `json:"source_type,omitempty"`
// Schematics job command parameter (playbook-name).
- CommandParameter *string
-
- // Describes a bastion resource.
- Bastion *BastionResourceDefinition
+ CommandParameter *string `json:"command_parameter,omitempty"`
// Target inventory record ID, used by the action or ansible playbook.
- Inventory *string
+ Inventory *string `json:"inventory,omitempty"`
+
+ // credentials of the Action.
+ Credentials []VariableData `json:"credentials,omitempty"`
+
+ // Describes a bastion resource.
+ Bastion *BastionResourceDefinition `json:"bastion,omitempty"`
// User editable variable data & system generated reference to value.
- BastionCredential *VariableData
+ BastionCredential *VariableData `json:"bastion_credential,omitempty"`
- // credentials of the Action.
- Credentials []VariableData
+ // Inventory of host and host group for the playbook in `INI` file format. For example, `"targets_ini":
+ // "[webserverhost]
+ // 172.22.192.6
+ // [dbhost]
+ // 172.22.192.5"`. For more information, about an inventory host group syntax, see [Inventory host
+ // groups](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-inventory-host-grps).
+ TargetsIni *string `json:"targets_ini,omitempty"`
// Input variables for the Action.
- Inputs []VariableData
+ Inputs []VariableData `json:"inputs,omitempty"`
// Output variables for the Action.
- Outputs []VariableData
+ Outputs []VariableData `json:"outputs,omitempty"`
// Environment variables for the Action.
- Settings []VariableData
+ Settings []VariableData `json:"settings,omitempty"`
// Computed state of the Action.
- State *ActionState
+ State *ActionState `json:"state,omitempty"`
// System lock status.
- SysLock *SystemLock
+ SysLock *SystemLock `json:"sys_lock,omitempty"`
- // The github token associated with the GIT. Required for cloning of repo.
- XGithubToken *string
+ // The personal access token associated with your GitHub or GitLab repository, required to clone the repository.
+ XGithubToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
}
// Constants associated with the CreateActionOptions.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
CreateActionOptions_Location_EuDe = "eu-de"
CreateActionOptions_Location_EuGb = "eu-gb"
@@ -5458,6 +5800,7 @@ const (
// Constants associated with the CreateActionOptions.SourceType property.
// Type of source for the Template.
const (
+ CreateActionOptions_SourceType_CosBucket = "cos_bucket"
CreateActionOptions_SourceType_ExternalScm = "external_scm"
CreateActionOptions_SourceType_GitHub = "git_hub"
CreateActionOptions_SourceType_GitHubEnterprise = "git_hub_enterprise"
@@ -5532,27 +5875,33 @@ func (_options *CreateActionOptions) SetCommandParameter(commandParameter string
return _options
}
-// SetBastion : Allow user to set Bastion
-func (_options *CreateActionOptions) SetBastion(bastion *BastionResourceDefinition) *CreateActionOptions {
- _options.Bastion = bastion
- return _options
-}
-
// SetInventory : Allow user to set Inventory
func (_options *CreateActionOptions) SetInventory(inventory string) *CreateActionOptions {
_options.Inventory = core.StringPtr(inventory)
return _options
}
+// SetCredentials : Allow user to set Credentials
+func (_options *CreateActionOptions) SetCredentials(credentials []VariableData) *CreateActionOptions {
+ _options.Credentials = credentials
+ return _options
+}
+
+// SetBastion : Allow user to set Bastion
+func (_options *CreateActionOptions) SetBastion(bastion *BastionResourceDefinition) *CreateActionOptions {
+ _options.Bastion = bastion
+ return _options
+}
+
// SetBastionCredential : Allow user to set BastionCredential
func (_options *CreateActionOptions) SetBastionCredential(bastionCredential *VariableData) *CreateActionOptions {
_options.BastionCredential = bastionCredential
return _options
}
-// SetCredentials : Allow user to set Credentials
-func (_options *CreateActionOptions) SetCredentials(credentials []VariableData) *CreateActionOptions {
- _options.Credentials = credentials
+// SetTargetsIni : Allow user to set TargetsIni
+func (_options *CreateActionOptions) SetTargetsIni(targetsIni string) *CreateActionOptions {
+ _options.TargetsIni = core.StringPtr(targetsIni)
return _options
}
@@ -5600,32 +5949,35 @@ func (options *CreateActionOptions) SetHeaders(param map[string]string) *CreateA
// CreateInventoryOptions : The CreateInventory options.
type CreateInventoryOptions struct {
- // Inventory name.
- Name *string
+ // The unique name of your Inventory resource. The name can be up to 128 characters long and can include alphanumeric
+ // characters, spaces, dashes, and underscores.
+ Name *string `json:"name,omitempty"`
- // Inventory description.
- Description *string
+ // The description of your Inventory resource. The description can be up to 2048 characters long in size.
+ Description *string `json:"description,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
- // Resource-group name for the Inventory definition. By default, Action will be created in Default Resource Group.
- ResourceGroup *string
+ // Resource-group name for the Inventory resource. By default, Action will be created in Default Resource Group.
+ ResourceGroup *string `json:"resource_group,omitempty"`
- // Input inventory of host and host group for the playbook, in the .ini file format.
- InventoriesIni *string
+ // Input inventory of host and host group for the playbook, in the `.ini` file format.
+ InventoriesIni *string `json:"inventories_ini,omitempty"`
- // Input resource queries that is used to dynamically generate the inventory of host and host group for the playbook.
- ResourceQueries []string
+ // Input resource queries that is used to dynamically generate the inventory of host and host group for the playbook.
+ ResourceQueries []string `json:"resource_queries,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
}
// Constants associated with the CreateInventoryOptions.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
CreateInventoryOptions_Location_EuDe = "eu-de"
CreateInventoryOptions_Location_EuGb = "eu-gb"
@@ -5683,47 +6035,48 @@ func (options *CreateInventoryOptions) SetHeaders(param map[string]string) *Crea
// CreateJobOptions : The CreateJob options.
type CreateJobOptions struct {
// The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ RefreshToken *string `json:"-" validate:"required"`
// Name of the Schematics automation resource.
- CommandObject *string
+ CommandObject *string `json:"command_object,omitempty"`
- // Job command object id (workspace-id or action-id or environment-id).
- CommandObjectID *string
+ // Job command object id (workspace-id, action-id).
+ CommandObjectID *string `json:"command_object_id,omitempty"`
// Schematics job command name.
- CommandName *string
+ CommandName *string `json:"command_name,omitempty"`
// Schematics job command parameter (playbook-name).
- CommandParameter *string
+ CommandParameter *string `json:"command_parameter,omitempty"`
// Command line options for the command.
- CommandOptions []string
+ CommandOptions []string `json:"command_options,omitempty"`
// Job inputs used by Action or Workspace.
- Inputs []VariableData
+ Inputs []VariableData `json:"inputs,omitempty"`
// Environment variables used by the Job while performing Action or Workspace.
- Settings []VariableData
+ Settings []VariableData `json:"settings,omitempty"`
// User defined tags, while running the job.
- Tags []string
+ Tags []string `json:"tags,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
// Job Status.
- Status *JobStatus
+ Status *JobStatus `json:"status,omitempty"`
// Job data.
- Data *JobData
+ Data *JobData `json:"data,omitempty"`
// Describes a bastion resource.
- Bastion *BastionResourceDefinition
+ Bastion *BastionResourceDefinition `json:"bastion,omitempty"`
// Job log summary record.
- LogSummary *JobLogSummary
+ LogSummary *JobLogSummary `json:"log_summary,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -5771,8 +6124,9 @@ const (
)
// Constants associated with the CreateJobOptions.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
CreateJobOptions_Location_EuDe = "eu-de"
CreateJobOptions_Location_EuGb = "eu-gb"
@@ -5880,12 +6234,12 @@ func (options *CreateJobOptions) SetHeaders(param map[string]string) *CreateJobO
// CreateResourceQueryOptions : The CreateResourceQuery options.
type CreateResourceQueryOptions struct {
// Resource type (cluster, vsi, icd, vpc).
- Type *string
+ Type *string `json:"type,omitempty"`
// Resource query name.
- Name *string
+ Name *string `json:"name,omitempty"`
- Queries []ResourceQuery
+ Queries []ResourceQuery `json:"queries,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -5929,25 +6283,25 @@ func (options *CreateResourceQueryOptions) SetHeaders(param map[string]string) *
// CreateWorkspaceDeletionJobOptions : The CreateWorkspaceDeletionJob options.
type CreateWorkspaceDeletionJobOptions struct {
// The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ RefreshToken *string `json:"-" validate:"required"`
// True to delete workspace.
- NewDeleteWorkspaces *bool
+ NewDeleteWorkspaces *bool `json:"delete_workspaces,omitempty"`
// True to destroy the resources managed by this workspace.
- NewDestroyResources *bool
+ NewDestroyResources *bool `json:"destroy_resources,omitempty"`
// Workspace deletion job name.
- NewJob *string
+ NewJob *string `json:"job,omitempty"`
- // Version.
- NewVersion *string
+ // Version of the terraform template.
+ NewVersion *string `json:"version,omitempty"`
// List of workspaces to be deleted.
- NewWorkspaces []string
+ NewWorkspaces []string `json:"workspaces,omitempty"`
// true or 1 - to destroy resources before deleting workspace; If this is true, refresh_token is mandatory.
- DestroyResources *string
+ DestroyResources *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6011,55 +6365,55 @@ func (options *CreateWorkspaceDeletionJobOptions) SetHeaders(param map[string]st
// CreateWorkspaceOptions : The CreateWorkspace options.
type CreateWorkspaceOptions struct {
// List of applied shared dataset ID.
- AppliedShareddataIds []string
+ AppliedShareddataIds []string `json:"applied_shareddata_ids,omitempty"`
// Information about the software template that you chose from the IBM Cloud catalog. This information is returned for
// IBM Cloud catalog offerings only.
- CatalogRef *CatalogRef
+ CatalogRef *CatalogRef `json:"catalog_ref,omitempty"`
// The description of the workspace.
- Description *string
+ Description *string `json:"description,omitempty"`
- // The location where you want to create your Schematics workspace and run Schematics actions. The location that you
+ // The location where you want to create your Schematics workspace and run the Schematics jobs. The location that you
// enter must match the API endpoint that you use. For example, if you use the Frankfurt API endpoint, you must specify
// `eu-de` as your location. If you use an API endpoint for a geography and you do not specify a location, Schematics
// determines the location based on availability.
- Location *string
+ Location *string `json:"location,omitempty"`
// The name of your workspace. The name can be up to 128 characters long and can include alphanumeric characters,
// spaces, dashes, and underscores. When you create a workspace for your own Terraform template, consider including the
// microservice component that you set up with your Terraform template and the IBM Cloud environment where you want to
// deploy your resources in your name.
- Name *string
+ Name *string `json:"name,omitempty"`
// The ID of the resource group where you want to provision the workspace.
- ResourceGroup *string
+ ResourceGroup *string `json:"resource_group,omitempty"`
- // Information that is shared across templates in IBM Cloud catalog offerings. This information is not provided when
- // you create a workspace from your own Terraform template.
- SharedData *SharedTargetData
+ // Information about the Target used by the templates originating from the IBM Cloud catalog offerings. This
+ // information is not relevant for workspace created using your own Terraform template.
+ SharedData *SharedTargetData `json:"shared_data,omitempty"`
// A list of tags that are associated with the workspace.
- Tags []string
+ Tags []string `json:"tags,omitempty"`
- // TemplateData -.
- TemplateData []TemplateSourceDataRequest
+ // Input data for the Template.
+ TemplateData []TemplateSourceDataRequest `json:"template_data,omitempty"`
// Workspace template ref.
- TemplateRef *string
+ TemplateRef *string `json:"template_ref,omitempty"`
- // TemplateRepoRequest -.
- TemplateRepo *TemplateRepoRequest
+ // Input variables for the Template repoository, while creating a workspace.
+ TemplateRepo *TemplateRepoRequest `json:"template_repo,omitempty"`
// List of Workspace type.
- Type []string
+ Type []string `json:"type,omitempty"`
// WorkspaceStatusRequest -.
- WorkspaceStatus *WorkspaceStatusRequest
+ WorkspaceStatus *WorkspaceStatusRequest `json:"workspace_status,omitempty"`
// The personal access token to authenticate with your private GitHub or GitLab repository and access your Terraform
// template.
- XGithubToken *string
+ XGithubToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6163,13 +6517,13 @@ func (options *CreateWorkspaceOptions) SetHeaders(param map[string]string) *Crea
// DeleteActionOptions : The DeleteAction options.
type DeleteActionOptions struct {
// Action Id. Use GET /actions API to look up the Action Ids in your IBM Cloud account.
- ActionID *string `validate:"required,ne="`
+ ActionID *string `json:"-" validate:"required,ne="`
// Equivalent to -force options in the command line.
- Force *bool
+ Force *bool `json:"-"`
// Auto propagate the chaange or deletion to the dependent resources.
- Propagate *bool
+ Propagate *bool `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6210,13 +6564,13 @@ func (options *DeleteActionOptions) SetHeaders(param map[string]string) *DeleteA
type DeleteInventoryOptions struct {
// Resource Inventory Id. Use GET /inventories API to look up the Resource Inventory definition Ids in your IBM Cloud
// account.
- InventoryID *string `validate:"required,ne="`
+ InventoryID *string `json:"-" validate:"required,ne="`
// Equivalent to -force options in the command line.
- Force *bool
+ Force *bool `json:"-"`
// Auto propagate the chaange or deletion to the dependent resources.
- Propagate *bool
+ Propagate *bool `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6256,16 +6610,16 @@ func (options *DeleteInventoryOptions) SetHeaders(param map[string]string) *Dele
// DeleteJobOptions : The DeleteJob options.
type DeleteJobOptions struct {
// Job Id. Use GET /jobs API to look up the Job Ids in your IBM Cloud account.
- JobID *string `validate:"required,ne="`
+ JobID *string `json:"-" validate:"required,ne="`
// The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ RefreshToken *string `json:"-" validate:"required"`
// Equivalent to -force options in the command line.
- Force *bool
+ Force *bool `json:"-"`
// Auto propagate the chaange or deletion to the dependent resources.
- Propagate *bool
+ Propagate *bool `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6313,13 +6667,13 @@ func (options *DeleteJobOptions) SetHeaders(param map[string]string) *DeleteJobO
type DeleteResourcesQueryOptions struct {
// Resource query Id. Use GET /resource_query API to look up the Resource query definition Ids in your IBM Cloud
// account.
- QueryID *string `validate:"required,ne="`
+ QueryID *string `json:"-" validate:"required,ne="`
// Equivalent to -force options in the command line.
- Force *bool
+ Force *bool `json:"-"`
// Auto propagate the chaange or deletion to the dependent resources.
- Propagate *bool
+ Propagate *bool `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6360,11 +6714,11 @@ func (options *DeleteResourcesQueryOptions) SetHeaders(param map[string]string)
type DeleteWorkspaceActivityOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the activity or job, for which you want to retrieve details. To find the job ID, use the `GET
// /v1/workspaces/{id}/actions` API.
- ActivityID *string `validate:"required,ne="`
+ ActivityID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6399,12 +6753,12 @@ func (options *DeleteWorkspaceActivityOptions) SetHeaders(param map[string]strin
// DeleteWorkspaceOptions : The DeleteWorkspace options.
type DeleteWorkspaceOptions struct {
// The ID of the workspace that you want to delete. To find the workspace ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// If set to `true`, refresh token header configuration is required to delete all the Terraform resources, and the
// Schematics workspace. If set to `false`, you can remove only the workspace. Your Terraform resources are still
// available and must be managed with the resource dashboard or CLI.
- DestroyResources *bool
+ DestroyResources *bool `json:"-"`
// The IAM refresh token is required only if you want to delete all the Terraform resources before deleting the
// Schematics workspace. If you want to delete the workspace only and keep all your Terraform resources, refresh token
@@ -6422,7 +6776,7 @@ type DeleteWorkspaceOptions struct {
// * If the token is expired, you can use `refresh token` to get a new IAM access token.
// * The `refresh_token` parameter cannot be used to retrieve a new IAM access token.
// * When the IAM access token is about to expire, use the API key to create a new access token.
- RefreshToken *string
+ RefreshToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6461,15 +6815,34 @@ func (options *DeleteWorkspaceOptions) SetHeaders(param map[string]string) *Dele
// DestroyWorkspaceCommandOptions : The DestroyWorkspaceCommand options.
type DestroyWorkspaceCommandOptions struct {
- // The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
- // API.
- WID *string `validate:"required,ne="`
+ // The ID of the workspace for which you want to perform a Schematics `destroy` job. To find the workspace ID, use the
+ // `GET /workspaces` API.
+ WID *string `json:"-" validate:"required,ne="`
- // The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ // The IAM refresh token is required only if you want to delete all the Terraform resources before deleting the
+ // Schematics workspace. If you want to delete the workspace only and keep all your Terraform resources, refresh token
+ // is not required.
+ //
+ // **Retrieving refresh token**:
+ // * Use `export IBMCLOUD_API_KEY=`, and execute `curl -X POST
+ // "https://iam.cloud.ibm.com/identity/token" -H "Content-Type: application/x-www-form-urlencoded" -d
+ // "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBMCLOUD_API_KEY" -u bx:bx`.
+ // * For more information, about creating IAM access token and API Docs, refer, [IAM access
+ // token](/apidocs/iam-identity-token-api#gettoken-password) and [Create API
+ // key](/apidocs/iam-identity-token-api#create-api-key).
+ //
+ // **Limitation**:
+ // * If the token is expired, you can use `refresh token` to get a new IAM access token.
+ // * The `refresh_token` parameter cannot be used to retrieve a new IAM access token.
+ // * When the IAM access token is about to expire, use the API key to create a new access token.
+ RefreshToken *string `json:"-" validate:"required"`
- // Workspace Activity Options Template.
- ActionOptions *WorkspaceActivityOptionsTemplate
+ // Workspace job options template.
+ ActionOptions *WorkspaceActivityOptionsTemplate `json:"action_options,omitempty"`
+
+ // The IAM delegated token for your IBM Cloud account. This token is required for requests that are sent via the UI
+ // only.
+ DelegatedToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6501,6 +6874,12 @@ func (_options *DestroyWorkspaceCommandOptions) SetActionOptions(actionOptions *
return _options
}
+// SetDelegatedToken : Allow user to set DelegatedToken
+func (_options *DestroyWorkspaceCommandOptions) SetDelegatedToken(delegatedToken string) *DestroyWorkspaceCommandOptions {
+ _options.DelegatedToken = core.StringPtr(delegatedToken)
+ return _options
+}
+
// SetHeaders : Allow user to set Headers
func (options *DestroyWorkspaceCommandOptions) SetHeaders(param map[string]string) *DestroyWorkspaceCommandOptions {
options.Headers = param
@@ -6549,7 +6928,7 @@ func UnmarshalEnvVariableResponse(m map[string]json.RawMessage, result interface
type ExecuteResourceQueryOptions struct {
// Resource query Id. Use GET /resource_query API to look up the Resource query definition Ids in your IBM Cloud
// account.
- QueryID *string `validate:"required,ne="`
+ QueryID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6584,11 +6963,15 @@ type ExternalSource struct {
// Connection details to IBM Cloud Catalog source.
Catalog *ExternalSourceCatalog `json:"catalog,omitempty"`
+
+ // Connection details to a IBM Cloud Object Storage bucket.
+ CosBucket *ExternalSourceCosBucket `json:"cos_bucket,omitempty"`
}
// Constants associated with the ExternalSource.SourceType property.
// Type of source for the Template.
const (
+ ExternalSource_SourceType_CosBucket = "cos_bucket"
ExternalSource_SourceType_ExternalScm = "external_scm"
ExternalSource_SourceType_GitHub = "git_hub"
ExternalSource_SourceType_GitHubEnterprise = "git_hub_enterprise"
@@ -6622,6 +7005,10 @@ func UnmarshalExternalSource(m map[string]json.RawMessage, result interface{}) (
if err != nil {
return
}
+ err = core.UnmarshalModel(m, "cos_bucket", &obj.CosBucket, UnmarshalExternalSourceCosBucket)
+ if err != nil {
+ return
+ }
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}
@@ -6685,6 +7072,23 @@ func UnmarshalExternalSourceCatalog(m map[string]json.RawMessage, result interfa
return
}
+// ExternalSourceCosBucket : Connection details to a IBM Cloud Object Storage bucket.
+type ExternalSourceCosBucket struct {
+ // COS Bucket Url.
+ CosBucketURL *string `json:"cos_bucket_url,omitempty"`
+}
+
+// UnmarshalExternalSourceCosBucket unmarshals an instance of ExternalSourceCosBucket from the specified map of raw messages.
+func UnmarshalExternalSourceCosBucket(m map[string]json.RawMessage, result interface{}) (err error) {
+ obj := new(ExternalSourceCosBucket)
+ err = core.UnmarshalPrimitive(m, "cos_bucket_url", &obj.CosBucketURL)
+ if err != nil {
+ return
+ }
+ reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
+ return
+}
+
// ExternalSourceGit : Connection details to Git source.
type ExternalSourceGit struct {
// The Complete URL which is computed by git_repo_url, git_repo_folder and branch.
@@ -6740,10 +7144,10 @@ func UnmarshalExternalSourceGit(m map[string]json.RawMessage, result interface{}
// GetActionOptions : The GetAction options.
type GetActionOptions struct {
// Action Id. Use GET /actions API to look up the Action Ids in your IBM Cloud account.
- ActionID *string `validate:"required,ne="`
+ ActionID *string `json:"-" validate:"required,ne="`
// Level of details returned by the get method.
- Profile *string
+ Profile *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6785,7 +7189,7 @@ func (options *GetActionOptions) SetHeaders(param map[string]string) *GetActionO
type GetAllWorkspaceInputsOptions struct {
// The ID of the workspace for which you want to retrieve information about the associated Terraform template. To find
// the workspace ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6810,111 +7214,43 @@ func (options *GetAllWorkspaceInputsOptions) SetHeaders(param map[string]string)
return options
}
-// GetDiscoveredKmsInstancesOptions : The GetDiscoveredKmsInstances options.
-type GetDiscoveredKmsInstancesOptions struct {
- // The encryption scheme to be used.
- EncryptionScheme *string `validate:"required"`
-
- // The location of the Resource.
- Location *string `validate:"required"`
-
- // The resource group (by default, fetch from all resource groups).
- ResourceGroup *string
-
- // The maximum number of workspaces that you want to list. The number must be a positive integer between 1 and 2000. If
- // no value is provided, 100 is used by default.
- Limit *int64
-
- // Name of the field to sort-by; Use the '.' character to delineate sub-resources and sub-fields (eg.
- // owner.last_name). Prepend the field with '+' or '-', indicating 'ascending' or 'descending' (default is ascending)
- // Ignore unrecognized or unsupported sort field.
- Sort *string
+// GetInventoryOptions : The GetInventory options.
+type GetInventoryOptions struct {
+ // Resource Inventory Id. Use GET /inventories API to look up the Resource Inventory definition Ids in your IBM Cloud
+ // account.
+ InventoryID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
}
-// NewGetDiscoveredKmsInstancesOptions : Instantiate GetDiscoveredKmsInstancesOptions
-func (*SchematicsV1) NewGetDiscoveredKmsInstancesOptions(encryptionScheme string, location string) *GetDiscoveredKmsInstancesOptions {
- return &GetDiscoveredKmsInstancesOptions{
- EncryptionScheme: core.StringPtr(encryptionScheme),
- Location: core.StringPtr(location),
+// NewGetInventoryOptions : Instantiate GetInventoryOptions
+func (*SchematicsV1) NewGetInventoryOptions(inventoryID string) *GetInventoryOptions {
+ return &GetInventoryOptions{
+ InventoryID: core.StringPtr(inventoryID),
}
}
-// SetEncryptionScheme : Allow user to set EncryptionScheme
-func (_options *GetDiscoveredKmsInstancesOptions) SetEncryptionScheme(encryptionScheme string) *GetDiscoveredKmsInstancesOptions {
- _options.EncryptionScheme = core.StringPtr(encryptionScheme)
- return _options
-}
-
-// SetLocation : Allow user to set Location
-func (_options *GetDiscoveredKmsInstancesOptions) SetLocation(location string) *GetDiscoveredKmsInstancesOptions {
- _options.Location = core.StringPtr(location)
+// SetInventoryID : Allow user to set InventoryID
+func (_options *GetInventoryOptions) SetInventoryID(inventoryID string) *GetInventoryOptions {
+ _options.InventoryID = core.StringPtr(inventoryID)
return _options
}
-// SetResourceGroup : Allow user to set ResourceGroup
-func (_options *GetDiscoveredKmsInstancesOptions) SetResourceGroup(resourceGroup string) *GetDiscoveredKmsInstancesOptions {
- _options.ResourceGroup = core.StringPtr(resourceGroup)
- return _options
-}
-
-// SetLimit : Allow user to set Limit
-func (_options *GetDiscoveredKmsInstancesOptions) SetLimit(limit int64) *GetDiscoveredKmsInstancesOptions {
- _options.Limit = core.Int64Ptr(limit)
- return _options
-}
-
-// SetSort : Allow user to set Sort
-func (_options *GetDiscoveredKmsInstancesOptions) SetSort(sort string) *GetDiscoveredKmsInstancesOptions {
- _options.Sort = core.StringPtr(sort)
- return _options
-}
-
-// SetHeaders : Allow user to set Headers
-func (options *GetDiscoveredKmsInstancesOptions) SetHeaders(param map[string]string) *GetDiscoveredKmsInstancesOptions {
- options.Headers = param
- return options
-}
-
-// GetInventoryOptions : The GetInventory options.
-type GetInventoryOptions struct {
- // Resource Inventory Id. Use GET /inventories API to look up the Resource Inventory definition Ids in your IBM Cloud
- // account.
- InventoryID *string `validate:"required,ne="`
-
- // Allows users to set headers on API requests
- Headers map[string]string
-}
-
-// NewGetInventoryOptions : Instantiate GetInventoryOptions
-func (*SchematicsV1) NewGetInventoryOptions(inventoryID string) *GetInventoryOptions {
- return &GetInventoryOptions{
- InventoryID: core.StringPtr(inventoryID),
- }
-}
-
-// SetInventoryID : Allow user to set InventoryID
-func (_options *GetInventoryOptions) SetInventoryID(inventoryID string) *GetInventoryOptions {
- _options.InventoryID = core.StringPtr(inventoryID)
- return _options
-}
-
-// SetHeaders : Allow user to set Headers
-func (options *GetInventoryOptions) SetHeaders(param map[string]string) *GetInventoryOptions {
- options.Headers = param
- return options
+// SetHeaders : Allow user to set Headers
+func (options *GetInventoryOptions) SetHeaders(param map[string]string) *GetInventoryOptions {
+ options.Headers = param
+ return options
}
// GetInventoryValueOptions : The GetInventoryValue options.
type GetInventoryValueOptions struct {
// Resource Inventory Id. Use GET /inventories API to look up the Resource Inventory definition Ids in your IBM Cloud
// account.
- InventoryID *string `validate:"required,ne="`
+ InventoryID *string `json:"-" validate:"required,ne="`
// Name of the variable.
- VarName *string `validate:"required,ne="`
+ VarName *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6949,10 +7285,10 @@ func (options *GetInventoryValueOptions) SetHeaders(param map[string]string) *Ge
// GetJobOptions : The GetJob options.
type GetJobOptions struct {
// Job Id. Use GET /jobs API to look up the Job Ids in your IBM Cloud account.
- JobID *string `validate:"required,ne="`
+ JobID *string `json:"-" validate:"required,ne="`
// Level of details returned by the get method.
- Profile *string
+ Profile *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -6993,7 +7329,7 @@ func (options *GetJobOptions) SetHeaders(param map[string]string) *GetJobOptions
// GetKmsSettingsOptions : The GetKmsSettings options.
type GetKmsSettingsOptions struct {
// The location of the Resource.
- Location *string `validate:"required"`
+ Location *string `json:"-" validate:"required"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7022,7 +7358,7 @@ func (options *GetKmsSettingsOptions) SetHeaders(param map[string]string) *GetKm
type GetResourcesQueryOptions struct {
// Resource query Id. Use GET /resource_query API to look up the Resource query definition Ids in your IBM Cloud
// account.
- QueryID *string `validate:"required,ne="`
+ QueryID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7069,27 +7405,31 @@ func (options *GetSchematicsVersionOptions) SetHeaders(param map[string]string)
type GetTemplateActivityLogOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
- // The Template ID for which you want to get the values. Use the GET /workspaces to look up the workspace IDs or
- // template IDs in your IBM Cloud account.
- TID *string `validate:"required,ne="`
+ // The ID that was assigned to your Terraform template or IBM Cloud catalog software template. To find the ID, use the
+ // GET /v1/workspaces API.
+ TID *string `json:"-" validate:"required,ne="`
// The ID of the activity or job, for which you want to retrieve details. To find the job ID, use the `GET
// /v1/workspaces/{id}/actions` API.
- ActivityID *string `validate:"required,ne="`
+ ActivityID *string `json:"-" validate:"required,ne="`
- // `false` will hide the terraform command header in the logs.
- LogTfCmd *bool
+ // Enter false to replace the first line in each Terraform command section, such as Terraform INIT or Terraform PLAN,
+ // with Schematics INIT (Schematics PLAN) in your log output. In addition, the log lines Starting command: terraform
+ // init -input=false -no-color and Starting command: terraform apply -state=terraform.tfstate
+ // -var-file=schematics.tfvars -auto-approve -no-color are suppressed. All subsequent command lines still use the
+ // Terraform command prefix. To remove this prefix, use the log_tf_prefix option.
+ LogTfCmd *bool `json:"-"`
// `false` will hide all the terraform command prefix in the log statements.
- LogTfPrefix *bool
+ LogTfPrefix *bool `json:"-"`
// `false` will hide all the null resource prefix in the log statements.
- LogTfNullResource *bool
+ LogTfNullResource *bool `json:"-"`
// `true` will format all logs to withhold the original format of ansible output in the log statements.
- LogTfAnsible *bool
+ LogTfAnsible *bool `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7156,23 +7496,27 @@ func (options *GetTemplateActivityLogOptions) SetHeaders(param map[string]string
type GetTemplateLogsOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
- // The Template ID for which you want to get the values. Use the GET /workspaces to look up the workspace IDs or
- // template IDs in your IBM Cloud account.
- TID *string `validate:"required,ne="`
+ // The ID that was assigned to your Terraform template or IBM Cloud catalog software template. To find the ID, use the
+ // GET /v1/workspaces API.
+ TID *string `json:"-" validate:"required,ne="`
- // `false` will hide the terraform command header in the logs.
- LogTfCmd *bool
+ // Enter false to replace the first line in each Terraform command section, such as Terraform INIT or Terraform PLAN,
+ // with Schematics INIT (Schematics PLAN) in your log output. In addition, the log lines Starting command: terraform
+ // init -input=false -no-color and Starting command: terraform apply -state=terraform.tfstate
+ // -var-file=schematics.tfvars -auto-approve -no-color are suppressed. All subsequent command lines still use the
+ // Terraform command prefix. To remove this prefix, use the log_tf_prefix option.
+ LogTfCmd *bool `json:"-"`
// `false` will hide all the terraform command prefix in the log statements.
- LogTfPrefix *bool
+ LogTfPrefix *bool `json:"-"`
// `false` will hide all the null resource prefix in the log statements.
- LogTfNullResource *bool
+ LogTfNullResource *bool `json:"-"`
// `true` will format all logs to withhold the original format of ansible output in the log statements.
- LogTfAnsible *bool
+ LogTfAnsible *bool `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7230,13 +7574,13 @@ func (options *GetTemplateLogsOptions) SetHeaders(param map[string]string) *GetT
// GetWorkspaceActivityLogsOptions : The GetWorkspaceActivityLogs options.
type GetWorkspaceActivityLogsOptions struct {
- // The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
- // API.
- WID *string `validate:"required,ne="`
+ // The ID of the workspace for which you want to retrieve the Terraform statefile URL. To find the workspace ID, use
+ // the GET /v1/workspaces API.
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the activity or job, for which you want to retrieve details. To find the job ID, use the `GET
// /v1/workspaces/{id}/actions` API.
- ActivityID *string `validate:"required,ne="`
+ ActivityID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7272,11 +7616,11 @@ func (options *GetWorkspaceActivityLogsOptions) SetHeaders(param map[string]stri
type GetWorkspaceActivityOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the activity or job, for which you want to retrieve details. To find the job ID, use the `GET
// /v1/workspaces/{id}/actions` API.
- ActivityID *string `validate:"required,ne="`
+ ActivityID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7311,7 +7655,7 @@ func (options *GetWorkspaceActivityOptions) SetHeaders(param map[string]string)
// GetWorkspaceDeletionJobStatusOptions : The GetWorkspaceDeletionJobStatus options.
type GetWorkspaceDeletionJobStatusOptions struct {
// The workspace job ID.
- WjID *string `validate:"required,ne="`
+ WjID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7340,12 +7684,12 @@ func (options *GetWorkspaceDeletionJobStatusOptions) SetHeaders(param map[string
type GetWorkspaceInputMetadataOptions struct {
// The ID of the workspace for which you want to retrieve the metadata of the input variables that are declared in the
// template. To find the workspace ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the Terraform template for which you want to retrieve the metadata of your input variables. When you
// create a workspace, the Terraform template that your workspace points to is assigned a unique ID. To find this ID,
// use the `GET /v1/workspaces` API and review the `template_data.id` value.
- TID *string `validate:"required,ne="`
+ TID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7381,12 +7725,12 @@ func (options *GetWorkspaceInputMetadataOptions) SetHeaders(param map[string]str
type GetWorkspaceInputsOptions struct {
// The ID of the workspace for which you want to retrieve the input variables that you declared in your Terraform
// template. To find the workspace ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the Terraform template for which you want to retrieve all your input variables. When you create a
// workspace, the Terraform template that your workspace points to is assigned a unique ID. To find this ID, use the
// `GET /v1/workspaces` API and review the `template_data.id` value.
- TID *string `validate:"required,ne="`
+ TID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7422,7 +7766,7 @@ func (options *GetWorkspaceInputsOptions) SetHeaders(param map[string]string) *G
type GetWorkspaceLogUrlsOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7451,7 +7795,7 @@ func (options *GetWorkspaceLogUrlsOptions) SetHeaders(param map[string]string) *
type GetWorkspaceOptions struct {
// The ID of the workspace for which you want to retrieve detailed information. To find the workspace ID, use the `GET
// /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7480,7 +7824,7 @@ func (options *GetWorkspaceOptions) SetHeaders(param map[string]string) *GetWork
type GetWorkspaceOutputsOptions struct {
// The ID of the workspace for which you want to retrieve output values. To find the workspace ID, use the `GET
// /workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7509,15 +7853,15 @@ func (options *GetWorkspaceOutputsOptions) SetHeaders(param map[string]string) *
type GetWorkspaceReadmeOptions struct {
// The ID of the workspace for which you want to retrieve the `README.md` file that is stored in the GitHub or GitLab
// repository that your workspace points to. To find the workspace ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The GitHub or GitLab branch where the `README.md` file is stored, or the commit ID or tag that references the
// `README.md` file that you want to retrieve. If you do not specify this option, the `README.md` file is retrieved
// from the master branch by default.
- Ref *string
+ Ref *string `json:"-"`
// The format of the readme file. Value ''markdown'' will give markdown, otherwise html.
- Formatted *string
+ Formatted *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7565,7 +7909,7 @@ func (options *GetWorkspaceReadmeOptions) SetHeaders(param map[string]string) *G
type GetWorkspaceResourcesOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7594,7 +7938,7 @@ func (options *GetWorkspaceResourcesOptions) SetHeaders(param map[string]string)
type GetWorkspaceStateOptions struct {
// The ID of the workspace for which you want to retrieve the Terraform statefile URL. To find the workspace ID, use
// the GET /v1/workspaces API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7623,12 +7967,12 @@ func (options *GetWorkspaceStateOptions) SetHeaders(param map[string]string) *Ge
type GetWorkspaceTemplateStateOptions struct {
// The ID of the workspace for which you want to retrieve the Terraform statefile URL. To find the workspace ID, use
// the GET /v1/workspaces API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the Terraform template for which you want to retrieve the Terraform statefile. When you create a
// workspace, the Terraform template that your workspace points to is assigned a unique ID. To find this ID, use the
// GET /v1/workspaces API and review the template_data.id value.
- TID *string `validate:"required,ne="`
+ TID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -7662,17 +8006,19 @@ func (options *GetWorkspaceTemplateStateOptions) SetHeaders(param map[string]str
// InventoryResourceRecord : Complete inventory resource details with user inputs and system generated data.
type InventoryResourceRecord struct {
- // Inventory name.
+ // The unique name of your Inventory. The name can be up to 128 characters long and can include alphanumeric
+ // characters, spaces, dashes, and underscores.
Name *string `json:"name,omitempty"`
// Inventory id.
ID *string `json:"id,omitempty"`
- // Inventory description.
+ // The description of your Inventory. The description can be up to 2048 characters long in size.
Description *string `json:"description,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
Location *string `json:"location,omitempty"`
// Resource-group name for the Inventory definition. By default, Action will be created in Default Resource Group.
@@ -7698,8 +8044,9 @@ type InventoryResourceRecord struct {
}
// Constants associated with the InventoryResourceRecord.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
InventoryResourceRecord_Location_EuDe = "eu-de"
InventoryResourceRecord_Location_EuGb = "eu-gb"
@@ -7801,7 +8148,7 @@ type Job struct {
// Name of the Schematics automation resource.
CommandObject *string `json:"command_object,omitempty"`
- // Job command object id (workspace-id or action-id or environment-id).
+ // Job command object id (workspace-id, action-id).
CommandObjectID *string `json:"command_object_id,omitempty"`
// Schematics job command name.
@@ -7828,11 +8175,13 @@ type Job struct {
// Job name, uniquely derived from the related Workspace or Action.
Name *string `json:"name,omitempty"`
- // Job description derived from the related Workspace or Action.
+ // The description of your job is derived from the related action or workspace. The description can be up to 2048
+ // characters long in size.
Description *string `json:"description,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
Location *string `json:"location,omitempty"`
// Resource-group name derived from the related Workspace or Action.
@@ -7920,8 +8269,9 @@ const (
)
// Constants associated with the Job.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
Job_Location_EuDe = "eu-de"
Job_Location_EuGb = "eu-gb"
@@ -8293,18 +8643,15 @@ func UnmarshalJobDataTemplate(m map[string]json.RawMessage, result interface{})
// JobDataWorkItem : Environment work items.
type JobDataWorkItem struct {
- // Workspace id.
- WorkspaceID *string `json:"workspace_id,omitempty"`
+ // command object id.
+ CommandObjectID *string `json:"command_object_id,omitempty"`
+
+ // command object name.
+ CommandObjectName *string `json:"command_object_name,omitempty"`
// layer name.
Layers *string `json:"layers,omitempty"`
- // Workspace name.
- WorkspaceName *string `json:"workspace_name,omitempty"`
-
- // Workspace job id.
- JobID *string `json:"job_id,omitempty"`
-
// Type of source for the Template.
SourceType *string `json:"source_type,omitempty"`
@@ -8320,6 +8667,9 @@ type JobDataWorkItem struct {
// Environment variables for the workItem.
Settings []VariableData `json:"settings,omitempty"`
+ // Status of the last job executed by the workitem.
+ LastJob *JobDataWorkItemLastJob `json:"last_job,omitempty"`
+
// Job status updation timestamp.
UpdatedAt *strfmt.DateTime `json:"updated_at,omitempty"`
}
@@ -8327,6 +8677,7 @@ type JobDataWorkItem struct {
// Constants associated with the JobDataWorkItem.SourceType property.
// Type of source for the Template.
const (
+ JobDataWorkItem_SourceType_CosBucket = "cos_bucket"
JobDataWorkItem_SourceType_ExternalScm = "external_scm"
JobDataWorkItem_SourceType_GitHub = "git_hub"
JobDataWorkItem_SourceType_GitHubEnterprise = "git_hub_enterprise"
@@ -8339,19 +8690,15 @@ const (
// UnmarshalJobDataWorkItem unmarshals an instance of JobDataWorkItem from the specified map of raw messages.
func UnmarshalJobDataWorkItem(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(JobDataWorkItem)
- err = core.UnmarshalPrimitive(m, "workspace_id", &obj.WorkspaceID)
- if err != nil {
- return
- }
- err = core.UnmarshalPrimitive(m, "layers", &obj.Layers)
+ err = core.UnmarshalPrimitive(m, "command_object_id", &obj.CommandObjectID)
if err != nil {
return
}
- err = core.UnmarshalPrimitive(m, "workspace_name", &obj.WorkspaceName)
+ err = core.UnmarshalPrimitive(m, "command_object_name", &obj.CommandObjectName)
if err != nil {
return
}
- err = core.UnmarshalPrimitive(m, "job_id", &obj.JobID)
+ err = core.UnmarshalPrimitive(m, "layers", &obj.Layers)
if err != nil {
return
}
@@ -8375,6 +8722,10 @@ func UnmarshalJobDataWorkItem(m map[string]json.RawMessage, result interface{})
if err != nil {
return
}
+ err = core.UnmarshalModel(m, "last_job", &obj.LastJob, UnmarshalJobDataWorkItemLastJob)
+ if err != nil {
+ return
+ }
err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt)
if err != nil {
return
@@ -8383,6 +8734,109 @@ func UnmarshalJobDataWorkItem(m map[string]json.RawMessage, result interface{})
return
}
+// JobDataWorkItemLastJob : Status of the last job executed by the workitem.
+type JobDataWorkItemLastJob struct {
+ // Name of the Schematics automation resource.
+ CommandObject *string `json:"command_object,omitempty"`
+
+ // command object name (workspace_name/action_name).
+ CommandObjectName *string `json:"command_object_name,omitempty"`
+
+ // Workitem command object id, maps to workspace_id or action_id.
+ CommandObjectID *string `json:"command_object_id,omitempty"`
+
+ // Schematics job command name.
+ CommandName *string `json:"command_name,omitempty"`
+
+ // Workspace job id.
+ JobID *string `json:"job_id,omitempty"`
+
+ // Status of Jobs.
+ JobStatus *string `json:"job_status,omitempty"`
+}
+
+// Constants associated with the JobDataWorkItemLastJob.CommandObject property.
+// Name of the Schematics automation resource.
+const (
+ JobDataWorkItemLastJob_CommandObject_Action = "action"
+ JobDataWorkItemLastJob_CommandObject_Environment = "environment"
+ JobDataWorkItemLastJob_CommandObject_System = "system"
+ JobDataWorkItemLastJob_CommandObject_Workspace = "workspace"
+)
+
+// Constants associated with the JobDataWorkItemLastJob.CommandName property.
+// Schematics job command name.
+const (
+ JobDataWorkItemLastJob_CommandName_AnsiblePlaybookCheck = "ansible_playbook_check"
+ JobDataWorkItemLastJob_CommandName_AnsiblePlaybookRun = "ansible_playbook_run"
+ JobDataWorkItemLastJob_CommandName_CreateAction = "create_action"
+ JobDataWorkItemLastJob_CommandName_CreateCart = "create_cart"
+ JobDataWorkItemLastJob_CommandName_CreateEnvironment = "create_environment"
+ JobDataWorkItemLastJob_CommandName_CreateWorkspace = "create_workspace"
+ JobDataWorkItemLastJob_CommandName_DeleteAction = "delete_action"
+ JobDataWorkItemLastJob_CommandName_DeleteEnvironment = "delete_environment"
+ JobDataWorkItemLastJob_CommandName_DeleteWorkspace = "delete_workspace"
+ JobDataWorkItemLastJob_CommandName_EnvironmentInit = "environment_init"
+ JobDataWorkItemLastJob_CommandName_EnvironmentInstall = "environment_install"
+ JobDataWorkItemLastJob_CommandName_EnvironmentUninstall = "environment_uninstall"
+ JobDataWorkItemLastJob_CommandName_PatchAction = "patch_action"
+ JobDataWorkItemLastJob_CommandName_PatchWorkspace = "patch_workspace"
+ JobDataWorkItemLastJob_CommandName_PutAction = "put_action"
+ JobDataWorkItemLastJob_CommandName_PutEnvironment = "put_environment"
+ JobDataWorkItemLastJob_CommandName_PutWorkspace = "put_workspace"
+ JobDataWorkItemLastJob_CommandName_RepositoryProcess = "repository_process"
+ JobDataWorkItemLastJob_CommandName_SystemKeyDelete = "system_key_delete"
+ JobDataWorkItemLastJob_CommandName_SystemKeyDisable = "system_key_disable"
+ JobDataWorkItemLastJob_CommandName_SystemKeyEnable = "system_key_enable"
+ JobDataWorkItemLastJob_CommandName_SystemKeyRestore = "system_key_restore"
+ JobDataWorkItemLastJob_CommandName_SystemKeyRotate = "system_key_rotate"
+ JobDataWorkItemLastJob_CommandName_WorkspaceApply = "workspace_apply"
+ JobDataWorkItemLastJob_CommandName_WorkspaceDestroy = "workspace_destroy"
+ JobDataWorkItemLastJob_CommandName_WorkspacePlan = "workspace_plan"
+ JobDataWorkItemLastJob_CommandName_WorkspaceRefresh = "workspace_refresh"
+)
+
+// Constants associated with the JobDataWorkItemLastJob.JobStatus property.
+// Status of Jobs.
+const (
+ JobDataWorkItemLastJob_JobStatus_JobCancelled = "job_cancelled"
+ JobDataWorkItemLastJob_JobStatus_JobFailed = "job_failed"
+ JobDataWorkItemLastJob_JobStatus_JobFinished = "job_finished"
+ JobDataWorkItemLastJob_JobStatus_JobInProgress = "job_in_progress"
+ JobDataWorkItemLastJob_JobStatus_JobPending = "job_pending"
+)
+
+// UnmarshalJobDataWorkItemLastJob unmarshals an instance of JobDataWorkItemLastJob from the specified map of raw messages.
+func UnmarshalJobDataWorkItemLastJob(m map[string]json.RawMessage, result interface{}) (err error) {
+ obj := new(JobDataWorkItemLastJob)
+ err = core.UnmarshalPrimitive(m, "command_object", &obj.CommandObject)
+ if err != nil {
+ return
+ }
+ err = core.UnmarshalPrimitive(m, "command_object_name", &obj.CommandObjectName)
+ if err != nil {
+ return
+ }
+ err = core.UnmarshalPrimitive(m, "command_object_id", &obj.CommandObjectID)
+ if err != nil {
+ return
+ }
+ err = core.UnmarshalPrimitive(m, "command_name", &obj.CommandName)
+ if err != nil {
+ return
+ }
+ err = core.UnmarshalPrimitive(m, "job_id", &obj.JobID)
+ if err != nil {
+ return
+ }
+ err = core.UnmarshalPrimitive(m, "job_status", &obj.JobStatus)
+ if err != nil {
+ return
+ }
+ reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
+ return
+}
+
// JobDataWorkspace : Workspace Job data.
type JobDataWorkspace struct {
// Workspace name.
@@ -8510,8 +8964,9 @@ type JobLite struct {
// User defined tags, while running the job.
Tags []string `json:"tags,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
Location *string `json:"location,omitempty"`
// Resource-group name derived from the related Workspace or Action.
@@ -8584,8 +9039,9 @@ const (
)
// Constants associated with the JobLite.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
JobLite_Location_EuDe = "eu-de"
JobLite_Location_EuGb = "eu-gb"
@@ -9863,24 +10319,24 @@ func UnmarshalKMSSettingsSecondaryCrk(m map[string]json.RawMessage, result inter
// ListActionsOptions : The ListActions options.
type ListActionsOptions struct {
- // The position of the workspace in the list of workspaces, from which you want to start listing your workspaces. For
- // example, if you have three workspaces in your account, the first workspace is assigned position number 0, the second
- // workspace is assigned position number 1, and so forth. If you have 6 workspaces and you want to list the details for
- // workspaces 2-6, enter 1. To limit the number of workspaces that is returned, use the `limit` option in addition to
- // the `offset` option. Negative numbers are not supported and are ignored.
- Offset *int64
+ // The starting position of the item in the list of items. For example, if you have three workspaces in your account,
+ // the first workspace is assigned position number 0, the second workspace is assigned position number 1, and so forth.
+ // If you have 6 workspaces and you want to list the details for workspaces 2-6, enter 1. To limit the number of
+ // workspaces that is returned, use the `limit` option in addition to the `offset` option. Negative numbers are not
+ // supported and are ignored.
+ Offset *int64 `json:"-"`
- // The maximum number of workspaces that you want to list. The number must be a positive integer between 1 and 2000. If
- // no value is provided, 100 is used by default.
- Limit *int64
+ // The maximum number of items that you want to list. The number must be a positive integer between 1 and 2000. If no
+ // value is provided, 100 is used by default.
+ Limit *int64 `json:"-"`
// Name of the field to sort-by; Use the '.' character to delineate sub-resources and sub-fields (eg.
// owner.last_name). Prepend the field with '+' or '-', indicating 'ascending' or 'descending' (default is ascending)
// Ignore unrecognized or unsupported sort field.
- Sort *string
+ Sort *string `json:"-"`
// Level of details returned by the get method.
- Profile *string
+ Profile *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -9930,24 +10386,24 @@ func (options *ListActionsOptions) SetHeaders(param map[string]string) *ListActi
// ListInventoriesOptions : The ListInventories options.
type ListInventoriesOptions struct {
- // The position of the workspace in the list of workspaces, from which you want to start listing your workspaces. For
- // example, if you have three workspaces in your account, the first workspace is assigned position number 0, the second
- // workspace is assigned position number 1, and so forth. If you have 6 workspaces and you want to list the details for
- // workspaces 2-6, enter 1. To limit the number of workspaces that is returned, use the `limit` option in addition to
- // the `offset` option. Negative numbers are not supported and are ignored.
- Offset *int64
+ // The starting position of the item in the list of items. For example, if you have three workspaces in your account,
+ // the first workspace is assigned position number 0, the second workspace is assigned position number 1, and so forth.
+ // If you have 6 workspaces and you want to list the details for workspaces 2-6, enter 1. To limit the number of
+ // workspaces that is returned, use the `limit` option in addition to the `offset` option. Negative numbers are not
+ // supported and are ignored.
+ Offset *int64 `json:"-"`
- // The maximum number of workspaces that you want to list. The number must be a positive integer between 1 and 2000. If
- // no value is provided, 100 is used by default.
- Limit *int64
+ // The maximum number of items that you want to list. The number must be a positive integer between 1 and 2000. If no
+ // value is provided, 100 is used by default.
+ Limit *int64 `json:"-"`
// Name of the field to sort-by; Use the '.' character to delineate sub-resources and sub-fields (eg.
// owner.last_name). Prepend the field with '+' or '-', indicating 'ascending' or 'descending' (default is ascending)
// Ignore unrecognized or unsupported sort field.
- Sort *string
+ Sort *string `json:"-"`
// Level of details returned by the get method.
- Profile *string
+ Profile *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -9999,7 +10455,7 @@ func (options *ListInventoriesOptions) SetHeaders(param map[string]string) *List
type ListInventoryValuesOptions struct {
// Resource Inventory Id. Use GET /inventories API to look up the Resource Inventory definition Ids in your IBM Cloud
// account.
- InventoryID *string `validate:"required,ne="`
+ InventoryID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10027,7 +10483,7 @@ func (options *ListInventoryValuesOptions) SetHeaders(param map[string]string) *
// ListJobLogsOptions : The ListJobLogs options.
type ListJobLogsOptions struct {
// Job Id. Use GET /jobs API to look up the Job Ids in your IBM Cloud account.
- JobID *string `validate:"required,ne="`
+ JobID *string `json:"-" validate:"required,ne="`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10054,36 +10510,36 @@ func (options *ListJobLogsOptions) SetHeaders(param map[string]string) *ListJobL
// ListJobsOptions : The ListJobs options.
type ListJobsOptions struct {
- // The position of the workspace in the list of workspaces, from which you want to start listing your workspaces. For
- // example, if you have three workspaces in your account, the first workspace is assigned position number 0, the second
- // workspace is assigned position number 1, and so forth. If you have 6 workspaces and you want to list the details for
- // workspaces 2-6, enter 1. To limit the number of workspaces that is returned, use the `limit` option in addition to
- // the `offset` option. Negative numbers are not supported and are ignored.
- Offset *int64
+ // The starting position of the item in the list of items. For example, if you have three workspaces in your account,
+ // the first workspace is assigned position number 0, the second workspace is assigned position number 1, and so forth.
+ // If you have 6 workspaces and you want to list the details for workspaces 2-6, enter 1. To limit the number of
+ // workspaces that is returned, use the `limit` option in addition to the `offset` option. Negative numbers are not
+ // supported and are ignored.
+ Offset *int64 `json:"-"`
- // The maximum number of workspaces that you want to list. The number must be a positive integer between 1 and 2000. If
- // no value is provided, 100 is used by default.
- Limit *int64
+ // The maximum number of items that you want to list. The number must be a positive integer between 1 and 2000. If no
+ // value is provided, 100 is used by default.
+ Limit *int64 `json:"-"`
// Name of the field to sort-by; Use the '.' character to delineate sub-resources and sub-fields (eg.
// owner.last_name). Prepend the field with '+' or '-', indicating 'ascending' or 'descending' (default is ascending)
// Ignore unrecognized or unsupported sort field.
- Sort *string
+ Sort *string `json:"-"`
// Level of details returned by the get method.
- Profile *string
+ Profile *string `json:"-"`
// Name of the resource (workspace, actions or controls).
- Resource *string
+ Resource *string `json:"-"`
- // the resource Id.
- ResourceID *string
+ // The Resource Id. It could be an Action-id or Workspace-id.
+ ResourceID *string `json:"-"`
// Action Id.
- ActionID *string
+ ActionID *string `json:"-"`
// list jobs.
- List *string
+ List *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10168,6 +10624,74 @@ func (options *ListJobsOptions) SetHeaders(param map[string]string) *ListJobsOpt
return options
}
+// ListKmsOptions : The ListKms options.
+type ListKmsOptions struct {
+ // The encryption scheme to be used.
+ EncryptionScheme *string `json:"-" validate:"required"`
+
+ // The location of the Resource.
+ Location *string `json:"-" validate:"required"`
+
+ // The resource group (by default, fetch from all resource groups).
+ ResourceGroup *string `json:"-"`
+
+ // The maximum number of items that you want to list. The number must be a positive integer between 1 and 2000. If no
+ // value is provided, 100 is used by default.
+ Limit *int64 `json:"-"`
+
+ // Name of the field to sort-by; Use the '.' character to delineate sub-resources and sub-fields (eg.
+ // owner.last_name). Prepend the field with '+' or '-', indicating 'ascending' or 'descending' (default is ascending)
+ // Ignore unrecognized or unsupported sort field.
+ Sort *string `json:"-"`
+
+ // Allows users to set headers on API requests
+ Headers map[string]string
+}
+
+// NewListKmsOptions : Instantiate ListKmsOptions
+func (*SchematicsV1) NewListKmsOptions(encryptionScheme string, location string) *ListKmsOptions {
+ return &ListKmsOptions{
+ EncryptionScheme: core.StringPtr(encryptionScheme),
+ Location: core.StringPtr(location),
+ }
+}
+
+// SetEncryptionScheme : Allow user to set EncryptionScheme
+func (_options *ListKmsOptions) SetEncryptionScheme(encryptionScheme string) *ListKmsOptions {
+ _options.EncryptionScheme = core.StringPtr(encryptionScheme)
+ return _options
+}
+
+// SetLocation : Allow user to set Location
+func (_options *ListKmsOptions) SetLocation(location string) *ListKmsOptions {
+ _options.Location = core.StringPtr(location)
+ return _options
+}
+
+// SetResourceGroup : Allow user to set ResourceGroup
+func (_options *ListKmsOptions) SetResourceGroup(resourceGroup string) *ListKmsOptions {
+ _options.ResourceGroup = core.StringPtr(resourceGroup)
+ return _options
+}
+
+// SetLimit : Allow user to set Limit
+func (_options *ListKmsOptions) SetLimit(limit int64) *ListKmsOptions {
+ _options.Limit = core.Int64Ptr(limit)
+ return _options
+}
+
+// SetSort : Allow user to set Sort
+func (_options *ListKmsOptions) SetSort(sort string) *ListKmsOptions {
+ _options.Sort = core.StringPtr(sort)
+ return _options
+}
+
+// SetHeaders : Allow user to set Headers
+func (options *ListKmsOptions) SetHeaders(param map[string]string) *ListKmsOptions {
+ options.Headers = param
+ return options
+}
+
// ListLocationsOptions : The ListLocations options.
type ListLocationsOptions struct {
@@ -10206,24 +10730,24 @@ func (options *ListResourceGroupOptions) SetHeaders(param map[string]string) *Li
// ListResourceQueryOptions : The ListResourceQuery options.
type ListResourceQueryOptions struct {
- // The position of the workspace in the list of workspaces, from which you want to start listing your workspaces. For
- // example, if you have three workspaces in your account, the first workspace is assigned position number 0, the second
- // workspace is assigned position number 1, and so forth. If you have 6 workspaces and you want to list the details for
- // workspaces 2-6, enter 1. To limit the number of workspaces that is returned, use the `limit` option in addition to
- // the `offset` option. Negative numbers are not supported and are ignored.
- Offset *int64
+ // The starting position of the item in the list of items. For example, if you have three workspaces in your account,
+ // the first workspace is assigned position number 0, the second workspace is assigned position number 1, and so forth.
+ // If you have 6 workspaces and you want to list the details for workspaces 2-6, enter 1. To limit the number of
+ // workspaces that is returned, use the `limit` option in addition to the `offset` option. Negative numbers are not
+ // supported and are ignored.
+ Offset *int64 `json:"-"`
- // The maximum number of workspaces that you want to list. The number must be a positive integer between 1 and 2000. If
- // no value is provided, 100 is used by default.
- Limit *int64
+ // The maximum number of items that you want to list. The number must be a positive integer between 1 and 2000. If no
+ // value is provided, 100 is used by default.
+ Limit *int64 `json:"-"`
// Name of the field to sort-by; Use the '.' character to delineate sub-resources and sub-fields (eg.
// owner.last_name). Prepend the field with '+' or '-', indicating 'ascending' or 'descending' (default is ascending)
// Ignore unrecognized or unsupported sort field.
- Sort *string
+ Sort *string `json:"-"`
// Level of details returned by the get method.
- Profile *string
+ Profile *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10293,18 +10817,18 @@ func (options *ListSchematicsLocationOptions) SetHeaders(param map[string]string
type ListWorkspaceActivitiesOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
- // The position of the workspace in the list of workspaces, from which you want to start listing your workspaces. For
- // example, if you have three workspaces in your account, the first workspace is assigned position number 0, the second
- // workspace is assigned position number 1, and so forth. If you have 6 workspaces and you want to list the details for
- // workspaces 2-6, enter 1. To limit the number of workspaces that is returned, use the `limit` option in addition to
- // the `offset` option. Negative numbers are not supported and are ignored.
- Offset *int64
+ // The starting position of the item in the list of items. For example, if you have three workspaces in your account,
+ // the first workspace is assigned position number 0, the second workspace is assigned position number 1, and so forth.
+ // If you have 6 workspaces and you want to list the details for workspaces 2-6, enter 1. To limit the number of
+ // workspaces that is returned, use the `limit` option in addition to the `offset` option. Negative numbers are not
+ // supported and are ignored.
+ Offset *int64 `json:"-"`
- // The maximum number of workspaces that you want to list. The number must be a positive integer between 1 and 2000. If
- // no value is provided, 100 is used by default.
- Limit *int64
+ // The maximum number of items that you want to list. The number must be a positive integer between 1 and 2000. If no
+ // value is provided, 100 is used by default.
+ Limit *int64 `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10343,16 +10867,16 @@ func (options *ListWorkspaceActivitiesOptions) SetHeaders(param map[string]strin
// ListWorkspacesOptions : The ListWorkspaces options.
type ListWorkspacesOptions struct {
- // The position of the workspace in the list of workspaces, from which you want to start listing your workspaces. For
- // example, if you have three workspaces in your account, the first workspace is assigned position number 0, the second
- // workspace is assigned position number 1, and so forth. If you have 6 workspaces and you want to list the details for
- // workspaces 2-6, enter 1. To limit the number of workspaces that is returned, use the `limit` option in addition to
- // the `offset` option. Negative numbers are not supported and are ignored.
- Offset *int64
+ // The starting position of the item in the list of items. For example, if you have three workspaces in your account,
+ // the first workspace is assigned position number 0, the second workspace is assigned position number 1, and so forth.
+ // If you have 6 workspaces and you want to list the details for workspaces 2-6, enter 1. To limit the number of
+ // workspaces that is returned, use the `limit` option in addition to the `offset` option. Negative numbers are not
+ // supported and are ignored.
+ Offset *int64 `json:"-"`
- // The maximum number of workspaces that you want to list. The number must be a positive integer between 1 and 2000. If
- // no value is provided, 100 is used by default.
- Limit *int64
+ // The maximum number of items that you want to list. The number must be a positive integer between 1 and 2000. If no
+ // value is provided, 100 is used by default.
+ Limit *int64 `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10381,18 +10905,18 @@ func (options *ListWorkspacesOptions) SetHeaders(param map[string]string) *ListW
return options
}
-// LogStoreResponse : LogStoreResponse -.
+// LogStoreResponse : Log file URL for job that ran against your workspace.
type LogStoreResponse struct {
- // Engine name.
+ // The provisioning engine that was used for the job.
EngineName *string `json:"engine_name,omitempty"`
- // Engine version.
+ // The version of the provisioning engine that was used for the job.
EngineVersion *string `json:"engine_version,omitempty"`
- // Engine id.
+ // The ID that was assigned to your Terraform template of IBM Cloud catalog software template.
ID *string `json:"id,omitempty"`
- // Log store url.
+ // The URL to access the logs that were created during the plan, apply, or destroy job.
LogStoreURL *string `json:"log_store_url,omitempty"`
}
@@ -10419,7 +10943,7 @@ func UnmarshalLogStoreResponse(m map[string]json.RawMessage, result interface{})
return
}
-// LogStoreResponseList : LogStoreResponseList -.
+// LogStoreResponseList : List of log file URL that ran against your workspace.
type LogStoreResponseList struct {
// Runtime data.
RuntimeData []LogStoreResponse `json:"runtime_data,omitempty"`
@@ -10436,9 +10960,17 @@ func UnmarshalLogStoreResponseList(m map[string]json.RawMessage, result interfac
return
}
-// LogSummary : LogSummary ...
+// LogSummary : Summary information extracted from the job logs.
type LogSummary struct {
- // WorkspaceActivityStatus activity status type.
+ // The status of your activity or job. To retrieve the URL to your job logs, use the GET
+ // /v1/workspaces/{id}/actions/{action_id}/logs API.
+ //
+ // * **COMPLETED**: The job completed successfully.
+ // * **CREATED**: The job was created, but the provisioning, modification, or removal of IBM Cloud resources has not
+ // started yet.
+ // * **FAILED**: An error occurred during the plan, apply, or destroy job. Use the job ID to retrieve the URL to the
+ // log files for your job.
+ // * **IN PROGRESS**: The job is in progress. You can use the log_url to access the logs.
ActivityStatus *string `json:"activity_status,omitempty"`
// Template detected type.
@@ -10465,7 +10997,7 @@ type LogSummary struct {
// Numner of template variables.
TemplateVariableCount *int64 `json:"template_variable_count,omitempty"`
- // Time takemn to perform activity.
+ // Elapsed time to run the job.
TimeTaken *float64 `json:"time_taken,omitempty"`
}
@@ -10557,12 +11089,31 @@ func UnmarshalOutputValuesInner(m map[string]json.RawMessage, result interface{}
// PlanWorkspaceCommandOptions : The PlanWorkspaceCommand options.
type PlanWorkspaceCommandOptions struct {
- // The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
- // API.
- WID *string `validate:"required,ne="`
+ // The ID of the workspace, for which you want to run a Schematics `plan` job. To find the ID of your workspace, use
+ // the `GET /v1/workspaces` API.
+ WID *string `json:"-" validate:"required,ne="`
- // The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ // The IAM refresh token is required only if you want to delete all the Terraform resources before deleting the
+ // Schematics workspace. If you want to delete the workspace only and keep all your Terraform resources, refresh token
+ // is not required.
+ //
+ // **Retrieving refresh token**:
+ // * Use `export IBMCLOUD_API_KEY=`, and execute `curl -X POST
+ // "https://iam.cloud.ibm.com/identity/token" -H "Content-Type: application/x-www-form-urlencoded" -d
+ // "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBMCLOUD_API_KEY" -u bx:bx`.
+ // * For more information, about creating IAM access token and API Docs, refer, [IAM access
+ // token](/apidocs/iam-identity-token-api#gettoken-password) and [Create API
+ // key](/apidocs/iam-identity-token-api#create-api-key).
+ //
+ // **Limitation**:
+ // * If the token is expired, you can use `refresh token` to get a new IAM access token.
+ // * The `refresh_token` parameter cannot be used to retrieve a new IAM access token.
+ // * When the IAM access token is about to expire, use the API key to create a new access token.
+ RefreshToken *string `json:"-" validate:"required"`
+
+ // The IAM delegated token for your IBM Cloud account. This token is required for requests that are sent via the UI
+ // only.
+ DelegatedToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10588,6 +11139,12 @@ func (_options *PlanWorkspaceCommandOptions) SetRefreshToken(refreshToken string
return _options
}
+// SetDelegatedToken : Allow user to set DelegatedToken
+func (_options *PlanWorkspaceCommandOptions) SetDelegatedToken(delegatedToken string) *PlanWorkspaceCommandOptions {
+ _options.DelegatedToken = core.StringPtr(delegatedToken)
+ return _options
+}
+
// SetHeaders : Allow user to set Headers
func (options *PlanWorkspaceCommandOptions) SetHeaders(param map[string]string) *PlanWorkspaceCommandOptions {
options.Headers = param
@@ -10597,19 +11154,19 @@ func (options *PlanWorkspaceCommandOptions) SetHeaders(param map[string]string)
// ProcessTemplateMetaDataOptions : The ProcessTemplateMetaData options.
type ProcessTemplateMetaDataOptions struct {
// Template type (terraform, ansible, helm, cloudpak, bash script).
- TemplateType *string `validate:"required"`
+ TemplateType *string `json:"template_type" validate:"required"`
// Source of templates, playbooks, or controls.
- Source *ExternalSource `validate:"required"`
+ Source *ExternalSource `json:"source" validate:"required"`
// Region to which request should go. Applicable only on global endpoint.
- Region *string
+ Region *string `json:"region,omitempty"`
// Type of source for the Template.
- SourceType *string
+ SourceType *string `json:"source_type,omitempty"`
- // The github token associated with the GIT. Required for cloning of repo.
- XGithubToken *string
+ // The personal access token associated with your GitHub or GitLab repository, required to clone the repository.
+ XGithubToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10618,6 +11175,7 @@ type ProcessTemplateMetaDataOptions struct {
// Constants associated with the ProcessTemplateMetaDataOptions.SourceType property.
// Type of source for the Template.
const (
+ ProcessTemplateMetaDataOptions_SourceType_CosBucket = "cos_bucket"
ProcessTemplateMetaDataOptions_SourceType_ExternalScm = "external_scm"
ProcessTemplateMetaDataOptions_SourceType_GitHub = "git_hub"
ProcessTemplateMetaDataOptions_SourceType_GitHubEnterprise = "git_hub_enterprise"
@@ -10673,12 +11231,31 @@ func (options *ProcessTemplateMetaDataOptions) SetHeaders(param map[string]strin
// RefreshWorkspaceCommandOptions : The RefreshWorkspaceCommand options.
type RefreshWorkspaceCommandOptions struct {
- // The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
- // API.
- WID *string `validate:"required,ne="`
+ // The ID of the workspace for which you want to perform a Schematics `refresh` job. To find the workspace ID, use the
+ // `GET /workspaces` API.
+ WID *string `json:"-" validate:"required,ne="`
- // The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ // The IAM refresh token is required only if you want to delete all the Terraform resources before deleting the
+ // Schematics workspace. If you want to delete the workspace only and keep all your Terraform resources, refresh token
+ // is not required.
+ //
+ // **Retrieving refresh token**:
+ // * Use `export IBMCLOUD_API_KEY=`, and execute `curl -X POST
+ // "https://iam.cloud.ibm.com/identity/token" -H "Content-Type: application/x-www-form-urlencoded" -d
+ // "grant_type=urn:ibm:params:oauth:grant-type:apikey&apikey=$IBMCLOUD_API_KEY" -u bx:bx`.
+ // * For more information, about creating IAM access token and API Docs, refer, [IAM access
+ // token](/apidocs/iam-identity-token-api#gettoken-password) and [Create API
+ // key](/apidocs/iam-identity-token-api#create-api-key).
+ //
+ // **Limitation**:
+ // * If the token is expired, you can use `refresh token` to get a new IAM access token.
+ // * The `refresh_token` parameter cannot be used to retrieve a new IAM access token.
+ // * When the IAM access token is about to expire, use the API key to create a new access token.
+ RefreshToken *string `json:"-" validate:"required"`
+
+ // The IAM delegated token for your IBM Cloud account. This token is required for requests that are sent via the UI
+ // only.
+ DelegatedToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -10704,6 +11281,12 @@ func (_options *RefreshWorkspaceCommandOptions) SetRefreshToken(refreshToken str
return _options
}
+// SetDelegatedToken : Allow user to set DelegatedToken
+func (_options *RefreshWorkspaceCommandOptions) SetDelegatedToken(delegatedToken string) *RefreshWorkspaceCommandOptions {
+ _options.DelegatedToken = core.StringPtr(delegatedToken)
+ return _options
+}
+
// SetHeaders : Allow user to set Headers
func (options *RefreshWorkspaceCommandOptions) SetHeaders(param map[string]string) *RefreshWorkspaceCommandOptions {
options.Headers = param
@@ -10714,34 +11297,37 @@ func (options *RefreshWorkspaceCommandOptions) SetHeaders(param map[string]strin
type ReplaceInventoryOptions struct {
// Resource Inventory Id. Use GET /inventories API to look up the Resource Inventory definition Ids in your IBM Cloud
// account.
- InventoryID *string `validate:"required,ne="`
+ InventoryID *string `json:"-" validate:"required,ne="`
- // Inventory name.
- Name *string
+ // The unique name of your Inventory resource. The name can be up to 128 characters long and can include alphanumeric
+ // characters, spaces, dashes, and underscores.
+ Name *string `json:"name,omitempty"`
- // Inventory description.
- Description *string
+ // The description of your Inventory resource. The description can be up to 2048 characters long in size.
+ Description *string `json:"description,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
- // Resource-group name for the Inventory definition. By default, Action will be created in Default Resource Group.
- ResourceGroup *string
+ // Resource-group name for the Inventory resource. By default, Action will be created in Default Resource Group.
+ ResourceGroup *string `json:"resource_group,omitempty"`
- // Input inventory of host and host group for the playbook, in the .ini file format.
- InventoriesIni *string
+ // Input inventory of host and host group for the playbook, in the `.ini` file format.
+ InventoriesIni *string `json:"inventories_ini,omitempty"`
- // Input resource queries that is used to dynamically generate the inventory of host and host group for the playbook.
- ResourceQueries []string
+ // Input resource queries that is used to dynamically generate the inventory of host and host group for the playbook.
+ ResourceQueries []string `json:"resource_queries,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
}
// Constants associated with the ReplaceInventoryOptions.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
ReplaceInventoryOptions_Location_EuDe = "eu-de"
ReplaceInventoryOptions_Location_EuGb = "eu-gb"
@@ -10804,298 +11390,29 @@ func (options *ReplaceInventoryOptions) SetHeaders(param map[string]string) *Rep
return options
}
-// ReplaceJobOptions : The ReplaceJob options.
-type ReplaceJobOptions struct {
- // Job Id. Use GET /jobs API to look up the Job Ids in your IBM Cloud account.
- JobID *string `validate:"required,ne="`
-
- // The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+// ReplaceResourcesQueryOptions : The ReplaceResourcesQuery options.
+type ReplaceResourcesQueryOptions struct {
+ // Resource query Id. Use GET /resource_query API to look up the Resource query definition Ids in your IBM Cloud
+ // account.
+ QueryID *string `json:"-" validate:"required,ne="`
- // Name of the Schematics automation resource.
- CommandObject *string
+ // Resource type (cluster, vsi, icd, vpc).
+ Type *string `json:"type,omitempty"`
- // Job command object id (workspace-id or action-id or environment-id).
- CommandObjectID *string
+ // Resource query name.
+ Name *string `json:"name,omitempty"`
- // Schematics job command name.
- CommandName *string
+ Queries []ResourceQuery `json:"queries,omitempty"`
- // Schematics job command parameter (playbook-name).
- CommandParameter *string
+ // Allows users to set headers on API requests
+ Headers map[string]string
+}
- // Command line options for the command.
- CommandOptions []string
-
- // Job inputs used by Action or Workspace.
- Inputs []VariableData
-
- // Environment variables used by the Job while performing Action or Workspace.
- Settings []VariableData
-
- // User defined tags, while running the job.
- Tags []string
-
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string
-
- // Job Status.
- Status *JobStatus
-
- // Job data.
- Data *JobData
-
- // Describes a bastion resource.
- Bastion *BastionResourceDefinition
-
- // Job log summary record.
- LogSummary *JobLogSummary
-
- // Allows users to set headers on API requests
- Headers map[string]string
-}
-
-// Constants associated with the ReplaceJobOptions.CommandObject property.
-// Name of the Schematics automation resource.
-const (
- ReplaceJobOptions_CommandObject_Action = "action"
- ReplaceJobOptions_CommandObject_Environment = "environment"
- ReplaceJobOptions_CommandObject_System = "system"
- ReplaceJobOptions_CommandObject_Workspace = "workspace"
-)
-
-// Constants associated with the ReplaceJobOptions.CommandName property.
-// Schematics job command name.
-const (
- ReplaceJobOptions_CommandName_AnsiblePlaybookCheck = "ansible_playbook_check"
- ReplaceJobOptions_CommandName_AnsiblePlaybookRun = "ansible_playbook_run"
- ReplaceJobOptions_CommandName_CreateAction = "create_action"
- ReplaceJobOptions_CommandName_CreateCart = "create_cart"
- ReplaceJobOptions_CommandName_CreateEnvironment = "create_environment"
- ReplaceJobOptions_CommandName_CreateWorkspace = "create_workspace"
- ReplaceJobOptions_CommandName_DeleteAction = "delete_action"
- ReplaceJobOptions_CommandName_DeleteEnvironment = "delete_environment"
- ReplaceJobOptions_CommandName_DeleteWorkspace = "delete_workspace"
- ReplaceJobOptions_CommandName_EnvironmentInit = "environment_init"
- ReplaceJobOptions_CommandName_EnvironmentInstall = "environment_install"
- ReplaceJobOptions_CommandName_EnvironmentUninstall = "environment_uninstall"
- ReplaceJobOptions_CommandName_PatchAction = "patch_action"
- ReplaceJobOptions_CommandName_PatchWorkspace = "patch_workspace"
- ReplaceJobOptions_CommandName_PutAction = "put_action"
- ReplaceJobOptions_CommandName_PutEnvironment = "put_environment"
- ReplaceJobOptions_CommandName_PutWorkspace = "put_workspace"
- ReplaceJobOptions_CommandName_RepositoryProcess = "repository_process"
- ReplaceJobOptions_CommandName_SystemKeyDelete = "system_key_delete"
- ReplaceJobOptions_CommandName_SystemKeyDisable = "system_key_disable"
- ReplaceJobOptions_CommandName_SystemKeyEnable = "system_key_enable"
- ReplaceJobOptions_CommandName_SystemKeyRestore = "system_key_restore"
- ReplaceJobOptions_CommandName_SystemKeyRotate = "system_key_rotate"
- ReplaceJobOptions_CommandName_WorkspaceApply = "workspace_apply"
- ReplaceJobOptions_CommandName_WorkspaceDestroy = "workspace_destroy"
- ReplaceJobOptions_CommandName_WorkspacePlan = "workspace_plan"
- ReplaceJobOptions_CommandName_WorkspaceRefresh = "workspace_refresh"
-)
-
-// Constants associated with the ReplaceJobOptions.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
-const (
- ReplaceJobOptions_Location_EuDe = "eu-de"
- ReplaceJobOptions_Location_EuGb = "eu-gb"
- ReplaceJobOptions_Location_UsEast = "us-east"
- ReplaceJobOptions_Location_UsSouth = "us-south"
-)
-
-// NewReplaceJobOptions : Instantiate ReplaceJobOptions
-func (*SchematicsV1) NewReplaceJobOptions(jobID string, refreshToken string) *ReplaceJobOptions {
- return &ReplaceJobOptions{
- JobID: core.StringPtr(jobID),
- RefreshToken: core.StringPtr(refreshToken),
- }
-}
-
-// SetJobID : Allow user to set JobID
-func (_options *ReplaceJobOptions) SetJobID(jobID string) *ReplaceJobOptions {
- _options.JobID = core.StringPtr(jobID)
- return _options
-}
-
-// SetRefreshToken : Allow user to set RefreshToken
-func (_options *ReplaceJobOptions) SetRefreshToken(refreshToken string) *ReplaceJobOptions {
- _options.RefreshToken = core.StringPtr(refreshToken)
- return _options
-}
-
-// SetCommandObject : Allow user to set CommandObject
-func (_options *ReplaceJobOptions) SetCommandObject(commandObject string) *ReplaceJobOptions {
- _options.CommandObject = core.StringPtr(commandObject)
- return _options
-}
-
-// SetCommandObjectID : Allow user to set CommandObjectID
-func (_options *ReplaceJobOptions) SetCommandObjectID(commandObjectID string) *ReplaceJobOptions {
- _options.CommandObjectID = core.StringPtr(commandObjectID)
- return _options
-}
-
-// SetCommandName : Allow user to set CommandName
-func (_options *ReplaceJobOptions) SetCommandName(commandName string) *ReplaceJobOptions {
- _options.CommandName = core.StringPtr(commandName)
- return _options
-}
-
-// SetCommandParameter : Allow user to set CommandParameter
-func (_options *ReplaceJobOptions) SetCommandParameter(commandParameter string) *ReplaceJobOptions {
- _options.CommandParameter = core.StringPtr(commandParameter)
- return _options
-}
-
-// SetCommandOptions : Allow user to set CommandOptions
-func (_options *ReplaceJobOptions) SetCommandOptions(commandOptions []string) *ReplaceJobOptions {
- _options.CommandOptions = commandOptions
- return _options
-}
-
-// SetInputs : Allow user to set Inputs
-func (_options *ReplaceJobOptions) SetInputs(inputs []VariableData) *ReplaceJobOptions {
- _options.Inputs = inputs
- return _options
-}
-
-// SetSettings : Allow user to set Settings
-func (_options *ReplaceJobOptions) SetSettings(settings []VariableData) *ReplaceJobOptions {
- _options.Settings = settings
- return _options
-}
-
-// SetTags : Allow user to set Tags
-func (_options *ReplaceJobOptions) SetTags(tags []string) *ReplaceJobOptions {
- _options.Tags = tags
- return _options
-}
-
-// SetLocation : Allow user to set Location
-func (_options *ReplaceJobOptions) SetLocation(location string) *ReplaceJobOptions {
- _options.Location = core.StringPtr(location)
- return _options
-}
-
-// SetStatus : Allow user to set Status
-func (_options *ReplaceJobOptions) SetStatus(status *JobStatus) *ReplaceJobOptions {
- _options.Status = status
- return _options
-}
-
-// SetData : Allow user to set Data
-func (_options *ReplaceJobOptions) SetData(data *JobData) *ReplaceJobOptions {
- _options.Data = data
- return _options
-}
-
-// SetBastion : Allow user to set Bastion
-func (_options *ReplaceJobOptions) SetBastion(bastion *BastionResourceDefinition) *ReplaceJobOptions {
- _options.Bastion = bastion
- return _options
-}
-
-// SetLogSummary : Allow user to set LogSummary
-func (_options *ReplaceJobOptions) SetLogSummary(logSummary *JobLogSummary) *ReplaceJobOptions {
- _options.LogSummary = logSummary
- return _options
-}
-
-// SetHeaders : Allow user to set Headers
-func (options *ReplaceJobOptions) SetHeaders(param map[string]string) *ReplaceJobOptions {
- options.Headers = param
- return options
-}
-
-// ReplaceKmsSettingsOptions : The ReplaceKmsSettings options.
-type ReplaceKmsSettingsOptions struct {
- // Location.
- Location *string
-
- // Encryption scheme.
- EncryptionScheme *string
-
- // Resource group.
- ResourceGroup *string
-
- // Primary CRK details.
- PrimaryCrk *KMSSettingsPrimaryCrk
-
- // Secondary CRK details.
- SecondaryCrk *KMSSettingsSecondaryCrk
-
- // Allows users to set headers on API requests
- Headers map[string]string
-}
-
-// NewReplaceKmsSettingsOptions : Instantiate ReplaceKmsSettingsOptions
-func (*SchematicsV1) NewReplaceKmsSettingsOptions() *ReplaceKmsSettingsOptions {
- return &ReplaceKmsSettingsOptions{}
-}
-
-// SetLocation : Allow user to set Location
-func (_options *ReplaceKmsSettingsOptions) SetLocation(location string) *ReplaceKmsSettingsOptions {
- _options.Location = core.StringPtr(location)
- return _options
-}
-
-// SetEncryptionScheme : Allow user to set EncryptionScheme
-func (_options *ReplaceKmsSettingsOptions) SetEncryptionScheme(encryptionScheme string) *ReplaceKmsSettingsOptions {
- _options.EncryptionScheme = core.StringPtr(encryptionScheme)
- return _options
-}
-
-// SetResourceGroup : Allow user to set ResourceGroup
-func (_options *ReplaceKmsSettingsOptions) SetResourceGroup(resourceGroup string) *ReplaceKmsSettingsOptions {
- _options.ResourceGroup = core.StringPtr(resourceGroup)
- return _options
-}
-
-// SetPrimaryCrk : Allow user to set PrimaryCrk
-func (_options *ReplaceKmsSettingsOptions) SetPrimaryCrk(primaryCrk *KMSSettingsPrimaryCrk) *ReplaceKmsSettingsOptions {
- _options.PrimaryCrk = primaryCrk
- return _options
-}
-
-// SetSecondaryCrk : Allow user to set SecondaryCrk
-func (_options *ReplaceKmsSettingsOptions) SetSecondaryCrk(secondaryCrk *KMSSettingsSecondaryCrk) *ReplaceKmsSettingsOptions {
- _options.SecondaryCrk = secondaryCrk
- return _options
-}
-
-// SetHeaders : Allow user to set Headers
-func (options *ReplaceKmsSettingsOptions) SetHeaders(param map[string]string) *ReplaceKmsSettingsOptions {
- options.Headers = param
- return options
-}
-
-// ReplaceResourcesQueryOptions : The ReplaceResourcesQuery options.
-type ReplaceResourcesQueryOptions struct {
- // Resource query Id. Use GET /resource_query API to look up the Resource query definition Ids in your IBM Cloud
- // account.
- QueryID *string `validate:"required,ne="`
-
- // Resource type (cluster, vsi, icd, vpc).
- Type *string
-
- // Resource query name.
- Name *string
-
- Queries []ResourceQuery
-
- // Allows users to set headers on API requests
- Headers map[string]string
-}
-
-// Constants associated with the ReplaceResourcesQueryOptions.Type property.
-// Resource type (cluster, vsi, icd, vpc).
-const (
- ReplaceResourcesQueryOptions_Type_Vsi = "vsi"
-)
+// Constants associated with the ReplaceResourcesQueryOptions.Type property.
+// Resource type (cluster, vsi, icd, vpc).
+const (
+ ReplaceResourcesQueryOptions_Type_Vsi = "vsi"
+)
// NewReplaceResourcesQueryOptions : Instantiate ReplaceResourcesQueryOptions
func (*SchematicsV1) NewReplaceResourcesQueryOptions(queryID string) *ReplaceResourcesQueryOptions {
@@ -11138,24 +11455,26 @@ func (options *ReplaceResourcesQueryOptions) SetHeaders(param map[string]string)
type ReplaceWorkspaceInputsOptions struct {
// The ID of the workspace for which you want to retrieve the input variables that you declared in your Terraform
// template. To find the workspace ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the Terraform template for which you want to retrieve all your input variables. When you create a
// workspace, the Terraform template that your workspace points to is assigned a unique ID. To find this ID, use the
// `GET /v1/workspaces` API and review the `template_data.id` value.
- TID *string `validate:"required,ne="`
-
- // A list of environment variables that you want to apply during the execution of a bash script or Terraform action.
- // This field must be provided as a list of key-value pairs, for example, **TF_LOG=debug**. Each entry will be a map
- // with one entry where `key is the environment variable name and value is value`. You can define environment variables
- // for IBM Cloud catalog offerings that are provisioned by using a bash script.
- EnvValues []interface{}
+ TID *string `json:"-" validate:"required,ne="`
+
+ // A list of environment variables that you want to apply during the execution of a bash script or Terraform job. This
+ // field must be provided as a list of key-value pairs, for example, **TF_LOG=debug**. Each entry will be a map with
+ // one entry where `key is the environment variable name and value is value`. You can define environment variables for
+ // IBM Cloud catalog offerings that are provisioned by using a bash script. See [example to use special environment
+ // variable](https://cloud.ibm.com/docs/schematics?topic=schematics-set-parallelism#parallelism-example) that are
+ // supported by Schematics.
+ EnvValues []interface{} `json:"env_values,omitempty"`
// User values.
- Values *string
+ Values *string `json:"values,omitempty"`
// VariablesRequest -.
- Variablestore []WorkspaceVariableRequest
+ Variablestore []WorkspaceVariableRequest `json:"variablestore,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -11208,39 +11527,39 @@ func (options *ReplaceWorkspaceInputsOptions) SetHeaders(param map[string]string
// ReplaceWorkspaceOptions : The ReplaceWorkspace options.
type ReplaceWorkspaceOptions struct {
// The ID of the workspace that you want to update. To find the ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Information about the software template that you chose from the IBM Cloud catalog. This information is returned for
// IBM Cloud catalog offerings only.
- CatalogRef *CatalogRef
+ CatalogRef *CatalogRef `json:"catalog_ref,omitempty"`
// The description of the workspace.
- Description *string
+ Description *string `json:"description,omitempty"`
// The name of the workspace.
- Name *string
+ Name *string `json:"name,omitempty"`
- // Information that is shared across templates in IBM Cloud catalog offerings. This information is not provided when
- // you create a workspace from your own Terraform template.
- SharedData *SharedTargetData
+ // Information about the Target used by the templates originating from the IBM Cloud catalog offerings. This
+ // information is not relevant for workspace created using your own Terraform template.
+ SharedData *SharedTargetData `json:"shared_data,omitempty"`
// A list of tags that you want to associate with your workspace.
- Tags []string
+ Tags []string `json:"tags,omitempty"`
- // TemplateData -.
- TemplateData []TemplateSourceDataRequest
+ // Input data for the Template.
+ TemplateData []TemplateSourceDataRequest `json:"template_data,omitempty"`
- // TemplateRepoUpdateRequest -.
- TemplateRepo *TemplateRepoUpdateRequest
+ // Input to update the template repository data.
+ TemplateRepo *TemplateRepoUpdateRequest `json:"template_repo,omitempty"`
// List of Workspace type.
- Type []string
+ Type []string `json:"type,omitempty"`
- // Information about the updated workspace status. -.
- WorkspaceStatus *WorkspaceStatusUpdateRequest
+ // Input to update the workspace status.
+ WorkspaceStatus *WorkspaceStatusUpdateRequest `json:"workspace_status,omitempty"`
- // Information about the last action that ran against the workspace. -.
- WorkspaceStatusMsg *WorkspaceStatusMessage
+ // Information about the last job that ran against the workspace. -.
+ WorkspaceStatusMsg *WorkspaceStatusMessage `json:"workspace_status_msg,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -11325,7 +11644,7 @@ func (options *ReplaceWorkspaceOptions) SetHeaders(param map[string]string) *Rep
return options
}
-// ResourceGroupResponse : Information about the resource group.
+// ResourceGroupResponse : A list of resource groups that your account has access to.
type ResourceGroupResponse struct {
// The ID of the account for which you listed the resource groups.
AccountID *string `json:"account_id,omitempty"`
@@ -11640,19 +11959,21 @@ func UnmarshalResourceQueryResponseRecordResponse(m map[string]json.RawMessage,
type RunWorkspaceCommandsOptions struct {
// The ID of the workspace for which you want to retrieve details. To find the workspace ID, use the `GET /workspaces`
// API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The IAM refresh token associated with the IBM Cloud account.
- RefreshToken *string `validate:"required"`
+ RefreshToken *string `json:"-" validate:"required"`
- // List of commands.
- Commands []TerraformCommand
+ // List of commands. You can execute single set of commands or multiple commands. For more information, about the
+ // payload of the multiple commands, refer to
+ // [Commands](https://cloud.ibm.com/docs/schematics?topic=schematics-schematics-cli-reference#commands).
+ Commands []TerraformCommand `json:"commands,omitempty"`
// Command name.
- OperationName *string
+ OperationName *string `json:"operation_name,omitempty"`
// Command description.
- Description *string
+ Description *string `json:"description,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -11865,8 +12186,8 @@ func UnmarshalSchematicsLocationsLite(m map[string]json.RawMessage, result inter
return
}
-// SharedTargetData : Information that is shared across templates in IBM Cloud catalog offerings. This information is not provided when you
-// create a workspace from your own Terraform template.
+// SharedTargetData : Information about the Target used by the templates originating from the IBM Cloud catalog offerings. This
+// information is not relevant for workspace created using your own Terraform template.
type SharedTargetData struct {
// Cluster created on.
ClusterCreatedOn *string `json:"cluster_created_on,omitempty"`
@@ -11950,8 +12271,8 @@ func UnmarshalSharedTargetData(m map[string]json.RawMessage, result interface{})
return
}
-// SharedTargetDataResponse : Information that is shared across templates in IBM Cloud catalog offerings. This information is not provided when you
-// create a workspace from your own Terraform template.
+// SharedTargetDataResponse : Information about the Target used by the templates originating from IBM Cloud catalog offerings. This information is
+// not relevant when you create a workspace from your own Terraform template.
type SharedTargetDataResponse struct {
// The ID of the cluster where you want to provision the resources of all IBM Cloud catalog templates that are included
// in the catalog offering.
@@ -12020,7 +12341,7 @@ type StateStoreResponse struct {
// The URL where the Terraform statefile (`terraform.tfstate`) is stored. You can use the statefile to find an overview
// of IBM Cloud resources that were created by Schematics. Schematics uses the statefile as an inventory list to
- // determine future create, update, or deletion actions.
+ // determine future create, update, or deletion jobs.
StateStoreURL *string `json:"state_store_url,omitempty"`
}
@@ -12119,9 +12440,9 @@ func UnmarshalTemplateMetaDataResponse(m map[string]json.RawMessage, result inte
return
}
-// TemplateReadme : The `README.md` file for the template that your workspace points to.
+// TemplateReadme : The `README.md` file for the template used by the workspace.
type TemplateReadme struct {
- // The `README.md` file for the template that your workspace points to.
+ // The `README.md` file for the template used by the workspace.
Readme *string `json:"readme,omitempty"`
}
@@ -12136,7 +12457,7 @@ func UnmarshalTemplateReadme(m map[string]json.RawMessage, result interface{}) (
return
}
-// TemplateRepoRequest : TemplateRepoRequest -.
+// TemplateRepoRequest : Input variables for the Template repoository, while creating a workspace.
type TemplateRepoRequest struct {
// The repository branch.
Branch *string `json:"branch,omitempty"`
@@ -12181,7 +12502,7 @@ func UnmarshalTemplateRepoRequest(m map[string]json.RawMessage, result interface
return
}
-// TemplateRepoResponse : TemplateRepoResponse -.
+// TemplateRepoResponse : Information about the Template repository used by the workspace.
type TemplateRepoResponse struct {
// The repository branch.
Branch *string `json:"branch,omitempty"`
@@ -12271,7 +12592,7 @@ func UnmarshalTemplateRepoTarUploadResponse(m map[string]json.RawMessage, result
return
}
-// TemplateRepoUpdateRequest : TemplateRepoUpdateRequest -.
+// TemplateRepoUpdateRequest : Input to update the template repository data.
type TemplateRepoUpdateRequest struct {
// The repository branch.
Branch *string `json:"branch,omitempty"`
@@ -12320,19 +12641,18 @@ func UnmarshalTemplateRepoUpdateRequest(m map[string]json.RawMessage, result int
type TemplateRepoUploadOptions struct {
// The ID of the workspace where you want to upload your `.tar` file. To find the workspace ID, use the `GET
// /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// The ID of the Terraform template in your workspace. When you create a workspace, a unique ID is assigned to your
// Terraform template, even if no template was provided during workspace creation. To find this ID, use the `GET
// /v1/workspaces` API and review the `template_data.id` value.
- TID *string `validate:"required,ne="`
+ TID *string `json:"-" validate:"required,ne="`
- // You can upload the `TAR` file of your template repository, to the workspace by using `tar` command to create the
- // file. For example, `tar -cvf mytarfile.tar $TEMPLATE_REPO_FOLDER`.
- File io.ReadCloser
+ // Template tar file.
+ File io.ReadCloser `json:"-"`
// The content type of file.
- FileContentType *string
+ FileContentType *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -12376,9 +12696,9 @@ func (options *TemplateRepoUploadOptions) SetHeaders(param map[string]string) *T
return options
}
-// TemplateResources : TemplateResources -.
+// TemplateResources : Information about the resources provisioned by the Terraform template.
type TemplateResources struct {
- // The subfolder in GitHub or GitLab where your Terraform templates are stored. If your template is stored in the root
+ // The subfolder in GitHub or GitLab where your Terraform templates are stored. If your template is stored in the root
// directory, `.` is returned.
Folder *string `json:"folder,omitempty"`
@@ -12464,7 +12784,7 @@ type TemplateRunTimeDataResponse struct {
// The URL where the Terraform statefile (`terraform.tfstate`) is stored. You can use the statefile to find an overview
// of IBM Cloud resources that were created by Schematics. Schematics uses the statefile as an inventory list to
- // determine future create, update, or deletion actions.
+ // determine future create, update, or deletion jobs.
StateStoreURL *string `json:"state_store_url,omitempty"`
}
@@ -12507,12 +12827,14 @@ func UnmarshalTemplateRunTimeDataResponse(m map[string]json.RawMessage, result i
return
}
-// TemplateSourceDataRequest : Input parameters to define input variables for your Schematics template.
+// TemplateSourceDataRequest : Input parameters to define input variables for your Terraform template.
type TemplateSourceDataRequest struct {
- // A list of environment variables that you want to apply during the execution of a bash script or Terraform action.
- // This field must be provided as a list of key-value pairs, for example, **TF_LOG=debug**. Each entry will be a map
- // with one entry where `key is the environment variable name and value is value`. You can define environment variables
- // for IBM Cloud catalog offerings that are provisioned by using a bash script.
+ // A list of environment variables that you want to apply during the execution of a bash script or Terraform job. This
+ // field must be provided as a list of key-value pairs, for example, **TF_LOG=debug**. Each entry will be a map with
+ // one entry where `key is the environment variable name and value is value`. You can define environment variables for
+ // IBM Cloud catalog offerings that are provisioned by using a bash script. See [example to use special environment
+ // variable](https://cloud.ibm.com/docs/schematics?topic=schematics-set-parallelism#parallelism-example) that are
+ // supported by Schematics.
EnvValues []interface{} `json:"env_values,omitempty"`
// The subfolder in your GitHub or GitLab repository where your Terraform template is stored.
@@ -12537,7 +12859,7 @@ type TemplateSourceDataRequest struct {
UninstallScriptName *string `json:"uninstall_script_name,omitempty"`
// A list of variable values that you want to apply during the Helm chart installation. The list must be provided in
- // JSON format, such as "autoscaling: enabled: true minReplicas: 2". The values that you define here override the
+ // JSON format, such as `"autoscaling: enabled: true minReplicas: 2"`. The values that you define here override the
// default Helm chart values. This field is supported only for IBM Cloud catalog offerings that are provisioned by
// using the Terraform Helm provider.
Values *string `json:"values,omitempty"`
@@ -12700,18 +13022,21 @@ func UnmarshalTemplateValues(m map[string]json.RawMessage, result interface{}) (
return
}
-// TerraformCommand : TerraformCommand -.
+// TerraformCommand : Inputs for running a Terraform command on the workspace.
type TerraformCommand struct {
- // Command to execute.
+ // You must provide the command to execute. Supported commands are `show`,`taint`, `untaint`, `state`, `import`,
+ // `output`.
Command *string `json:"command,omitempty"`
- // Command Parameters.
+ // The required address parameters for the command name. You can send the option flag and address parameter in the
+ // payload. **Syntax ** "command_params": "=", "". **Example ** "command_params":
+ // "-allow-missing=true", "-lock=true", "data.template_file.test".
CommandParams *string `json:"command_params,omitempty"`
- // Command name.
+ // The optional name for the command block.
CommandName *string `json:"command_name,omitempty"`
- // Command description.
+ // The optional text to describe the command block.
CommandDesc *string `json:"command_desc,omitempty"`
// Instruction to continue or break in case of error.
@@ -12720,7 +13045,7 @@ type TerraformCommand struct {
// Dependency on previous commands.
CommandDependsOn *string `json:"command_depends_on,omitempty"`
- // Command status.
+ // Displays the command executed status, either `success` or `failure`.
CommandStatus *string `json:"command_status,omitempty"`
}
@@ -12762,76 +13087,87 @@ func UnmarshalTerraformCommand(m map[string]json.RawMessage, result interface{})
// UpdateActionOptions : The UpdateAction options.
type UpdateActionOptions struct {
// Action Id. Use GET /actions API to look up the Action Ids in your IBM Cloud account.
- ActionID *string `validate:"required,ne="`
+ ActionID *string `json:"-" validate:"required,ne="`
- // Action name (unique for an account).
- Name *string
+ // The unique name of your action. The name can be up to 128 characters long and can include alphanumeric characters,
+ // spaces, dashes, and underscores. **Example** you can use the name to stop action.
+ Name *string `json:"name,omitempty"`
// Action description.
- Description *string
+ Description *string `json:"description,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
- // Resource-group name for the Action. By default, Action will be created in Default Resource Group.
- ResourceGroup *string
+ // Resource-group name for an action. By default, action is created in default resource group.
+ ResourceGroup *string `json:"resource_group,omitempty"`
// Action tags.
- Tags []string
+ Tags []string `json:"tags,omitempty"`
// User defined status of the Schematics object.
- UserState *UserState
+ UserState *UserState `json:"user_state,omitempty"`
- // URL of the README file, for the source.
- SourceReadmeURL *string
+ // URL of the `README` file, for the source URL.
+ SourceReadmeURL *string `json:"source_readme_url,omitempty"`
// Source of templates, playbooks, or controls.
- Source *ExternalSource
+ Source *ExternalSource `json:"source,omitempty"`
// Type of source for the Template.
- SourceType *string
+ SourceType *string `json:"source_type,omitempty"`
// Schematics job command parameter (playbook-name).
- CommandParameter *string
-
- // Describes a bastion resource.
- Bastion *BastionResourceDefinition
+ CommandParameter *string `json:"command_parameter,omitempty"`
// Target inventory record ID, used by the action or ansible playbook.
- Inventory *string
+ Inventory *string `json:"inventory,omitempty"`
+
+ // credentials of the Action.
+ Credentials []VariableData `json:"credentials,omitempty"`
+
+ // Describes a bastion resource.
+ Bastion *BastionResourceDefinition `json:"bastion,omitempty"`
// User editable variable data & system generated reference to value.
- BastionCredential *VariableData
+ BastionCredential *VariableData `json:"bastion_credential,omitempty"`
- // credentials of the Action.
- Credentials []VariableData
+ // Inventory of host and host group for the playbook in `INI` file format. For example, `"targets_ini":
+ // "[webserverhost]
+ // 172.22.192.6
+ // [dbhost]
+ // 172.22.192.5"`. For more information, about an inventory host group syntax, see [Inventory host
+ // groups](/docs/schematics?topic=schematics-schematics-cli-reference#schematics-inventory-host-grps).
+ TargetsIni *string `json:"targets_ini,omitempty"`
// Input variables for the Action.
- Inputs []VariableData
+ Inputs []VariableData `json:"inputs,omitempty"`
// Output variables for the Action.
- Outputs []VariableData
+ Outputs []VariableData `json:"outputs,omitempty"`
// Environment variables for the Action.
- Settings []VariableData
+ Settings []VariableData `json:"settings,omitempty"`
// Computed state of the Action.
- State *ActionState
+ State *ActionState `json:"state,omitempty"`
// System lock status.
- SysLock *SystemLock
+ SysLock *SystemLock `json:"sys_lock,omitempty"`
- // The github token associated with the GIT. Required for cloning of repo.
- XGithubToken *string
+ // The personal access token associated with your GitHub or GitLab repository, required to clone the repository.
+ XGithubToken *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
}
// Constants associated with the UpdateActionOptions.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
UpdateActionOptions_Location_EuDe = "eu-de"
UpdateActionOptions_Location_EuGb = "eu-gb"
@@ -12842,6 +13178,7 @@ const (
// Constants associated with the UpdateActionOptions.SourceType property.
// Type of source for the Template.
const (
+ UpdateActionOptions_SourceType_CosBucket = "cos_bucket"
UpdateActionOptions_SourceType_ExternalScm = "external_scm"
UpdateActionOptions_SourceType_GitHub = "git_hub"
UpdateActionOptions_SourceType_GitHubEnterprise = "git_hub_enterprise"
@@ -12924,27 +13261,33 @@ func (_options *UpdateActionOptions) SetCommandParameter(commandParameter string
return _options
}
-// SetBastion : Allow user to set Bastion
-func (_options *UpdateActionOptions) SetBastion(bastion *BastionResourceDefinition) *UpdateActionOptions {
- _options.Bastion = bastion
- return _options
-}
-
// SetInventory : Allow user to set Inventory
func (_options *UpdateActionOptions) SetInventory(inventory string) *UpdateActionOptions {
_options.Inventory = core.StringPtr(inventory)
return _options
}
+// SetCredentials : Allow user to set Credentials
+func (_options *UpdateActionOptions) SetCredentials(credentials []VariableData) *UpdateActionOptions {
+ _options.Credentials = credentials
+ return _options
+}
+
+// SetBastion : Allow user to set Bastion
+func (_options *UpdateActionOptions) SetBastion(bastion *BastionResourceDefinition) *UpdateActionOptions {
+ _options.Bastion = bastion
+ return _options
+}
+
// SetBastionCredential : Allow user to set BastionCredential
func (_options *UpdateActionOptions) SetBastionCredential(bastionCredential *VariableData) *UpdateActionOptions {
_options.BastionCredential = bastionCredential
return _options
}
-// SetCredentials : Allow user to set Credentials
-func (_options *UpdateActionOptions) SetCredentials(credentials []VariableData) *UpdateActionOptions {
- _options.Credentials = credentials
+// SetTargetsIni : Allow user to set TargetsIni
+func (_options *UpdateActionOptions) SetTargetsIni(targetsIni string) *UpdateActionOptions {
+ _options.TargetsIni = core.StringPtr(targetsIni)
return _options
}
@@ -12994,34 +13337,37 @@ func (options *UpdateActionOptions) SetHeaders(param map[string]string) *UpdateA
type UpdateInventoryOptions struct {
// Resource Inventory Id. Use GET /inventories API to look up the Resource Inventory definition Ids in your IBM Cloud
// account.
- InventoryID *string `validate:"required,ne="`
+ InventoryID *string `json:"-" validate:"required,ne="`
- // Inventory name.
- Name *string
+ // The unique name of your Inventory resource. The name can be up to 128 characters long and can include alphanumeric
+ // characters, spaces, dashes, and underscores.
+ Name *string `json:"name,omitempty"`
- // Inventory description.
- Description *string
+ // The description of your Inventory resource. The description can be up to 2048 characters long in size.
+ Description *string `json:"description,omitempty"`
- // List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of
- // the resources provisioned using Schematics.
- Location *string
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
- // Resource-group name for the Inventory definition. By default, Action will be created in Default Resource Group.
- ResourceGroup *string
+ // Resource-group name for the Inventory resource. By default, Action will be created in Default Resource Group.
+ ResourceGroup *string `json:"resource_group,omitempty"`
- // Input inventory of host and host group for the playbook, in the .ini file format.
- InventoriesIni *string
+ // Input inventory of host and host group for the playbook, in the `.ini` file format.
+ InventoriesIni *string `json:"inventories_ini,omitempty"`
- // Input resource queries that is used to dynamically generate the inventory of host and host group for the playbook.
- ResourceQueries []string
+ // Input resource queries that is used to dynamically generate the inventory of host and host group for the playbook.
+ ResourceQueries []string `json:"resource_queries,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
}
// Constants associated with the UpdateInventoryOptions.Location property.
-// List of workspace locations supported by IBM Cloud Schematics service. Note, this does not limit the location of the
-// resources provisioned using Schematics.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
const (
UpdateInventoryOptions_Location_EuDe = "eu-de"
UpdateInventoryOptions_Location_EuGb = "eu-gb"
@@ -13084,42 +13430,313 @@ func (options *UpdateInventoryOptions) SetHeaders(param map[string]string) *Upda
return options
}
+// UpdateJobOptions : The UpdateJob options.
+type UpdateJobOptions struct {
+ // Job Id. Use GET /jobs API to look up the Job Ids in your IBM Cloud account.
+ JobID *string `json:"-" validate:"required,ne="`
+
+ // The IAM refresh token associated with the IBM Cloud account.
+ RefreshToken *string `json:"-" validate:"required"`
+
+ // Name of the Schematics automation resource.
+ CommandObject *string `json:"command_object,omitempty"`
+
+ // Job command object id (workspace-id, action-id).
+ CommandObjectID *string `json:"command_object_id,omitempty"`
+
+ // Schematics job command name.
+ CommandName *string `json:"command_name,omitempty"`
+
+ // Schematics job command parameter (playbook-name).
+ CommandParameter *string `json:"command_parameter,omitempty"`
+
+ // Command line options for the command.
+ CommandOptions []string `json:"command_options,omitempty"`
+
+ // Job inputs used by Action or Workspace.
+ Inputs []VariableData `json:"inputs,omitempty"`
+
+ // Environment variables used by the Job while performing Action or Workspace.
+ Settings []VariableData `json:"settings,omitempty"`
+
+ // User defined tags, while running the job.
+ Tags []string `json:"tags,omitempty"`
+
+ // List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+ // right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+ // provisioned using Schematics.
+ Location *string `json:"location,omitempty"`
+
+ // Job Status.
+ Status *JobStatus `json:"status,omitempty"`
+
+ // Job data.
+ Data *JobData `json:"data,omitempty"`
+
+ // Describes a bastion resource.
+ Bastion *BastionResourceDefinition `json:"bastion,omitempty"`
+
+ // Job log summary record.
+ LogSummary *JobLogSummary `json:"log_summary,omitempty"`
+
+ // Allows users to set headers on API requests
+ Headers map[string]string
+}
+
+// Constants associated with the UpdateJobOptions.CommandObject property.
+// Name of the Schematics automation resource.
+const (
+ UpdateJobOptions_CommandObject_Action = "action"
+ UpdateJobOptions_CommandObject_Environment = "environment"
+ UpdateJobOptions_CommandObject_System = "system"
+ UpdateJobOptions_CommandObject_Workspace = "workspace"
+)
+
+// Constants associated with the UpdateJobOptions.CommandName property.
+// Schematics job command name.
+const (
+ UpdateJobOptions_CommandName_AnsiblePlaybookCheck = "ansible_playbook_check"
+ UpdateJobOptions_CommandName_AnsiblePlaybookRun = "ansible_playbook_run"
+ UpdateJobOptions_CommandName_CreateAction = "create_action"
+ UpdateJobOptions_CommandName_CreateCart = "create_cart"
+ UpdateJobOptions_CommandName_CreateEnvironment = "create_environment"
+ UpdateJobOptions_CommandName_CreateWorkspace = "create_workspace"
+ UpdateJobOptions_CommandName_DeleteAction = "delete_action"
+ UpdateJobOptions_CommandName_DeleteEnvironment = "delete_environment"
+ UpdateJobOptions_CommandName_DeleteWorkspace = "delete_workspace"
+ UpdateJobOptions_CommandName_EnvironmentInit = "environment_init"
+ UpdateJobOptions_CommandName_EnvironmentInstall = "environment_install"
+ UpdateJobOptions_CommandName_EnvironmentUninstall = "environment_uninstall"
+ UpdateJobOptions_CommandName_PatchAction = "patch_action"
+ UpdateJobOptions_CommandName_PatchWorkspace = "patch_workspace"
+ UpdateJobOptions_CommandName_PutAction = "put_action"
+ UpdateJobOptions_CommandName_PutEnvironment = "put_environment"
+ UpdateJobOptions_CommandName_PutWorkspace = "put_workspace"
+ UpdateJobOptions_CommandName_RepositoryProcess = "repository_process"
+ UpdateJobOptions_CommandName_SystemKeyDelete = "system_key_delete"
+ UpdateJobOptions_CommandName_SystemKeyDisable = "system_key_disable"
+ UpdateJobOptions_CommandName_SystemKeyEnable = "system_key_enable"
+ UpdateJobOptions_CommandName_SystemKeyRestore = "system_key_restore"
+ UpdateJobOptions_CommandName_SystemKeyRotate = "system_key_rotate"
+ UpdateJobOptions_CommandName_WorkspaceApply = "workspace_apply"
+ UpdateJobOptions_CommandName_WorkspaceDestroy = "workspace_destroy"
+ UpdateJobOptions_CommandName_WorkspacePlan = "workspace_plan"
+ UpdateJobOptions_CommandName_WorkspaceRefresh = "workspace_refresh"
+)
+
+// Constants associated with the UpdateJobOptions.Location property.
+// List of locations supported by IBM Cloud Schematics service. While creating your workspace or action, choose the
+// right region, since it cannot be changed. Note, this does not limit the location of the IBM Cloud resources,
+// provisioned using Schematics.
+const (
+ UpdateJobOptions_Location_EuDe = "eu-de"
+ UpdateJobOptions_Location_EuGb = "eu-gb"
+ UpdateJobOptions_Location_UsEast = "us-east"
+ UpdateJobOptions_Location_UsSouth = "us-south"
+)
+
+// NewUpdateJobOptions : Instantiate UpdateJobOptions
+func (*SchematicsV1) NewUpdateJobOptions(jobID string, refreshToken string) *UpdateJobOptions {
+ return &UpdateJobOptions{
+ JobID: core.StringPtr(jobID),
+ RefreshToken: core.StringPtr(refreshToken),
+ }
+}
+
+// SetJobID : Allow user to set JobID
+func (_options *UpdateJobOptions) SetJobID(jobID string) *UpdateJobOptions {
+ _options.JobID = core.StringPtr(jobID)
+ return _options
+}
+
+// SetRefreshToken : Allow user to set RefreshToken
+func (_options *UpdateJobOptions) SetRefreshToken(refreshToken string) *UpdateJobOptions {
+ _options.RefreshToken = core.StringPtr(refreshToken)
+ return _options
+}
+
+// SetCommandObject : Allow user to set CommandObject
+func (_options *UpdateJobOptions) SetCommandObject(commandObject string) *UpdateJobOptions {
+ _options.CommandObject = core.StringPtr(commandObject)
+ return _options
+}
+
+// SetCommandObjectID : Allow user to set CommandObjectID
+func (_options *UpdateJobOptions) SetCommandObjectID(commandObjectID string) *UpdateJobOptions {
+ _options.CommandObjectID = core.StringPtr(commandObjectID)
+ return _options
+}
+
+// SetCommandName : Allow user to set CommandName
+func (_options *UpdateJobOptions) SetCommandName(commandName string) *UpdateJobOptions {
+ _options.CommandName = core.StringPtr(commandName)
+ return _options
+}
+
+// SetCommandParameter : Allow user to set CommandParameter
+func (_options *UpdateJobOptions) SetCommandParameter(commandParameter string) *UpdateJobOptions {
+ _options.CommandParameter = core.StringPtr(commandParameter)
+ return _options
+}
+
+// SetCommandOptions : Allow user to set CommandOptions
+func (_options *UpdateJobOptions) SetCommandOptions(commandOptions []string) *UpdateJobOptions {
+ _options.CommandOptions = commandOptions
+ return _options
+}
+
+// SetInputs : Allow user to set Inputs
+func (_options *UpdateJobOptions) SetInputs(inputs []VariableData) *UpdateJobOptions {
+ _options.Inputs = inputs
+ return _options
+}
+
+// SetSettings : Allow user to set Settings
+func (_options *UpdateJobOptions) SetSettings(settings []VariableData) *UpdateJobOptions {
+ _options.Settings = settings
+ return _options
+}
+
+// SetTags : Allow user to set Tags
+func (_options *UpdateJobOptions) SetTags(tags []string) *UpdateJobOptions {
+ _options.Tags = tags
+ return _options
+}
+
+// SetLocation : Allow user to set Location
+func (_options *UpdateJobOptions) SetLocation(location string) *UpdateJobOptions {
+ _options.Location = core.StringPtr(location)
+ return _options
+}
+
+// SetStatus : Allow user to set Status
+func (_options *UpdateJobOptions) SetStatus(status *JobStatus) *UpdateJobOptions {
+ _options.Status = status
+ return _options
+}
+
+// SetData : Allow user to set Data
+func (_options *UpdateJobOptions) SetData(data *JobData) *UpdateJobOptions {
+ _options.Data = data
+ return _options
+}
+
+// SetBastion : Allow user to set Bastion
+func (_options *UpdateJobOptions) SetBastion(bastion *BastionResourceDefinition) *UpdateJobOptions {
+ _options.Bastion = bastion
+ return _options
+}
+
+// SetLogSummary : Allow user to set LogSummary
+func (_options *UpdateJobOptions) SetLogSummary(logSummary *JobLogSummary) *UpdateJobOptions {
+ _options.LogSummary = logSummary
+ return _options
+}
+
+// SetHeaders : Allow user to set Headers
+func (options *UpdateJobOptions) SetHeaders(param map[string]string) *UpdateJobOptions {
+ options.Headers = param
+ return options
+}
+
+// UpdateKmsSettingsOptions : The UpdateKmsSettings options.
+type UpdateKmsSettingsOptions struct {
+ // Location.
+ Location *string `json:"location,omitempty"`
+
+ // Encryption scheme.
+ EncryptionScheme *string `json:"encryption_scheme,omitempty"`
+
+ // Resource group.
+ ResourceGroup *string `json:"resource_group,omitempty"`
+
+ // Primary CRK details.
+ PrimaryCrk *KMSSettingsPrimaryCrk `json:"primary_crk,omitempty"`
+
+ // Secondary CRK details.
+ SecondaryCrk *KMSSettingsSecondaryCrk `json:"secondary_crk,omitempty"`
+
+ // Allows users to set headers on API requests
+ Headers map[string]string
+}
+
+// NewUpdateKmsSettingsOptions : Instantiate UpdateKmsSettingsOptions
+func (*SchematicsV1) NewUpdateKmsSettingsOptions() *UpdateKmsSettingsOptions {
+ return &UpdateKmsSettingsOptions{}
+}
+
+// SetLocation : Allow user to set Location
+func (_options *UpdateKmsSettingsOptions) SetLocation(location string) *UpdateKmsSettingsOptions {
+ _options.Location = core.StringPtr(location)
+ return _options
+}
+
+// SetEncryptionScheme : Allow user to set EncryptionScheme
+func (_options *UpdateKmsSettingsOptions) SetEncryptionScheme(encryptionScheme string) *UpdateKmsSettingsOptions {
+ _options.EncryptionScheme = core.StringPtr(encryptionScheme)
+ return _options
+}
+
+// SetResourceGroup : Allow user to set ResourceGroup
+func (_options *UpdateKmsSettingsOptions) SetResourceGroup(resourceGroup string) *UpdateKmsSettingsOptions {
+ _options.ResourceGroup = core.StringPtr(resourceGroup)
+ return _options
+}
+
+// SetPrimaryCrk : Allow user to set PrimaryCrk
+func (_options *UpdateKmsSettingsOptions) SetPrimaryCrk(primaryCrk *KMSSettingsPrimaryCrk) *UpdateKmsSettingsOptions {
+ _options.PrimaryCrk = primaryCrk
+ return _options
+}
+
+// SetSecondaryCrk : Allow user to set SecondaryCrk
+func (_options *UpdateKmsSettingsOptions) SetSecondaryCrk(secondaryCrk *KMSSettingsSecondaryCrk) *UpdateKmsSettingsOptions {
+ _options.SecondaryCrk = secondaryCrk
+ return _options
+}
+
+// SetHeaders : Allow user to set Headers
+func (options *UpdateKmsSettingsOptions) SetHeaders(param map[string]string) *UpdateKmsSettingsOptions {
+ options.Headers = param
+ return options
+}
+
// UpdateWorkspaceOptions : The UpdateWorkspace options.
type UpdateWorkspaceOptions struct {
// The ID of the workspace that you want to update. To find the ID, use the `GET /v1/workspaces` API.
- WID *string `validate:"required,ne="`
+ WID *string `json:"-" validate:"required,ne="`
// Information about the software template that you chose from the IBM Cloud catalog. This information is returned for
// IBM Cloud catalog offerings only.
- CatalogRef *CatalogRef
+ CatalogRef *CatalogRef `json:"catalog_ref,omitempty"`
// The description of the workspace.
- Description *string
+ Description *string `json:"description,omitempty"`
// The name of the workspace.
- Name *string
+ Name *string `json:"name,omitempty"`
- // Information that is shared across templates in IBM Cloud catalog offerings. This information is not provided when
- // you create a workspace from your own Terraform template.
- SharedData *SharedTargetData
+ // Information about the Target used by the templates originating from the IBM Cloud catalog offerings. This
+ // information is not relevant for workspace created using your own Terraform template.
+ SharedData *SharedTargetData `json:"shared_data,omitempty"`
// A list of tags that you want to associate with your workspace.
- Tags []string
+ Tags []string `json:"tags,omitempty"`
- // TemplateData -.
- TemplateData []TemplateSourceDataRequest
+ // Input data for the Template.
+ TemplateData []TemplateSourceDataRequest `json:"template_data,omitempty"`
- // TemplateRepoUpdateRequest -.
- TemplateRepo *TemplateRepoUpdateRequest
+ // Input to update the template repository data.
+ TemplateRepo *TemplateRepoUpdateRequest `json:"template_repo,omitempty"`
// List of Workspace type.
- Type []string
+ Type []string `json:"type,omitempty"`
- // Information about the updated workspace status. -.
- WorkspaceStatus *WorkspaceStatusUpdateRequest
+ // Input to update the workspace status.
+ WorkspaceStatus *WorkspaceStatusUpdateRequest `json:"workspace_status,omitempty"`
- // Information about the last action that ran against the workspace. -.
- WorkspaceStatusMsg *WorkspaceStatusMessage
+ // Information about the last job that ran against the workspace. -.
+ WorkspaceStatusMsg *WorkspaceStatusMessage `json:"workspace_status_msg,omitempty"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -13207,14 +13824,13 @@ func (options *UpdateWorkspaceOptions) SetHeaders(param map[string]string) *Upda
// UploadTemplateTarActionOptions : The UploadTemplateTarAction options.
type UploadTemplateTarActionOptions struct {
// Action Id. Use GET /actions API to look up the Action Ids in your IBM Cloud account.
- ActionID *string `validate:"required,ne="`
+ ActionID *string `json:"-" validate:"required,ne="`
- // You can upload the `TAR` file of your template repository, to the workspace by using `tar` command to create the
- // file. For example, `tar -cvf mytarfile.tar $TEMPLATE_REPO_FOLDER`.
- File io.ReadCloser
+ // Template tar file.
+ File io.ReadCloser `json:"-"`
// The content type of file.
- FileContentType *string
+ FileContentType *string `json:"-"`
// Allows users to set headers on API requests
Headers map[string]string
@@ -13301,10 +13917,12 @@ func UnmarshalUserState(m map[string]json.RawMessage, result interface{}) (err e
// UserValues : UserValues -.
type UserValues struct {
- // A list of environment variables that you want to apply during the execution of a bash script or Terraform action.
- // This field must be provided as a list of key-value pairs, for example, **TF_LOG=debug**. Each entry will be a map
- // with one entry where `key is the environment variable name and value is value`. You can define environment variables
- // for IBM Cloud catalog offerings that are provisioned by using a bash script.
+ // A list of environment variables that you want to apply during the execution of a bash script or Terraform job. This
+ // field must be provided as a list of key-value pairs, for example, **TF_LOG=debug**. Each entry will be a map with
+ // one entry where `key is the environment variable name and value is value`. You can define environment variables for
+ // IBM Cloud catalog offerings that are provisioned by using a bash script. See [example to use special environment
+ // variable](https://cloud.ibm.com/docs/schematics?topic=schematics-set-parallelism#parallelism-example) that are
+ // supported by Schematics.
EnvValues []interface{} `json:"env_values,omitempty"`
// User values.
@@ -13574,15 +14192,15 @@ func UnmarshalVersionResponse(m map[string]json.RawMessage, result interface{})
return
}
-// WorkspaceActivities : WorkspaceActivities -.
+// WorkspaceActivities : List of workspace jobs.
type WorkspaceActivities struct {
- // List of workspace activities.
+ // List of workspace jobs.
Actions []WorkspaceActivity `json:"actions,omitempty"`
- // Workspace id.
+ // The ID of the workspace.
WorkspaceID *string `json:"workspace_id,omitempty"`
- // Workspace name.
+ // The name of the workspace.
WorkspaceName *string `json:"workspace_name,omitempty"`
}
@@ -13605,24 +14223,41 @@ func UnmarshalWorkspaceActivities(m map[string]json.RawMessage, result interface
return
}
-// WorkspaceActivity : WorkspaceActivity -.
+// WorkspaceActivity : Information about the workspace jobs.
type WorkspaceActivity struct {
- // Activity id.
+ // The ID of the activity or job. You can use the ID to retrieve the logs for that job by using the `GET
+ // /v1/workspaces/{id}/actions/{action_id}/logs` API.
ActionID *string `json:"action_id,omitempty"`
- // StatusMessages -.
+ // Information about the success or failure of your job, including a success or error code and the timestamp when the
+ // job succeeded or failed.
Message []string `json:"message,omitempty"`
- // WorkspaceActivityAction activity action type.
+ // The type of actovoty or job that ran against your workspace.
+ //
+ // * **APPLY**: The apply job was created when you used the `PUT /v1/workspaces/{id}/apply` API to apply a Terraform
+ // template in IBM Cloud.
+ // * **DESTROY**: The destroy job was created when you used the `DELETE /v1/workspaces/{id}/destroy` API to remove all
+ // resources that are associated with your workspace.
+ // * **PLAN**: The plan job was created when you used the `POST /v1/workspaces/{id}/plan` API to create a Terraform
+ // execution plan.
Name *string `json:"name,omitempty"`
- // Activity performed at.
+ // The timestamp when the job was initiated.
PerformedAt *strfmt.DateTime `json:"performed_at,omitempty"`
- // Activity performed by.
+ // The user ID who initiated the job.
PerformedBy *string `json:"performed_by,omitempty"`
- // WorkspaceActivityStatus activity status type.
+ // The status of your activity or job. To retrieve the URL to your job logs, use the GET
+ // /v1/workspaces/{id}/actions/{action_id}/logs API.
+ //
+ // * **COMPLETED**: The job completed successfully.
+ // * **CREATED**: The job was created, but the provisioning, modification, or removal of IBM Cloud resources has not
+ // started yet.
+ // * **FAILED**: An error occurred during the plan, apply, or destroy job. Use the job ID to retrieve the URL to the
+ // log files for your job.
+ // * **IN PROGRESS**: The job is in progress. You can use the log_url to access the logs.
Status *string `json:"status,omitempty"`
// List of template activities.
@@ -13664,9 +14299,10 @@ func UnmarshalWorkspaceActivity(m map[string]json.RawMessage, result interface{}
return
}
-// WorkspaceActivityApplyResult : WorkspaceActivityApplyResult -.
+// WorkspaceActivityApplyResult : Response after successfully initiating a request to `apply` the Terraform template in IBM Cloud.
type WorkspaceActivityApplyResult struct {
- // Activity id.
+ // The ID of the activity or job that was created when you initiated a request to `apply` a Terraform template. You
+ // can use the ID to retrieve log file by using the `GET /v1/workspaces/{id}/actions/{action_id}/logs` API.
Activityid *string `json:"activityid,omitempty"`
}
@@ -13681,9 +14317,11 @@ func UnmarshalWorkspaceActivityApplyResult(m map[string]json.RawMessage, result
return
}
-// WorkspaceActivityCommandResult : WorkspaceActivityCommandResult -.
+// WorkspaceActivityCommandResult : Response after successfully initiating a request to run a workspace command on the stack of resources provisioned
+// using Terraform.
type WorkspaceActivityCommandResult struct {
- // Activity id.
+ // The ID of the job that was created when you initiated a request to `apply` a Terraform template. You can use the ID
+ // to retrieve log file by using the `GET /v1/workspaces/{id}/actions/{action_id}/logs` API.
Activityid *string `json:"activityid,omitempty"`
}
@@ -13698,9 +14336,10 @@ func UnmarshalWorkspaceActivityCommandResult(m map[string]json.RawMessage, resul
return
}
-// WorkspaceActivityDestroyResult : WorkspaceActivityDestroyResult -.
+// WorkspaceActivityDestroyResult : Response after successfully initiating a request to `destroy` the stack of resources provisioned using Terraform.
type WorkspaceActivityDestroyResult struct {
- // Activity id.
+ // The ID of the activity or job that was created when you initiated a request to `destroy` a Terraform template. You
+ // can use the ID to retrieve log file by using the `GET /v1/workspaces/{id}/actions/{action_id}/logs` API.
Activityid *string `json:"activityid,omitempty"`
}
@@ -13715,15 +14354,22 @@ func UnmarshalWorkspaceActivityDestroyResult(m map[string]json.RawMessage, resul
return
}
-// WorkspaceActivityLogs : WorkspaceActivityLogs -.
+// WorkspaceActivityLogs : Workspace job logs for all the templates in the workspace.
type WorkspaceActivityLogs struct {
- // Activity id.
+ // The ID of the activity or job that ran against your workspace.
ActionID *string `json:"action_id,omitempty"`
- // WorkspaceActivityAction activity action type.
+ // The type of actovoty or job that ran against your workspace.
+ //
+ // * **APPLY**: The apply job was created when you used the `PUT /v1/workspaces/{id}/apply` API to apply a Terraform
+ // template in IBM Cloud.
+ // * **DESTROY**: The destroy job was created when you used the `DELETE /v1/workspaces/{id}/destroy` API to remove all
+ // resources that are associated with your workspace.
+ // * **PLAN**: The plan job was created when you used the `POST /v1/workspaces/{id}/plan` API to create a Terraform
+ // execution plan.
Name *string `json:"name,omitempty"`
- // List of activity logs.
+ // List of templates in the workspace.
Templates []WorkspaceActivityTemplateLogs `json:"templates,omitempty"`
}
@@ -13746,12 +14392,12 @@ func UnmarshalWorkspaceActivityLogs(m map[string]json.RawMessage, result interfa
return
}
-// WorkspaceActivityOptionsTemplate : Workspace Activity Options Template.
+// WorkspaceActivityOptionsTemplate : Workspace job options template.
type WorkspaceActivityOptionsTemplate struct {
- // Workspace Activity targets.
+ // A list of Terraform resources to target.
Target []string `json:"target,omitempty"`
- // Workspace Activity tfvars.
+ // Terraform variables for the workspace job options.
TfVars []string `json:"tf_vars,omitempty"`
}
@@ -13770,9 +14416,10 @@ func UnmarshalWorkspaceActivityOptionsTemplate(m map[string]json.RawMessage, res
return
}
-// WorkspaceActivityPlanResult : WorkspaceActivityPlanResult -.
+// WorkspaceActivityPlanResult : Response after successfully initiating a request to `plan` the Terraform template in IBM Cloud.
type WorkspaceActivityPlanResult struct {
- // Activity id.
+ // The ID of the activity or job that was created when you initiated a request to `plan` a Terraform template. You can
+ // use the ID to retrieve log file by using the `GET /v1/workspaces/{id}/actions/{action_id}/logs` API.
Activityid *string `json:"activityid,omitempty"`
}
@@ -13787,9 +14434,10 @@ func UnmarshalWorkspaceActivityPlanResult(m map[string]json.RawMessage, result i
return
}
-// WorkspaceActivityRefreshResult : WorkspaceActivityRefreshResult -.
+// WorkspaceActivityRefreshResult : Response after successfully initiating a request to `refresh` the Terraform template in IBM Cloud.
type WorkspaceActivityRefreshResult struct {
- // Activity id.
+ // The ID of the activity or job that was created for your workspace `refresh` activity or job. You can use the ID to
+ // retrieve the log file by using the `GET /v1/workspaces/{id}/actions/{action_id}/logs` API.
Activityid *string `json:"activityid,omitempty"`
}
@@ -13804,12 +14452,12 @@ func UnmarshalWorkspaceActivityRefreshResult(m map[string]json.RawMessage, resul
return
}
-// WorkspaceActivityTemplate : WorkspaceActivityTemplate -.
+// WorkspaceActivityTemplate : Information about the template in the workspace.
type WorkspaceActivityTemplate struct {
- // End time for the activity.
+ // End time for the job.
EndTime *strfmt.DateTime `json:"end_time,omitempty"`
- // LogSummary ...
+ // Summary information extracted from the job logs.
LogSummary *LogSummary `json:"log_summary,omitempty"`
// Log URL.
@@ -13818,16 +14466,24 @@ type WorkspaceActivityTemplate struct {
// Message.
Message *string `json:"message,omitempty"`
- // Activity start time.
+ // Job start time.
StartTime *strfmt.DateTime `json:"start_time,omitempty"`
- // WorkspaceActivityStatus activity status type.
+ // The status of your activity or job. To retrieve the URL to your job logs, use the GET
+ // /v1/workspaces/{id}/actions/{action_id}/logs API.
+ //
+ // * **COMPLETED**: The job completed successfully.
+ // * **CREATED**: The job was created, but the provisioning, modification, or removal of IBM Cloud resources has not
+ // started yet.
+ // * **FAILED**: An error occurred during the plan, apply, or destroy job. Use the job ID to retrieve the URL to the
+ // log files for your job.
+ // * **IN PROGRESS**: The job is in progress. You can use the log_url to access the logs.
Status *string `json:"status,omitempty"`
- // Template id.
+ // The ID that was assigned to your Terraform template or IBM Cloud catalog software template.
TemplateID *string `json:"template_id,omitempty"`
- // Template type.
+ // The type of template.
TemplateType *string `json:"template_type,omitempty"`
}
@@ -13870,15 +14526,15 @@ func UnmarshalWorkspaceActivityTemplate(m map[string]json.RawMessage, result int
return
}
-// WorkspaceActivityTemplateLogs : WorkspaceActivityTemplateLogs -.
+// WorkspaceActivityTemplateLogs : Information about the log URL for a job that ran for a template against your workspace.
type WorkspaceActivityTemplateLogs struct {
- // Log URL.
+ // The URL to access the logs that were created during the plan, apply, or destroy job.
LogURL *string `json:"log_url,omitempty"`
- // Template id.
+ // The ID that was assigned to your Terraform template or IBM Cloud catalog software template.
TemplateID *string `json:"template_id,omitempty"`
- // Template type.
+ // The type of template.
TemplateType *string `json:"template_type,omitempty"`
}
@@ -13901,7 +14557,7 @@ func UnmarshalWorkspaceActivityTemplateLogs(m map[string]json.RawMessage, result
return
}
-// WorkspaceBulkDeleteResponse : WorkspaceBulkDeleteResponse -.
+// WorkspaceBulkDeleteResponse : Response after successfully initiating the bulk job to delete multiple workspaces.
type WorkspaceBulkDeleteResponse struct {
// Workspace deletion job name.
Job *string `json:"job,omitempty"`
@@ -13925,9 +14581,9 @@ func UnmarshalWorkspaceBulkDeleteResponse(m map[string]json.RawMessage, result i
return
}
-// WorkspaceJobResponse : WorkspaceJobResponse -.
+// WorkspaceJobResponse : Response from the workspace bulk job status.
type WorkspaceJobResponse struct {
- // JobStatusType -.
+ // Status of the workspace bulk job.
JobStatus *WorkspaceJobStatusType `json:"job_status,omitempty"`
}
@@ -13942,7 +14598,7 @@ func UnmarshalWorkspaceJobResponse(m map[string]json.RawMessage, result interfac
return
}
-// WorkspaceJobStatusType : JobStatusType -.
+// WorkspaceJobStatusType : Status of the workspace bulk job.
type WorkspaceJobStatusType struct {
// List of failed workspace jobs.
Failed []string `json:"failed,omitempty"`
@@ -13980,7 +14636,7 @@ func UnmarshalWorkspaceJobStatusType(m map[string]json.RawMessage, result interf
return
}
-// WorkspaceResponse : Overview of workspace details.
+// WorkspaceResponse : Workspace details.
type WorkspaceResponse struct {
// List of applied shared dataset ID.
AppliedShareddataIds []string `json:"applied_shareddata_ids,omitempty"`
@@ -14019,8 +14675,8 @@ type WorkspaceResponse struct {
// Information about the provisioning engine, state file, and runtime logs.
RuntimeData []TemplateRunTimeDataResponse `json:"runtime_data,omitempty"`
- // Information that is shared across templates in IBM Cloud catalog offerings. This information is not provided when
- // you create a workspace from your own Terraform template.
+ // Information about the Target used by the templates originating from IBM Cloud catalog offerings. This information is
+ // not relevant when you create a workspace from your own Terraform template.
SharedData *SharedTargetDataResponse `json:"shared_data,omitempty"`
// The status of the workspace.
@@ -14038,7 +14694,7 @@ type WorkspaceResponse struct {
// workspace status is set to `Failed`.
//
// **Inactive**: The Terraform template was scanned successfully and the workspace creation is complete. You can now
- // start running Schematics plan and apply actions to provision the IBM Cloud resources that you specified in your
+ // start running Schematics plan and apply jobs to provision the IBM Cloud resources that you specified in your
// template. If you have an `Active` workspace and decide to remove all your resources, your workspace is set to
// `Inactive` after all your resources are removed.
//
@@ -14049,7 +14705,7 @@ type WorkspaceResponse struct {
// is successful, the workspace state changes to `Inactive`. If errors in your template are found, the state changes to
// `Template Error`.
//
- // **Stopped**: The Schematics plan, apply, or destroy action was cancelled manually.
+ // **Stopped**: The Schematics plan, apply, or destroy job was cancelled manually.
//
// **Template Error**: The Schematics template contains errors and cannot be processed.
Status *string `json:"status,omitempty"`
@@ -14063,7 +14719,7 @@ type WorkspaceResponse struct {
// Workspace template reference.
TemplateRef *string `json:"template_ref,omitempty"`
- // TemplateRepoResponse -.
+ // Information about the Template repository used by the workspace.
TemplateRepo *TemplateRepoResponse `json:"template_repo,omitempty"`
// The Terraform version that was used to run your Terraform code.
@@ -14075,10 +14731,10 @@ type WorkspaceResponse struct {
// The user ID that updated the workspace.
UpdatedBy *string `json:"updated_by,omitempty"`
- // Response parameter that indicate if a workspace is frozen or locked. -.
+ // Response that indicate the status of the workspace as either frozen or locked.
WorkspaceStatus *WorkspaceStatusResponse `json:"workspace_status,omitempty"`
- // Information about the last action that ran against the workspace. -.
+ // Information about the last job that ran against the workspace. -.
WorkspaceStatusMsg *WorkspaceStatusMessage `json:"workspace_status_msg,omitempty"`
}
@@ -14181,7 +14837,7 @@ func UnmarshalWorkspaceResponse(m map[string]json.RawMessage, result interface{}
return
}
-// WorkspaceResponseList : WorkspaceResponseList -.
+// WorkspaceResponseList : List of workspaces.
type WorkspaceResponseList struct {
// The number of workspaces in the IBM Cloud account that you have access to and that matched your search criteria.
Count *int64 `json:"count,omitempty"`
@@ -14221,13 +14877,13 @@ func UnmarshalWorkspaceResponseList(m map[string]json.RawMessage, result interfa
return
}
-// WorkspaceStatusMessage : Information about the last action that ran against the workspace. -.
+// WorkspaceStatusMessage : Information about the last job that ran against the workspace. -.
type WorkspaceStatusMessage struct {
- // The success or error code that was returned for the last plan, apply, or destroy action that ran against your
+ // The success or error code that was returned for the last plan, apply, or destroy job that ran against your
// workspace.
StatusCode *string `json:"status_code,omitempty"`
- // The success or error message that was returned for the last plan, apply, or destroy action that ran against your
+ // The success or error message that was returned for the last plan, apply, or destroy job that ran against your
// workspace.
StatusMsg *string `json:"status_msg,omitempty"`
}
@@ -14261,7 +14917,7 @@ type WorkspaceStatusRequest struct {
// If set to true, the workspace is locked and disabled for changes.
Locked *bool `json:"locked,omitempty"`
- // The user ID that initiated a resource-related action, such as applying or destroying resources, that locked the
+ // The user ID that initiated a resource-related job, such as applying or destroying resources, that locked the
// workspace.
LockedBy *string `json:"locked_by,omitempty"`
@@ -14300,7 +14956,7 @@ func UnmarshalWorkspaceStatusRequest(m map[string]json.RawMessage, result interf
return
}
-// WorkspaceStatusResponse : Response parameter that indicate if a workspace is frozen or locked. -.
+// WorkspaceStatusResponse : Response that indicate the status of the workspace as either frozen or locked.
type WorkspaceStatusResponse struct {
// If set to true, the workspace is frozen and changes to the workspace are disabled.
Frozen *bool `json:"frozen,omitempty"`
@@ -14314,7 +14970,7 @@ type WorkspaceStatusResponse struct {
// If set to true, the workspace is locked and disabled for changes.
Locked *bool `json:"locked,omitempty"`
- // The user ID that initiated a resource-related action, such as applying or destroying resources, that locked the
+ // The user ID that initiated a resource-related job, such as applying or destroying resources, that locked the
// workspace.
LockedBy *string `json:"locked_by,omitempty"`
@@ -14353,7 +15009,7 @@ func UnmarshalWorkspaceStatusResponse(m map[string]json.RawMessage, result inter
return
}
-// WorkspaceStatusUpdateRequest : Information about the updated workspace status. -.
+// WorkspaceStatusUpdateRequest : Input to update the workspace status.
type WorkspaceStatusUpdateRequest struct {
// If set to true, the workspace is frozen and changes to the workspace are disabled.
Frozen *bool `json:"frozen,omitempty"`
@@ -14405,13 +15061,13 @@ func UnmarshalWorkspaceStatusUpdateRequest(m map[string]json.RawMessage, result
return
}
-// WorkspaceTemplateValuesResponse : Information about the template that your workspace points to.
+// WorkspaceTemplateValuesResponse : Response with the template details in your workspace.
type WorkspaceTemplateValuesResponse struct {
// Information about the provisioning engine, state file, and runtime logs.
RuntimeData []TemplateRunTimeDataResponse `json:"runtime_data,omitempty"`
- // Information that is shared across templates in IBM Cloud catalog offerings. This information is not provided when
- // you create a workspace from your own Terraform template.
+ // Information about the Target used by the templates originating from the IBM Cloud catalog offerings. This
+ // information is not relevant for workspace created using your own Terraform template.
SharedData *SharedTargetData `json:"shared_data,omitempty"`
// Information about the input variables that are used in the template.
@@ -14437,7 +15093,7 @@ func UnmarshalWorkspaceTemplateValuesResponse(m map[string]json.RawMessage, resu
return
}
-// WorkspaceVariableRequest : Detailed information about the input variables that your template uses.
+// WorkspaceVariableRequest : Input variables for your workspace.
type WorkspaceVariableRequest struct {
// The description of your input variable.
Description *string `json:"description,omitempty"`
@@ -14501,7 +15157,7 @@ func UnmarshalWorkspaceVariableRequest(m map[string]json.RawMessage, result inte
// WorkspaceVariableResponse : The description of your input variable.
type WorkspaceVariableResponse struct {
- // Variable descrption.
+ // The description of your input variable.
Description *string `json:"description,omitempty"`
// The name of the variable.
diff --git a/schematicsv1/schematics_v1_integration_test.go b/schematicsv1/schematics_v1_integration_test.go
index 370f744..d397ac6 100644
--- a/schematicsv1/schematics_v1_integration_test.go
+++ b/schematicsv1/schematics_v1_integration_test.go
@@ -148,7 +148,10 @@ func waitForWorkspaceStatus(wid *string, status string) {
func waitForWorkspaceActivityStatus(wid *string, activityid *string, status string) {
var activitystatus string
for strings.Compare(activitystatus, status) != 0 {
- activitystatus = *getWorkspaceActivityByID(wid, activityid).Status
+ status := getWorkspaceActivityByID(wid, activityid)
+ if status != nil {
+ activitystatus = *status.Status
+ }
//fmt.Println(activitystatus)
time.Sleep(2 * time.Second)
}
diff --git a/schematicsv1/schematics_v1_test.go b/schematicsv1/schematics_v1_test.go
index 257f608..cad12d3 100644
--- a/schematicsv1/schematics_v1_test.go
+++ b/schematicsv1/schematics_v1_test.go
@@ -33,21981 +33,22330 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
-
- var _ = Describe(`SchematicsV1`, func() {
- var testServer *httptest.Server
- Describe(`Service constructor tests`, func() {
- It(`Instantiate service client`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(schematicsService).ToNot(BeNil())
- Expect(serviceErr).To(BeNil())
- })
- It(`Instantiate service client with error: Invalid URL`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: "{BAD_URL_STRING",
- })
- Expect(schematicsService).To(BeNil())
- Expect(serviceErr).ToNot(BeNil())
- })
- It(`Instantiate service client with error: Invalid Auth`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: "https://schematicsv1/api",
- Authenticator: &core.BasicAuthenticator{
- Username: "",
- Password: "",
- },
- })
- Expect(schematicsService).To(BeNil())
- Expect(serviceErr).ToNot(BeNil())
- })
- })
- Describe(`Service constructor tests using external config`, func() {
- Context(`Using external config, construct service client instances`, func() {
- // Map containing environment variables used in testing.
- var testEnvironment = map[string]string{
- "SCHEMATICS_URL": "https://schematicsv1/api",
- "SCHEMATICS_AUTH_TYPE": "noauth",
- }
-
- It(`Create service client using external config successfully`, func() {
- SetTestEnvironment(testEnvironment)
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{
- })
- Expect(schematicsService).ToNot(BeNil())
- Expect(serviceErr).To(BeNil())
- ClearTestEnvironment(testEnvironment)
-
- clone := schematicsService.Clone()
- Expect(clone).ToNot(BeNil())
- Expect(clone.Service != schematicsService.Service).To(BeTrue())
- Expect(clone.GetServiceURL()).To(Equal(schematicsService.GetServiceURL()))
- Expect(clone.Service.Options.Authenticator).To(Equal(schematicsService.Service.Options.Authenticator))
- })
- It(`Create service client using external config and set url from constructor successfully`, func() {
- SetTestEnvironment(testEnvironment)
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{
- URL: "https://testService/api",
- })
- Expect(schematicsService).ToNot(BeNil())
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService.Service.GetServiceURL()).To(Equal("https://testService/api"))
- ClearTestEnvironment(testEnvironment)
-
- clone := schematicsService.Clone()
- Expect(clone).ToNot(BeNil())
- Expect(clone.Service != schematicsService.Service).To(BeTrue())
- Expect(clone.GetServiceURL()).To(Equal(schematicsService.GetServiceURL()))
- Expect(clone.Service.Options.Authenticator).To(Equal(schematicsService.Service.Options.Authenticator))
- })
- It(`Create service client using external config and set url programatically successfully`, func() {
- SetTestEnvironment(testEnvironment)
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{
- })
- err := schematicsService.SetServiceURL("https://testService/api")
- Expect(err).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService.Service.GetServiceURL()).To(Equal("https://testService/api"))
- ClearTestEnvironment(testEnvironment)
-
- clone := schematicsService.Clone()
- Expect(clone).ToNot(BeNil())
- Expect(clone.Service != schematicsService.Service).To(BeTrue())
- Expect(clone.GetServiceURL()).To(Equal(schematicsService.GetServiceURL()))
- Expect(clone.Service.Options.Authenticator).To(Equal(schematicsService.Service.Options.Authenticator))
- })
- })
- Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
- // Map containing environment variables used in testing.
- var testEnvironment = map[string]string{
- "SCHEMATICS_URL": "https://schematicsv1/api",
- "SCHEMATICS_AUTH_TYPE": "someOtherAuth",
- }
-
- SetTestEnvironment(testEnvironment)
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{
- })
-
- It(`Instantiate service client with error`, func() {
- Expect(schematicsService).To(BeNil())
- Expect(serviceErr).ToNot(BeNil())
- ClearTestEnvironment(testEnvironment)
- })
- })
- Context(`Using external config, construct service client instances with error: Invalid URL`, func() {
- // Map containing environment variables used in testing.
- var testEnvironment = map[string]string{
- "SCHEMATICS_AUTH_TYPE": "NOAuth",
- }
-
- SetTestEnvironment(testEnvironment)
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{
- URL: "{BAD_URL_STRING",
- })
-
- It(`Instantiate service client with error`, func() {
- Expect(schematicsService).To(BeNil())
- Expect(serviceErr).ToNot(BeNil())
- ClearTestEnvironment(testEnvironment)
- })
- })
- })
- Describe(`Regional endpoint tests`, func() {
- It(`GetServiceURLForRegion(region string)`, func() {
- var url string
- var err error
- url, err = schematicsv1.GetServiceURLForRegion("INVALID_REGION")
- Expect(url).To(BeEmpty())
- Expect(err).ToNot(BeNil())
- fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
- })
- })
- Describe(`ListSchematicsLocation(listSchematicsLocationOptions *ListSchematicsLocationOptions) - Operation response error`, func() {
- listSchematicsLocationPath := "/v1/locations"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listSchematicsLocationPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListSchematicsLocation with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListSchematicsLocationOptions model
- listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
- listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListSchematicsLocation(listSchematicsLocationOptions *ListSchematicsLocationOptions)`, func() {
- listSchematicsLocationPath := "/v1/locations"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listSchematicsLocationPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"name": "Name", "id": "ID", "country": "Country", "geography": "Geography", "geography_code": "GeographyCode", "metro": "Metro", "multizone_metro": "MultizoneMetro", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]`)
- }))
- })
- It(`Invoke ListSchematicsLocation successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListSchematicsLocationOptions model
- listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
- listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListSchematicsLocationWithContext(ctx, listSchematicsLocationOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListSchematicsLocationWithContext(ctx, listSchematicsLocationOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listSchematicsLocationPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"name": "Name", "id": "ID", "country": "Country", "geography": "Geography", "geography_code": "GeographyCode", "metro": "Metro", "multizone_metro": "MultizoneMetro", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]`)
- }))
- })
- It(`Invoke ListSchematicsLocation successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListSchematicsLocation(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListSchematicsLocationOptions model
- listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
- listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListSchematicsLocation with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListSchematicsLocationOptions model
- listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
- listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListSchematicsLocation successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListSchematicsLocationOptions model
- listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
- listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListResourceGroup(listResourceGroupOptions *ListResourceGroupOptions) - Operation response error`, func() {
- listResourceGroupPath := "/v1/resource_groups"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listResourceGroupPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListResourceGroup with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListResourceGroupOptions model
- listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
- listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListResourceGroup(listResourceGroupOptions *ListResourceGroupOptions)`, func() {
- listResourceGroupPath := "/v1/resource_groups"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listResourceGroupPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"account_id": "AccountID", "crn": "Crn", "default": false, "name": "Name", "resource_group_id": "ResourceGroupID", "state": "State"}]`)
- }))
- })
- It(`Invoke ListResourceGroup successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListResourceGroupOptions model
- listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
- listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListResourceGroupWithContext(ctx, listResourceGroupOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListResourceGroupWithContext(ctx, listResourceGroupOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listResourceGroupPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"account_id": "AccountID", "crn": "Crn", "default": false, "name": "Name", "resource_group_id": "ResourceGroupID", "state": "State"}]`)
- }))
- })
- It(`Invoke ListResourceGroup successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListResourceGroup(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListResourceGroupOptions model
- listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
- listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListResourceGroup with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListResourceGroupOptions model
- listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
- listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListResourceGroup successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListResourceGroupOptions model
- listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
- listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetSchematicsVersion(getSchematicsVersionOptions *GetSchematicsVersionOptions) - Operation response error`, func() {
- getSchematicsVersionPath := "/v1/version"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getSchematicsVersionPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetSchematicsVersion with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetSchematicsVersionOptions model
- getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
- getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetSchematicsVersion(getSchematicsVersionOptions *GetSchematicsVersionOptions)`, func() {
- getSchematicsVersionPath := "/v1/version"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getSchematicsVersionPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"builddate": "Builddate", "buildno": "Buildno", "commitsha": "Commitsha", "helm_provider_version": "HelmProviderVersion", "helm_version": "HelmVersion", "supported_template_types": {"anyKey": "anyValue"}, "terraform_provider_version": "TerraformProviderVersion", "terraform_version": "TerraformVersion"}`)
- }))
- })
- It(`Invoke GetSchematicsVersion successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetSchematicsVersionOptions model
- getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
- getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetSchematicsVersionWithContext(ctx, getSchematicsVersionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetSchematicsVersionWithContext(ctx, getSchematicsVersionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getSchematicsVersionPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"builddate": "Builddate", "buildno": "Buildno", "commitsha": "Commitsha", "helm_provider_version": "HelmProviderVersion", "helm_version": "HelmVersion", "supported_template_types": {"anyKey": "anyValue"}, "terraform_provider_version": "TerraformProviderVersion", "terraform_version": "TerraformVersion"}`)
- }))
- })
- It(`Invoke GetSchematicsVersion successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetSchematicsVersion(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetSchematicsVersionOptions model
- getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
- getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetSchematicsVersion with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetSchematicsVersionOptions model
- getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
- getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetSchematicsVersion successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetSchematicsVersionOptions model
- getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
- getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListLocations(listLocationsOptions *ListLocationsOptions) - Operation response error`, func() {
- listLocationsPath := "/v2/locations"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listLocationsPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListLocations with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListLocationsOptions model
- listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
- listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListLocations(listLocationsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListLocations(listLocationsOptions *ListLocationsOptions)`, func() {
- listLocationsPath := "/v2/locations"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listLocationsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"locations": [{"region": "Region", "metro": "Metro", "geography_code": "GeographyCode", "geography": "Geography", "country": "Country", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]}`)
- }))
- })
- It(`Invoke ListLocations successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListLocationsOptions model
- listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
- listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListLocationsWithContext(ctx, listLocationsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListLocationsWithContext(ctx, listLocationsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listLocationsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"locations": [{"region": "Region", "metro": "Metro", "geography_code": "GeographyCode", "geography": "Geography", "country": "Country", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]}`)
- }))
- })
- It(`Invoke ListLocations successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListLocations(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListLocationsOptions model
- listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
- listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListLocations(listLocationsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListLocations with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListLocationsOptions model
- listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
- listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListLocations successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListLocationsOptions model
- listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
- listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListWorkspaces(listWorkspacesOptions *ListWorkspacesOptions) - Operation response error`, func() {
- listWorkspacesPath := "/v1/workspaces"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listWorkspacesPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListWorkspaces with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListWorkspacesOptions model
- listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
- listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListWorkspaces(listWorkspacesOptions *ListWorkspacesOptions)`, func() {
- listWorkspacesPath := "/v1/workspaces"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listWorkspacesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"count": 5, "limit": 5, "offset": 6, "workspaces": [{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}]}`)
- }))
- })
- It(`Invoke ListWorkspaces successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListWorkspacesOptions model
- listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
- listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListWorkspacesWithContext(ctx, listWorkspacesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListWorkspacesWithContext(ctx, listWorkspacesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listWorkspacesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"count": 5, "limit": 5, "offset": 6, "workspaces": [{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}]}`)
- }))
- })
- It(`Invoke ListWorkspaces successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListWorkspaces(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListWorkspacesOptions model
- listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
- listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListWorkspaces with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListWorkspacesOptions model
- listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
- listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListWorkspaces successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListWorkspacesOptions model
- listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
- listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateWorkspace(createWorkspaceOptions *CreateWorkspaceOptions) - Operation response error`, func() {
- createWorkspacePath := "/v1/workspaces"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createWorkspacePath))
- Expect(req.Method).To(Equal("POST"))
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(201)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke CreateWorkspace with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoRequest model
- templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
- templateRepoRequestModel.Branch = core.StringPtr("testString")
- templateRepoRequestModel.Release = core.StringPtr("testString")
- templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusRequest model
- workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
- workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateWorkspaceOptions model
- createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
- createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
- createWorkspaceOptionsModel.CatalogRef = catalogRefModel
- createWorkspaceOptionsModel.Description = core.StringPtr("testString")
- createWorkspaceOptionsModel.Location = core.StringPtr("testString")
- createWorkspaceOptionsModel.Name = core.StringPtr("testString")
- createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
- createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- createWorkspaceOptionsModel.Tags = []string{"testString"}
- createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
- createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
- createWorkspaceOptionsModel.Type = []string{"testString"}
- createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
- createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
- createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateWorkspace(createWorkspaceOptions *CreateWorkspaceOptions)`, func() {
- createWorkspacePath := "/v1/workspaces"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createWorkspacePath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(201)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke CreateWorkspace successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoRequest model
- templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
- templateRepoRequestModel.Branch = core.StringPtr("testString")
- templateRepoRequestModel.Release = core.StringPtr("testString")
- templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusRequest model
- workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
- workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateWorkspaceOptions model
- createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
- createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
- createWorkspaceOptionsModel.CatalogRef = catalogRefModel
- createWorkspaceOptionsModel.Description = core.StringPtr("testString")
- createWorkspaceOptionsModel.Location = core.StringPtr("testString")
- createWorkspaceOptionsModel.Name = core.StringPtr("testString")
- createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
- createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- createWorkspaceOptionsModel.Tags = []string{"testString"}
- createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
- createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
- createWorkspaceOptionsModel.Type = []string{"testString"}
- createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
- createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
- createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.CreateWorkspaceWithContext(ctx, createWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.CreateWorkspaceWithContext(ctx, createWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createWorkspacePath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(201)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke CreateWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.CreateWorkspace(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoRequest model
- templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
- templateRepoRequestModel.Branch = core.StringPtr("testString")
- templateRepoRequestModel.Release = core.StringPtr("testString")
- templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusRequest model
- workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
- workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateWorkspaceOptions model
- createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
- createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
- createWorkspaceOptionsModel.CatalogRef = catalogRefModel
- createWorkspaceOptionsModel.Description = core.StringPtr("testString")
- createWorkspaceOptionsModel.Location = core.StringPtr("testString")
- createWorkspaceOptionsModel.Name = core.StringPtr("testString")
- createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
- createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- createWorkspaceOptionsModel.Tags = []string{"testString"}
- createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
- createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
- createWorkspaceOptionsModel.Type = []string{"testString"}
- createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
- createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
- createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke CreateWorkspace with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoRequest model
- templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
- templateRepoRequestModel.Branch = core.StringPtr("testString")
- templateRepoRequestModel.Release = core.StringPtr("testString")
- templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusRequest model
- workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
- workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateWorkspaceOptions model
- createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
- createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
- createWorkspaceOptionsModel.CatalogRef = catalogRefModel
- createWorkspaceOptionsModel.Description = core.StringPtr("testString")
- createWorkspaceOptionsModel.Location = core.StringPtr("testString")
- createWorkspaceOptionsModel.Name = core.StringPtr("testString")
- createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
- createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- createWorkspaceOptionsModel.Tags = []string{"testString"}
- createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
- createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
- createWorkspaceOptionsModel.Type = []string{"testString"}
- createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
- createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
- createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(201)
- }))
- })
- It(`Invoke CreateWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoRequest model
- templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
- templateRepoRequestModel.Branch = core.StringPtr("testString")
- templateRepoRequestModel.Release = core.StringPtr("testString")
- templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusRequest model
- workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
- workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateWorkspaceOptions model
- createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
- createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
- createWorkspaceOptionsModel.CatalogRef = catalogRefModel
- createWorkspaceOptionsModel.Description = core.StringPtr("testString")
- createWorkspaceOptionsModel.Location = core.StringPtr("testString")
- createWorkspaceOptionsModel.Name = core.StringPtr("testString")
- createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
- createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- createWorkspaceOptionsModel.Tags = []string{"testString"}
- createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
- createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
- createWorkspaceOptionsModel.Type = []string{"testString"}
- createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
- createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
- createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspace(getWorkspaceOptions *GetWorkspaceOptions) - Operation response error`, func() {
- getWorkspacePath := "/v1/workspaces/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspacePath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspace with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceOptions model
- getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
- getWorkspaceOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspace(getWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspace(getWorkspaceOptions *GetWorkspaceOptions)`, func() {
- getWorkspacePath := "/v1/workspaces/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspacePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke GetWorkspace successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceOptions model
- getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
- getWorkspaceOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceWithContext(ctx, getWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceWithContext(ctx, getWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspacePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke GetWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspace(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceOptions model
- getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
- getWorkspaceOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspace(getWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspace with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceOptions model
- getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
- getWorkspaceOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceOptions model with no property values
- getWorkspaceOptionsModelNew := new(schematicsv1.GetWorkspaceOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspace(getWorkspaceOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceOptions model
- getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
- getWorkspaceOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceWorkspace(replaceWorkspaceOptions *ReplaceWorkspaceOptions) - Operation response error`, func() {
- replaceWorkspacePath := "/v1/workspaces/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspacePath))
- Expect(req.Method).To(Equal("PUT"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ReplaceWorkspace with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceOptions model
- replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
- replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
- replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- replaceWorkspaceOptionsModel.Tags = []string{"testString"}
- replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- replaceWorkspaceOptionsModel.Type = []string{"testString"}
- replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceWorkspace(replaceWorkspaceOptions *ReplaceWorkspaceOptions)`, func() {
- replaceWorkspacePath := "/v1/workspaces/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspacePath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke ReplaceWorkspace successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceOptions model
- replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
- replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
- replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- replaceWorkspaceOptionsModel.Tags = []string{"testString"}
- replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- replaceWorkspaceOptionsModel.Type = []string{"testString"}
- replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ReplaceWorkspaceWithContext(ctx, replaceWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ReplaceWorkspaceWithContext(ctx, replaceWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspacePath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke ReplaceWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ReplaceWorkspace(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceOptions model
- replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
- replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
- replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- replaceWorkspaceOptionsModel.Tags = []string{"testString"}
- replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- replaceWorkspaceOptionsModel.Type = []string{"testString"}
- replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ReplaceWorkspace with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceOptions model
- replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
- replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
- replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- replaceWorkspaceOptionsModel.Tags = []string{"testString"}
- replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- replaceWorkspaceOptionsModel.Type = []string{"testString"}
- replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ReplaceWorkspaceOptions model with no property values
- replaceWorkspaceOptionsModelNew := new(schematicsv1.ReplaceWorkspaceOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ReplaceWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceOptions model
- replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
- replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
- replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
- replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- replaceWorkspaceOptionsModel.Tags = []string{"testString"}
- replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- replaceWorkspaceOptionsModel.Type = []string{"testString"}
- replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DeleteWorkspace(deleteWorkspaceOptions *DeleteWorkspaceOptions)`, func() {
- deleteWorkspacePath := "/v1/workspaces/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspacePath))
- Expect(req.Method).To(Equal("DELETE"))
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // TODO: Add check for destroy_resources query parameter
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `"OperationResponse"`)
- }))
- })
- It(`Invoke DeleteWorkspace successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the DeleteWorkspaceOptions model
- deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
- deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
- deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.DeleteWorkspaceWithContext(ctx, deleteWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.DeleteWorkspaceWithContext(ctx, deleteWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspacePath))
- Expect(req.Method).To(Equal("DELETE"))
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // TODO: Add check for destroy_resources query parameter
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `"OperationResponse"`)
- }))
- })
- It(`Invoke DeleteWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.DeleteWorkspace(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the DeleteWorkspaceOptions model
- deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
- deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
- deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke DeleteWorkspace with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteWorkspaceOptions model
- deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
- deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
- deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the DeleteWorkspaceOptions model with no property values
- deleteWorkspaceOptionsModelNew := new(schematicsv1.DeleteWorkspaceOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke DeleteWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteWorkspaceOptions model
- deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
- deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
- deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
- deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UpdateWorkspace(updateWorkspaceOptions *UpdateWorkspaceOptions) - Operation response error`, func() {
- updateWorkspacePath := "/v1/workspaces/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateWorkspacePath))
- Expect(req.Method).To(Equal("PATCH"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke UpdateWorkspace with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the UpdateWorkspaceOptions model
- updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
- updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
- updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
- updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
- updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
- updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- updateWorkspaceOptionsModel.Tags = []string{"testString"}
- updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- updateWorkspaceOptionsModel.Type = []string{"testString"}
- updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UpdateWorkspace(updateWorkspaceOptions *UpdateWorkspaceOptions)`, func() {
- updateWorkspacePath := "/v1/workspaces/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateWorkspacePath))
- Expect(req.Method).To(Equal("PATCH"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke UpdateWorkspace successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the UpdateWorkspaceOptions model
- updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
- updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
- updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
- updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
- updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
- updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- updateWorkspaceOptionsModel.Tags = []string{"testString"}
- updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- updateWorkspaceOptionsModel.Type = []string{"testString"}
- updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.UpdateWorkspaceWithContext(ctx, updateWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.UpdateWorkspaceWithContext(ctx, updateWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateWorkspacePath))
- Expect(req.Method).To(Equal("PATCH"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
- }))
- })
- It(`Invoke UpdateWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.UpdateWorkspace(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the UpdateWorkspaceOptions model
- updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
- updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
- updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
- updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
- updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
- updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- updateWorkspaceOptionsModel.Tags = []string{"testString"}
- updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- updateWorkspaceOptionsModel.Type = []string{"testString"}
- updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke UpdateWorkspace with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the UpdateWorkspaceOptions model
- updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
- updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
- updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
- updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
- updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
- updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- updateWorkspaceOptionsModel.Tags = []string{"testString"}
- updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- updateWorkspaceOptionsModel.Type = []string{"testString"}
- updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the UpdateWorkspaceOptions model with no property values
- updateWorkspaceOptionsModelNew := new(schematicsv1.UpdateWorkspaceOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.UpdateWorkspace(updateWorkspaceOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke UpdateWorkspace successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
-
- // Construct an instance of the UpdateWorkspaceOptions model
- updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
- updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
- updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
- updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
- updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
- updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
- updateWorkspaceOptionsModel.Tags = []string{"testString"}
- updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
- updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
- updateWorkspaceOptionsModel.Type = []string{"testString"}
- updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
- updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
- updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceReadme(getWorkspaceReadmeOptions *GetWorkspaceReadmeOptions) - Operation response error`, func() {
- getWorkspaceReadmePath := "/v1/workspaces/testString/templates/readme"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceReadmePath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["ref"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["formatted"]).To(Equal([]string{"markdown"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceReadme with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceReadmeOptions model
- getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
- getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
- getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceReadme(getWorkspaceReadmeOptions *GetWorkspaceReadmeOptions)`, func() {
- getWorkspaceReadmePath := "/v1/workspaces/testString/templates/readme"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceReadmePath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["ref"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["formatted"]).To(Equal([]string{"markdown"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"readme": "Readme"}`)
- }))
- })
- It(`Invoke GetWorkspaceReadme successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceReadmeOptions model
- getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
- getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
- getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceReadmeWithContext(ctx, getWorkspaceReadmeOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceReadmeWithContext(ctx, getWorkspaceReadmeOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceReadmePath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["ref"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["formatted"]).To(Equal([]string{"markdown"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"readme": "Readme"}`)
- }))
- })
- It(`Invoke GetWorkspaceReadme successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceReadme(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceReadmeOptions model
- getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
- getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
- getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceReadme with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceReadmeOptions model
- getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
- getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
- getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceReadmeOptions model with no property values
- getWorkspaceReadmeOptionsModelNew := new(schematicsv1.GetWorkspaceReadmeOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceReadme successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceReadmeOptions model
- getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
- getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
- getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
- getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`TemplateRepoUpload(templateRepoUploadOptions *TemplateRepoUploadOptions) - Operation response error`, func() {
- templateRepoUploadPath := "/v1/workspaces/testString/template_data/testString/template_repo_upload"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(templateRepoUploadPath))
- Expect(req.Method).To(Equal("PUT"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke TemplateRepoUpload with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the TemplateRepoUploadOptions model
- templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
- templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
- templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
- templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`TemplateRepoUpload(templateRepoUploadOptions *TemplateRepoUploadOptions)`, func() {
- templateRepoUploadPath := "/v1/workspaces/testString/template_data/testString/template_repo_upload"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(templateRepoUploadPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
- }))
- })
- It(`Invoke TemplateRepoUpload successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the TemplateRepoUploadOptions model
- templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
- templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
- templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
- templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.TemplateRepoUploadWithContext(ctx, templateRepoUploadOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.TemplateRepoUploadWithContext(ctx, templateRepoUploadOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(templateRepoUploadPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
- }))
- })
- It(`Invoke TemplateRepoUpload successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.TemplateRepoUpload(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the TemplateRepoUploadOptions model
- templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
- templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
- templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
- templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke TemplateRepoUpload with error: Param validation error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the TemplateRepoUploadOptions model
- templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
- // Invoke operation with invalid options model (negative test)
- result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- It(`Invoke TemplateRepoUpload with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the TemplateRepoUploadOptions model
- templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
- templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
- templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
- templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the TemplateRepoUploadOptions model with no property values
- templateRepoUploadOptionsModelNew := new(schematicsv1.TemplateRepoUploadOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke TemplateRepoUpload successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the TemplateRepoUploadOptions model
- templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
- templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
- templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
- templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
- templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceInputs(getWorkspaceInputsOptions *GetWorkspaceInputsOptions) - Operation response error`, func() {
- getWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputsPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceInputs with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceInputsOptions model
- getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
- getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceInputs(getWorkspaceInputsOptions *GetWorkspaceInputsOptions)`, func() {
- getWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"values_metadata": [{"anyKey": "anyValue"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceInputs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceInputsOptions model
- getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
- getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceInputsWithContext(ctx, getWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceInputsWithContext(ctx, getWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"values_metadata": [{"anyKey": "anyValue"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceInputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceInputs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceInputsOptions model
- getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
- getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceInputs with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceInputsOptions model
- getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
- getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceInputsOptions model with no property values
- getWorkspaceInputsOptionsModelNew := new(schematicsv1.GetWorkspaceInputsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceInputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceInputsOptions model
- getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
- getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions *ReplaceWorkspaceInputsOptions) - Operation response error`, func() {
- replaceWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspaceInputsPath))
- Expect(req.Method).To(Equal("PUT"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ReplaceWorkspaceInputs with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceInputsOptions model
- replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
- replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions *ReplaceWorkspaceInputsOptions)`, func() {
- replaceWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspaceInputsPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"env_values": [{"anyKey": "anyValue"}], "values": "Values", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}`)
- }))
- })
- It(`Invoke ReplaceWorkspaceInputs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceInputsOptions model
- replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
- replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ReplaceWorkspaceInputsWithContext(ctx, replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ReplaceWorkspaceInputsWithContext(ctx, replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspaceInputsPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"env_values": [{"anyKey": "anyValue"}], "values": "Values", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}`)
- }))
- })
- It(`Invoke ReplaceWorkspaceInputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceInputsOptions model
- replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
- replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ReplaceWorkspaceInputs with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceInputsOptions model
- replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
- replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ReplaceWorkspaceInputsOptions model with no property values
- replaceWorkspaceInputsOptionsModelNew := new(schematicsv1.ReplaceWorkspaceInputsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ReplaceWorkspaceInputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceWorkspaceInputsOptions model
- replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
- replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
- replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetAllWorkspaceInputs(getAllWorkspaceInputsOptions *GetAllWorkspaceInputsOptions) - Operation response error`, func() {
- getAllWorkspaceInputsPath := "/v1/workspaces/testString/templates/values"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getAllWorkspaceInputsPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetAllWorkspaceInputs with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetAllWorkspaceInputsOptions model
- getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
- getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetAllWorkspaceInputs(getAllWorkspaceInputsOptions *GetAllWorkspaceInputsOptions)`, func() {
- getAllWorkspaceInputsPath := "/v1/workspaces/testString/templates/values"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getAllWorkspaceInputsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_created_on": "ClusterCreatedOn", "cluster_id": "ClusterID", "cluster_name": "ClusterName", "cluster_type": "ClusterType", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID", "worker_count": 11, "worker_machine_type": "WorkerMachineType"}, "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}]}`)
- }))
- })
- It(`Invoke GetAllWorkspaceInputs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetAllWorkspaceInputsOptions model
- getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
- getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetAllWorkspaceInputsWithContext(ctx, getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetAllWorkspaceInputsWithContext(ctx, getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getAllWorkspaceInputsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_created_on": "ClusterCreatedOn", "cluster_id": "ClusterID", "cluster_name": "ClusterName", "cluster_type": "ClusterType", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID", "worker_count": 11, "worker_machine_type": "WorkerMachineType"}, "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}]}`)
- }))
- })
- It(`Invoke GetAllWorkspaceInputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetAllWorkspaceInputs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetAllWorkspaceInputsOptions model
- getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
- getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetAllWorkspaceInputs with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetAllWorkspaceInputsOptions model
- getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
- getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetAllWorkspaceInputsOptions model with no property values
- getAllWorkspaceInputsOptionsModelNew := new(schematicsv1.GetAllWorkspaceInputsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetAllWorkspaceInputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetAllWorkspaceInputsOptions model
- getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
- getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
- getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptions *GetWorkspaceInputMetadataOptions)`, func() {
- getWorkspaceInputMetadataPath := "/v1/workspaces/testString/template_data/testString/values_metadata"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputMetadataPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
- }))
- })
- It(`Invoke GetWorkspaceInputMetadata successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceInputMetadataOptions model
- getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
- getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceInputMetadataWithContext(ctx, getWorkspaceInputMetadataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceInputMetadataWithContext(ctx, getWorkspaceInputMetadataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputMetadataPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
- }))
- })
- It(`Invoke GetWorkspaceInputMetadata successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceInputMetadataOptions model
- getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
- getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceInputMetadata with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceInputMetadataOptions model
- getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
- getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceInputMetadataOptions model with no property values
- getWorkspaceInputMetadataOptionsModelNew := new(schematicsv1.GetWorkspaceInputMetadataOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceInputMetadata successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceInputMetadataOptions model
- getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
- getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceOutputs(getWorkspaceOutputsOptions *GetWorkspaceOutputsOptions) - Operation response error`, func() {
- getWorkspaceOutputsPath := "/v1/workspaces/testString/output_values"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceOutputsPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceOutputs with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceOutputsOptions model
- getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
- getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceOutputs(getWorkspaceOutputsOptions *GetWorkspaceOutputsOptions)`, func() {
- getWorkspaceOutputsPath := "/v1/workspaces/testString/output_values"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceOutputsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "output_values": [{"anyKey": "anyValue"}], "value_type": "ValueType"}]`)
- }))
- })
- It(`Invoke GetWorkspaceOutputs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceOutputsOptions model
- getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
- getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceOutputsWithContext(ctx, getWorkspaceOutputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceOutputsWithContext(ctx, getWorkspaceOutputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceOutputsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "output_values": [{"anyKey": "anyValue"}], "value_type": "ValueType"}]`)
- }))
- })
- It(`Invoke GetWorkspaceOutputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceOutputs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceOutputsOptions model
- getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
- getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceOutputs with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceOutputsOptions model
- getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
- getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceOutputsOptions model with no property values
- getWorkspaceOutputsOptionsModelNew := new(schematicsv1.GetWorkspaceOutputsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceOutputs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceOutputsOptions model
- getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
- getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceResources(getWorkspaceResourcesOptions *GetWorkspaceResourcesOptions) - Operation response error`, func() {
- getWorkspaceResourcesPath := "/v1/workspaces/testString/resources"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceResourcesPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceResources with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceResourcesOptions model
- getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
- getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceResources(getWorkspaceResourcesOptions *GetWorkspaceResourcesOptions)`, func() {
- getWorkspaceResourcesPath := "/v1/workspaces/testString/resources"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceResourcesPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "null_resources": [{"anyKey": "anyValue"}], "related_resources": [{"anyKey": "anyValue"}], "resources": [{"anyKey": "anyValue"}], "resources_count": 14, "template_type": "TemplateType"}]`)
- }))
- })
- It(`Invoke GetWorkspaceResources successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceResourcesOptions model
- getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
- getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceResourcesWithContext(ctx, getWorkspaceResourcesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceResourcesWithContext(ctx, getWorkspaceResourcesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceResourcesPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "null_resources": [{"anyKey": "anyValue"}], "related_resources": [{"anyKey": "anyValue"}], "resources": [{"anyKey": "anyValue"}], "resources_count": 14, "template_type": "TemplateType"}]`)
- }))
- })
- It(`Invoke GetWorkspaceResources successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceResources(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceResourcesOptions model
- getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
- getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceResources with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceResourcesOptions model
- getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
- getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceResourcesOptions model with no property values
- getWorkspaceResourcesOptionsModelNew := new(schematicsv1.GetWorkspaceResourcesOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceResources successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceResourcesOptions model
- getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
- getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceState(getWorkspaceStateOptions *GetWorkspaceStateOptions) - Operation response error`, func() {
- getWorkspaceStatePath := "/v1/workspaces/testString/state_stores"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceStatePath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceState with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceStateOptions model
- getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
- getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceState(getWorkspaceStateOptions *GetWorkspaceStateOptions)`, func() {
- getWorkspaceStatePath := "/v1/workspaces/testString/state_stores"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceStatePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "state_store_url": "StateStoreURL"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceState successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceStateOptions model
- getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
- getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceStateWithContext(ctx, getWorkspaceStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceStateWithContext(ctx, getWorkspaceStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceStatePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "state_store_url": "StateStoreURL"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceState successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceState(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceStateOptions model
- getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
- getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceState with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceStateOptions model
- getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
- getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceStateOptions model with no property values
- getWorkspaceStateOptionsModelNew := new(schematicsv1.GetWorkspaceStateOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceState successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceStateOptions model
- getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
- getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceTemplateState(getWorkspaceTemplateStateOptions *GetWorkspaceTemplateStateOptions)`, func() {
- getWorkspaceTemplateStatePath := "/v1/workspaces/testString/runtime_data/testString/state_store"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceTemplateStatePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
- }))
- })
- It(`Invoke GetWorkspaceTemplateState successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceTemplateStateOptions model
- getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
- getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceTemplateStateWithContext(ctx, getWorkspaceTemplateStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceTemplateStateWithContext(ctx, getWorkspaceTemplateStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceTemplateStatePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
- }))
- })
- It(`Invoke GetWorkspaceTemplateState successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceTemplateState(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceTemplateStateOptions model
- getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
- getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceTemplateState with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceTemplateStateOptions model
- getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
- getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceTemplateStateOptions model with no property values
- getWorkspaceTemplateStateOptionsModelNew := new(schematicsv1.GetWorkspaceTemplateStateOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceTemplateState successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceTemplateStateOptions model
- getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
- getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
- getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptions *GetWorkspaceActivityLogsOptions) - Operation response error`, func() {
- getWorkspaceActivityLogsPath := "/v1/workspaces/testString/actions/testString/logs"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityLogsPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceActivityLogs with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityLogsOptions model
- getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
- getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptions *GetWorkspaceActivityLogsOptions)`, func() {
- getWorkspaceActivityLogsPath := "/v1/workspaces/testString/actions/testString/logs"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityLogsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "name": "Name", "templates": [{"log_url": "LogURL", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceActivityLogs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceActivityLogsOptions model
- getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
- getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceActivityLogsWithContext(ctx, getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceActivityLogsWithContext(ctx, getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityLogsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "name": "Name", "templates": [{"log_url": "LogURL", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceActivityLogs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityLogsOptions model
- getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
- getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceActivityLogs with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityLogsOptions model
- getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
- getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceActivityLogsOptions model with no property values
- getWorkspaceActivityLogsOptionsModelNew := new(schematicsv1.GetWorkspaceActivityLogsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceActivityLogs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityLogsOptions model
- getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
- getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceLogUrls(getWorkspaceLogUrlsOptions *GetWorkspaceLogUrlsOptions) - Operation response error`, func() {
- getWorkspaceLogUrlsPath := "/v1/workspaces/testString/log_stores"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceLogUrlsPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceLogUrls with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceLogUrlsOptions model
- getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
- getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceLogUrls(getWorkspaceLogUrlsOptions *GetWorkspaceLogUrlsOptions)`, func() {
- getWorkspaceLogUrlsPath := "/v1/workspaces/testString/log_stores"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceLogUrlsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceLogUrls successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceLogUrlsOptions model
- getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
- getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceLogUrlsWithContext(ctx, getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceLogUrlsWithContext(ctx, getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceLogUrlsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceLogUrls successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceLogUrls(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceLogUrlsOptions model
- getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
- getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceLogUrls with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceLogUrlsOptions model
- getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
- getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceLogUrlsOptions model with no property values
- getWorkspaceLogUrlsOptionsModelNew := new(schematicsv1.GetWorkspaceLogUrlsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceLogUrls successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceLogUrlsOptions model
- getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
- getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetTemplateLogs(getTemplateLogsOptions *GetTemplateLogsOptions)`, func() {
- getTemplateLogsPath := "/v1/workspaces/testString/runtime_data/testString/log_store"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getTemplateLogsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // TODO: Add check for log_tf_cmd query parameter
- // TODO: Add check for log_tf_prefix query parameter
- // TODO: Add check for log_tf_null_resource query parameter
- // TODO: Add check for log_tf_ansible query parameter
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `"OperationResponse"`)
- }))
- })
- It(`Invoke GetTemplateLogs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetTemplateLogsOptions model
- getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
- getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetTemplateLogsWithContext(ctx, getTemplateLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetTemplateLogsWithContext(ctx, getTemplateLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getTemplateLogsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // TODO: Add check for log_tf_cmd query parameter
- // TODO: Add check for log_tf_prefix query parameter
- // TODO: Add check for log_tf_null_resource query parameter
- // TODO: Add check for log_tf_ansible query parameter
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `"OperationResponse"`)
- }))
- })
- It(`Invoke GetTemplateLogs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetTemplateLogs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetTemplateLogsOptions model
- getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
- getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetTemplateLogs with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetTemplateLogsOptions model
- getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
- getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetTemplateLogsOptions model with no property values
- getTemplateLogsOptionsModelNew := new(schematicsv1.GetTemplateLogsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetTemplateLogs(getTemplateLogsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetTemplateLogs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetTemplateLogsOptions model
- getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
- getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
- getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetTemplateActivityLog(getTemplateActivityLogOptions *GetTemplateActivityLogOptions)`, func() {
- getTemplateActivityLogPath := "/v1/workspaces/testString/runtime_data/testString/log_store/actions/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getTemplateActivityLogPath))
- Expect(req.Method).To(Equal("GET"))
-
- // TODO: Add check for log_tf_cmd query parameter
- // TODO: Add check for log_tf_prefix query parameter
- // TODO: Add check for log_tf_null_resource query parameter
- // TODO: Add check for log_tf_ansible query parameter
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `"OperationResponse"`)
- }))
- })
- It(`Invoke GetTemplateActivityLog successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetTemplateActivityLogOptions model
- getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
- getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetTemplateActivityLogWithContext(ctx, getTemplateActivityLogOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetTemplateActivityLogWithContext(ctx, getTemplateActivityLogOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getTemplateActivityLogPath))
- Expect(req.Method).To(Equal("GET"))
-
- // TODO: Add check for log_tf_cmd query parameter
- // TODO: Add check for log_tf_prefix query parameter
- // TODO: Add check for log_tf_null_resource query parameter
- // TODO: Add check for log_tf_ansible query parameter
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `"OperationResponse"`)
- }))
- })
- It(`Invoke GetTemplateActivityLog successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetTemplateActivityLog(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetTemplateActivityLogOptions model
- getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
- getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetTemplateActivityLog with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetTemplateActivityLogOptions model
- getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
- getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetTemplateActivityLogOptions model with no property values
- getTemplateActivityLogOptionsModelNew := new(schematicsv1.GetTemplateActivityLogOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetTemplateActivityLog successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetTemplateActivityLogOptions model
- getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
- getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
- getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
- getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListActions(listActionsOptions *ListActionsOptions) - Operation response error`, func() {
- listActionsPath := "/v2/actions"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listActionsPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListActions with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListActionsOptions model
- listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
- listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listActionsOptionsModel.Sort = core.StringPtr("testString")
- listActionsOptionsModel.Profile = core.StringPtr("ids")
- listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListActions(listActionsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListActions(listActionsOptions *ListActionsOptions)`, func() {
- listActionsPath := "/v2/actions"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listActionsPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "actions": [{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "id": "ID", "crn": "Crn", "location": "us-south", "resource_group": "ResourceGroup", "namespace": "Namespace", "tags": ["Tags"], "playbook_name": "PlaybookName", "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "state": {"status_code": "normal", "status_message": "StatusMessage"}, "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy"}]}`)
- }))
- })
- It(`Invoke ListActions successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListActionsOptions model
- listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
- listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listActionsOptionsModel.Sort = core.StringPtr("testString")
- listActionsOptionsModel.Profile = core.StringPtr("ids")
- listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListActionsWithContext(ctx, listActionsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListActionsWithContext(ctx, listActionsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listActionsPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "actions": [{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "id": "ID", "crn": "Crn", "location": "us-south", "resource_group": "ResourceGroup", "namespace": "Namespace", "tags": ["Tags"], "playbook_name": "PlaybookName", "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "state": {"status_code": "normal", "status_message": "StatusMessage"}, "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy"}]}`)
- }))
- })
- It(`Invoke ListActions successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListActions(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListActionsOptions model
- listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
- listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listActionsOptionsModel.Sort = core.StringPtr("testString")
- listActionsOptionsModel.Profile = core.StringPtr("ids")
- listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListActions(listActionsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListActions with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListActionsOptions model
- listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
- listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listActionsOptionsModel.Sort = core.StringPtr("testString")
- listActionsOptionsModel.Profile = core.StringPtr("ids")
- listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListActions successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListActionsOptions model
- listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
- listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listActionsOptionsModel.Sort = core.StringPtr("testString")
- listActionsOptionsModel.Profile = core.StringPtr("ids")
- listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateAction(createActionOptions *CreateActionOptions) - Operation response error`, func() {
- createActionPath := "/v2/actions"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createActionPath))
- Expect(req.Method).To(Equal("POST"))
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(201)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke CreateAction with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateActionOptions model
- createActionOptionsModel := new(schematicsv1.CreateActionOptions)
- createActionOptionsModel.Name = core.StringPtr("Stop Action")
- createActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- createActionOptionsModel.Location = core.StringPtr("us-south")
- createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- createActionOptionsModel.Tags = []string{"testString"}
- createActionOptionsModel.UserState = userStateModel
- createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- createActionOptionsModel.Source = externalSourceModel
- createActionOptionsModel.SourceType = core.StringPtr("local")
- createActionOptionsModel.CommandParameter = core.StringPtr("testString")
- createActionOptionsModel.Bastion = bastionResourceDefinitionModel
- createActionOptionsModel.Inventory = core.StringPtr("testString")
- createActionOptionsModel.BastionCredential = variableDataModel
- createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.State = actionStateModel
- createActionOptionsModel.SysLock = systemLockModel
- createActionOptionsModel.XGithubToken = core.StringPtr("testString")
- createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.CreateAction(createActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateAction(createActionOptions *CreateActionOptions)`, func() {
- createActionPath := "/v2/actions"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createActionPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(201)
- fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "bastion": {"name": "Name", "host": "Host"}, "inventory": "Inventory", "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke CreateAction successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateActionOptions model
- createActionOptionsModel := new(schematicsv1.CreateActionOptions)
- createActionOptionsModel.Name = core.StringPtr("Stop Action")
- createActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- createActionOptionsModel.Location = core.StringPtr("us-south")
- createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- createActionOptionsModel.Tags = []string{"testString"}
- createActionOptionsModel.UserState = userStateModel
- createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- createActionOptionsModel.Source = externalSourceModel
- createActionOptionsModel.SourceType = core.StringPtr("local")
- createActionOptionsModel.CommandParameter = core.StringPtr("testString")
- createActionOptionsModel.Bastion = bastionResourceDefinitionModel
- createActionOptionsModel.Inventory = core.StringPtr("testString")
- createActionOptionsModel.BastionCredential = variableDataModel
- createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.State = actionStateModel
- createActionOptionsModel.SysLock = systemLockModel
- createActionOptionsModel.XGithubToken = core.StringPtr("testString")
- createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.CreateActionWithContext(ctx, createActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.CreateActionWithContext(ctx, createActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createActionPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(201)
- fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "bastion": {"name": "Name", "host": "Host"}, "inventory": "Inventory", "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke CreateAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.CreateAction(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateActionOptions model
- createActionOptionsModel := new(schematicsv1.CreateActionOptions)
- createActionOptionsModel.Name = core.StringPtr("Stop Action")
- createActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- createActionOptionsModel.Location = core.StringPtr("us-south")
- createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- createActionOptionsModel.Tags = []string{"testString"}
- createActionOptionsModel.UserState = userStateModel
- createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- createActionOptionsModel.Source = externalSourceModel
- createActionOptionsModel.SourceType = core.StringPtr("local")
- createActionOptionsModel.CommandParameter = core.StringPtr("testString")
- createActionOptionsModel.Bastion = bastionResourceDefinitionModel
- createActionOptionsModel.Inventory = core.StringPtr("testString")
- createActionOptionsModel.BastionCredential = variableDataModel
- createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.State = actionStateModel
- createActionOptionsModel.SysLock = systemLockModel
- createActionOptionsModel.XGithubToken = core.StringPtr("testString")
- createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.CreateAction(createActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke CreateAction with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateActionOptions model
- createActionOptionsModel := new(schematicsv1.CreateActionOptions)
- createActionOptionsModel.Name = core.StringPtr("Stop Action")
- createActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- createActionOptionsModel.Location = core.StringPtr("us-south")
- createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- createActionOptionsModel.Tags = []string{"testString"}
- createActionOptionsModel.UserState = userStateModel
- createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- createActionOptionsModel.Source = externalSourceModel
- createActionOptionsModel.SourceType = core.StringPtr("local")
- createActionOptionsModel.CommandParameter = core.StringPtr("testString")
- createActionOptionsModel.Bastion = bastionResourceDefinitionModel
- createActionOptionsModel.Inventory = core.StringPtr("testString")
- createActionOptionsModel.BastionCredential = variableDataModel
- createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.State = actionStateModel
- createActionOptionsModel.SysLock = systemLockModel
- createActionOptionsModel.XGithubToken = core.StringPtr("testString")
- createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(201)
- }))
- })
- It(`Invoke CreateAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the CreateActionOptions model
- createActionOptionsModel := new(schematicsv1.CreateActionOptions)
- createActionOptionsModel.Name = core.StringPtr("Stop Action")
- createActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- createActionOptionsModel.Location = core.StringPtr("us-south")
- createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- createActionOptionsModel.Tags = []string{"testString"}
- createActionOptionsModel.UserState = userStateModel
- createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- createActionOptionsModel.Source = externalSourceModel
- createActionOptionsModel.SourceType = core.StringPtr("local")
- createActionOptionsModel.CommandParameter = core.StringPtr("testString")
- createActionOptionsModel.Bastion = bastionResourceDefinitionModel
- createActionOptionsModel.Inventory = core.StringPtr("testString")
- createActionOptionsModel.BastionCredential = variableDataModel
- createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createActionOptionsModel.State = actionStateModel
- createActionOptionsModel.SysLock = systemLockModel
- createActionOptionsModel.XGithubToken = core.StringPtr("testString")
- createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetAction(getActionOptions *GetActionOptions) - Operation response error`, func() {
- getActionPath := "/v2/actions/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getActionPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetAction with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetActionOptions model
- getActionOptionsModel := new(schematicsv1.GetActionOptions)
- getActionOptionsModel.ActionID = core.StringPtr("testString")
- getActionOptionsModel.Profile = core.StringPtr("summary")
- getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetAction(getActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetAction(getActionOptions *GetActionOptions)`, func() {
- getActionPath := "/v2/actions/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getActionPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "bastion": {"name": "Name", "host": "Host"}, "inventory": "Inventory", "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke GetAction successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetActionOptions model
- getActionOptionsModel := new(schematicsv1.GetActionOptions)
- getActionOptionsModel.ActionID = core.StringPtr("testString")
- getActionOptionsModel.Profile = core.StringPtr("summary")
- getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetActionWithContext(ctx, getActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetActionWithContext(ctx, getActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getActionPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "bastion": {"name": "Name", "host": "Host"}, "inventory": "Inventory", "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke GetAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetAction(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetActionOptions model
- getActionOptionsModel := new(schematicsv1.GetActionOptions)
- getActionOptionsModel.ActionID = core.StringPtr("testString")
- getActionOptionsModel.Profile = core.StringPtr("summary")
- getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetAction(getActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetAction with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetActionOptions model
- getActionOptionsModel := new(schematicsv1.GetActionOptions)
- getActionOptionsModel.ActionID = core.StringPtr("testString")
- getActionOptionsModel.Profile = core.StringPtr("summary")
- getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetActionOptions model with no property values
- getActionOptionsModelNew := new(schematicsv1.GetActionOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetAction(getActionOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetActionOptions model
- getActionOptionsModel := new(schematicsv1.GetActionOptions)
- getActionOptionsModel.ActionID = core.StringPtr("testString")
- getActionOptionsModel.Profile = core.StringPtr("summary")
- getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DeleteAction(deleteActionOptions *DeleteActionOptions)`, func() {
- deleteActionPath := "/v2/actions/testString"
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteActionPath))
- Expect(req.Method).To(Equal("DELETE"))
-
- Expect(req.Header["Force"]).ToNot(BeNil())
- Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
- Expect(req.Header["Propagate"]).ToNot(BeNil())
- Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
- res.WriteHeader(204)
- }))
- })
- It(`Invoke DeleteAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- response, operationErr := schematicsService.DeleteAction(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
-
- // Construct an instance of the DeleteActionOptions model
- deleteActionOptionsModel := new(schematicsv1.DeleteActionOptions)
- deleteActionOptionsModel.ActionID = core.StringPtr("testString")
- deleteActionOptionsModel.Force = core.BoolPtr(true)
- deleteActionOptionsModel.Propagate = core.BoolPtr(true)
- deleteActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- response, operationErr = schematicsService.DeleteAction(deleteActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- })
- It(`Invoke DeleteAction with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteActionOptions model
- deleteActionOptionsModel := new(schematicsv1.DeleteActionOptions)
- deleteActionOptionsModel.ActionID = core.StringPtr("testString")
- deleteActionOptionsModel.Force = core.BoolPtr(true)
- deleteActionOptionsModel.Propagate = core.BoolPtr(true)
- deleteActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- response, operationErr := schematicsService.DeleteAction(deleteActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- // Construct a second instance of the DeleteActionOptions model with no property values
- deleteActionOptionsModelNew := new(schematicsv1.DeleteActionOptions)
- // Invoke operation with invalid model (negative test)
- response, operationErr = schematicsService.DeleteAction(deleteActionOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UpdateAction(updateActionOptions *UpdateActionOptions) - Operation response error`, func() {
- updateActionPath := "/v2/actions/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateActionPath))
- Expect(req.Method).To(Equal("PATCH"))
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke UpdateAction with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the UpdateActionOptions model
- updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
- updateActionOptionsModel.ActionID = core.StringPtr("testString")
- updateActionOptionsModel.Name = core.StringPtr("Stop Action")
- updateActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- updateActionOptionsModel.Location = core.StringPtr("us-south")
- updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateActionOptionsModel.Tags = []string{"testString"}
- updateActionOptionsModel.UserState = userStateModel
- updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- updateActionOptionsModel.Source = externalSourceModel
- updateActionOptionsModel.SourceType = core.StringPtr("local")
- updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
- updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
- updateActionOptionsModel.Inventory = core.StringPtr("testString")
- updateActionOptionsModel.BastionCredential = variableDataModel
- updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.State = actionStateModel
- updateActionOptionsModel.SysLock = systemLockModel
- updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
- updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.UpdateAction(updateActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UpdateAction(updateActionOptions *UpdateActionOptions)`, func() {
- updateActionPath := "/v2/actions/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateActionPath))
- Expect(req.Method).To(Equal("PATCH"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "bastion": {"name": "Name", "host": "Host"}, "inventory": "Inventory", "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke UpdateAction successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the UpdateActionOptions model
- updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
- updateActionOptionsModel.ActionID = core.StringPtr("testString")
- updateActionOptionsModel.Name = core.StringPtr("Stop Action")
- updateActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- updateActionOptionsModel.Location = core.StringPtr("us-south")
- updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateActionOptionsModel.Tags = []string{"testString"}
- updateActionOptionsModel.UserState = userStateModel
- updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- updateActionOptionsModel.Source = externalSourceModel
- updateActionOptionsModel.SourceType = core.StringPtr("local")
- updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
- updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
- updateActionOptionsModel.Inventory = core.StringPtr("testString")
- updateActionOptionsModel.BastionCredential = variableDataModel
- updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.State = actionStateModel
- updateActionOptionsModel.SysLock = systemLockModel
- updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
- updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.UpdateActionWithContext(ctx, updateActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.UpdateActionWithContext(ctx, updateActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateActionPath))
- Expect(req.Method).To(Equal("PATCH"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "bastion": {"name": "Name", "host": "Host"}, "inventory": "Inventory", "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke UpdateAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.UpdateAction(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the UpdateActionOptions model
- updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
- updateActionOptionsModel.ActionID = core.StringPtr("testString")
- updateActionOptionsModel.Name = core.StringPtr("Stop Action")
- updateActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- updateActionOptionsModel.Location = core.StringPtr("us-south")
- updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateActionOptionsModel.Tags = []string{"testString"}
- updateActionOptionsModel.UserState = userStateModel
- updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- updateActionOptionsModel.Source = externalSourceModel
- updateActionOptionsModel.SourceType = core.StringPtr("local")
- updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
- updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
- updateActionOptionsModel.Inventory = core.StringPtr("testString")
- updateActionOptionsModel.BastionCredential = variableDataModel
- updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.State = actionStateModel
- updateActionOptionsModel.SysLock = systemLockModel
- updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
- updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.UpdateAction(updateActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke UpdateAction with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the UpdateActionOptions model
- updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
- updateActionOptionsModel.ActionID = core.StringPtr("testString")
- updateActionOptionsModel.Name = core.StringPtr("Stop Action")
- updateActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- updateActionOptionsModel.Location = core.StringPtr("us-south")
- updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateActionOptionsModel.Tags = []string{"testString"}
- updateActionOptionsModel.UserState = userStateModel
- updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- updateActionOptionsModel.Source = externalSourceModel
- updateActionOptionsModel.SourceType = core.StringPtr("local")
- updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
- updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
- updateActionOptionsModel.Inventory = core.StringPtr("testString")
- updateActionOptionsModel.BastionCredential = variableDataModel
- updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.State = actionStateModel
- updateActionOptionsModel.SysLock = systemLockModel
- updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
- updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the UpdateActionOptions model with no property values
- updateActionOptionsModelNew := new(schematicsv1.UpdateActionOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.UpdateAction(updateActionOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke UpdateAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the UpdateActionOptions model
- updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
- updateActionOptionsModel.ActionID = core.StringPtr("testString")
- updateActionOptionsModel.Name = core.StringPtr("Stop Action")
- updateActionOptionsModel.Description = core.StringPtr("This Action can be used to Stop the targets")
- updateActionOptionsModel.Location = core.StringPtr("us-south")
- updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateActionOptionsModel.Tags = []string{"testString"}
- updateActionOptionsModel.UserState = userStateModel
- updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
- updateActionOptionsModel.Source = externalSourceModel
- updateActionOptionsModel.SourceType = core.StringPtr("local")
- updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
- updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
- updateActionOptionsModel.Inventory = core.StringPtr("testString")
- updateActionOptionsModel.BastionCredential = variableDataModel
- updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- updateActionOptionsModel.State = actionStateModel
- updateActionOptionsModel.SysLock = systemLockModel
- updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
- updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UploadTemplateTarAction(uploadTemplateTarActionOptions *UploadTemplateTarActionOptions) - Operation response error`, func() {
- uploadTemplateTarActionPath := "/v2/actions/testString/template_repo_upload"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(uploadTemplateTarActionPath))
- Expect(req.Method).To(Equal("PUT"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke UploadTemplateTarAction with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UploadTemplateTarActionOptions model
- uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
- uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
- uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UploadTemplateTarAction(uploadTemplateTarActionOptions *UploadTemplateTarActionOptions)`, func() {
- uploadTemplateTarActionPath := "/v2/actions/testString/template_repo_upload"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(uploadTemplateTarActionPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
- }))
- })
- It(`Invoke UploadTemplateTarAction successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the UploadTemplateTarActionOptions model
- uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
- uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
- uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.UploadTemplateTarActionWithContext(ctx, uploadTemplateTarActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.UploadTemplateTarActionWithContext(ctx, uploadTemplateTarActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(uploadTemplateTarActionPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
- }))
- })
- It(`Invoke UploadTemplateTarAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.UploadTemplateTarAction(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the UploadTemplateTarActionOptions model
- uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
- uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
- uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke UploadTemplateTarAction with error: Param validation error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UploadTemplateTarActionOptions model
- uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
- // Invoke operation with invalid options model (negative test)
- result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- It(`Invoke UploadTemplateTarAction with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UploadTemplateTarActionOptions model
- uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
- uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
- uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the UploadTemplateTarActionOptions model with no property values
- uploadTemplateTarActionOptionsModelNew := new(schematicsv1.UploadTemplateTarActionOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke UploadTemplateTarAction successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UploadTemplateTarActionOptions model
- uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
- uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
- uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
- uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListWorkspaceActivities(listWorkspaceActivitiesOptions *ListWorkspaceActivitiesOptions) - Operation response error`, func() {
- listWorkspaceActivitiesPath := "/v1/workspaces/testString/actions"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listWorkspaceActivitiesPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListWorkspaceActivities with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListWorkspaceActivitiesOptions model
- listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
- listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
- listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListWorkspaceActivities(listWorkspaceActivitiesOptions *ListWorkspaceActivitiesOptions)`, func() {
- listWorkspaceActivitiesPath := "/v1/workspaces/testString/actions"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listWorkspaceActivitiesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"actions": [{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}], "workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName"}`)
- }))
- })
- It(`Invoke ListWorkspaceActivities successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListWorkspaceActivitiesOptions model
- listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
- listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
- listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListWorkspaceActivitiesWithContext(ctx, listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListWorkspaceActivitiesWithContext(ctx, listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listWorkspaceActivitiesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"actions": [{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}], "workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName"}`)
- }))
- })
- It(`Invoke ListWorkspaceActivities successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListWorkspaceActivities(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListWorkspaceActivitiesOptions model
- listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
- listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
- listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListWorkspaceActivities with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListWorkspaceActivitiesOptions model
- listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
- listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
- listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ListWorkspaceActivitiesOptions model with no property values
- listWorkspaceActivitiesOptionsModelNew := new(schematicsv1.ListWorkspaceActivitiesOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListWorkspaceActivities successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListWorkspaceActivitiesOptions model
- listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
- listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
- listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceActivity(getWorkspaceActivityOptions *GetWorkspaceActivityOptions) - Operation response error`, func() {
- getWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceActivity with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityOptions model
- getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
- getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceActivity(getWorkspaceActivityOptions *GetWorkspaceActivityOptions)`, func() {
- getWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceActivity successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceActivityOptions model
- getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
- getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceActivityWithContext(ctx, getWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceActivityWithContext(ctx, getWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
- }))
- })
- It(`Invoke GetWorkspaceActivity successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceActivity(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityOptions model
- getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
- getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceActivity with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityOptions model
- getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
- getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceActivityOptions model with no property values
- getWorkspaceActivityOptionsModelNew := new(schematicsv1.GetWorkspaceActivityOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceActivity successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceActivityOptions model
- getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
- getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DeleteWorkspaceActivity(deleteWorkspaceActivityOptions *DeleteWorkspaceActivityOptions) - Operation response error`, func() {
- deleteWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspaceActivityPath))
- Expect(req.Method).To(Equal("DELETE"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke DeleteWorkspaceActivity with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteWorkspaceActivityOptions model
- deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
- deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DeleteWorkspaceActivity(deleteWorkspaceActivityOptions *DeleteWorkspaceActivityOptions)`, func() {
- deleteWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspaceActivityPath))
- Expect(req.Method).To(Equal("DELETE"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke DeleteWorkspaceActivity successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the DeleteWorkspaceActivityOptions model
- deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
- deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.DeleteWorkspaceActivityWithContext(ctx, deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.DeleteWorkspaceActivityWithContext(ctx, deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspaceActivityPath))
- Expect(req.Method).To(Equal("DELETE"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke DeleteWorkspaceActivity successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.DeleteWorkspaceActivity(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the DeleteWorkspaceActivityOptions model
- deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
- deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke DeleteWorkspaceActivity with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteWorkspaceActivityOptions model
- deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
- deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the DeleteWorkspaceActivityOptions model with no property values
- deleteWorkspaceActivityOptionsModelNew := new(schematicsv1.DeleteWorkspaceActivityOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke DeleteWorkspaceActivity successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteWorkspaceActivityOptions model
- deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
- deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
- deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`RunWorkspaceCommands(runWorkspaceCommandsOptions *RunWorkspaceCommandsOptions) - Operation response error`, func() {
- runWorkspaceCommandsPath := "/v1/workspaces/testString/commands"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(runWorkspaceCommandsPath))
- Expect(req.Method).To(Equal("PUT"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke RunWorkspaceCommands with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the TerraformCommand model
- terraformCommandModel := new(schematicsv1.TerraformCommand)
- terraformCommandModel.Command = core.StringPtr("testString")
- terraformCommandModel.CommandParams = core.StringPtr("testString")
- terraformCommandModel.CommandName = core.StringPtr("testString")
- terraformCommandModel.CommandDesc = core.StringPtr("testString")
- terraformCommandModel.CommandOnError = core.StringPtr("testString")
- terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
- terraformCommandModel.CommandStatus = core.StringPtr("testString")
-
- // Construct an instance of the RunWorkspaceCommandsOptions model
- runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
- runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
- runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`RunWorkspaceCommands(runWorkspaceCommandsOptions *RunWorkspaceCommandsOptions)`, func() {
- runWorkspaceCommandsPath := "/v1/workspaces/testString/commands"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(runWorkspaceCommandsPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke RunWorkspaceCommands successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the TerraformCommand model
- terraformCommandModel := new(schematicsv1.TerraformCommand)
- terraformCommandModel.Command = core.StringPtr("testString")
- terraformCommandModel.CommandParams = core.StringPtr("testString")
- terraformCommandModel.CommandName = core.StringPtr("testString")
- terraformCommandModel.CommandDesc = core.StringPtr("testString")
- terraformCommandModel.CommandOnError = core.StringPtr("testString")
- terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
- terraformCommandModel.CommandStatus = core.StringPtr("testString")
-
- // Construct an instance of the RunWorkspaceCommandsOptions model
- runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
- runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
- runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.RunWorkspaceCommandsWithContext(ctx, runWorkspaceCommandsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.RunWorkspaceCommandsWithContext(ctx, runWorkspaceCommandsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(runWorkspaceCommandsPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke RunWorkspaceCommands successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.RunWorkspaceCommands(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the TerraformCommand model
- terraformCommandModel := new(schematicsv1.TerraformCommand)
- terraformCommandModel.Command = core.StringPtr("testString")
- terraformCommandModel.CommandParams = core.StringPtr("testString")
- terraformCommandModel.CommandName = core.StringPtr("testString")
- terraformCommandModel.CommandDesc = core.StringPtr("testString")
- terraformCommandModel.CommandOnError = core.StringPtr("testString")
- terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
- terraformCommandModel.CommandStatus = core.StringPtr("testString")
-
- // Construct an instance of the RunWorkspaceCommandsOptions model
- runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
- runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
- runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke RunWorkspaceCommands with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the TerraformCommand model
- terraformCommandModel := new(schematicsv1.TerraformCommand)
- terraformCommandModel.Command = core.StringPtr("testString")
- terraformCommandModel.CommandParams = core.StringPtr("testString")
- terraformCommandModel.CommandName = core.StringPtr("testString")
- terraformCommandModel.CommandDesc = core.StringPtr("testString")
- terraformCommandModel.CommandOnError = core.StringPtr("testString")
- terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
- terraformCommandModel.CommandStatus = core.StringPtr("testString")
-
- // Construct an instance of the RunWorkspaceCommandsOptions model
- runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
- runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
- runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the RunWorkspaceCommandsOptions model with no property values
- runWorkspaceCommandsOptionsModelNew := new(schematicsv1.RunWorkspaceCommandsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke RunWorkspaceCommands successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the TerraformCommand model
- terraformCommandModel := new(schematicsv1.TerraformCommand)
- terraformCommandModel.Command = core.StringPtr("testString")
- terraformCommandModel.CommandParams = core.StringPtr("testString")
- terraformCommandModel.CommandName = core.StringPtr("testString")
- terraformCommandModel.CommandDesc = core.StringPtr("testString")
- terraformCommandModel.CommandOnError = core.StringPtr("testString")
- terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
- terraformCommandModel.CommandStatus = core.StringPtr("testString")
-
- // Construct an instance of the RunWorkspaceCommandsOptions model
- runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
- runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
- runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
- runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ApplyWorkspaceCommand(applyWorkspaceCommandOptions *ApplyWorkspaceCommandOptions) - Operation response error`, func() {
- applyWorkspaceCommandPath := "/v1/workspaces/testString/apply"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(applyWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ApplyWorkspaceCommand with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the ApplyWorkspaceCommandOptions model
- applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
- applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ApplyWorkspaceCommand(applyWorkspaceCommandOptions *ApplyWorkspaceCommandOptions)`, func() {
- applyWorkspaceCommandPath := "/v1/workspaces/testString/apply"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(applyWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke ApplyWorkspaceCommand successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the ApplyWorkspaceCommandOptions model
- applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
- applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ApplyWorkspaceCommandWithContext(ctx, applyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ApplyWorkspaceCommandWithContext(ctx, applyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(applyWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke ApplyWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ApplyWorkspaceCommand(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the ApplyWorkspaceCommandOptions model
- applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
- applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ApplyWorkspaceCommand with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the ApplyWorkspaceCommandOptions model
- applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
- applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ApplyWorkspaceCommandOptions model with no property values
- applyWorkspaceCommandOptionsModelNew := new(schematicsv1.ApplyWorkspaceCommandOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke ApplyWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the ApplyWorkspaceCommandOptions model
- applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
- applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DestroyWorkspaceCommand(destroyWorkspaceCommandOptions *DestroyWorkspaceCommandOptions) - Operation response error`, func() {
- destroyWorkspaceCommandPath := "/v1/workspaces/testString/destroy"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(destroyWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke DestroyWorkspaceCommand with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the DestroyWorkspaceCommandOptions model
- destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
- destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DestroyWorkspaceCommand(destroyWorkspaceCommandOptions *DestroyWorkspaceCommandOptions)`, func() {
- destroyWorkspaceCommandPath := "/v1/workspaces/testString/destroy"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(destroyWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke DestroyWorkspaceCommand successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the DestroyWorkspaceCommandOptions model
- destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
- destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.DestroyWorkspaceCommandWithContext(ctx, destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.DestroyWorkspaceCommandWithContext(ctx, destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(destroyWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke DestroyWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.DestroyWorkspaceCommand(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the DestroyWorkspaceCommandOptions model
- destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
- destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke DestroyWorkspaceCommand with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the DestroyWorkspaceCommandOptions model
- destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
- destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the DestroyWorkspaceCommandOptions model with no property values
- destroyWorkspaceCommandOptionsModelNew := new(schematicsv1.DestroyWorkspaceCommandOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke DestroyWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
-
- // Construct an instance of the DestroyWorkspaceCommandOptions model
- destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
- destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
- destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`PlanWorkspaceCommand(planWorkspaceCommandOptions *PlanWorkspaceCommandOptions) - Operation response error`, func() {
- planWorkspaceCommandPath := "/v1/workspaces/testString/plan"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(planWorkspaceCommandPath))
- Expect(req.Method).To(Equal("POST"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke PlanWorkspaceCommand with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the PlanWorkspaceCommandOptions model
- planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
- planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`PlanWorkspaceCommand(planWorkspaceCommandOptions *PlanWorkspaceCommandOptions)`, func() {
- planWorkspaceCommandPath := "/v1/workspaces/testString/plan"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(planWorkspaceCommandPath))
- Expect(req.Method).To(Equal("POST"))
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke PlanWorkspaceCommand successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the PlanWorkspaceCommandOptions model
- planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
- planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.PlanWorkspaceCommandWithContext(ctx, planWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.PlanWorkspaceCommandWithContext(ctx, planWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(planWorkspaceCommandPath))
- Expect(req.Method).To(Equal("POST"))
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke PlanWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.PlanWorkspaceCommand(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the PlanWorkspaceCommandOptions model
- planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
- planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke PlanWorkspaceCommand with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the PlanWorkspaceCommandOptions model
- planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
- planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the PlanWorkspaceCommandOptions model with no property values
- planWorkspaceCommandOptionsModelNew := new(schematicsv1.PlanWorkspaceCommandOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke PlanWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the PlanWorkspaceCommandOptions model
- planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
- planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`RefreshWorkspaceCommand(refreshWorkspaceCommandOptions *RefreshWorkspaceCommandOptions) - Operation response error`, func() {
- refreshWorkspaceCommandPath := "/v1/workspaces/testString/refresh"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(refreshWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke RefreshWorkspaceCommand with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the RefreshWorkspaceCommandOptions model
- refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
- refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`RefreshWorkspaceCommand(refreshWorkspaceCommandOptions *RefreshWorkspaceCommandOptions)`, func() {
- refreshWorkspaceCommandPath := "/v1/workspaces/testString/refresh"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(refreshWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke RefreshWorkspaceCommand successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the RefreshWorkspaceCommandOptions model
- refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
- refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.RefreshWorkspaceCommandWithContext(ctx, refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.RefreshWorkspaceCommandWithContext(ctx, refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(refreshWorkspaceCommandPath))
- Expect(req.Method).To(Equal("PUT"))
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
- }))
- })
- It(`Invoke RefreshWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.RefreshWorkspaceCommand(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the RefreshWorkspaceCommandOptions model
- refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
- refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke RefreshWorkspaceCommand with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the RefreshWorkspaceCommandOptions model
- refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
- refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the RefreshWorkspaceCommandOptions model with no property values
- refreshWorkspaceCommandOptionsModelNew := new(schematicsv1.RefreshWorkspaceCommandOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke RefreshWorkspaceCommand successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the RefreshWorkspaceCommandOptions model
- refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
- refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
- refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListJobs(listJobsOptions *ListJobsOptions) - Operation response error`, func() {
- listJobsPath := "/v2/jobs"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listJobsPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- Expect(req.URL.Query()["resource"]).To(Equal([]string{"workspace"}))
- Expect(req.URL.Query()["resource_id"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["action_id"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["list"]).To(Equal([]string{"all"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListJobs with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListJobsOptions model
- listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
- listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listJobsOptionsModel.Sort = core.StringPtr("testString")
- listJobsOptionsModel.Profile = core.StringPtr("ids")
- listJobsOptionsModel.Resource = core.StringPtr("workspace")
- listJobsOptionsModel.ResourceID = core.StringPtr("testString")
- listJobsOptionsModel.ActionID = core.StringPtr("testString")
- listJobsOptionsModel.List = core.StringPtr("all")
- listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListJobs(listJobsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListJobs(listJobsOptions *ListJobsOptions)`, func() {
- listJobsPath := "/v2/jobs"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listJobsPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- Expect(req.URL.Query()["resource"]).To(Equal([]string{"workspace"}))
- Expect(req.URL.Query()["resource_id"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["action_id"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["list"]).To(Equal([]string{"all"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "jobs": [{"id": "ID", "name": "Name", "description": "Description", "command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "tags": ["Tags"], "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "duration": "Duration", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "updated_at": "2019-01-01T12:00:00.000Z"}]}`)
- }))
- })
- It(`Invoke ListJobs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListJobsOptions model
- listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
- listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listJobsOptionsModel.Sort = core.StringPtr("testString")
- listJobsOptionsModel.Profile = core.StringPtr("ids")
- listJobsOptionsModel.Resource = core.StringPtr("workspace")
- listJobsOptionsModel.ResourceID = core.StringPtr("testString")
- listJobsOptionsModel.ActionID = core.StringPtr("testString")
- listJobsOptionsModel.List = core.StringPtr("all")
- listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListJobsWithContext(ctx, listJobsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListJobsWithContext(ctx, listJobsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listJobsPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- Expect(req.URL.Query()["resource"]).To(Equal([]string{"workspace"}))
- Expect(req.URL.Query()["resource_id"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["action_id"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["list"]).To(Equal([]string{"all"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "jobs": [{"id": "ID", "name": "Name", "description": "Description", "command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "tags": ["Tags"], "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "duration": "Duration", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "updated_at": "2019-01-01T12:00:00.000Z"}]}`)
- }))
- })
- It(`Invoke ListJobs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListJobs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListJobsOptions model
- listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
- listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listJobsOptionsModel.Sort = core.StringPtr("testString")
- listJobsOptionsModel.Profile = core.StringPtr("ids")
- listJobsOptionsModel.Resource = core.StringPtr("workspace")
- listJobsOptionsModel.ResourceID = core.StringPtr("testString")
- listJobsOptionsModel.ActionID = core.StringPtr("testString")
- listJobsOptionsModel.List = core.StringPtr("all")
- listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListJobs(listJobsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListJobs with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListJobsOptions model
- listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
- listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listJobsOptionsModel.Sort = core.StringPtr("testString")
- listJobsOptionsModel.Profile = core.StringPtr("ids")
- listJobsOptionsModel.Resource = core.StringPtr("workspace")
- listJobsOptionsModel.ResourceID = core.StringPtr("testString")
- listJobsOptionsModel.ActionID = core.StringPtr("testString")
- listJobsOptionsModel.List = core.StringPtr("all")
- listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListJobs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListJobsOptions model
- listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
- listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
- listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
- listJobsOptionsModel.Sort = core.StringPtr("testString")
- listJobsOptionsModel.Profile = core.StringPtr("ids")
- listJobsOptionsModel.Resource = core.StringPtr("workspace")
- listJobsOptionsModel.ResourceID = core.StringPtr("testString")
- listJobsOptionsModel.ActionID = core.StringPtr("testString")
- listJobsOptionsModel.List = core.StringPtr("all")
- listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateJob(createJobOptions *CreateJobOptions) - Operation response error`, func() {
- createJobPath := "/v2/jobs"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createJobPath))
- Expect(req.Method).To(Equal("POST"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke CreateJob with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the CreateJobOptions model
- createJobOptionsModel := new(schematicsv1.CreateJobOptions)
- createJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createJobOptionsModel.CommandObject = core.StringPtr("workspace")
- createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- createJobOptionsModel.CommandParameter = core.StringPtr("testString")
- createJobOptionsModel.CommandOptions = []string{"testString"}
- createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Tags = []string{"testString"}
- createJobOptionsModel.Location = core.StringPtr("us-south")
- createJobOptionsModel.Status = jobStatusModel
- createJobOptionsModel.Data = jobDataModel
- createJobOptionsModel.Bastion = bastionResourceDefinitionModel
- createJobOptionsModel.LogSummary = jobLogSummaryModel
- createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.CreateJob(createJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateJob(createJobOptions *CreateJobOptions)`, func() {
- createJobPath := "/v2/jobs"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createJobPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"workspace_id": "WorkspaceID", "layers": "Layers", "workspace_name": "WorkspaceName", "job_id": "JobID", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke CreateJob successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the CreateJobOptions model
- createJobOptionsModel := new(schematicsv1.CreateJobOptions)
- createJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createJobOptionsModel.CommandObject = core.StringPtr("workspace")
- createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- createJobOptionsModel.CommandParameter = core.StringPtr("testString")
- createJobOptionsModel.CommandOptions = []string{"testString"}
- createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Tags = []string{"testString"}
- createJobOptionsModel.Location = core.StringPtr("us-south")
- createJobOptionsModel.Status = jobStatusModel
- createJobOptionsModel.Data = jobDataModel
- createJobOptionsModel.Bastion = bastionResourceDefinitionModel
- createJobOptionsModel.LogSummary = jobLogSummaryModel
- createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.CreateJobWithContext(ctx, createJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.CreateJobWithContext(ctx, createJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createJobPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"workspace_id": "WorkspaceID", "layers": "Layers", "workspace_name": "WorkspaceName", "job_id": "JobID", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke CreateJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.CreateJob(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the CreateJobOptions model
- createJobOptionsModel := new(schematicsv1.CreateJobOptions)
- createJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createJobOptionsModel.CommandObject = core.StringPtr("workspace")
- createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- createJobOptionsModel.CommandParameter = core.StringPtr("testString")
- createJobOptionsModel.CommandOptions = []string{"testString"}
- createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Tags = []string{"testString"}
- createJobOptionsModel.Location = core.StringPtr("us-south")
- createJobOptionsModel.Status = jobStatusModel
- createJobOptionsModel.Data = jobDataModel
- createJobOptionsModel.Bastion = bastionResourceDefinitionModel
- createJobOptionsModel.LogSummary = jobLogSummaryModel
- createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.CreateJob(createJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke CreateJob with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the CreateJobOptions model
- createJobOptionsModel := new(schematicsv1.CreateJobOptions)
- createJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createJobOptionsModel.CommandObject = core.StringPtr("workspace")
- createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- createJobOptionsModel.CommandParameter = core.StringPtr("testString")
- createJobOptionsModel.CommandOptions = []string{"testString"}
- createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Tags = []string{"testString"}
- createJobOptionsModel.Location = core.StringPtr("us-south")
- createJobOptionsModel.Status = jobStatusModel
- createJobOptionsModel.Data = jobDataModel
- createJobOptionsModel.Bastion = bastionResourceDefinitionModel
- createJobOptionsModel.LogSummary = jobLogSummaryModel
- createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the CreateJobOptions model with no property values
- createJobOptionsModelNew := new(schematicsv1.CreateJobOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.CreateJob(createJobOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke CreateJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the CreateJobOptions model
- createJobOptionsModel := new(schematicsv1.CreateJobOptions)
- createJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createJobOptionsModel.CommandObject = core.StringPtr("workspace")
- createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- createJobOptionsModel.CommandParameter = core.StringPtr("testString")
- createJobOptionsModel.CommandOptions = []string{"testString"}
- createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- createJobOptionsModel.Tags = []string{"testString"}
- createJobOptionsModel.Location = core.StringPtr("us-south")
- createJobOptionsModel.Status = jobStatusModel
- createJobOptionsModel.Data = jobDataModel
- createJobOptionsModel.Bastion = bastionResourceDefinitionModel
- createJobOptionsModel.LogSummary = jobLogSummaryModel
- createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetJob(getJobOptions *GetJobOptions) - Operation response error`, func() {
- getJobPath := "/v2/jobs/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getJobPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetJob with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetJobOptions model
- getJobOptionsModel := new(schematicsv1.GetJobOptions)
- getJobOptionsModel.JobID = core.StringPtr("testString")
- getJobOptionsModel.Profile = core.StringPtr("summary")
- getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetJob(getJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetJob(getJobOptions *GetJobOptions)`, func() {
- getJobPath := "/v2/jobs/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getJobPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"workspace_id": "WorkspaceID", "layers": "Layers", "workspace_name": "WorkspaceName", "job_id": "JobID", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke GetJob successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetJobOptions model
- getJobOptionsModel := new(schematicsv1.GetJobOptions)
- getJobOptionsModel.JobID = core.StringPtr("testString")
- getJobOptionsModel.Profile = core.StringPtr("summary")
- getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetJobWithContext(ctx, getJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetJobWithContext(ctx, getJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getJobPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"workspace_id": "WorkspaceID", "layers": "Layers", "workspace_name": "WorkspaceName", "job_id": "JobID", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke GetJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetJob(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetJobOptions model
- getJobOptionsModel := new(schematicsv1.GetJobOptions)
- getJobOptionsModel.JobID = core.StringPtr("testString")
- getJobOptionsModel.Profile = core.StringPtr("summary")
- getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetJob(getJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetJob with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetJobOptions model
- getJobOptionsModel := new(schematicsv1.GetJobOptions)
- getJobOptionsModel.JobID = core.StringPtr("testString")
- getJobOptionsModel.Profile = core.StringPtr("summary")
- getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetJobOptions model with no property values
- getJobOptionsModelNew := new(schematicsv1.GetJobOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetJob(getJobOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetJobOptions model
- getJobOptionsModel := new(schematicsv1.GetJobOptions)
- getJobOptionsModel.JobID = core.StringPtr("testString")
- getJobOptionsModel.Profile = core.StringPtr("summary")
- getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceJob(replaceJobOptions *ReplaceJobOptions) - Operation response error`, func() {
- replaceJobPath := "/v2/jobs/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceJobPath))
- Expect(req.Method).To(Equal("PUT"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ReplaceJob with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the ReplaceJobOptions model
- replaceJobOptionsModel := new(schematicsv1.ReplaceJobOptions)
- replaceJobOptionsModel.JobID = core.StringPtr("testString")
- replaceJobOptionsModel.RefreshToken = core.StringPtr("testString")
- replaceJobOptionsModel.CommandObject = core.StringPtr("workspace")
- replaceJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- replaceJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- replaceJobOptionsModel.CommandParameter = core.StringPtr("testString")
- replaceJobOptionsModel.CommandOptions = []string{"testString"}
- replaceJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Tags = []string{"testString"}
- replaceJobOptionsModel.Location = core.StringPtr("us-south")
- replaceJobOptionsModel.Status = jobStatusModel
- replaceJobOptionsModel.Data = jobDataModel
- replaceJobOptionsModel.Bastion = bastionResourceDefinitionModel
- replaceJobOptionsModel.LogSummary = jobLogSummaryModel
- replaceJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ReplaceJob(replaceJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ReplaceJob(replaceJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceJob(replaceJobOptions *ReplaceJobOptions)`, func() {
- replaceJobPath := "/v2/jobs/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceJobPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"workspace_id": "WorkspaceID", "layers": "Layers", "workspace_name": "WorkspaceName", "job_id": "JobID", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke ReplaceJob successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the ReplaceJobOptions model
- replaceJobOptionsModel := new(schematicsv1.ReplaceJobOptions)
- replaceJobOptionsModel.JobID = core.StringPtr("testString")
- replaceJobOptionsModel.RefreshToken = core.StringPtr("testString")
- replaceJobOptionsModel.CommandObject = core.StringPtr("workspace")
- replaceJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- replaceJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- replaceJobOptionsModel.CommandParameter = core.StringPtr("testString")
- replaceJobOptionsModel.CommandOptions = []string{"testString"}
- replaceJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Tags = []string{"testString"}
- replaceJobOptionsModel.Location = core.StringPtr("us-south")
- replaceJobOptionsModel.Status = jobStatusModel
- replaceJobOptionsModel.Data = jobDataModel
- replaceJobOptionsModel.Bastion = bastionResourceDefinitionModel
- replaceJobOptionsModel.LogSummary = jobLogSummaryModel
- replaceJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ReplaceJobWithContext(ctx, replaceJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ReplaceJob(replaceJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ReplaceJobWithContext(ctx, replaceJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceJobPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"workspace_id": "WorkspaceID", "layers": "Layers", "workspace_name": "WorkspaceName", "job_id": "JobID", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke ReplaceJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ReplaceJob(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the ReplaceJobOptions model
- replaceJobOptionsModel := new(schematicsv1.ReplaceJobOptions)
- replaceJobOptionsModel.JobID = core.StringPtr("testString")
- replaceJobOptionsModel.RefreshToken = core.StringPtr("testString")
- replaceJobOptionsModel.CommandObject = core.StringPtr("workspace")
- replaceJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- replaceJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- replaceJobOptionsModel.CommandParameter = core.StringPtr("testString")
- replaceJobOptionsModel.CommandOptions = []string{"testString"}
- replaceJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Tags = []string{"testString"}
- replaceJobOptionsModel.Location = core.StringPtr("us-south")
- replaceJobOptionsModel.Status = jobStatusModel
- replaceJobOptionsModel.Data = jobDataModel
- replaceJobOptionsModel.Bastion = bastionResourceDefinitionModel
- replaceJobOptionsModel.LogSummary = jobLogSummaryModel
- replaceJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ReplaceJob(replaceJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ReplaceJob with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the ReplaceJobOptions model
- replaceJobOptionsModel := new(schematicsv1.ReplaceJobOptions)
- replaceJobOptionsModel.JobID = core.StringPtr("testString")
- replaceJobOptionsModel.RefreshToken = core.StringPtr("testString")
- replaceJobOptionsModel.CommandObject = core.StringPtr("workspace")
- replaceJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- replaceJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- replaceJobOptionsModel.CommandParameter = core.StringPtr("testString")
- replaceJobOptionsModel.CommandOptions = []string{"testString"}
- replaceJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Tags = []string{"testString"}
- replaceJobOptionsModel.Location = core.StringPtr("us-south")
- replaceJobOptionsModel.Status = jobStatusModel
- replaceJobOptionsModel.Data = jobDataModel
- replaceJobOptionsModel.Bastion = bastionResourceDefinitionModel
- replaceJobOptionsModel.LogSummary = jobLogSummaryModel
- replaceJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ReplaceJob(replaceJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ReplaceJobOptions model with no property values
- replaceJobOptionsModelNew := new(schematicsv1.ReplaceJobOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ReplaceJob(replaceJobOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke ReplaceJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
-
- // Construct an instance of the ReplaceJobOptions model
- replaceJobOptionsModel := new(schematicsv1.ReplaceJobOptions)
- replaceJobOptionsModel.JobID = core.StringPtr("testString")
- replaceJobOptionsModel.RefreshToken = core.StringPtr("testString")
- replaceJobOptionsModel.CommandObject = core.StringPtr("workspace")
- replaceJobOptionsModel.CommandObjectID = core.StringPtr("testString")
- replaceJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
- replaceJobOptionsModel.CommandParameter = core.StringPtr("testString")
- replaceJobOptionsModel.CommandOptions = []string{"testString"}
- replaceJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- replaceJobOptionsModel.Tags = []string{"testString"}
- replaceJobOptionsModel.Location = core.StringPtr("us-south")
- replaceJobOptionsModel.Status = jobStatusModel
- replaceJobOptionsModel.Data = jobDataModel
- replaceJobOptionsModel.Bastion = bastionResourceDefinitionModel
- replaceJobOptionsModel.LogSummary = jobLogSummaryModel
- replaceJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ReplaceJob(replaceJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DeleteJob(deleteJobOptions *DeleteJobOptions)`, func() {
- deleteJobPath := "/v2/jobs/testString"
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteJobPath))
- Expect(req.Method).To(Equal("DELETE"))
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- Expect(req.Header["Force"]).ToNot(BeNil())
- Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
- Expect(req.Header["Propagate"]).ToNot(BeNil())
- Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
- res.WriteHeader(204)
- }))
- })
- It(`Invoke DeleteJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- response, operationErr := schematicsService.DeleteJob(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
-
- // Construct an instance of the DeleteJobOptions model
- deleteJobOptionsModel := new(schematicsv1.DeleteJobOptions)
- deleteJobOptionsModel.JobID = core.StringPtr("testString")
- deleteJobOptionsModel.RefreshToken = core.StringPtr("testString")
- deleteJobOptionsModel.Force = core.BoolPtr(true)
- deleteJobOptionsModel.Propagate = core.BoolPtr(true)
- deleteJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- response, operationErr = schematicsService.DeleteJob(deleteJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- })
- It(`Invoke DeleteJob with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteJobOptions model
- deleteJobOptionsModel := new(schematicsv1.DeleteJobOptions)
- deleteJobOptionsModel.JobID = core.StringPtr("testString")
- deleteJobOptionsModel.RefreshToken = core.StringPtr("testString")
- deleteJobOptionsModel.Force = core.BoolPtr(true)
- deleteJobOptionsModel.Propagate = core.BoolPtr(true)
- deleteJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- response, operationErr := schematicsService.DeleteJob(deleteJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- // Construct a second instance of the DeleteJobOptions model with no property values
- deleteJobOptionsModelNew := new(schematicsv1.DeleteJobOptions)
- // Invoke operation with invalid model (negative test)
- response, operationErr = schematicsService.DeleteJob(deleteJobOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListJobLogs(listJobLogsOptions *ListJobLogsOptions) - Operation response error`, func() {
- listJobLogsPath := "/v2/jobs/testString/logs"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listJobLogsPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListJobLogs with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListJobLogsOptions model
- listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
- listJobLogsOptionsModel.JobID = core.StringPtr("testString")
- listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListJobLogs(listJobLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListJobLogs(listJobLogsOptions *ListJobLogsOptions)`, func() {
- listJobLogsPath := "/v2/jobs/testString/logs"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listJobLogsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"job_id": "JobID", "job_name": "JobName", "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "format": "json", "details": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke ListJobLogs successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListJobLogsOptions model
- listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
- listJobLogsOptionsModel.JobID = core.StringPtr("testString")
- listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListJobLogsWithContext(ctx, listJobLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListJobLogsWithContext(ctx, listJobLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listJobLogsPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(202)
- fmt.Fprintf(res, "%s", `{"job_id": "JobID", "job_name": "JobName", "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "format": "json", "details": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "updated_at": "2019-01-01T12:00:00.000Z"}`)
- }))
- })
- It(`Invoke ListJobLogs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListJobLogs(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListJobLogsOptions model
- listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
- listJobLogsOptionsModel.JobID = core.StringPtr("testString")
- listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListJobLogs(listJobLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListJobLogs with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListJobLogsOptions model
- listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
- listJobLogsOptionsModel.JobID = core.StringPtr("testString")
- listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ListJobLogsOptions model with no property values
- listJobLogsOptionsModelNew := new(schematicsv1.ListJobLogsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ListJobLogs(listJobLogsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(202)
- }))
- })
- It(`Invoke ListJobLogs successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListJobLogsOptions model
- listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
- listJobLogsOptionsModel.JobID = core.StringPtr("testString")
- listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptions *CreateWorkspaceDeletionJobOptions) - Operation response error`, func() {
- createWorkspaceDeletionJobPath := "/v1/workspace_jobs"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createWorkspaceDeletionJobPath))
- Expect(req.Method).To(Equal("POST"))
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- Expect(req.URL.Query()["destroy_resources"]).To(Equal([]string{"testString"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke CreateWorkspaceDeletionJob with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CreateWorkspaceDeletionJobOptions model
- createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
- createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
- createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptions *CreateWorkspaceDeletionJobOptions)`, func() {
- createWorkspaceDeletionJobPath := "/v1/workspace_jobs"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createWorkspaceDeletionJobPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- Expect(req.URL.Query()["destroy_resources"]).To(Equal([]string{"testString"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"job": "Job", "job_id": "JobID"}`)
- }))
- })
- It(`Invoke CreateWorkspaceDeletionJob successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the CreateWorkspaceDeletionJobOptions model
- createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
- createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
- createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.CreateWorkspaceDeletionJobWithContext(ctx, createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.CreateWorkspaceDeletionJobWithContext(ctx, createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createWorkspaceDeletionJobPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["Refresh_token"]).ToNot(BeNil())
- Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- Expect(req.URL.Query()["destroy_resources"]).To(Equal([]string{"testString"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"job": "Job", "job_id": "JobID"}`)
- }))
- })
- It(`Invoke CreateWorkspaceDeletionJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the CreateWorkspaceDeletionJobOptions model
- createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
- createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
- createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke CreateWorkspaceDeletionJob with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CreateWorkspaceDeletionJobOptions model
- createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
- createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
- createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the CreateWorkspaceDeletionJobOptions model with no property values
- createWorkspaceDeletionJobOptionsModelNew := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke CreateWorkspaceDeletionJob successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CreateWorkspaceDeletionJobOptions model
- createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
- createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
- createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
- createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
- createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptions *GetWorkspaceDeletionJobStatusOptions) - Operation response error`, func() {
- getWorkspaceDeletionJobStatusPath := "/v1/workspace_jobs/testString/status"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceDeletionJobStatusPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetWorkspaceDeletionJobStatus with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
- getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
- getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
- getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptions *GetWorkspaceDeletionJobStatusOptions)`, func() {
- getWorkspaceDeletionJobStatusPath := "/v1/workspace_jobs/testString/status"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceDeletionJobStatusPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"job_status": {"failed": ["Failed"], "in_progress": ["InProgress"], "success": ["Success"], "last_updated_on": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke GetWorkspaceDeletionJobStatus successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
- getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
- getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
- getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetWorkspaceDeletionJobStatusWithContext(ctx, getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetWorkspaceDeletionJobStatusWithContext(ctx, getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceDeletionJobStatusPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"job_status": {"failed": ["Failed"], "in_progress": ["InProgress"], "success": ["Success"], "last_updated_on": "2019-01-01T12:00:00.000Z"}}`)
- }))
- })
- It(`Invoke GetWorkspaceDeletionJobStatus successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
- getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
- getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
- getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetWorkspaceDeletionJobStatus with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
- getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
- getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
- getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetWorkspaceDeletionJobStatusOptions model with no property values
- getWorkspaceDeletionJobStatusOptionsModelNew := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetWorkspaceDeletionJobStatus successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
- getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
- getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
- getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListInventories(listInventoriesOptions *ListInventoriesOptions) - Operation response error`, func() {
- listInventoriesPath := "/v2/inventories"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listInventoriesPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListInventories with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListInventoriesOptions model
- listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
- listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listInventoriesOptionsModel.Sort = core.StringPtr("testString")
- listInventoriesOptionsModel.Profile = core.StringPtr("ids")
- listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListInventories(listInventoriesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListInventories(listInventoriesOptions *ListInventoriesOptions)`, func() {
- listInventoriesPath := "/v2/inventories"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listInventoriesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
- }))
- })
- It(`Invoke ListInventories successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListInventoriesOptions model
- listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
- listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listInventoriesOptionsModel.Sort = core.StringPtr("testString")
- listInventoriesOptionsModel.Profile = core.StringPtr("ids")
- listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListInventoriesWithContext(ctx, listInventoriesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListInventoriesWithContext(ctx, listInventoriesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listInventoriesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
- }))
- })
- It(`Invoke ListInventories successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListInventories(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListInventoriesOptions model
- listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
- listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listInventoriesOptionsModel.Sort = core.StringPtr("testString")
- listInventoriesOptionsModel.Profile = core.StringPtr("ids")
- listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListInventories(listInventoriesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListInventories with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListInventoriesOptions model
- listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
- listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listInventoriesOptionsModel.Sort = core.StringPtr("testString")
- listInventoriesOptionsModel.Profile = core.StringPtr("ids")
- listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListInventories successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListInventoriesOptions model
- listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
- listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
- listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
- listInventoriesOptionsModel.Sort = core.StringPtr("testString")
- listInventoriesOptionsModel.Profile = core.StringPtr("ids")
- listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateInventory(createInventoryOptions *CreateInventoryOptions) - Operation response error`, func() {
- createInventoryPath := "/v2/inventories"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createInventoryPath))
- Expect(req.Method).To(Equal("POST"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke CreateInventory with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CreateInventoryOptions model
- createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
- createInventoryOptionsModel.Name = core.StringPtr("testString")
- createInventoryOptionsModel.Description = core.StringPtr("testString")
- createInventoryOptionsModel.Location = core.StringPtr("us-south")
- createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- createInventoryOptionsModel.ResourceQueries = []string{"testString"}
- createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.CreateInventory(createInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateInventory(createInventoryOptions *CreateInventoryOptions)`, func() {
- createInventoryPath := "/v2/inventories"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createInventoryPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke CreateInventory successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the CreateInventoryOptions model
- createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
- createInventoryOptionsModel.Name = core.StringPtr("testString")
- createInventoryOptionsModel.Description = core.StringPtr("testString")
- createInventoryOptionsModel.Location = core.StringPtr("us-south")
- createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- createInventoryOptionsModel.ResourceQueries = []string{"testString"}
- createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.CreateInventoryWithContext(ctx, createInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.CreateInventoryWithContext(ctx, createInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createInventoryPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke CreateInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.CreateInventory(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the CreateInventoryOptions model
- createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
- createInventoryOptionsModel.Name = core.StringPtr("testString")
- createInventoryOptionsModel.Description = core.StringPtr("testString")
- createInventoryOptionsModel.Location = core.StringPtr("us-south")
- createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- createInventoryOptionsModel.ResourceQueries = []string{"testString"}
- createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.CreateInventory(createInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke CreateInventory with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CreateInventoryOptions model
- createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
- createInventoryOptionsModel.Name = core.StringPtr("testString")
- createInventoryOptionsModel.Description = core.StringPtr("testString")
- createInventoryOptionsModel.Location = core.StringPtr("us-south")
- createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- createInventoryOptionsModel.ResourceQueries = []string{"testString"}
- createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke CreateInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the CreateInventoryOptions model
- createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
- createInventoryOptionsModel.Name = core.StringPtr("testString")
- createInventoryOptionsModel.Description = core.StringPtr("testString")
- createInventoryOptionsModel.Location = core.StringPtr("us-south")
- createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- createInventoryOptionsModel.ResourceQueries = []string{"testString"}
- createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetInventory(getInventoryOptions *GetInventoryOptions) - Operation response error`, func() {
- getInventoryPath := "/v2/inventories/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getInventoryPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetInventory with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetInventoryOptions model
- getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
- getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetInventory(getInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetInventory(getInventoryOptions *GetInventoryOptions)`, func() {
- getInventoryPath := "/v2/inventories/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getInventoryPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke GetInventory successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetInventoryOptions model
- getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
- getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetInventoryWithContext(ctx, getInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetInventoryWithContext(ctx, getInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getInventoryPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke GetInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetInventory(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetInventoryOptions model
- getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
- getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetInventory(getInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetInventory with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetInventoryOptions model
- getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
- getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetInventoryOptions model with no property values
- getInventoryOptionsModelNew := new(schematicsv1.GetInventoryOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetInventory(getInventoryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetInventoryOptions model
- getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
- getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceInventory(replaceInventoryOptions *ReplaceInventoryOptions) - Operation response error`, func() {
- replaceInventoryPath := "/v2/inventories/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceInventoryPath))
- Expect(req.Method).To(Equal("PUT"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ReplaceInventory with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ReplaceInventoryOptions model
- replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
- replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- replaceInventoryOptionsModel.Name = core.StringPtr("testString")
- replaceInventoryOptionsModel.Description = core.StringPtr("testString")
- replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
- replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
- replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceInventory(replaceInventoryOptions *ReplaceInventoryOptions)`, func() {
- replaceInventoryPath := "/v2/inventories/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceInventoryPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke ReplaceInventory successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ReplaceInventoryOptions model
- replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
- replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- replaceInventoryOptionsModel.Name = core.StringPtr("testString")
- replaceInventoryOptionsModel.Description = core.StringPtr("testString")
- replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
- replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
- replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ReplaceInventoryWithContext(ctx, replaceInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ReplaceInventoryWithContext(ctx, replaceInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceInventoryPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke ReplaceInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ReplaceInventory(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ReplaceInventoryOptions model
- replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
- replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- replaceInventoryOptionsModel.Name = core.StringPtr("testString")
- replaceInventoryOptionsModel.Description = core.StringPtr("testString")
- replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
- replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
- replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ReplaceInventory with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ReplaceInventoryOptions model
- replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
- replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- replaceInventoryOptionsModel.Name = core.StringPtr("testString")
- replaceInventoryOptionsModel.Description = core.StringPtr("testString")
- replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
- replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
- replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ReplaceInventoryOptions model with no property values
- replaceInventoryOptionsModelNew := new(schematicsv1.ReplaceInventoryOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ReplaceInventory(replaceInventoryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ReplaceInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ReplaceInventoryOptions model
- replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
- replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- replaceInventoryOptionsModel.Name = core.StringPtr("testString")
- replaceInventoryOptionsModel.Description = core.StringPtr("testString")
- replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
- replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
- replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DeleteInventory(deleteInventoryOptions *DeleteInventoryOptions)`, func() {
- deleteInventoryPath := "/v2/inventories/testString"
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteInventoryPath))
- Expect(req.Method).To(Equal("DELETE"))
-
- Expect(req.Header["Force"]).ToNot(BeNil())
- Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
- Expect(req.Header["Propagate"]).ToNot(BeNil())
- Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
- res.WriteHeader(204)
- }))
- })
- It(`Invoke DeleteInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- response, operationErr := schematicsService.DeleteInventory(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
-
- // Construct an instance of the DeleteInventoryOptions model
- deleteInventoryOptionsModel := new(schematicsv1.DeleteInventoryOptions)
- deleteInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- deleteInventoryOptionsModel.Force = core.BoolPtr(true)
- deleteInventoryOptionsModel.Propagate = core.BoolPtr(true)
- deleteInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- response, operationErr = schematicsService.DeleteInventory(deleteInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- })
- It(`Invoke DeleteInventory with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteInventoryOptions model
- deleteInventoryOptionsModel := new(schematicsv1.DeleteInventoryOptions)
- deleteInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- deleteInventoryOptionsModel.Force = core.BoolPtr(true)
- deleteInventoryOptionsModel.Propagate = core.BoolPtr(true)
- deleteInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- response, operationErr := schematicsService.DeleteInventory(deleteInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- // Construct a second instance of the DeleteInventoryOptions model with no property values
- deleteInventoryOptionsModelNew := new(schematicsv1.DeleteInventoryOptions)
- // Invoke operation with invalid model (negative test)
- response, operationErr = schematicsService.DeleteInventory(deleteInventoryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UpdateInventory(updateInventoryOptions *UpdateInventoryOptions) - Operation response error`, func() {
- updateInventoryPath := "/v2/inventories/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateInventoryPath))
- Expect(req.Method).To(Equal("PATCH"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke UpdateInventory with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UpdateInventoryOptions model
- updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
- updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- updateInventoryOptionsModel.Name = core.StringPtr("testString")
- updateInventoryOptionsModel.Description = core.StringPtr("testString")
- updateInventoryOptionsModel.Location = core.StringPtr("us-south")
- updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
- updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.UpdateInventory(updateInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`UpdateInventory(updateInventoryOptions *UpdateInventoryOptions)`, func() {
- updateInventoryPath := "/v2/inventories/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateInventoryPath))
- Expect(req.Method).To(Equal("PATCH"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke UpdateInventory successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the UpdateInventoryOptions model
- updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
- updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- updateInventoryOptionsModel.Name = core.StringPtr("testString")
- updateInventoryOptionsModel.Description = core.StringPtr("testString")
- updateInventoryOptionsModel.Location = core.StringPtr("us-south")
- updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
- updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.UpdateInventoryWithContext(ctx, updateInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.UpdateInventoryWithContext(ctx, updateInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(updateInventoryPath))
- Expect(req.Method).To(Equal("PATCH"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke UpdateInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.UpdateInventory(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the UpdateInventoryOptions model
- updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
- updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- updateInventoryOptionsModel.Name = core.StringPtr("testString")
- updateInventoryOptionsModel.Description = core.StringPtr("testString")
- updateInventoryOptionsModel.Location = core.StringPtr("us-south")
- updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
- updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.UpdateInventory(updateInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke UpdateInventory with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UpdateInventoryOptions model
- updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
- updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- updateInventoryOptionsModel.Name = core.StringPtr("testString")
- updateInventoryOptionsModel.Description = core.StringPtr("testString")
- updateInventoryOptionsModel.Location = core.StringPtr("us-south")
- updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
- updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the UpdateInventoryOptions model with no property values
- updateInventoryOptionsModelNew := new(schematicsv1.UpdateInventoryOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.UpdateInventory(updateInventoryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke UpdateInventory successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the UpdateInventoryOptions model
- updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
- updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
- updateInventoryOptionsModel.Name = core.StringPtr("testString")
- updateInventoryOptionsModel.Description = core.StringPtr("testString")
- updateInventoryOptionsModel.Location = core.StringPtr("us-south")
- updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
- updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
- updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
- updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListInventoryValues(listInventoryValuesOptions *ListInventoryValuesOptions) - Operation response error`, func() {
- listInventoryValuesPath := "/v2/inventories/testString/variables"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listInventoryValuesPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListInventoryValues with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListInventoryValuesOptions model
- listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
- listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
- listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListInventoryValues(listInventoryValuesOptions *ListInventoryValuesOptions)`, func() {
- listInventoryValuesPath := "/v2/inventories/testString/variables"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listInventoryValuesPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
- }))
- })
- It(`Invoke ListInventoryValues successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListInventoryValuesOptions model
- listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
- listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
- listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListInventoryValuesWithContext(ctx, listInventoryValuesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListInventoryValuesWithContext(ctx, listInventoryValuesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listInventoryValuesPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
- }))
- })
- It(`Invoke ListInventoryValues successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListInventoryValues(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListInventoryValuesOptions model
- listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
- listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
- listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListInventoryValues with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListInventoryValuesOptions model
- listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
- listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
- listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ListInventoryValuesOptions model with no property values
- listInventoryValuesOptionsModelNew := new(schematicsv1.ListInventoryValuesOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ListInventoryValues(listInventoryValuesOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListInventoryValues successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListInventoryValuesOptions model
- listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
- listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
- listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetInventoryValue(getInventoryValueOptions *GetInventoryValueOptions) - Operation response error`, func() {
- getInventoryValuePath := "/v2/inventories/testString/variables/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getInventoryValuePath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetInventoryValue with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetInventoryValueOptions model
- getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
- getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
- getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetInventoryValue(getInventoryValueOptions *GetInventoryValueOptions)`, func() {
- getInventoryValuePath := "/v2/inventories/testString/variables/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getInventoryValuePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke GetInventoryValue successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetInventoryValueOptions model
- getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
- getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
- getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetInventoryValueWithContext(ctx, getInventoryValueOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetInventoryValueWithContext(ctx, getInventoryValueOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getInventoryValuePath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
- }))
- })
- It(`Invoke GetInventoryValue successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetInventoryValue(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetInventoryValueOptions model
- getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
- getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
- getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetInventoryValue with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetInventoryValueOptions model
- getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
- getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
- getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetInventoryValueOptions model with no property values
- getInventoryValueOptionsModelNew := new(schematicsv1.GetInventoryValueOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetInventoryValue(getInventoryValueOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetInventoryValue successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetInventoryValueOptions model
- getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
- getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
- getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
- getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListResourceQuery(listResourceQueryOptions *ListResourceQueryOptions) - Operation response error`, func() {
- listResourceQueryPath := "/v2/resources_query"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listResourceQueryPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ListResourceQuery with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListResourceQueryOptions model
- listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
- listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
- listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
- listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
- listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
- listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ListResourceQuery(listResourceQueryOptions *ListResourceQueryOptions)`, func() {
- listResourceQueryPath := "/v2/resources_query"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listResourceQueryPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "resource_queries": [{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}]}`)
- }))
- })
- It(`Invoke ListResourceQuery successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ListResourceQueryOptions model
- listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
- listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
- listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
- listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
- listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
- listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ListResourceQueryWithContext(ctx, listResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ListResourceQueryWithContext(ctx, listResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(listResourceQueryPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "resource_queries": [{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}]}`)
- }))
- })
- It(`Invoke ListResourceQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ListResourceQuery(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ListResourceQueryOptions model
- listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
- listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
- listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
- listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
- listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
- listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ListResourceQuery with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListResourceQueryOptions model
- listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
- listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
- listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
- listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
- listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
- listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ListResourceQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ListResourceQueryOptions model
- listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
- listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
- listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
- listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
- listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
- listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateResourceQuery(createResourceQueryOptions *CreateResourceQueryOptions) - Operation response error`, func() {
- createResourceQueryPath := "/v2/resources_query"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createResourceQueryPath))
- Expect(req.Method).To(Equal("POST"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke CreateResourceQuery with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the CreateResourceQueryOptions model
- createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
- createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
- createResourceQueryOptionsModel.Name = core.StringPtr("testString")
- createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`CreateResourceQuery(createResourceQueryOptions *CreateResourceQueryOptions)`, func() {
- createResourceQueryPath := "/v2/resources_query"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createResourceQueryPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
- }))
- })
- It(`Invoke CreateResourceQuery successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the CreateResourceQueryOptions model
- createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
- createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
- createResourceQueryOptionsModel.Name = core.StringPtr("testString")
- createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.CreateResourceQueryWithContext(ctx, createResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.CreateResourceQueryWithContext(ctx, createResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(createResourceQueryPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
- }))
- })
- It(`Invoke CreateResourceQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.CreateResourceQuery(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the CreateResourceQueryOptions model
- createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
- createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
- createResourceQueryOptionsModel.Name = core.StringPtr("testString")
- createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke CreateResourceQuery with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the CreateResourceQueryOptions model
- createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
- createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
- createResourceQueryOptionsModel.Name = core.StringPtr("testString")
- createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke CreateResourceQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the CreateResourceQueryOptions model
- createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
- createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
- createResourceQueryOptionsModel.Name = core.StringPtr("testString")
- createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetResourcesQuery(getResourcesQueryOptions *GetResourcesQueryOptions) - Operation response error`, func() {
- getResourcesQueryPath := "/v2/resources_query/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getResourcesQueryPath))
- Expect(req.Method).To(Equal("GET"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetResourcesQuery with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetResourcesQueryOptions model
- getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
- getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetResourcesQuery(getResourcesQueryOptions *GetResourcesQueryOptions)`, func() {
- getResourcesQueryPath := "/v2/resources_query/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getResourcesQueryPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
- }))
- })
- It(`Invoke GetResourcesQuery successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetResourcesQueryOptions model
- getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
- getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetResourcesQueryWithContext(ctx, getResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetResourcesQueryWithContext(ctx, getResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getResourcesQueryPath))
- Expect(req.Method).To(Equal("GET"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
- }))
- })
- It(`Invoke GetResourcesQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetResourcesQuery(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetResourcesQueryOptions model
- getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
- getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetResourcesQuery with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetResourcesQueryOptions model
- getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
- getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetResourcesQueryOptions model with no property values
- getResourcesQueryOptionsModelNew := new(schematicsv1.GetResourcesQueryOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetResourcesQuery(getResourcesQueryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetResourcesQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetResourcesQueryOptions model
- getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
- getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceResourcesQuery(replaceResourcesQueryOptions *ReplaceResourcesQueryOptions) - Operation response error`, func() {
- replaceResourcesQueryPath := "/v2/resources_query/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceResourcesQueryPath))
- Expect(req.Method).To(Equal("PUT"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ReplaceResourcesQuery with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the ReplaceResourcesQueryOptions model
- replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
- replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
- replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceResourcesQuery(replaceResourcesQueryOptions *ReplaceResourcesQueryOptions)`, func() {
- replaceResourcesQueryPath := "/v2/resources_query/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceResourcesQueryPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
- }))
- })
- It(`Invoke ReplaceResourcesQuery successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the ReplaceResourcesQueryOptions model
- replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
- replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
- replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ReplaceResourcesQueryWithContext(ctx, replaceResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ReplaceResourcesQueryWithContext(ctx, replaceResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceResourcesQueryPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
- }))
- })
- It(`Invoke ReplaceResourcesQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ReplaceResourcesQuery(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the ReplaceResourcesQueryOptions model
- replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
- replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
- replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ReplaceResourcesQuery with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the ReplaceResourcesQueryOptions model
- replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
- replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
- replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ReplaceResourcesQueryOptions model with no property values
- replaceResourcesQueryOptionsModelNew := new(schematicsv1.ReplaceResourcesQueryOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ReplaceResourcesQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
-
- // Construct an instance of the ReplaceResourcesQueryOptions model
- replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
- replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
- replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
- replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
- replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ExecuteResourceQuery(executeResourceQueryOptions *ExecuteResourceQueryOptions) - Operation response error`, func() {
- executeResourceQueryPath := "/v2/resources_query/testString"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(executeResourceQueryPath))
- Expect(req.Method).To(Equal("POST"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ExecuteResourceQuery with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ExecuteResourceQueryOptions model
- executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
- executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
- executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ExecuteResourceQuery(executeResourceQueryOptions *ExecuteResourceQueryOptions)`, func() {
- executeResourceQueryPath := "/v2/resources_query/testString"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(executeResourceQueryPath))
- Expect(req.Method).To(Equal("POST"))
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"response": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"], "query_output": [{"name": "Name", "value": "Value"}]}]}`)
- }))
- })
- It(`Invoke ExecuteResourceQuery successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ExecuteResourceQueryOptions model
- executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
- executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
- executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ExecuteResourceQueryWithContext(ctx, executeResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ExecuteResourceQueryWithContext(ctx, executeResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(executeResourceQueryPath))
- Expect(req.Method).To(Equal("POST"))
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"response": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"], "query_output": [{"name": "Name", "value": "Value"}]}]}`)
- }))
- })
- It(`Invoke ExecuteResourceQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ExecuteResourceQuery(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ExecuteResourceQueryOptions model
- executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
- executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
- executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ExecuteResourceQuery with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ExecuteResourceQueryOptions model
- executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
- executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
- executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ExecuteResourceQueryOptions model with no property values
- executeResourceQueryOptionsModelNew := new(schematicsv1.ExecuteResourceQueryOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ExecuteResourceQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ExecuteResourceQueryOptions model
- executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
- executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
- executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`DeleteResourcesQuery(deleteResourcesQueryOptions *DeleteResourcesQueryOptions)`, func() {
- deleteResourcesQueryPath := "/v2/resources_query/testString"
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(deleteResourcesQueryPath))
- Expect(req.Method).To(Equal("DELETE"))
-
- Expect(req.Header["Force"]).ToNot(BeNil())
- Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
- Expect(req.Header["Propagate"]).ToNot(BeNil())
- Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
- res.WriteHeader(204)
- }))
- })
- It(`Invoke DeleteResourcesQuery successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- response, operationErr := schematicsService.DeleteResourcesQuery(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
-
- // Construct an instance of the DeleteResourcesQueryOptions model
- deleteResourcesQueryOptionsModel := new(schematicsv1.DeleteResourcesQueryOptions)
- deleteResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- deleteResourcesQueryOptionsModel.Force = core.BoolPtr(true)
- deleteResourcesQueryOptionsModel.Propagate = core.BoolPtr(true)
- deleteResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- response, operationErr = schematicsService.DeleteResourcesQuery(deleteResourcesQueryOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- })
- It(`Invoke DeleteResourcesQuery with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the DeleteResourcesQueryOptions model
- deleteResourcesQueryOptionsModel := new(schematicsv1.DeleteResourcesQueryOptions)
- deleteResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
- deleteResourcesQueryOptionsModel.Force = core.BoolPtr(true)
- deleteResourcesQueryOptionsModel.Propagate = core.BoolPtr(true)
- deleteResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- response, operationErr := schematicsService.DeleteResourcesQuery(deleteResourcesQueryOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- // Construct a second instance of the DeleteResourcesQueryOptions model with no property values
- deleteResourcesQueryOptionsModelNew := new(schematicsv1.DeleteResourcesQueryOptions)
- // Invoke operation with invalid model (negative test)
- response, operationErr = schematicsService.DeleteResourcesQuery(deleteResourcesQueryOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetKmsSettings(getKmsSettingsOptions *GetKmsSettingsOptions) - Operation response error`, func() {
- getKmsSettingsPath := "/v2/settings/kms"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getKmsSettingsPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetKmsSettings with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetKmsSettingsOptions model
- getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
- getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetKmsSettings(getKmsSettingsOptions *GetKmsSettingsOptions)`, func() {
- getKmsSettingsPath := "/v2/settings/kms"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getKmsSettingsPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
- }))
- })
- It(`Invoke GetKmsSettings successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetKmsSettingsOptions model
- getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
- getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetKmsSettingsWithContext(ctx, getKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetKmsSettingsWithContext(ctx, getKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getKmsSettingsPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
- }))
- })
- It(`Invoke GetKmsSettings successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetKmsSettings(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetKmsSettingsOptions model
- getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
- getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetKmsSettings with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetKmsSettingsOptions model
- getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
- getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetKmsSettingsOptions model with no property values
- getKmsSettingsOptionsModelNew := new(schematicsv1.GetKmsSettingsOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetKmsSettings(getKmsSettingsOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetKmsSettings successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetKmsSettingsOptions model
- getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
- getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceKmsSettings(replaceKmsSettingsOptions *ReplaceKmsSettingsOptions) - Operation response error`, func() {
- replaceKmsSettingsPath := "/v2/settings/kms"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceKmsSettingsPath))
- Expect(req.Method).To(Equal("PUT"))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ReplaceKmsSettings with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the KMSSettingsPrimaryCrk model
- kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
- kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the KMSSettingsSecondaryCrk model
- kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
- kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceKmsSettingsOptions model
- replaceKmsSettingsOptionsModel := new(schematicsv1.ReplaceKmsSettingsOptions)
- replaceKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
- replaceKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
- replaceKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ReplaceKmsSettings(replaceKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ReplaceKmsSettings(replaceKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ReplaceKmsSettings(replaceKmsSettingsOptions *ReplaceKmsSettingsOptions)`, func() {
- replaceKmsSettingsPath := "/v2/settings/kms"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceKmsSettingsPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
- }))
- })
- It(`Invoke ReplaceKmsSettings successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the KMSSettingsPrimaryCrk model
- kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
- kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the KMSSettingsSecondaryCrk model
- kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
- kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceKmsSettingsOptions model
- replaceKmsSettingsOptionsModel := new(schematicsv1.ReplaceKmsSettingsOptions)
- replaceKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
- replaceKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
- replaceKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ReplaceKmsSettingsWithContext(ctx, replaceKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ReplaceKmsSettings(replaceKmsSettingsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ReplaceKmsSettingsWithContext(ctx, replaceKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(replaceKmsSettingsPath))
- Expect(req.Method).To(Equal("PUT"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
- }))
- })
- It(`Invoke ReplaceKmsSettings successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ReplaceKmsSettings(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the KMSSettingsPrimaryCrk model
- kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
- kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the KMSSettingsSecondaryCrk model
- kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
- kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceKmsSettingsOptions model
- replaceKmsSettingsOptionsModel := new(schematicsv1.ReplaceKmsSettingsOptions)
- replaceKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
- replaceKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
- replaceKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ReplaceKmsSettings(replaceKmsSettingsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ReplaceKmsSettings with error: Operation request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the KMSSettingsPrimaryCrk model
- kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
- kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the KMSSettingsSecondaryCrk model
- kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
- kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceKmsSettingsOptions model
- replaceKmsSettingsOptionsModel := new(schematicsv1.ReplaceKmsSettingsOptions)
- replaceKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
- replaceKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
- replaceKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ReplaceKmsSettings(replaceKmsSettingsOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ReplaceKmsSettings successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the KMSSettingsPrimaryCrk model
- kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
- kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the KMSSettingsSecondaryCrk model
- kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
- kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
-
- // Construct an instance of the ReplaceKmsSettingsOptions model
- replaceKmsSettingsOptionsModel := new(schematicsv1.ReplaceKmsSettingsOptions)
- replaceKmsSettingsOptionsModel.Location = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
- replaceKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
- replaceKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
- replaceKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ReplaceKmsSettings(replaceKmsSettingsOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptions *GetDiscoveredKmsInstancesOptions) - Operation response error`, func() {
- getDiscoveredKmsInstancesPath := "/v2/settings/kms_instances"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getDiscoveredKmsInstancesPath))
- Expect(req.Method).To(Equal("GET"))
- Expect(req.URL.Query()["encryption_scheme"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["resource_group"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke GetDiscoveredKmsInstances with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetDiscoveredKmsInstancesOptions model
- getDiscoveredKmsInstancesOptionsModel := new(schematicsv1.GetDiscoveredKmsInstancesOptions)
- getDiscoveredKmsInstancesOptionsModel.EncryptionScheme = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Location = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.ResourceGroup = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Limit = core.Int64Ptr(int64(1))
- getDiscoveredKmsInstancesOptionsModel.Sort = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptions *GetDiscoveredKmsInstancesOptions)`, func() {
- getDiscoveredKmsInstancesPath := "/v2/settings/kms_instances"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getDiscoveredKmsInstancesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["encryption_scheme"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["resource_group"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "kms_instances": [{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "kms_crn": "KmsCrn", "kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "kms_public_endpoint": "KmsPublicEndpoint", "keys": [{"name": "Name", "crn": "Crn", "error": "Error"}]}]}`)
- }))
- })
- It(`Invoke GetDiscoveredKmsInstances successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the GetDiscoveredKmsInstancesOptions model
- getDiscoveredKmsInstancesOptionsModel := new(schematicsv1.GetDiscoveredKmsInstancesOptions)
- getDiscoveredKmsInstancesOptionsModel.EncryptionScheme = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Location = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.ResourceGroup = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Limit = core.Int64Ptr(int64(1))
- getDiscoveredKmsInstancesOptionsModel.Sort = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.GetDiscoveredKmsInstancesWithContext(ctx, getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.GetDiscoveredKmsInstancesWithContext(ctx, getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(getDiscoveredKmsInstancesPath))
- Expect(req.Method).To(Equal("GET"))
-
- Expect(req.URL.Query()["encryption_scheme"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["resource_group"]).To(Equal([]string{"testString"}))
- Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
- Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "kms_instances": [{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "kms_crn": "KmsCrn", "kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "kms_public_endpoint": "KmsPublicEndpoint", "keys": [{"name": "Name", "crn": "Crn", "error": "Error"}]}]}`)
- }))
- })
- It(`Invoke GetDiscoveredKmsInstances successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.GetDiscoveredKmsInstances(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the GetDiscoveredKmsInstancesOptions model
- getDiscoveredKmsInstancesOptionsModel := new(schematicsv1.GetDiscoveredKmsInstancesOptions)
- getDiscoveredKmsInstancesOptionsModel.EncryptionScheme = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Location = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.ResourceGroup = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Limit = core.Int64Ptr(int64(1))
- getDiscoveredKmsInstancesOptionsModel.Sort = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke GetDiscoveredKmsInstances with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetDiscoveredKmsInstancesOptions model
- getDiscoveredKmsInstancesOptionsModel := new(schematicsv1.GetDiscoveredKmsInstancesOptions)
- getDiscoveredKmsInstancesOptionsModel.EncryptionScheme = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Location = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.ResourceGroup = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Limit = core.Int64Ptr(int64(1))
- getDiscoveredKmsInstancesOptionsModel.Sort = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the GetDiscoveredKmsInstancesOptions model with no property values
- getDiscoveredKmsInstancesOptionsModelNew := new(schematicsv1.GetDiscoveredKmsInstancesOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke GetDiscoveredKmsInstances successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the GetDiscoveredKmsInstancesOptions model
- getDiscoveredKmsInstancesOptionsModel := new(schematicsv1.GetDiscoveredKmsInstancesOptions)
- getDiscoveredKmsInstancesOptionsModel.EncryptionScheme = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Location = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.ResourceGroup = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Limit = core.Int64Ptr(int64(1))
- getDiscoveredKmsInstancesOptionsModel.Sort = core.StringPtr("testString")
- getDiscoveredKmsInstancesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.GetDiscoveredKmsInstances(getDiscoveredKmsInstancesOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ProcessTemplateMetaData(processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions) - Operation response error`, func() {
- processTemplateMetaDataPath := "/v2/template_metadata_processor"
- Context(`Using mock server endpoint with invalid JSON response`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(processTemplateMetaDataPath))
- Expect(req.Method).To(Equal("POST"))
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, `} this is not valid json {`)
- }))
- })
- It(`Invoke ProcessTemplateMetaData with error: Operation response processing error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the ProcessTemplateMetaDataOptions model
- processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
- processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Source = externalSourceModel
- processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
- processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Expect response parsing to fail since we are receiving a text/plain response
- result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
-
- // Enable retries and test again
- schematicsService.EnableRetries(0, 0)
- result, response, operationErr = schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`ProcessTemplateMetaData(processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions)`, func() {
- processTemplateMetaDataPath := "/v2/template_metadata_processor"
- Context(`Using mock server endpoint with timeout`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(processTemplateMetaDataPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Sleep a short time to support a timeout test
- time.Sleep(100 * time.Millisecond)
-
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "Type", "variables": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}]}`)
- }))
- })
- It(`Invoke ProcessTemplateMetaData successfully with retries`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
- schematicsService.EnableRetries(0, 0)
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the ProcessTemplateMetaDataOptions model
- processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
- processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Source = externalSourceModel
- processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
- processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with a Context to test a timeout error
- ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc()
- _, _, operationErr := schematicsService.ProcessTemplateMetaDataWithContext(ctx, processTemplateMetaDataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
-
- // Disable retries and test again
- schematicsService.DisableRetries()
- result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- // Re-test the timeout error with retries disabled
- ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
- defer cancelFunc2()
- _, _, operationErr = schematicsService.ProcessTemplateMetaDataWithContext(ctx, processTemplateMetaDataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Verify the contents of the request
- Expect(req.URL.EscapedPath()).To(Equal(processTemplateMetaDataPath))
- Expect(req.Method).To(Equal("POST"))
-
- // For gzip-disabled operation, verify Content-Encoding is not set.
- Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
-
- // If there is a body, then make sure we can read it
- bodyBuf := new(bytes.Buffer)
- if req.Header.Get("Content-Encoding") == "gzip" {
- body, err := core.NewGzipDecompressionReader(req.Body)
- Expect(err).To(BeNil())
- _, err = bodyBuf.ReadFrom(body)
- Expect(err).To(BeNil())
- } else {
- _, err := bodyBuf.ReadFrom(req.Body)
- Expect(err).To(BeNil())
- }
- fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
-
- Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
- Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
- // Set mock response
- res.Header().Set("Content-type", "application/json")
- res.WriteHeader(200)
- fmt.Fprintf(res, "%s", `{"type": "Type", "variables": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}]}`)
- }))
- })
- It(`Invoke ProcessTemplateMetaData successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Invoke operation with nil options model (negative test)
- result, response, operationErr := schematicsService.ProcessTemplateMetaData(nil)
- Expect(operationErr).NotTo(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the ProcessTemplateMetaDataOptions model
- processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
- processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Source = externalSourceModel
- processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
- processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation with valid options model (positive test)
- result, response, operationErr = schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
- Expect(result).ToNot(BeNil())
-
- })
- It(`Invoke ProcessTemplateMetaData with error: Operation validation and request error`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the ProcessTemplateMetaDataOptions model
- processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
- processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Source = externalSourceModel
- processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
- processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
- // Invoke operation with empty URL (negative test)
- err := schematicsService.SetServiceURL("")
- Expect(err).To(BeNil())
- result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
- Expect(operationErr).ToNot(BeNil())
- Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- // Construct a second instance of the ProcessTemplateMetaDataOptions model with no property values
- processTemplateMetaDataOptionsModelNew := new(schematicsv1.ProcessTemplateMetaDataOptions)
- // Invoke operation with invalid model (negative test)
- result, response, operationErr = schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModelNew)
- Expect(operationErr).ToNot(BeNil())
- Expect(response).To(BeNil())
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- Context(`Using mock server endpoint with missing response body`, func() {
- BeforeEach(func() {
- testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
- defer GinkgoRecover()
-
- // Set success status code with no respoonse body
- res.WriteHeader(200)
- }))
- })
- It(`Invoke ProcessTemplateMetaData successfully`, func() {
- schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: testServer.URL,
- Authenticator: &core.NoAuthAuthenticator{},
- })
- Expect(serviceErr).To(BeNil())
- Expect(schematicsService).ToNot(BeNil())
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
-
- // Construct an instance of the ProcessTemplateMetaDataOptions model
- processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
- processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Source = externalSourceModel
- processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
- processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
- processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
-
- // Invoke operation
- result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
- Expect(operationErr).To(BeNil())
- Expect(response).ToNot(BeNil())
-
- // Verify a nil result
- Expect(result).To(BeNil())
- })
- AfterEach(func() {
- testServer.Close()
- })
- })
- })
- Describe(`Model constructor tests`, func() {
- Context(`Using a service client instance`, func() {
- schematicsService, _ := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
- URL: "http://schematicsv1modelgenerator.com",
- Authenticator: &core.NoAuthAuthenticator{},
- })
- It(`Invoke NewApplyWorkspaceCommandOptions successfully`, func() {
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- Expect(workspaceActivityOptionsTemplateModel).ToNot(BeNil())
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
- Expect(workspaceActivityOptionsTemplateModel.Target).To(Equal([]string{"testString"}))
- Expect(workspaceActivityOptionsTemplateModel.TfVars).To(Equal([]string{"testString"}))
-
- // Construct an instance of the ApplyWorkspaceCommandOptions model
- wID := "testString"
- refreshToken := "testString"
- applyWorkspaceCommandOptionsModel := schematicsService.NewApplyWorkspaceCommandOptions(wID, refreshToken)
- applyWorkspaceCommandOptionsModel.SetWID("testString")
- applyWorkspaceCommandOptionsModel.SetRefreshToken("testString")
- applyWorkspaceCommandOptionsModel.SetActionOptions(workspaceActivityOptionsTemplateModel)
- applyWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(applyWorkspaceCommandOptionsModel).ToNot(BeNil())
- Expect(applyWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(applyWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(applyWorkspaceCommandOptionsModel.ActionOptions).To(Equal(workspaceActivityOptionsTemplateModel))
- Expect(applyWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewCreateActionOptions successfully`, func() {
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- Expect(userStateModel).ToNot(BeNil())
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(userStateModel.State).To(Equal(core.StringPtr("draft")))
- Expect(userStateModel.SetBy).To(Equal(core.StringPtr("testString")))
- Expect(userStateModel.SetAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- Expect(externalSourceGitModel).ToNot(BeNil())
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
- Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- Expect(externalSourceCatalogModel).ToNot(BeNil())
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
- Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- Expect(externalSourceModel).ToNot(BeNil())
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
- Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
- Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- Expect(bastionResourceDefinitionModel).ToNot(BeNil())
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
- Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- Expect(variableMetadataModel).ToNot(BeNil())
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
- Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
- Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- Expect(variableDataModel).ToNot(BeNil())
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
- Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- Expect(actionStateModel).ToNot(BeNil())
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
- Expect(actionStateModel.StatusCode).To(Equal(core.StringPtr("normal")))
- Expect(actionStateModel.StatusJobID).To(Equal(core.StringPtr("testString")))
- Expect(actionStateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- Expect(systemLockModel).ToNot(BeNil())
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(systemLockModel.SysLocked).To(Equal(core.BoolPtr(true)))
- Expect(systemLockModel.SysLockedBy).To(Equal(core.StringPtr("testString")))
- Expect(systemLockModel.SysLockedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the CreateActionOptions model
- createActionOptionsModel := schematicsService.NewCreateActionOptions()
- createActionOptionsModel.SetName("Stop Action")
- createActionOptionsModel.SetDescription("This Action can be used to Stop the targets")
- createActionOptionsModel.SetLocation("us-south")
- createActionOptionsModel.SetResourceGroup("testString")
- createActionOptionsModel.SetTags([]string{"testString"})
- createActionOptionsModel.SetUserState(userStateModel)
- createActionOptionsModel.SetSourceReadmeURL("testString")
- createActionOptionsModel.SetSource(externalSourceModel)
- createActionOptionsModel.SetSourceType("local")
- createActionOptionsModel.SetCommandParameter("testString")
- createActionOptionsModel.SetBastion(bastionResourceDefinitionModel)
- createActionOptionsModel.SetInventory("testString")
- createActionOptionsModel.SetBastionCredential(variableDataModel)
- createActionOptionsModel.SetCredentials([]schematicsv1.VariableData{*variableDataModel})
- createActionOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
- createActionOptionsModel.SetOutputs([]schematicsv1.VariableData{*variableDataModel})
- createActionOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
- createActionOptionsModel.SetState(actionStateModel)
- createActionOptionsModel.SetSysLock(systemLockModel)
- createActionOptionsModel.SetXGithubToken("testString")
- createActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(createActionOptionsModel).ToNot(BeNil())
- Expect(createActionOptionsModel.Name).To(Equal(core.StringPtr("Stop Action")))
- Expect(createActionOptionsModel.Description).To(Equal(core.StringPtr("This Action can be used to Stop the targets")))
- Expect(createActionOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(createActionOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(createActionOptionsModel.Tags).To(Equal([]string{"testString"}))
- Expect(createActionOptionsModel.UserState).To(Equal(userStateModel))
- Expect(createActionOptionsModel.SourceReadmeURL).To(Equal(core.StringPtr("testString")))
- Expect(createActionOptionsModel.Source).To(Equal(externalSourceModel))
- Expect(createActionOptionsModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(createActionOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
- Expect(createActionOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
- Expect(createActionOptionsModel.Inventory).To(Equal(core.StringPtr("testString")))
- Expect(createActionOptionsModel.BastionCredential).To(Equal(variableDataModel))
- Expect(createActionOptionsModel.Credentials).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(createActionOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(createActionOptionsModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(createActionOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(createActionOptionsModel.State).To(Equal(actionStateModel))
- Expect(createActionOptionsModel.SysLock).To(Equal(systemLockModel))
- Expect(createActionOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
- Expect(createActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewCreateInventoryOptions successfully`, func() {
- // Construct an instance of the CreateInventoryOptions model
- createInventoryOptionsModel := schematicsService.NewCreateInventoryOptions()
- createInventoryOptionsModel.SetName("testString")
- createInventoryOptionsModel.SetDescription("testString")
- createInventoryOptionsModel.SetLocation("us-south")
- createInventoryOptionsModel.SetResourceGroup("testString")
- createInventoryOptionsModel.SetInventoriesIni("testString")
- createInventoryOptionsModel.SetResourceQueries([]string{"testString"})
- createInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(createInventoryOptionsModel).ToNot(BeNil())
- Expect(createInventoryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(createInventoryOptionsModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(createInventoryOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(createInventoryOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(createInventoryOptionsModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
- Expect(createInventoryOptionsModel.ResourceQueries).To(Equal([]string{"testString"}))
- Expect(createInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewCreateJobOptions successfully`, func() {
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- Expect(variableMetadataModel).ToNot(BeNil())
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
- Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
- Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- Expect(variableDataModel).ToNot(BeNil())
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
- Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- Expect(jobStatusWorkitemModel).ToNot(BeNil())
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusWorkitemModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusWorkitemModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- Expect(jobStatusFlowModel).ToNot(BeNil())
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusFlowModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusFlowModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusFlowModel.Workitems).To(Equal([]schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}))
- Expect(jobStatusFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- Expect(jobStatusTemplateModel).ToNot(BeNil())
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
- Expect(jobStatusTemplateModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusTemplateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- Expect(jobStatusWorkspaceModel).ToNot(BeNil())
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkspaceModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusWorkspaceModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkspaceModel.FlowStatus).To(Equal(jobStatusFlowModel))
- Expect(jobStatusWorkspaceModel.TemplateStatus).To(Equal([]schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}))
- Expect(jobStatusWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- Expect(jobStatusActionModel).ToNot(BeNil())
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusActionModel.ActionName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusActionModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.BastionStatusCode).To(Equal(core.StringPtr("none")))
- Expect(jobStatusActionModel.BastionStatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.TargetsStatusCode).To(Equal(core.StringPtr("none")))
- Expect(jobStatusActionModel.TargetsStatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- Expect(jobStatusSchematicsResourcesModel).ToNot(BeNil())
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusSchematicsResourcesModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusSchematicsResourcesModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusSchematicsResourcesModel.SchematicsResourceID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusSchematicsResourcesModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- Expect(jobStatusSystemModel).ToNot(BeNil())
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusSystemModel.SystemStatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusSystemModel.SystemStatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusSystemModel.SchematicsResourceStatus).To(Equal([]schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}))
- Expect(jobStatusSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- Expect(jobStatusModel).ToNot(BeNil())
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
- Expect(jobStatusModel.WorkspaceJobStatus).To(Equal(jobStatusWorkspaceModel))
- Expect(jobStatusModel.ActionJobStatus).To(Equal(jobStatusActionModel))
- Expect(jobStatusModel.SystemJobStatus).To(Equal(jobStatusSystemModel))
- Expect(jobStatusModel.FlowJobStatus).To(Equal(jobStatusFlowModel))
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- Expect(jobDataTemplateModel).ToNot(BeNil())
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
- Expect(jobDataTemplateModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataTemplateModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataTemplateModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- Expect(jobDataWorkspaceModel).ToNot(BeNil())
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkspaceModel.FlowID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkspaceModel.FlowName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkspaceModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkspaceModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkspaceModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkspaceModel.TemplateData).To(Equal([]schematicsv1.JobDataTemplate{*jobDataTemplateModel}))
- Expect(jobDataWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- Expect(inventoryResourceRecordModel).ToNot(BeNil())
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
- Expect(inventoryResourceRecordModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(inventoryResourceRecordModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.ResourceQueries).To(Equal([]string{"testString"}))
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- Expect(jobDataActionModel).ToNot(BeNil())
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
- Expect(jobDataActionModel.ActionName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataActionModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataActionModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataActionModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
- Expect(jobDataActionModel.InventoryRecord).To(Equal(inventoryResourceRecordModel))
- Expect(jobDataActionModel.MaterializedInventory).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- Expect(jobDataSystemModel).ToNot(BeNil())
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataSystemModel.KeyID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataSystemModel.SchematicsResourceID).To(Equal([]string{"testString"}))
- Expect(jobDataSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- Expect(externalSourceGitModel).ToNot(BeNil())
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
- Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- Expect(externalSourceCatalogModel).ToNot(BeNil())
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
- Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- Expect(externalSourceModel).ToNot(BeNil())
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
- Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
- Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- Expect(jobDataWorkItemModel).ToNot(BeNil())
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataWorkItemModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.Layers).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(jobDataWorkItemModel.Source).To(Equal(externalSourceModel))
- Expect(jobDataWorkItemModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkItemModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkItemModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkItemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- Expect(jobDataFlowModel).ToNot(BeNil())
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataFlowModel.Workitems).To(Equal([]schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}))
- Expect(jobDataFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- Expect(jobDataModel).ToNot(BeNil())
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
- Expect(jobDataModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
- Expect(jobDataModel.WorkspaceJobData).To(Equal(jobDataWorkspaceModel))
- Expect(jobDataModel.ActionJobData).To(Equal(jobDataActionModel))
- Expect(jobDataModel.SystemJobData).To(Equal(jobDataSystemModel))
- Expect(jobDataModel.FlowJobData).To(Equal(jobDataFlowModel))
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- Expect(bastionResourceDefinitionModel).ToNot(BeNil())
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
- Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
- Expect(jobLogSummaryRepoDownloadJobModel).ToNot(BeNil())
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
- Expect(jobLogSummaryWorkspaceJobModel).ToNot(BeNil())
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- Expect(jobLogSummaryWorkitemsModel).ToNot(BeNil())
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
- Expect(jobLogSummaryWorkitemsModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
- Expect(jobLogSummaryWorkitemsModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(jobLogSummaryWorkitemsModel.LogURL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- Expect(jobLogSummaryFlowJobModel).ToNot(BeNil())
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
- Expect(jobLogSummaryFlowJobModel.Workitems).To(Equal([]schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}))
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- Expect(jobLogSummaryActionJobRecapModel).ToNot(BeNil())
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
- Expect(jobLogSummaryActionJobRecapModel.Target).To(Equal([]string{"testString"}))
- Expect(jobLogSummaryActionJobRecapModel.Ok).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Changed).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Skipped).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Unreachable).To(Equal(core.Float64Ptr(float64(72.5))))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- Expect(jobLogSummaryActionJobModel).ToNot(BeNil())
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
- Expect(jobLogSummaryActionJobModel.Recap).To(Equal(jobLogSummaryActionJobRecapModel))
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- Expect(jobLogSummarySystemJobModel).ToNot(BeNil())
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
- Expect(jobLogSummarySystemJobModel.Success).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummarySystemJobModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- Expect(jobLogSummaryModel).ToNot(BeNil())
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
- Expect(jobLogSummaryModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
- Expect(jobLogSummaryModel.RepoDownloadJob).To(Equal(jobLogSummaryRepoDownloadJobModel))
- Expect(jobLogSummaryModel.WorkspaceJob).To(Equal(jobLogSummaryWorkspaceJobModel))
- Expect(jobLogSummaryModel.FlowJob).To(Equal(jobLogSummaryFlowJobModel))
- Expect(jobLogSummaryModel.ActionJob).To(Equal(jobLogSummaryActionJobModel))
- Expect(jobLogSummaryModel.SystemJob).To(Equal(jobLogSummarySystemJobModel))
-
- // Construct an instance of the CreateJobOptions model
- refreshToken := "testString"
- createJobOptionsModel := schematicsService.NewCreateJobOptions(refreshToken)
- createJobOptionsModel.SetRefreshToken("testString")
- createJobOptionsModel.SetCommandObject("workspace")
- createJobOptionsModel.SetCommandObjectID("testString")
- createJobOptionsModel.SetCommandName("workspace_plan")
- createJobOptionsModel.SetCommandParameter("testString")
- createJobOptionsModel.SetCommandOptions([]string{"testString"})
- createJobOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
- createJobOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
- createJobOptionsModel.SetTags([]string{"testString"})
- createJobOptionsModel.SetLocation("us-south")
- createJobOptionsModel.SetStatus(jobStatusModel)
- createJobOptionsModel.SetData(jobDataModel)
- createJobOptionsModel.SetBastion(bastionResourceDefinitionModel)
- createJobOptionsModel.SetLogSummary(jobLogSummaryModel)
- createJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(createJobOptionsModel).ToNot(BeNil())
- Expect(createJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(createJobOptionsModel.CommandObject).To(Equal(core.StringPtr("workspace")))
- Expect(createJobOptionsModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
- Expect(createJobOptionsModel.CommandName).To(Equal(core.StringPtr("workspace_plan")))
- Expect(createJobOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
- Expect(createJobOptionsModel.CommandOptions).To(Equal([]string{"testString"}))
- Expect(createJobOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(createJobOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(createJobOptionsModel.Tags).To(Equal([]string{"testString"}))
- Expect(createJobOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(createJobOptionsModel.Status).To(Equal(jobStatusModel))
- Expect(createJobOptionsModel.Data).To(Equal(jobDataModel))
- Expect(createJobOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
- Expect(createJobOptionsModel.LogSummary).To(Equal(jobLogSummaryModel))
- Expect(createJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewCreateResourceQueryOptions successfully`, func() {
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- Expect(resourceQueryParamModel).ToNot(BeNil())
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
- Expect(resourceQueryParamModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(resourceQueryParamModel.Value).To(Equal(core.StringPtr("testString")))
- Expect(resourceQueryParamModel.Description).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- Expect(resourceQueryModel).ToNot(BeNil())
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
- Expect(resourceQueryModel.QueryType).To(Equal(core.StringPtr("workspaces")))
- Expect(resourceQueryModel.QueryCondition).To(Equal([]schematicsv1.ResourceQueryParam{*resourceQueryParamModel}))
- Expect(resourceQueryModel.QuerySelect).To(Equal([]string{"testString"}))
-
- // Construct an instance of the CreateResourceQueryOptions model
- createResourceQueryOptionsModel := schematicsService.NewCreateResourceQueryOptions()
- createResourceQueryOptionsModel.SetType("vsi")
- createResourceQueryOptionsModel.SetName("testString")
- createResourceQueryOptionsModel.SetQueries([]schematicsv1.ResourceQuery{*resourceQueryModel})
- createResourceQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(createResourceQueryOptionsModel).ToNot(BeNil())
- Expect(createResourceQueryOptionsModel.Type).To(Equal(core.StringPtr("vsi")))
- Expect(createResourceQueryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(createResourceQueryOptionsModel.Queries).To(Equal([]schematicsv1.ResourceQuery{*resourceQueryModel}))
- Expect(createResourceQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewCreateWorkspaceDeletionJobOptions successfully`, func() {
- // Construct an instance of the CreateWorkspaceDeletionJobOptions model
- refreshToken := "testString"
- createWorkspaceDeletionJobOptionsModel := schematicsService.NewCreateWorkspaceDeletionJobOptions(refreshToken)
- createWorkspaceDeletionJobOptionsModel.SetRefreshToken("testString")
- createWorkspaceDeletionJobOptionsModel.SetNewDeleteWorkspaces(true)
- createWorkspaceDeletionJobOptionsModel.SetNewDestroyResources(true)
- createWorkspaceDeletionJobOptionsModel.SetNewJob("testString")
- createWorkspaceDeletionJobOptionsModel.SetNewVersion("testString")
- createWorkspaceDeletionJobOptionsModel.SetNewWorkspaces([]string{"testString"})
- createWorkspaceDeletionJobOptionsModel.SetDestroyResources("testString")
- createWorkspaceDeletionJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(createWorkspaceDeletionJobOptionsModel).ToNot(BeNil())
- Expect(createWorkspaceDeletionJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces).To(Equal(core.BoolPtr(true)))
- Expect(createWorkspaceDeletionJobOptionsModel.NewDestroyResources).To(Equal(core.BoolPtr(true)))
- Expect(createWorkspaceDeletionJobOptionsModel.NewJob).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceDeletionJobOptionsModel.NewVersion).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceDeletionJobOptionsModel.NewWorkspaces).To(Equal([]string{"testString"}))
- Expect(createWorkspaceDeletionJobOptionsModel.DestroyResources).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceDeletionJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewCreateWorkspaceOptions successfully`, func() {
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- Expect(catalogRefModel).ToNot(BeNil())
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
- Expect(catalogRefModel.DryRun).To(Equal(core.BoolPtr(true)))
- Expect(catalogRefModel.OwningAccount).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemIconURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemID).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemName).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemReadmeURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.LaunchURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- Expect(sharedTargetDataModel).ToNot(BeNil())
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
- Expect(sharedTargetDataModel.ClusterCreatedOn).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterID).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterName).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterType).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.EntitlementKeys).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(sharedTargetDataModel.Namespace).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.Region).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ResourceGroupID).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.WorkerCount).To(Equal(core.Int64Ptr(int64(26))))
- Expect(sharedTargetDataModel.WorkerMachineType).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- Expect(workspaceVariableRequestModel).ToNot(BeNil())
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
- Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- Expect(templateSourceDataRequestModel).ToNot(BeNil())
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- Expect(templateSourceDataRequestModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(templateSourceDataRequestModel.Folder).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Compact).To(Equal(core.BoolPtr(true)))
- Expect(templateSourceDataRequestModel.InitStateFile).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Type).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.UninstallScriptName).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Values).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.ValuesMetadata).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(templateSourceDataRequestModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
-
- // Construct an instance of the TemplateRepoRequest model
- templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
- Expect(templateRepoRequestModel).ToNot(BeNil())
- templateRepoRequestModel.Branch = core.StringPtr("testString")
- templateRepoRequestModel.Release = core.StringPtr("testString")
- templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoRequestModel.URL = core.StringPtr("testString")
- Expect(templateRepoRequestModel.Branch).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoRequestModel.Release).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoRequestModel.RepoShaValue).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoRequestModel.RepoURL).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoRequestModel.URL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the WorkspaceStatusRequest model
- workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
- Expect(workspaceStatusRequestModel).ToNot(BeNil())
- workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(workspaceStatusRequestModel.Frozen).To(Equal(core.BoolPtr(true)))
- Expect(workspaceStatusRequestModel.FrozenAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
- Expect(workspaceStatusRequestModel.FrozenBy).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusRequestModel.Locked).To(Equal(core.BoolPtr(true)))
- Expect(workspaceStatusRequestModel.LockedBy).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusRequestModel.LockedTime).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the CreateWorkspaceOptions model
- createWorkspaceOptionsModel := schematicsService.NewCreateWorkspaceOptions()
- createWorkspaceOptionsModel.SetAppliedShareddataIds([]string{"testString"})
- createWorkspaceOptionsModel.SetCatalogRef(catalogRefModel)
- createWorkspaceOptionsModel.SetDescription("testString")
- createWorkspaceOptionsModel.SetLocation("testString")
- createWorkspaceOptionsModel.SetName("testString")
- createWorkspaceOptionsModel.SetResourceGroup("testString")
- createWorkspaceOptionsModel.SetSharedData(sharedTargetDataModel)
- createWorkspaceOptionsModel.SetTags([]string{"testString"})
- createWorkspaceOptionsModel.SetTemplateData([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel})
- createWorkspaceOptionsModel.SetTemplateRef("testString")
- createWorkspaceOptionsModel.SetTemplateRepo(templateRepoRequestModel)
- createWorkspaceOptionsModel.SetType([]string{"testString"})
- createWorkspaceOptionsModel.SetWorkspaceStatus(workspaceStatusRequestModel)
- createWorkspaceOptionsModel.SetXGithubToken("testString")
- createWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(createWorkspaceOptionsModel).ToNot(BeNil())
- Expect(createWorkspaceOptionsModel.AppliedShareddataIds).To(Equal([]string{"testString"}))
- Expect(createWorkspaceOptionsModel.CatalogRef).To(Equal(catalogRefModel))
- Expect(createWorkspaceOptionsModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceOptionsModel.Location).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceOptionsModel.SharedData).To(Equal(sharedTargetDataModel))
- Expect(createWorkspaceOptionsModel.Tags).To(Equal([]string{"testString"}))
- Expect(createWorkspaceOptionsModel.TemplateData).To(Equal([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}))
- Expect(createWorkspaceOptionsModel.TemplateRef).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceOptionsModel.TemplateRepo).To(Equal(templateRepoRequestModel))
- Expect(createWorkspaceOptionsModel.Type).To(Equal([]string{"testString"}))
- Expect(createWorkspaceOptionsModel.WorkspaceStatus).To(Equal(workspaceStatusRequestModel))
- Expect(createWorkspaceOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
- Expect(createWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewDeleteActionOptions successfully`, func() {
- // Construct an instance of the DeleteActionOptions model
- actionID := "testString"
- deleteActionOptionsModel := schematicsService.NewDeleteActionOptions(actionID)
- deleteActionOptionsModel.SetActionID("testString")
- deleteActionOptionsModel.SetForce(true)
- deleteActionOptionsModel.SetPropagate(true)
- deleteActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(deleteActionOptionsModel).ToNot(BeNil())
- Expect(deleteActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
- Expect(deleteActionOptionsModel.Force).To(Equal(core.BoolPtr(true)))
- Expect(deleteActionOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
- Expect(deleteActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewDeleteInventoryOptions successfully`, func() {
- // Construct an instance of the DeleteInventoryOptions model
- inventoryID := "testString"
- deleteInventoryOptionsModel := schematicsService.NewDeleteInventoryOptions(inventoryID)
- deleteInventoryOptionsModel.SetInventoryID("testString")
- deleteInventoryOptionsModel.SetForce(true)
- deleteInventoryOptionsModel.SetPropagate(true)
- deleteInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(deleteInventoryOptionsModel).ToNot(BeNil())
- Expect(deleteInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
- Expect(deleteInventoryOptionsModel.Force).To(Equal(core.BoolPtr(true)))
- Expect(deleteInventoryOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
- Expect(deleteInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewDeleteJobOptions successfully`, func() {
- // Construct an instance of the DeleteJobOptions model
- jobID := "testString"
- refreshToken := "testString"
- deleteJobOptionsModel := schematicsService.NewDeleteJobOptions(jobID, refreshToken)
- deleteJobOptionsModel.SetJobID("testString")
- deleteJobOptionsModel.SetRefreshToken("testString")
- deleteJobOptionsModel.SetForce(true)
- deleteJobOptionsModel.SetPropagate(true)
- deleteJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(deleteJobOptionsModel).ToNot(BeNil())
- Expect(deleteJobOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(deleteJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(deleteJobOptionsModel.Force).To(Equal(core.BoolPtr(true)))
- Expect(deleteJobOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
- Expect(deleteJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewDeleteResourcesQueryOptions successfully`, func() {
- // Construct an instance of the DeleteResourcesQueryOptions model
- queryID := "testString"
- deleteResourcesQueryOptionsModel := schematicsService.NewDeleteResourcesQueryOptions(queryID)
- deleteResourcesQueryOptionsModel.SetQueryID("testString")
- deleteResourcesQueryOptionsModel.SetForce(true)
- deleteResourcesQueryOptionsModel.SetPropagate(true)
- deleteResourcesQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(deleteResourcesQueryOptionsModel).ToNot(BeNil())
- Expect(deleteResourcesQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
- Expect(deleteResourcesQueryOptionsModel.Force).To(Equal(core.BoolPtr(true)))
- Expect(deleteResourcesQueryOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
- Expect(deleteResourcesQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewDeleteWorkspaceActivityOptions successfully`, func() {
- // Construct an instance of the DeleteWorkspaceActivityOptions model
- wID := "testString"
- activityID := "testString"
- deleteWorkspaceActivityOptionsModel := schematicsService.NewDeleteWorkspaceActivityOptions(wID, activityID)
- deleteWorkspaceActivityOptionsModel.SetWID("testString")
- deleteWorkspaceActivityOptionsModel.SetActivityID("testString")
- deleteWorkspaceActivityOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(deleteWorkspaceActivityOptionsModel).ToNot(BeNil())
- Expect(deleteWorkspaceActivityOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(deleteWorkspaceActivityOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
- Expect(deleteWorkspaceActivityOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewDeleteWorkspaceOptions successfully`, func() {
- // Construct an instance of the DeleteWorkspaceOptions model
- wID := "testString"
- deleteWorkspaceOptionsModel := schematicsService.NewDeleteWorkspaceOptions(wID)
- deleteWorkspaceOptionsModel.SetWID("testString")
- deleteWorkspaceOptionsModel.SetDestroyResources(true)
- deleteWorkspaceOptionsModel.SetRefreshToken("testString")
- deleteWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(deleteWorkspaceOptionsModel).ToNot(BeNil())
- Expect(deleteWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(deleteWorkspaceOptionsModel.DestroyResources).To(Equal(core.BoolPtr(true)))
- Expect(deleteWorkspaceOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(deleteWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewDestroyWorkspaceCommandOptions successfully`, func() {
- // Construct an instance of the WorkspaceActivityOptionsTemplate model
- workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
- Expect(workspaceActivityOptionsTemplateModel).ToNot(BeNil())
- workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
- workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
- Expect(workspaceActivityOptionsTemplateModel.Target).To(Equal([]string{"testString"}))
- Expect(workspaceActivityOptionsTemplateModel.TfVars).To(Equal([]string{"testString"}))
-
- // Construct an instance of the DestroyWorkspaceCommandOptions model
- wID := "testString"
- refreshToken := "testString"
- destroyWorkspaceCommandOptionsModel := schematicsService.NewDestroyWorkspaceCommandOptions(wID, refreshToken)
- destroyWorkspaceCommandOptionsModel.SetWID("testString")
- destroyWorkspaceCommandOptionsModel.SetRefreshToken("testString")
- destroyWorkspaceCommandOptionsModel.SetActionOptions(workspaceActivityOptionsTemplateModel)
- destroyWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(destroyWorkspaceCommandOptionsModel).ToNot(BeNil())
- Expect(destroyWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(destroyWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(destroyWorkspaceCommandOptionsModel.ActionOptions).To(Equal(workspaceActivityOptionsTemplateModel))
- Expect(destroyWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewExecuteResourceQueryOptions successfully`, func() {
- // Construct an instance of the ExecuteResourceQueryOptions model
- queryID := "testString"
- executeResourceQueryOptionsModel := schematicsService.NewExecuteResourceQueryOptions(queryID)
- executeResourceQueryOptionsModel.SetQueryID("testString")
- executeResourceQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(executeResourceQueryOptionsModel).ToNot(BeNil())
- Expect(executeResourceQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
- Expect(executeResourceQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewExternalSource successfully`, func() {
- sourceType := "local"
- _model, err := schematicsService.NewExternalSource(sourceType)
- Expect(_model).ToNot(BeNil())
- Expect(err).To(BeNil())
- })
- It(`Invoke NewGetActionOptions successfully`, func() {
- // Construct an instance of the GetActionOptions model
- actionID := "testString"
- getActionOptionsModel := schematicsService.NewGetActionOptions(actionID)
- getActionOptionsModel.SetActionID("testString")
- getActionOptionsModel.SetProfile("summary")
- getActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getActionOptionsModel).ToNot(BeNil())
- Expect(getActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
- Expect(getActionOptionsModel.Profile).To(Equal(core.StringPtr("summary")))
- Expect(getActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetAllWorkspaceInputsOptions successfully`, func() {
- // Construct an instance of the GetAllWorkspaceInputsOptions model
- wID := "testString"
- getAllWorkspaceInputsOptionsModel := schematicsService.NewGetAllWorkspaceInputsOptions(wID)
- getAllWorkspaceInputsOptionsModel.SetWID("testString")
- getAllWorkspaceInputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getAllWorkspaceInputsOptionsModel).ToNot(BeNil())
- Expect(getAllWorkspaceInputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getAllWorkspaceInputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetDiscoveredKmsInstancesOptions successfully`, func() {
- // Construct an instance of the GetDiscoveredKmsInstancesOptions model
- encryptionScheme := "testString"
- location := "testString"
- getDiscoveredKmsInstancesOptionsModel := schematicsService.NewGetDiscoveredKmsInstancesOptions(encryptionScheme, location)
- getDiscoveredKmsInstancesOptionsModel.SetEncryptionScheme("testString")
- getDiscoveredKmsInstancesOptionsModel.SetLocation("testString")
- getDiscoveredKmsInstancesOptionsModel.SetResourceGroup("testString")
- getDiscoveredKmsInstancesOptionsModel.SetLimit(int64(1))
- getDiscoveredKmsInstancesOptionsModel.SetSort("testString")
- getDiscoveredKmsInstancesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getDiscoveredKmsInstancesOptionsModel).ToNot(BeNil())
- Expect(getDiscoveredKmsInstancesOptionsModel.EncryptionScheme).To(Equal(core.StringPtr("testString")))
- Expect(getDiscoveredKmsInstancesOptionsModel.Location).To(Equal(core.StringPtr("testString")))
- Expect(getDiscoveredKmsInstancesOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(getDiscoveredKmsInstancesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
- Expect(getDiscoveredKmsInstancesOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
- Expect(getDiscoveredKmsInstancesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetInventoryOptions successfully`, func() {
- // Construct an instance of the GetInventoryOptions model
- inventoryID := "testString"
- getInventoryOptionsModel := schematicsService.NewGetInventoryOptions(inventoryID)
- getInventoryOptionsModel.SetInventoryID("testString")
- getInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getInventoryOptionsModel).ToNot(BeNil())
- Expect(getInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
- Expect(getInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetInventoryValueOptions successfully`, func() {
- // Construct an instance of the GetInventoryValueOptions model
- inventoryID := "testString"
- varName := "testString"
- getInventoryValueOptionsModel := schematicsService.NewGetInventoryValueOptions(inventoryID, varName)
- getInventoryValueOptionsModel.SetInventoryID("testString")
- getInventoryValueOptionsModel.SetVarName("testString")
- getInventoryValueOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getInventoryValueOptionsModel).ToNot(BeNil())
- Expect(getInventoryValueOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
- Expect(getInventoryValueOptionsModel.VarName).To(Equal(core.StringPtr("testString")))
- Expect(getInventoryValueOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetJobOptions successfully`, func() {
- // Construct an instance of the GetJobOptions model
- jobID := "testString"
- getJobOptionsModel := schematicsService.NewGetJobOptions(jobID)
- getJobOptionsModel.SetJobID("testString")
- getJobOptionsModel.SetProfile("summary")
- getJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getJobOptionsModel).ToNot(BeNil())
- Expect(getJobOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(getJobOptionsModel.Profile).To(Equal(core.StringPtr("summary")))
- Expect(getJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetKmsSettingsOptions successfully`, func() {
- // Construct an instance of the GetKmsSettingsOptions model
- location := "testString"
- getKmsSettingsOptionsModel := schematicsService.NewGetKmsSettingsOptions(location)
- getKmsSettingsOptionsModel.SetLocation("testString")
- getKmsSettingsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getKmsSettingsOptionsModel).ToNot(BeNil())
- Expect(getKmsSettingsOptionsModel.Location).To(Equal(core.StringPtr("testString")))
- Expect(getKmsSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetResourcesQueryOptions successfully`, func() {
- // Construct an instance of the GetResourcesQueryOptions model
- queryID := "testString"
- getResourcesQueryOptionsModel := schematicsService.NewGetResourcesQueryOptions(queryID)
- getResourcesQueryOptionsModel.SetQueryID("testString")
- getResourcesQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getResourcesQueryOptionsModel).ToNot(BeNil())
- Expect(getResourcesQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
- Expect(getResourcesQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetSchematicsVersionOptions successfully`, func() {
- // Construct an instance of the GetSchematicsVersionOptions model
- getSchematicsVersionOptionsModel := schematicsService.NewGetSchematicsVersionOptions()
- getSchematicsVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getSchematicsVersionOptionsModel).ToNot(BeNil())
- Expect(getSchematicsVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetTemplateActivityLogOptions successfully`, func() {
- // Construct an instance of the GetTemplateActivityLogOptions model
- wID := "testString"
- tID := "testString"
- activityID := "testString"
- getTemplateActivityLogOptionsModel := schematicsService.NewGetTemplateActivityLogOptions(wID, tID, activityID)
- getTemplateActivityLogOptionsModel.SetWID("testString")
- getTemplateActivityLogOptionsModel.SetTID("testString")
- getTemplateActivityLogOptionsModel.SetActivityID("testString")
- getTemplateActivityLogOptionsModel.SetLogTfCmd(true)
- getTemplateActivityLogOptionsModel.SetLogTfPrefix(true)
- getTemplateActivityLogOptionsModel.SetLogTfNullResource(true)
- getTemplateActivityLogOptionsModel.SetLogTfAnsible(true)
- getTemplateActivityLogOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getTemplateActivityLogOptionsModel).ToNot(BeNil())
- Expect(getTemplateActivityLogOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getTemplateActivityLogOptionsModel.TID).To(Equal(core.StringPtr("testString")))
- Expect(getTemplateActivityLogOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
- Expect(getTemplateActivityLogOptionsModel.LogTfCmd).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateActivityLogOptionsModel.LogTfPrefix).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateActivityLogOptionsModel.LogTfNullResource).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateActivityLogOptionsModel.LogTfAnsible).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateActivityLogOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetTemplateLogsOptions successfully`, func() {
- // Construct an instance of the GetTemplateLogsOptions model
- wID := "testString"
- tID := "testString"
- getTemplateLogsOptionsModel := schematicsService.NewGetTemplateLogsOptions(wID, tID)
- getTemplateLogsOptionsModel.SetWID("testString")
- getTemplateLogsOptionsModel.SetTID("testString")
- getTemplateLogsOptionsModel.SetLogTfCmd(true)
- getTemplateLogsOptionsModel.SetLogTfPrefix(true)
- getTemplateLogsOptionsModel.SetLogTfNullResource(true)
- getTemplateLogsOptionsModel.SetLogTfAnsible(true)
- getTemplateLogsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getTemplateLogsOptionsModel).ToNot(BeNil())
- Expect(getTemplateLogsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getTemplateLogsOptionsModel.TID).To(Equal(core.StringPtr("testString")))
- Expect(getTemplateLogsOptionsModel.LogTfCmd).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateLogsOptionsModel.LogTfPrefix).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateLogsOptionsModel.LogTfNullResource).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateLogsOptionsModel.LogTfAnsible).To(Equal(core.BoolPtr(true)))
- Expect(getTemplateLogsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceActivityLogsOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceActivityLogsOptions model
- wID := "testString"
- activityID := "testString"
- getWorkspaceActivityLogsOptionsModel := schematicsService.NewGetWorkspaceActivityLogsOptions(wID, activityID)
- getWorkspaceActivityLogsOptionsModel.SetWID("testString")
- getWorkspaceActivityLogsOptionsModel.SetActivityID("testString")
- getWorkspaceActivityLogsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceActivityLogsOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceActivityLogsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceActivityLogsOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceActivityLogsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceActivityOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceActivityOptions model
- wID := "testString"
- activityID := "testString"
- getWorkspaceActivityOptionsModel := schematicsService.NewGetWorkspaceActivityOptions(wID, activityID)
- getWorkspaceActivityOptionsModel.SetWID("testString")
- getWorkspaceActivityOptionsModel.SetActivityID("testString")
- getWorkspaceActivityOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceActivityOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceActivityOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceActivityOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceActivityOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceDeletionJobStatusOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
- wjID := "testString"
- getWorkspaceDeletionJobStatusOptionsModel := schematicsService.NewGetWorkspaceDeletionJobStatusOptions(wjID)
- getWorkspaceDeletionJobStatusOptionsModel.SetWjID("testString")
- getWorkspaceDeletionJobStatusOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceDeletionJobStatusOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceDeletionJobStatusOptionsModel.WjID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceDeletionJobStatusOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceInputMetadataOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceInputMetadataOptions model
- wID := "testString"
- tID := "testString"
- getWorkspaceInputMetadataOptionsModel := schematicsService.NewGetWorkspaceInputMetadataOptions(wID, tID)
- getWorkspaceInputMetadataOptionsModel.SetWID("testString")
- getWorkspaceInputMetadataOptionsModel.SetTID("testString")
- getWorkspaceInputMetadataOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceInputMetadataOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceInputMetadataOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceInputMetadataOptionsModel.TID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceInputMetadataOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceInputsOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceInputsOptions model
- wID := "testString"
- tID := "testString"
- getWorkspaceInputsOptionsModel := schematicsService.NewGetWorkspaceInputsOptions(wID, tID)
- getWorkspaceInputsOptionsModel.SetWID("testString")
- getWorkspaceInputsOptionsModel.SetTID("testString")
- getWorkspaceInputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceInputsOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceInputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceInputsOptionsModel.TID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceInputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceLogUrlsOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceLogUrlsOptions model
- wID := "testString"
- getWorkspaceLogUrlsOptionsModel := schematicsService.NewGetWorkspaceLogUrlsOptions(wID)
- getWorkspaceLogUrlsOptionsModel.SetWID("testString")
- getWorkspaceLogUrlsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceLogUrlsOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceLogUrlsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceLogUrlsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceOptions model
- wID := "testString"
- getWorkspaceOptionsModel := schematicsService.NewGetWorkspaceOptions(wID)
- getWorkspaceOptionsModel.SetWID("testString")
- getWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceOutputsOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceOutputsOptions model
- wID := "testString"
- getWorkspaceOutputsOptionsModel := schematicsService.NewGetWorkspaceOutputsOptions(wID)
- getWorkspaceOutputsOptionsModel.SetWID("testString")
- getWorkspaceOutputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceOutputsOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceOutputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceOutputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceReadmeOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceReadmeOptions model
- wID := "testString"
- getWorkspaceReadmeOptionsModel := schematicsService.NewGetWorkspaceReadmeOptions(wID)
- getWorkspaceReadmeOptionsModel.SetWID("testString")
- getWorkspaceReadmeOptionsModel.SetRef("testString")
- getWorkspaceReadmeOptionsModel.SetFormatted("markdown")
- getWorkspaceReadmeOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceReadmeOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceReadmeOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceReadmeOptionsModel.Ref).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceReadmeOptionsModel.Formatted).To(Equal(core.StringPtr("markdown")))
- Expect(getWorkspaceReadmeOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceResourcesOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceResourcesOptions model
- wID := "testString"
- getWorkspaceResourcesOptionsModel := schematicsService.NewGetWorkspaceResourcesOptions(wID)
- getWorkspaceResourcesOptionsModel.SetWID("testString")
- getWorkspaceResourcesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceResourcesOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceResourcesOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceResourcesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceStateOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceStateOptions model
- wID := "testString"
- getWorkspaceStateOptionsModel := schematicsService.NewGetWorkspaceStateOptions(wID)
- getWorkspaceStateOptionsModel.SetWID("testString")
- getWorkspaceStateOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceStateOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceStateOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceStateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewGetWorkspaceTemplateStateOptions successfully`, func() {
- // Construct an instance of the GetWorkspaceTemplateStateOptions model
- wID := "testString"
- tID := "testString"
- getWorkspaceTemplateStateOptionsModel := schematicsService.NewGetWorkspaceTemplateStateOptions(wID, tID)
- getWorkspaceTemplateStateOptionsModel.SetWID("testString")
- getWorkspaceTemplateStateOptionsModel.SetTID("testString")
- getWorkspaceTemplateStateOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(getWorkspaceTemplateStateOptionsModel).ToNot(BeNil())
- Expect(getWorkspaceTemplateStateOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceTemplateStateOptionsModel.TID).To(Equal(core.StringPtr("testString")))
- Expect(getWorkspaceTemplateStateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewJobData successfully`, func() {
- jobType := "repo_download_job"
- _model, err := schematicsService.NewJobData(jobType)
- Expect(_model).ToNot(BeNil())
- Expect(err).To(BeNil())
- })
- It(`Invoke NewListActionsOptions successfully`, func() {
- // Construct an instance of the ListActionsOptions model
- listActionsOptionsModel := schematicsService.NewListActionsOptions()
- listActionsOptionsModel.SetOffset(int64(0))
- listActionsOptionsModel.SetLimit(int64(1))
- listActionsOptionsModel.SetSort("testString")
- listActionsOptionsModel.SetProfile("ids")
- listActionsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listActionsOptionsModel).ToNot(BeNil())
- Expect(listActionsOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
- Expect(listActionsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
- Expect(listActionsOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
- Expect(listActionsOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
- Expect(listActionsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListInventoriesOptions successfully`, func() {
- // Construct an instance of the ListInventoriesOptions model
- listInventoriesOptionsModel := schematicsService.NewListInventoriesOptions()
- listInventoriesOptionsModel.SetOffset(int64(0))
- listInventoriesOptionsModel.SetLimit(int64(1))
- listInventoriesOptionsModel.SetSort("testString")
- listInventoriesOptionsModel.SetProfile("ids")
- listInventoriesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listInventoriesOptionsModel).ToNot(BeNil())
- Expect(listInventoriesOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
- Expect(listInventoriesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
- Expect(listInventoriesOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
- Expect(listInventoriesOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
- Expect(listInventoriesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListInventoryValuesOptions successfully`, func() {
- // Construct an instance of the ListInventoryValuesOptions model
- inventoryID := "testString"
- listInventoryValuesOptionsModel := schematicsService.NewListInventoryValuesOptions(inventoryID)
- listInventoryValuesOptionsModel.SetInventoryID("testString")
- listInventoryValuesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listInventoryValuesOptionsModel).ToNot(BeNil())
- Expect(listInventoryValuesOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
- Expect(listInventoryValuesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListJobLogsOptions successfully`, func() {
- // Construct an instance of the ListJobLogsOptions model
- jobID := "testString"
- listJobLogsOptionsModel := schematicsService.NewListJobLogsOptions(jobID)
- listJobLogsOptionsModel.SetJobID("testString")
- listJobLogsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listJobLogsOptionsModel).ToNot(BeNil())
- Expect(listJobLogsOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(listJobLogsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListJobsOptions successfully`, func() {
- // Construct an instance of the ListJobsOptions model
- listJobsOptionsModel := schematicsService.NewListJobsOptions()
- listJobsOptionsModel.SetOffset(int64(0))
- listJobsOptionsModel.SetLimit(int64(1))
- listJobsOptionsModel.SetSort("testString")
- listJobsOptionsModel.SetProfile("ids")
- listJobsOptionsModel.SetResource("workspace")
- listJobsOptionsModel.SetResourceID("testString")
- listJobsOptionsModel.SetActionID("testString")
- listJobsOptionsModel.SetList("all")
- listJobsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listJobsOptionsModel).ToNot(BeNil())
- Expect(listJobsOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
- Expect(listJobsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
- Expect(listJobsOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
- Expect(listJobsOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
- Expect(listJobsOptionsModel.Resource).To(Equal(core.StringPtr("workspace")))
- Expect(listJobsOptionsModel.ResourceID).To(Equal(core.StringPtr("testString")))
- Expect(listJobsOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
- Expect(listJobsOptionsModel.List).To(Equal(core.StringPtr("all")))
- Expect(listJobsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListLocationsOptions successfully`, func() {
- // Construct an instance of the ListLocationsOptions model
- listLocationsOptionsModel := schematicsService.NewListLocationsOptions()
- listLocationsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listLocationsOptionsModel).ToNot(BeNil())
- Expect(listLocationsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListResourceGroupOptions successfully`, func() {
- // Construct an instance of the ListResourceGroupOptions model
- listResourceGroupOptionsModel := schematicsService.NewListResourceGroupOptions()
- listResourceGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listResourceGroupOptionsModel).ToNot(BeNil())
- Expect(listResourceGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListResourceQueryOptions successfully`, func() {
- // Construct an instance of the ListResourceQueryOptions model
- listResourceQueryOptionsModel := schematicsService.NewListResourceQueryOptions()
- listResourceQueryOptionsModel.SetOffset(int64(0))
- listResourceQueryOptionsModel.SetLimit(int64(1))
- listResourceQueryOptionsModel.SetSort("testString")
- listResourceQueryOptionsModel.SetProfile("ids")
- listResourceQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listResourceQueryOptionsModel).ToNot(BeNil())
- Expect(listResourceQueryOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
- Expect(listResourceQueryOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
- Expect(listResourceQueryOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
- Expect(listResourceQueryOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
- Expect(listResourceQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListSchematicsLocationOptions successfully`, func() {
- // Construct an instance of the ListSchematicsLocationOptions model
- listSchematicsLocationOptionsModel := schematicsService.NewListSchematicsLocationOptions()
- listSchematicsLocationOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listSchematicsLocationOptionsModel).ToNot(BeNil())
- Expect(listSchematicsLocationOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListWorkspaceActivitiesOptions successfully`, func() {
- // Construct an instance of the ListWorkspaceActivitiesOptions model
- wID := "testString"
- listWorkspaceActivitiesOptionsModel := schematicsService.NewListWorkspaceActivitiesOptions(wID)
- listWorkspaceActivitiesOptionsModel.SetWID("testString")
- listWorkspaceActivitiesOptionsModel.SetOffset(int64(0))
- listWorkspaceActivitiesOptionsModel.SetLimit(int64(1))
- listWorkspaceActivitiesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listWorkspaceActivitiesOptionsModel).ToNot(BeNil())
- Expect(listWorkspaceActivitiesOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(listWorkspaceActivitiesOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
- Expect(listWorkspaceActivitiesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
- Expect(listWorkspaceActivitiesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewListWorkspacesOptions successfully`, func() {
- // Construct an instance of the ListWorkspacesOptions model
- listWorkspacesOptionsModel := schematicsService.NewListWorkspacesOptions()
- listWorkspacesOptionsModel.SetOffset(int64(0))
- listWorkspacesOptionsModel.SetLimit(int64(1))
- listWorkspacesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(listWorkspacesOptionsModel).ToNot(BeNil())
- Expect(listWorkspacesOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
- Expect(listWorkspacesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
- Expect(listWorkspacesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewPlanWorkspaceCommandOptions successfully`, func() {
- // Construct an instance of the PlanWorkspaceCommandOptions model
- wID := "testString"
- refreshToken := "testString"
- planWorkspaceCommandOptionsModel := schematicsService.NewPlanWorkspaceCommandOptions(wID, refreshToken)
- planWorkspaceCommandOptionsModel.SetWID("testString")
- planWorkspaceCommandOptionsModel.SetRefreshToken("testString")
- planWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(planWorkspaceCommandOptionsModel).ToNot(BeNil())
- Expect(planWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(planWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(planWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewProcessTemplateMetaDataOptions successfully`, func() {
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- Expect(externalSourceGitModel).ToNot(BeNil())
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
- Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- Expect(externalSourceCatalogModel).ToNot(BeNil())
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
- Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- Expect(externalSourceModel).ToNot(BeNil())
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
- Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
- Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
-
- // Construct an instance of the ProcessTemplateMetaDataOptions model
- processTemplateMetaDataOptionsTemplateType := "testString"
- var processTemplateMetaDataOptionsSource *schematicsv1.ExternalSource = nil
- processTemplateMetaDataOptionsModel := schematicsService.NewProcessTemplateMetaDataOptions(processTemplateMetaDataOptionsTemplateType, processTemplateMetaDataOptionsSource)
- processTemplateMetaDataOptionsModel.SetTemplateType("testString")
- processTemplateMetaDataOptionsModel.SetSource(externalSourceModel)
- processTemplateMetaDataOptionsModel.SetRegion("testString")
- processTemplateMetaDataOptionsModel.SetSourceType("local")
- processTemplateMetaDataOptionsModel.SetXGithubToken("testString")
- processTemplateMetaDataOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(processTemplateMetaDataOptionsModel).ToNot(BeNil())
- Expect(processTemplateMetaDataOptionsModel.TemplateType).To(Equal(core.StringPtr("testString")))
- Expect(processTemplateMetaDataOptionsModel.Source).To(Equal(externalSourceModel))
- Expect(processTemplateMetaDataOptionsModel.Region).To(Equal(core.StringPtr("testString")))
- Expect(processTemplateMetaDataOptionsModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(processTemplateMetaDataOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
- Expect(processTemplateMetaDataOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewRefreshWorkspaceCommandOptions successfully`, func() {
- // Construct an instance of the RefreshWorkspaceCommandOptions model
- wID := "testString"
- refreshToken := "testString"
- refreshWorkspaceCommandOptionsModel := schematicsService.NewRefreshWorkspaceCommandOptions(wID, refreshToken)
- refreshWorkspaceCommandOptionsModel.SetWID("testString")
- refreshWorkspaceCommandOptionsModel.SetRefreshToken("testString")
- refreshWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(refreshWorkspaceCommandOptionsModel).ToNot(BeNil())
- Expect(refreshWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(refreshWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(refreshWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewReplaceInventoryOptions successfully`, func() {
- // Construct an instance of the ReplaceInventoryOptions model
- inventoryID := "testString"
- replaceInventoryOptionsModel := schematicsService.NewReplaceInventoryOptions(inventoryID)
- replaceInventoryOptionsModel.SetInventoryID("testString")
- replaceInventoryOptionsModel.SetName("testString")
- replaceInventoryOptionsModel.SetDescription("testString")
- replaceInventoryOptionsModel.SetLocation("us-south")
- replaceInventoryOptionsModel.SetResourceGroup("testString")
- replaceInventoryOptionsModel.SetInventoriesIni("testString")
- replaceInventoryOptionsModel.SetResourceQueries([]string{"testString"})
- replaceInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(replaceInventoryOptionsModel).ToNot(BeNil())
- Expect(replaceInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
- Expect(replaceInventoryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(replaceInventoryOptionsModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(replaceInventoryOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(replaceInventoryOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(replaceInventoryOptionsModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
- Expect(replaceInventoryOptionsModel.ResourceQueries).To(Equal([]string{"testString"}))
- Expect(replaceInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewReplaceJobOptions successfully`, func() {
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- Expect(variableMetadataModel).ToNot(BeNil())
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
- Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
- Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- Expect(variableDataModel).ToNot(BeNil())
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
- Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
-
- // Construct an instance of the JobStatusWorkitem model
- jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
- Expect(jobStatusWorkitemModel).ToNot(BeNil())
- jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
- jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkitemModel.JobID = core.StringPtr("testString")
- jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusWorkitemModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusWorkitemModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkitemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusFlow model
- jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
- Expect(jobStatusFlowModel).ToNot(BeNil())
- jobStatusFlowModel.FlowID = core.StringPtr("testString")
- jobStatusFlowModel.FlowName = core.StringPtr("testString")
- jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
- jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
- jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
- jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusFlowModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusFlowModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusFlowModel.Workitems).To(Equal([]schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}))
- Expect(jobStatusFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusTemplate model
- jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
- Expect(jobStatusTemplateModel).ToNot(BeNil())
- jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
- jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
- jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
- jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
- jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
- Expect(jobStatusTemplateModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusTemplateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusWorkspace model
- jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
- Expect(jobStatusWorkspaceModel).ToNot(BeNil())
- jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
- jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
- jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
- jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
- jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkspaceModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusWorkspaceModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusWorkspaceModel.FlowStatus).To(Equal(jobStatusFlowModel))
- Expect(jobStatusWorkspaceModel.TemplateStatus).To(Equal([]schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}))
- Expect(jobStatusWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusAction model
- jobStatusActionModel := new(schematicsv1.JobStatusAction)
- Expect(jobStatusActionModel).ToNot(BeNil())
- jobStatusActionModel.ActionName = core.StringPtr("testString")
- jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
- jobStatusActionModel.StatusMessage = core.StringPtr("testString")
- jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
- jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
- jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
- jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusActionModel.ActionName).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusActionModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.BastionStatusCode).To(Equal(core.StringPtr("none")))
- Expect(jobStatusActionModel.BastionStatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.TargetsStatusCode).To(Equal(core.StringPtr("none")))
- Expect(jobStatusActionModel.TargetsStatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusSchematicsResources model
- jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
- Expect(jobStatusSchematicsResourcesModel).ToNot(BeNil())
- jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
- jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
- jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusSchematicsResourcesModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusSchematicsResourcesModel.StatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusSchematicsResourcesModel.SchematicsResourceID).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusSchematicsResourcesModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatusSystem model
- jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
- Expect(jobStatusSystemModel).ToNot(BeNil())
- jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
- jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
- jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
- jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobStatusSystemModel.SystemStatusMessage).To(Equal(core.StringPtr("testString")))
- Expect(jobStatusSystemModel.SystemStatusCode).To(Equal(core.StringPtr("job_pending")))
- Expect(jobStatusSystemModel.SchematicsResourceStatus).To(Equal([]schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}))
- Expect(jobStatusSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobStatus model
- jobStatusModel := new(schematicsv1.JobStatus)
- Expect(jobStatusModel).ToNot(BeNil())
- jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
- jobStatusModel.ActionJobStatus = jobStatusActionModel
- jobStatusModel.SystemJobStatus = jobStatusSystemModel
- jobStatusModel.FlowJobStatus = jobStatusFlowModel
- Expect(jobStatusModel.WorkspaceJobStatus).To(Equal(jobStatusWorkspaceModel))
- Expect(jobStatusModel.ActionJobStatus).To(Equal(jobStatusActionModel))
- Expect(jobStatusModel.SystemJobStatus).To(Equal(jobStatusSystemModel))
- Expect(jobStatusModel.FlowJobStatus).To(Equal(jobStatusFlowModel))
-
- // Construct an instance of the JobDataTemplate model
- jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
- Expect(jobDataTemplateModel).ToNot(BeNil())
- jobDataTemplateModel.TemplateID = core.StringPtr("testString")
- jobDataTemplateModel.TemplateName = core.StringPtr("testString")
- jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
- jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
- Expect(jobDataTemplateModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataTemplateModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataTemplateModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobDataWorkspace model
- jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
- Expect(jobDataWorkspaceModel).ToNot(BeNil())
- jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
- jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
- jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
- jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkspaceModel.FlowID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkspaceModel.FlowName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkspaceModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkspaceModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkspaceModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkspaceModel.TemplateData).To(Equal([]schematicsv1.JobDataTemplate{*jobDataTemplateModel}))
- Expect(jobDataWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the InventoryResourceRecord model
- inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
- Expect(inventoryResourceRecordModel).ToNot(BeNil())
- inventoryResourceRecordModel.Name = core.StringPtr("testString")
- inventoryResourceRecordModel.Description = core.StringPtr("testString")
- inventoryResourceRecordModel.Location = core.StringPtr("us-south")
- inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
- inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
- inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
- Expect(inventoryResourceRecordModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(inventoryResourceRecordModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
- Expect(inventoryResourceRecordModel.ResourceQueries).To(Equal([]string{"testString"}))
-
- // Construct an instance of the JobDataAction model
- jobDataActionModel := new(schematicsv1.JobDataAction)
- Expect(jobDataActionModel).ToNot(BeNil())
- jobDataActionModel.ActionName = core.StringPtr("testString")
- jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
- jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
- Expect(jobDataActionModel.ActionName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataActionModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataActionModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataActionModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
- Expect(jobDataActionModel.InventoryRecord).To(Equal(inventoryResourceRecordModel))
- Expect(jobDataActionModel.MaterializedInventory).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the JobDataSystem model
- jobDataSystemModel := new(schematicsv1.JobDataSystem)
- Expect(jobDataSystemModel).ToNot(BeNil())
- jobDataSystemModel.KeyID = core.StringPtr("testString")
- jobDataSystemModel.SchematicsResourceID = []string{"testString"}
- jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataSystemModel.KeyID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataSystemModel.SchematicsResourceID).To(Equal([]string{"testString"}))
- Expect(jobDataSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- Expect(externalSourceGitModel).ToNot(BeNil())
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
- Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- Expect(externalSourceCatalogModel).ToNot(BeNil())
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
- Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- Expect(externalSourceModel).ToNot(BeNil())
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
- Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
- Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
-
- // Construct an instance of the JobDataWorkItem model
- jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
- Expect(jobDataWorkItemModel).ToNot(BeNil())
- jobDataWorkItemModel.WorkspaceID = core.StringPtr("testString")
- jobDataWorkItemModel.Layers = core.StringPtr("testString")
- jobDataWorkItemModel.WorkspaceName = core.StringPtr("testString")
- jobDataWorkItemModel.JobID = core.StringPtr("testString")
- jobDataWorkItemModel.SourceType = core.StringPtr("local")
- jobDataWorkItemModel.Source = externalSourceModel
- jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
- jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataWorkItemModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.Layers).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataWorkItemModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(jobDataWorkItemModel.Source).To(Equal(externalSourceModel))
- Expect(jobDataWorkItemModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkItemModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkItemModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(jobDataWorkItemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobDataFlow model
- jobDataFlowModel := new(schematicsv1.JobDataFlow)
- Expect(jobDataFlowModel).ToNot(BeNil())
- jobDataFlowModel.FlowID = core.StringPtr("testString")
- jobDataFlowModel.FlowName = core.StringPtr("testString")
- jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
- jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(jobDataFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
- Expect(jobDataFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
- Expect(jobDataFlowModel.Workitems).To(Equal([]schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}))
- Expect(jobDataFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the JobData model
- jobDataModel := new(schematicsv1.JobData)
- Expect(jobDataModel).ToNot(BeNil())
- jobDataModel.JobType = core.StringPtr("repo_download_job")
- jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
- jobDataModel.ActionJobData = jobDataActionModel
- jobDataModel.SystemJobData = jobDataSystemModel
- jobDataModel.FlowJobData = jobDataFlowModel
- Expect(jobDataModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
- Expect(jobDataModel.WorkspaceJobData).To(Equal(jobDataWorkspaceModel))
- Expect(jobDataModel.ActionJobData).To(Equal(jobDataActionModel))
- Expect(jobDataModel.SystemJobData).To(Equal(jobDataSystemModel))
- Expect(jobDataModel.FlowJobData).To(Equal(jobDataFlowModel))
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- Expect(bastionResourceDefinitionModel).ToNot(BeNil())
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
- Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the JobLogSummaryRepoDownloadJob model
- jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
- Expect(jobLogSummaryRepoDownloadJobModel).ToNot(BeNil())
-
- // Construct an instance of the JobLogSummaryWorkspaceJob model
- jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
- Expect(jobLogSummaryWorkspaceJobModel).ToNot(BeNil())
-
- // Construct an instance of the JobLogSummaryWorkitems model
- jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
- Expect(jobLogSummaryWorkitemsModel).ToNot(BeNil())
- jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
- jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
- Expect(jobLogSummaryWorkitemsModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
- Expect(jobLogSummaryWorkitemsModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(jobLogSummaryWorkitemsModel.LogURL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the JobLogSummaryFlowJob model
- jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
- Expect(jobLogSummaryFlowJobModel).ToNot(BeNil())
- jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
- Expect(jobLogSummaryFlowJobModel.Workitems).To(Equal([]schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}))
-
- // Construct an instance of the JobLogSummaryActionJobRecap model
- jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
- Expect(jobLogSummaryActionJobRecapModel).ToNot(BeNil())
- jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
- jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
- jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
- Expect(jobLogSummaryActionJobRecapModel.Target).To(Equal([]string{"testString"}))
- Expect(jobLogSummaryActionJobRecapModel.Ok).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Changed).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Skipped).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummaryActionJobRecapModel.Unreachable).To(Equal(core.Float64Ptr(float64(72.5))))
-
- // Construct an instance of the JobLogSummaryActionJob model
- jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
- Expect(jobLogSummaryActionJobModel).ToNot(BeNil())
- jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
- Expect(jobLogSummaryActionJobModel.Recap).To(Equal(jobLogSummaryActionJobRecapModel))
-
- // Construct an instance of the JobLogSummarySystemJob model
- jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
- Expect(jobLogSummarySystemJobModel).ToNot(BeNil())
- jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
- jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
- Expect(jobLogSummarySystemJobModel.Success).To(Equal(core.Float64Ptr(float64(72.5))))
- Expect(jobLogSummarySystemJobModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
-
- // Construct an instance of the JobLogSummary model
- jobLogSummaryModel := new(schematicsv1.JobLogSummary)
- Expect(jobLogSummaryModel).ToNot(BeNil())
- jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
- jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
- jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
- jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
- jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
- jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
- Expect(jobLogSummaryModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
- Expect(jobLogSummaryModel.RepoDownloadJob).To(Equal(jobLogSummaryRepoDownloadJobModel))
- Expect(jobLogSummaryModel.WorkspaceJob).To(Equal(jobLogSummaryWorkspaceJobModel))
- Expect(jobLogSummaryModel.FlowJob).To(Equal(jobLogSummaryFlowJobModel))
- Expect(jobLogSummaryModel.ActionJob).To(Equal(jobLogSummaryActionJobModel))
- Expect(jobLogSummaryModel.SystemJob).To(Equal(jobLogSummarySystemJobModel))
-
- // Construct an instance of the ReplaceJobOptions model
- jobID := "testString"
- refreshToken := "testString"
- replaceJobOptionsModel := schematicsService.NewReplaceJobOptions(jobID, refreshToken)
- replaceJobOptionsModel.SetJobID("testString")
- replaceJobOptionsModel.SetRefreshToken("testString")
- replaceJobOptionsModel.SetCommandObject("workspace")
- replaceJobOptionsModel.SetCommandObjectID("testString")
- replaceJobOptionsModel.SetCommandName("workspace_plan")
- replaceJobOptionsModel.SetCommandParameter("testString")
- replaceJobOptionsModel.SetCommandOptions([]string{"testString"})
- replaceJobOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
- replaceJobOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
- replaceJobOptionsModel.SetTags([]string{"testString"})
- replaceJobOptionsModel.SetLocation("us-south")
- replaceJobOptionsModel.SetStatus(jobStatusModel)
- replaceJobOptionsModel.SetData(jobDataModel)
- replaceJobOptionsModel.SetBastion(bastionResourceDefinitionModel)
- replaceJobOptionsModel.SetLogSummary(jobLogSummaryModel)
- replaceJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(replaceJobOptionsModel).ToNot(BeNil())
- Expect(replaceJobOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
- Expect(replaceJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(replaceJobOptionsModel.CommandObject).To(Equal(core.StringPtr("workspace")))
- Expect(replaceJobOptionsModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
- Expect(replaceJobOptionsModel.CommandName).To(Equal(core.StringPtr("workspace_plan")))
- Expect(replaceJobOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
- Expect(replaceJobOptionsModel.CommandOptions).To(Equal([]string{"testString"}))
- Expect(replaceJobOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(replaceJobOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(replaceJobOptionsModel.Tags).To(Equal([]string{"testString"}))
- Expect(replaceJobOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(replaceJobOptionsModel.Status).To(Equal(jobStatusModel))
- Expect(replaceJobOptionsModel.Data).To(Equal(jobDataModel))
- Expect(replaceJobOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
- Expect(replaceJobOptionsModel.LogSummary).To(Equal(jobLogSummaryModel))
- Expect(replaceJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewReplaceKmsSettingsOptions successfully`, func() {
- // Construct an instance of the KMSSettingsPrimaryCrk model
- kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
- Expect(kmsSettingsPrimaryCrkModel).ToNot(BeNil())
- kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
- Expect(kmsSettingsPrimaryCrkModel.KmsName).To(Equal(core.StringPtr("testString")))
- Expect(kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint).To(Equal(core.StringPtr("testString")))
- Expect(kmsSettingsPrimaryCrkModel.KeyCrn).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the KMSSettingsSecondaryCrk model
- kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
- Expect(kmsSettingsSecondaryCrkModel).ToNot(BeNil())
- kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
- kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
- Expect(kmsSettingsSecondaryCrkModel.KmsName).To(Equal(core.StringPtr("testString")))
- Expect(kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint).To(Equal(core.StringPtr("testString")))
- Expect(kmsSettingsSecondaryCrkModel.KeyCrn).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ReplaceKmsSettingsOptions model
- replaceKmsSettingsOptionsModel := schematicsService.NewReplaceKmsSettingsOptions()
- replaceKmsSettingsOptionsModel.SetLocation("testString")
- replaceKmsSettingsOptionsModel.SetEncryptionScheme("testString")
- replaceKmsSettingsOptionsModel.SetResourceGroup("testString")
- replaceKmsSettingsOptionsModel.SetPrimaryCrk(kmsSettingsPrimaryCrkModel)
- replaceKmsSettingsOptionsModel.SetSecondaryCrk(kmsSettingsSecondaryCrkModel)
- replaceKmsSettingsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(replaceKmsSettingsOptionsModel).ToNot(BeNil())
- Expect(replaceKmsSettingsOptionsModel.Location).To(Equal(core.StringPtr("testString")))
- Expect(replaceKmsSettingsOptionsModel.EncryptionScheme).To(Equal(core.StringPtr("testString")))
- Expect(replaceKmsSettingsOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(replaceKmsSettingsOptionsModel.PrimaryCrk).To(Equal(kmsSettingsPrimaryCrkModel))
- Expect(replaceKmsSettingsOptionsModel.SecondaryCrk).To(Equal(kmsSettingsSecondaryCrkModel))
- Expect(replaceKmsSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewReplaceResourcesQueryOptions successfully`, func() {
- // Construct an instance of the ResourceQueryParam model
- resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
- Expect(resourceQueryParamModel).ToNot(BeNil())
- resourceQueryParamModel.Name = core.StringPtr("testString")
- resourceQueryParamModel.Value = core.StringPtr("testString")
- resourceQueryParamModel.Description = core.StringPtr("testString")
- Expect(resourceQueryParamModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(resourceQueryParamModel.Value).To(Equal(core.StringPtr("testString")))
- Expect(resourceQueryParamModel.Description).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ResourceQuery model
- resourceQueryModel := new(schematicsv1.ResourceQuery)
- Expect(resourceQueryModel).ToNot(BeNil())
- resourceQueryModel.QueryType = core.StringPtr("workspaces")
- resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
- resourceQueryModel.QuerySelect = []string{"testString"}
- Expect(resourceQueryModel.QueryType).To(Equal(core.StringPtr("workspaces")))
- Expect(resourceQueryModel.QueryCondition).To(Equal([]schematicsv1.ResourceQueryParam{*resourceQueryParamModel}))
- Expect(resourceQueryModel.QuerySelect).To(Equal([]string{"testString"}))
-
- // Construct an instance of the ReplaceResourcesQueryOptions model
- queryID := "testString"
- replaceResourcesQueryOptionsModel := schematicsService.NewReplaceResourcesQueryOptions(queryID)
- replaceResourcesQueryOptionsModel.SetQueryID("testString")
- replaceResourcesQueryOptionsModel.SetType("vsi")
- replaceResourcesQueryOptionsModel.SetName("testString")
- replaceResourcesQueryOptionsModel.SetQueries([]schematicsv1.ResourceQuery{*resourceQueryModel})
- replaceResourcesQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(replaceResourcesQueryOptionsModel).ToNot(BeNil())
- Expect(replaceResourcesQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
- Expect(replaceResourcesQueryOptionsModel.Type).To(Equal(core.StringPtr("vsi")))
- Expect(replaceResourcesQueryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(replaceResourcesQueryOptionsModel.Queries).To(Equal([]schematicsv1.ResourceQuery{*resourceQueryModel}))
- Expect(replaceResourcesQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewReplaceWorkspaceInputsOptions successfully`, func() {
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- Expect(workspaceVariableRequestModel).ToNot(BeNil())
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
- Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ReplaceWorkspaceInputsOptions model
- wID := "testString"
- tID := "testString"
- replaceWorkspaceInputsOptionsModel := schematicsService.NewReplaceWorkspaceInputsOptions(wID, tID)
- replaceWorkspaceInputsOptionsModel.SetWID("testString")
- replaceWorkspaceInputsOptionsModel.SetTID("testString")
- replaceWorkspaceInputsOptionsModel.SetEnvValues([]interface{}{map[string]interface{}{"anyKey": "anyValue"}})
- replaceWorkspaceInputsOptionsModel.SetValues("testString")
- replaceWorkspaceInputsOptionsModel.SetVariablestore([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel})
- replaceWorkspaceInputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(replaceWorkspaceInputsOptionsModel).ToNot(BeNil())
- Expect(replaceWorkspaceInputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(replaceWorkspaceInputsOptionsModel.TID).To(Equal(core.StringPtr("testString")))
- Expect(replaceWorkspaceInputsOptionsModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(replaceWorkspaceInputsOptionsModel.Values).To(Equal(core.StringPtr("testString")))
- Expect(replaceWorkspaceInputsOptionsModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
- Expect(replaceWorkspaceInputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewReplaceWorkspaceOptions successfully`, func() {
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- Expect(catalogRefModel).ToNot(BeNil())
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
- Expect(catalogRefModel.DryRun).To(Equal(core.BoolPtr(true)))
- Expect(catalogRefModel.OwningAccount).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemIconURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemID).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemName).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemReadmeURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.LaunchURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- Expect(sharedTargetDataModel).ToNot(BeNil())
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
- Expect(sharedTargetDataModel.ClusterCreatedOn).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterID).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterName).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterType).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.EntitlementKeys).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(sharedTargetDataModel.Namespace).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.Region).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ResourceGroupID).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.WorkerCount).To(Equal(core.Int64Ptr(int64(26))))
- Expect(sharedTargetDataModel.WorkerMachineType).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- Expect(workspaceVariableRequestModel).ToNot(BeNil())
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
- Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- Expect(templateSourceDataRequestModel).ToNot(BeNil())
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- Expect(templateSourceDataRequestModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(templateSourceDataRequestModel.Folder).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Compact).To(Equal(core.BoolPtr(true)))
- Expect(templateSourceDataRequestModel.InitStateFile).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Type).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.UninstallScriptName).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Values).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.ValuesMetadata).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(templateSourceDataRequestModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- Expect(templateRepoUpdateRequestModel).ToNot(BeNil())
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
- Expect(templateRepoUpdateRequestModel.Branch).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.Release).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.RepoShaValue).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.RepoURL).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.URL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- Expect(workspaceStatusUpdateRequestModel).ToNot(BeNil())
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(workspaceStatusUpdateRequestModel.Frozen).To(Equal(core.BoolPtr(true)))
- Expect(workspaceStatusUpdateRequestModel.FrozenAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
- Expect(workspaceStatusUpdateRequestModel.FrozenBy).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusUpdateRequestModel.Locked).To(Equal(core.BoolPtr(true)))
- Expect(workspaceStatusUpdateRequestModel.LockedBy).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusUpdateRequestModel.LockedTime).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- Expect(workspaceStatusMessageModel).ToNot(BeNil())
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
- Expect(workspaceStatusMessageModel.StatusCode).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusMessageModel.StatusMsg).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ReplaceWorkspaceOptions model
- wID := "testString"
- replaceWorkspaceOptionsModel := schematicsService.NewReplaceWorkspaceOptions(wID)
- replaceWorkspaceOptionsModel.SetWID("testString")
- replaceWorkspaceOptionsModel.SetCatalogRef(catalogRefModel)
- replaceWorkspaceOptionsModel.SetDescription("testString")
- replaceWorkspaceOptionsModel.SetName("testString")
- replaceWorkspaceOptionsModel.SetSharedData(sharedTargetDataModel)
- replaceWorkspaceOptionsModel.SetTags([]string{"testString"})
- replaceWorkspaceOptionsModel.SetTemplateData([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel})
- replaceWorkspaceOptionsModel.SetTemplateRepo(templateRepoUpdateRequestModel)
- replaceWorkspaceOptionsModel.SetType([]string{"testString"})
- replaceWorkspaceOptionsModel.SetWorkspaceStatus(workspaceStatusUpdateRequestModel)
- replaceWorkspaceOptionsModel.SetWorkspaceStatusMsg(workspaceStatusMessageModel)
- replaceWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(replaceWorkspaceOptionsModel).ToNot(BeNil())
- Expect(replaceWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(replaceWorkspaceOptionsModel.CatalogRef).To(Equal(catalogRefModel))
- Expect(replaceWorkspaceOptionsModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(replaceWorkspaceOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(replaceWorkspaceOptionsModel.SharedData).To(Equal(sharedTargetDataModel))
- Expect(replaceWorkspaceOptionsModel.Tags).To(Equal([]string{"testString"}))
- Expect(replaceWorkspaceOptionsModel.TemplateData).To(Equal([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}))
- Expect(replaceWorkspaceOptionsModel.TemplateRepo).To(Equal(templateRepoUpdateRequestModel))
- Expect(replaceWorkspaceOptionsModel.Type).To(Equal([]string{"testString"}))
- Expect(replaceWorkspaceOptionsModel.WorkspaceStatus).To(Equal(workspaceStatusUpdateRequestModel))
- Expect(replaceWorkspaceOptionsModel.WorkspaceStatusMsg).To(Equal(workspaceStatusMessageModel))
- Expect(replaceWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewRunWorkspaceCommandsOptions successfully`, func() {
- // Construct an instance of the TerraformCommand model
- terraformCommandModel := new(schematicsv1.TerraformCommand)
- Expect(terraformCommandModel).ToNot(BeNil())
- terraformCommandModel.Command = core.StringPtr("testString")
- terraformCommandModel.CommandParams = core.StringPtr("testString")
- terraformCommandModel.CommandName = core.StringPtr("testString")
- terraformCommandModel.CommandDesc = core.StringPtr("testString")
- terraformCommandModel.CommandOnError = core.StringPtr("testString")
- terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
- terraformCommandModel.CommandStatus = core.StringPtr("testString")
- Expect(terraformCommandModel.Command).To(Equal(core.StringPtr("testString")))
- Expect(terraformCommandModel.CommandParams).To(Equal(core.StringPtr("testString")))
- Expect(terraformCommandModel.CommandName).To(Equal(core.StringPtr("testString")))
- Expect(terraformCommandModel.CommandDesc).To(Equal(core.StringPtr("testString")))
- Expect(terraformCommandModel.CommandOnError).To(Equal(core.StringPtr("testString")))
- Expect(terraformCommandModel.CommandDependsOn).To(Equal(core.StringPtr("testString")))
- Expect(terraformCommandModel.CommandStatus).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the RunWorkspaceCommandsOptions model
- wID := "testString"
- refreshToken := "testString"
- runWorkspaceCommandsOptionsModel := schematicsService.NewRunWorkspaceCommandsOptions(wID, refreshToken)
- runWorkspaceCommandsOptionsModel.SetWID("testString")
- runWorkspaceCommandsOptionsModel.SetRefreshToken("testString")
- runWorkspaceCommandsOptionsModel.SetCommands([]schematicsv1.TerraformCommand{*terraformCommandModel})
- runWorkspaceCommandsOptionsModel.SetOperationName("testString")
- runWorkspaceCommandsOptionsModel.SetDescription("testString")
- runWorkspaceCommandsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(runWorkspaceCommandsOptionsModel).ToNot(BeNil())
- Expect(runWorkspaceCommandsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(runWorkspaceCommandsOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
- Expect(runWorkspaceCommandsOptionsModel.Commands).To(Equal([]schematicsv1.TerraformCommand{*terraformCommandModel}))
- Expect(runWorkspaceCommandsOptionsModel.OperationName).To(Equal(core.StringPtr("testString")))
- Expect(runWorkspaceCommandsOptionsModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(runWorkspaceCommandsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewTemplateRepoUploadOptions successfully`, func() {
- // Construct an instance of the TemplateRepoUploadOptions model
- wID := "testString"
- tID := "testString"
- templateRepoUploadOptionsModel := schematicsService.NewTemplateRepoUploadOptions(wID, tID)
- templateRepoUploadOptionsModel.SetWID("testString")
- templateRepoUploadOptionsModel.SetTID("testString")
- templateRepoUploadOptionsModel.SetFile(CreateMockReader("This is a mock file."))
- templateRepoUploadOptionsModel.SetFileContentType("testString")
- templateRepoUploadOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(templateRepoUploadOptionsModel).ToNot(BeNil())
- Expect(templateRepoUploadOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUploadOptionsModel.TID).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUploadOptionsModel.File).To(Equal(CreateMockReader("This is a mock file.")))
- Expect(templateRepoUploadOptionsModel.FileContentType).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUploadOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewUpdateActionOptions successfully`, func() {
- // Construct an instance of the UserState model
- userStateModel := new(schematicsv1.UserState)
- Expect(userStateModel).ToNot(BeNil())
- userStateModel.State = core.StringPtr("draft")
- userStateModel.SetBy = core.StringPtr("testString")
- userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(userStateModel.State).To(Equal(core.StringPtr("draft")))
- Expect(userStateModel.SetBy).To(Equal(core.StringPtr("testString")))
- Expect(userStateModel.SetAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the ExternalSourceGit model
- externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
- Expect(externalSourceGitModel).ToNot(BeNil())
- externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
- externalSourceGitModel.GitToken = core.StringPtr("testString")
- externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
- externalSourceGitModel.GitRelease = core.StringPtr("testString")
- externalSourceGitModel.GitBranch = core.StringPtr("testString")
- Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSourceCatalog model
- externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
- Expect(externalSourceCatalogModel).ToNot(BeNil())
- externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
- externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
- Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
- Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the ExternalSource model
- externalSourceModel := new(schematicsv1.ExternalSource)
- Expect(externalSourceModel).ToNot(BeNil())
- externalSourceModel.SourceType = core.StringPtr("local")
- externalSourceModel.Git = externalSourceGitModel
- externalSourceModel.Catalog = externalSourceCatalogModel
- Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
- Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
-
- // Construct an instance of the BastionResourceDefinition model
- bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
- Expect(bastionResourceDefinitionModel).ToNot(BeNil())
- bastionResourceDefinitionModel.Name = core.StringPtr("testString")
- bastionResourceDefinitionModel.Host = core.StringPtr("testString")
- Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the VariableMetadata model
- variableMetadataModel := new(schematicsv1.VariableMetadata)
- Expect(variableMetadataModel).ToNot(BeNil())
- variableMetadataModel.Type = core.StringPtr("boolean")
- variableMetadataModel.Aliases = []string{"testString"}
- variableMetadataModel.Description = core.StringPtr("testString")
- variableMetadataModel.DefaultValue = core.StringPtr("testString")
- variableMetadataModel.Secure = core.BoolPtr(true)
- variableMetadataModel.Immutable = core.BoolPtr(true)
- variableMetadataModel.Hidden = core.BoolPtr(true)
- variableMetadataModel.Options = []string{"testString"}
- variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
- variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
- variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
- variableMetadataModel.Matches = core.StringPtr("testString")
- variableMetadataModel.Position = core.Int64Ptr(int64(38))
- variableMetadataModel.GroupBy = core.StringPtr("testString")
- variableMetadataModel.Source = core.StringPtr("testString")
- Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
- Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
- Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
- Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
- Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
- Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the VariableData model
- variableDataModel := new(schematicsv1.VariableData)
- Expect(variableDataModel).ToNot(BeNil())
- variableDataModel.Name = core.StringPtr("testString")
- variableDataModel.Value = core.StringPtr("testString")
- variableDataModel.Metadata = variableMetadataModel
- Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
- Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
-
- // Construct an instance of the ActionState model
- actionStateModel := new(schematicsv1.ActionState)
- Expect(actionStateModel).ToNot(BeNil())
- actionStateModel.StatusCode = core.StringPtr("normal")
- actionStateModel.StatusJobID = core.StringPtr("testString")
- actionStateModel.StatusMessage = core.StringPtr("testString")
- Expect(actionStateModel.StatusCode).To(Equal(core.StringPtr("normal")))
- Expect(actionStateModel.StatusJobID).To(Equal(core.StringPtr("testString")))
- Expect(actionStateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the SystemLock model
- systemLockModel := new(schematicsv1.SystemLock)
- Expect(systemLockModel).ToNot(BeNil())
- systemLockModel.SysLocked = core.BoolPtr(true)
- systemLockModel.SysLockedBy = core.StringPtr("testString")
- systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(systemLockModel.SysLocked).To(Equal(core.BoolPtr(true)))
- Expect(systemLockModel.SysLockedBy).To(Equal(core.StringPtr("testString")))
- Expect(systemLockModel.SysLockedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the UpdateActionOptions model
- actionID := "testString"
- updateActionOptionsModel := schematicsService.NewUpdateActionOptions(actionID)
- updateActionOptionsModel.SetActionID("testString")
- updateActionOptionsModel.SetName("Stop Action")
- updateActionOptionsModel.SetDescription("This Action can be used to Stop the targets")
- updateActionOptionsModel.SetLocation("us-south")
- updateActionOptionsModel.SetResourceGroup("testString")
- updateActionOptionsModel.SetTags([]string{"testString"})
- updateActionOptionsModel.SetUserState(userStateModel)
- updateActionOptionsModel.SetSourceReadmeURL("testString")
- updateActionOptionsModel.SetSource(externalSourceModel)
- updateActionOptionsModel.SetSourceType("local")
- updateActionOptionsModel.SetCommandParameter("testString")
- updateActionOptionsModel.SetBastion(bastionResourceDefinitionModel)
- updateActionOptionsModel.SetInventory("testString")
- updateActionOptionsModel.SetBastionCredential(variableDataModel)
- updateActionOptionsModel.SetCredentials([]schematicsv1.VariableData{*variableDataModel})
- updateActionOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
- updateActionOptionsModel.SetOutputs([]schematicsv1.VariableData{*variableDataModel})
- updateActionOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
- updateActionOptionsModel.SetState(actionStateModel)
- updateActionOptionsModel.SetSysLock(systemLockModel)
- updateActionOptionsModel.SetXGithubToken("testString")
- updateActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(updateActionOptionsModel).ToNot(BeNil())
- Expect(updateActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
- Expect(updateActionOptionsModel.Name).To(Equal(core.StringPtr("Stop Action")))
- Expect(updateActionOptionsModel.Description).To(Equal(core.StringPtr("This Action can be used to Stop the targets")))
- Expect(updateActionOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(updateActionOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(updateActionOptionsModel.Tags).To(Equal([]string{"testString"}))
- Expect(updateActionOptionsModel.UserState).To(Equal(userStateModel))
- Expect(updateActionOptionsModel.SourceReadmeURL).To(Equal(core.StringPtr("testString")))
- Expect(updateActionOptionsModel.Source).To(Equal(externalSourceModel))
- Expect(updateActionOptionsModel.SourceType).To(Equal(core.StringPtr("local")))
- Expect(updateActionOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
- Expect(updateActionOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
- Expect(updateActionOptionsModel.Inventory).To(Equal(core.StringPtr("testString")))
- Expect(updateActionOptionsModel.BastionCredential).To(Equal(variableDataModel))
- Expect(updateActionOptionsModel.Credentials).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(updateActionOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(updateActionOptionsModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(updateActionOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
- Expect(updateActionOptionsModel.State).To(Equal(actionStateModel))
- Expect(updateActionOptionsModel.SysLock).To(Equal(systemLockModel))
- Expect(updateActionOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
- Expect(updateActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewUpdateInventoryOptions successfully`, func() {
- // Construct an instance of the UpdateInventoryOptions model
- inventoryID := "testString"
- updateInventoryOptionsModel := schematicsService.NewUpdateInventoryOptions(inventoryID)
- updateInventoryOptionsModel.SetInventoryID("testString")
- updateInventoryOptionsModel.SetName("testString")
- updateInventoryOptionsModel.SetDescription("testString")
- updateInventoryOptionsModel.SetLocation("us-south")
- updateInventoryOptionsModel.SetResourceGroup("testString")
- updateInventoryOptionsModel.SetInventoriesIni("testString")
- updateInventoryOptionsModel.SetResourceQueries([]string{"testString"})
- updateInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(updateInventoryOptionsModel).ToNot(BeNil())
- Expect(updateInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
- Expect(updateInventoryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(updateInventoryOptionsModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(updateInventoryOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
- Expect(updateInventoryOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
- Expect(updateInventoryOptionsModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
- Expect(updateInventoryOptionsModel.ResourceQueries).To(Equal([]string{"testString"}))
- Expect(updateInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewUpdateWorkspaceOptions successfully`, func() {
- // Construct an instance of the CatalogRef model
- catalogRefModel := new(schematicsv1.CatalogRef)
- Expect(catalogRefModel).ToNot(BeNil())
- catalogRefModel.DryRun = core.BoolPtr(true)
- catalogRefModel.OwningAccount = core.StringPtr("testString")
- catalogRefModel.ItemIconURL = core.StringPtr("testString")
- catalogRefModel.ItemID = core.StringPtr("testString")
- catalogRefModel.ItemName = core.StringPtr("testString")
- catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
- catalogRefModel.ItemURL = core.StringPtr("testString")
- catalogRefModel.LaunchURL = core.StringPtr("testString")
- catalogRefModel.OfferingVersion = core.StringPtr("testString")
- Expect(catalogRefModel.DryRun).To(Equal(core.BoolPtr(true)))
- Expect(catalogRefModel.OwningAccount).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemIconURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemID).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemName).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemReadmeURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.ItemURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.LaunchURL).To(Equal(core.StringPtr("testString")))
- Expect(catalogRefModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the SharedTargetData model
- sharedTargetDataModel := new(schematicsv1.SharedTargetData)
- Expect(sharedTargetDataModel).ToNot(BeNil())
- sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
- sharedTargetDataModel.ClusterID = core.StringPtr("testString")
- sharedTargetDataModel.ClusterName = core.StringPtr("testString")
- sharedTargetDataModel.ClusterType = core.StringPtr("testString")
- sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- sharedTargetDataModel.Namespace = core.StringPtr("testString")
- sharedTargetDataModel.Region = core.StringPtr("testString")
- sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
- sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
- sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
- Expect(sharedTargetDataModel.ClusterCreatedOn).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterID).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterName).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ClusterType).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.EntitlementKeys).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(sharedTargetDataModel.Namespace).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.Region).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.ResourceGroupID).To(Equal(core.StringPtr("testString")))
- Expect(sharedTargetDataModel.WorkerCount).To(Equal(core.Int64Ptr(int64(26))))
- Expect(sharedTargetDataModel.WorkerMachineType).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the WorkspaceVariableRequest model
- workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
- Expect(workspaceVariableRequestModel).ToNot(BeNil())
- workspaceVariableRequestModel.Description = core.StringPtr("testString")
- workspaceVariableRequestModel.Name = core.StringPtr("testString")
- workspaceVariableRequestModel.Secure = core.BoolPtr(true)
- workspaceVariableRequestModel.Type = core.StringPtr("testString")
- workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
- workspaceVariableRequestModel.Value = core.StringPtr("testString")
- Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
- Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
- Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the TemplateSourceDataRequest model
- templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
- Expect(templateSourceDataRequestModel).ToNot(BeNil())
- templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Folder = core.StringPtr("testString")
- templateSourceDataRequestModel.Compact = core.BoolPtr(true)
- templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
- templateSourceDataRequestModel.Type = core.StringPtr("testString")
- templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
- templateSourceDataRequestModel.Values = core.StringPtr("testString")
- templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
- templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
- Expect(templateSourceDataRequestModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(templateSourceDataRequestModel.Folder).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Compact).To(Equal(core.BoolPtr(true)))
- Expect(templateSourceDataRequestModel.InitStateFile).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Type).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.UninstallScriptName).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.Values).To(Equal(core.StringPtr("testString")))
- Expect(templateSourceDataRequestModel.ValuesMetadata).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
- Expect(templateSourceDataRequestModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
-
- // Construct an instance of the TemplateRepoUpdateRequest model
- templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
- Expect(templateRepoUpdateRequestModel).ToNot(BeNil())
- templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
- templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
- templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
- templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
- Expect(templateRepoUpdateRequestModel.Branch).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.Release).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.RepoShaValue).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.RepoURL).To(Equal(core.StringPtr("testString")))
- Expect(templateRepoUpdateRequestModel.URL).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the WorkspaceStatusUpdateRequest model
- workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
- Expect(workspaceStatusUpdateRequestModel).ToNot(BeNil())
- workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
- workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
- workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(workspaceStatusUpdateRequestModel.Frozen).To(Equal(core.BoolPtr(true)))
- Expect(workspaceStatusUpdateRequestModel.FrozenAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
- Expect(workspaceStatusUpdateRequestModel.FrozenBy).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusUpdateRequestModel.Locked).To(Equal(core.BoolPtr(true)))
- Expect(workspaceStatusUpdateRequestModel.LockedBy).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusUpdateRequestModel.LockedTime).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
-
- // Construct an instance of the WorkspaceStatusMessage model
- workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
- Expect(workspaceStatusMessageModel).ToNot(BeNil())
- workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
- workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
- Expect(workspaceStatusMessageModel.StatusCode).To(Equal(core.StringPtr("testString")))
- Expect(workspaceStatusMessageModel.StatusMsg).To(Equal(core.StringPtr("testString")))
-
- // Construct an instance of the UpdateWorkspaceOptions model
- wID := "testString"
- updateWorkspaceOptionsModel := schematicsService.NewUpdateWorkspaceOptions(wID)
- updateWorkspaceOptionsModel.SetWID("testString")
- updateWorkspaceOptionsModel.SetCatalogRef(catalogRefModel)
- updateWorkspaceOptionsModel.SetDescription("testString")
- updateWorkspaceOptionsModel.SetName("testString")
- updateWorkspaceOptionsModel.SetSharedData(sharedTargetDataModel)
- updateWorkspaceOptionsModel.SetTags([]string{"testString"})
- updateWorkspaceOptionsModel.SetTemplateData([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel})
- updateWorkspaceOptionsModel.SetTemplateRepo(templateRepoUpdateRequestModel)
- updateWorkspaceOptionsModel.SetType([]string{"testString"})
- updateWorkspaceOptionsModel.SetWorkspaceStatus(workspaceStatusUpdateRequestModel)
- updateWorkspaceOptionsModel.SetWorkspaceStatusMsg(workspaceStatusMessageModel)
- updateWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(updateWorkspaceOptionsModel).ToNot(BeNil())
- Expect(updateWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
- Expect(updateWorkspaceOptionsModel.CatalogRef).To(Equal(catalogRefModel))
- Expect(updateWorkspaceOptionsModel.Description).To(Equal(core.StringPtr("testString")))
- Expect(updateWorkspaceOptionsModel.Name).To(Equal(core.StringPtr("testString")))
- Expect(updateWorkspaceOptionsModel.SharedData).To(Equal(sharedTargetDataModel))
- Expect(updateWorkspaceOptionsModel.Tags).To(Equal([]string{"testString"}))
- Expect(updateWorkspaceOptionsModel.TemplateData).To(Equal([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}))
- Expect(updateWorkspaceOptionsModel.TemplateRepo).To(Equal(templateRepoUpdateRequestModel))
- Expect(updateWorkspaceOptionsModel.Type).To(Equal([]string{"testString"}))
- Expect(updateWorkspaceOptionsModel.WorkspaceStatus).To(Equal(workspaceStatusUpdateRequestModel))
- Expect(updateWorkspaceOptionsModel.WorkspaceStatusMsg).To(Equal(workspaceStatusMessageModel))
- Expect(updateWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- It(`Invoke NewUploadTemplateTarActionOptions successfully`, func() {
- // Construct an instance of the UploadTemplateTarActionOptions model
- actionID := "testString"
- uploadTemplateTarActionOptionsModel := schematicsService.NewUploadTemplateTarActionOptions(actionID)
- uploadTemplateTarActionOptionsModel.SetActionID("testString")
- uploadTemplateTarActionOptionsModel.SetFile(CreateMockReader("This is a mock file."))
- uploadTemplateTarActionOptionsModel.SetFileContentType("testString")
- uploadTemplateTarActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
- Expect(uploadTemplateTarActionOptionsModel).ToNot(BeNil())
- Expect(uploadTemplateTarActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
- Expect(uploadTemplateTarActionOptionsModel.File).To(Equal(CreateMockReader("This is a mock file.")))
- Expect(uploadTemplateTarActionOptionsModel.FileContentType).To(Equal(core.StringPtr("testString")))
- Expect(uploadTemplateTarActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
- })
- })
- })
- Describe(`Utility function tests`, func() {
- It(`Invoke CreateMockByteArray() successfully`, func() {
- mockByteArray := CreateMockByteArray("This is a test")
- Expect(mockByteArray).ToNot(BeNil())
- })
- It(`Invoke CreateMockUUID() successfully`, func() {
- mockUUID := CreateMockUUID("9fab83da-98cb-4f18-a7ba-b6f0435c9673")
- Expect(mockUUID).ToNot(BeNil())
- })
- It(`Invoke CreateMockReader() successfully`, func() {
- mockReader := CreateMockReader("This is a test.")
- Expect(mockReader).ToNot(BeNil())
- })
- It(`Invoke CreateMockDate() successfully`, func() {
- mockDate := CreateMockDate("2019-01-01")
- Expect(mockDate).ToNot(BeNil())
- })
- It(`Invoke CreateMockDateTime() successfully`, func() {
- mockDateTime := CreateMockDateTime("2019-01-01T12:00:00.000Z")
- Expect(mockDateTime).ToNot(BeNil())
- })
- })
- })
-
- //
- // Utility functions used by the generated test code
- //
-
- func CreateMockByteArray(mockData string) *[]byte {
- ba := make([]byte, 0)
- ba = append(ba, mockData...)
- return &ba
- }
-
- func CreateMockUUID(mockData string) *strfmt.UUID {
- uuid := strfmt.UUID(mockData)
- return &uuid
- }
-
- func CreateMockReader(mockData string) io.ReadCloser {
- return ioutil.NopCloser(bytes.NewReader([]byte(mockData)))
- }
-
- func CreateMockDate(mockData string) *strfmt.Date {
- d, err := core.ParseDate(mockData)
- if err != nil {
- return nil
- }
- return &d
- }
-
- func CreateMockDateTime(mockData string) *strfmt.DateTime {
- d, err := core.ParseDateTime(mockData)
- if err != nil {
- return nil
- }
- return &d
- }
-
- func SetTestEnvironment(testEnvironment map[string]string) {
- for key, value := range testEnvironment {
- os.Setenv(key, value)
- }
- }
-
- func ClearTestEnvironment(testEnvironment map[string]string) {
- for key := range testEnvironment {
- os.Unsetenv(key)
- }
- }
-
\ No newline at end of file
+
+var _ = Describe(`SchematicsV1`, func() {
+ var testServer *httptest.Server
+ Describe(`Service constructor tests`, func() {
+ It(`Instantiate service client`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(schematicsService).ToNot(BeNil())
+ Expect(serviceErr).To(BeNil())
+ })
+ It(`Instantiate service client with error: Invalid URL`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: "{BAD_URL_STRING",
+ })
+ Expect(schematicsService).To(BeNil())
+ Expect(serviceErr).ToNot(BeNil())
+ })
+ It(`Instantiate service client with error: Invalid Auth`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: "https://schematicsv1/api",
+ Authenticator: &core.BasicAuthenticator{
+ Username: "",
+ Password: "",
+ },
+ })
+ Expect(schematicsService).To(BeNil())
+ Expect(serviceErr).ToNot(BeNil())
+ })
+ })
+ Describe(`Service constructor tests using external config`, func() {
+ Context(`Using external config, construct service client instances`, func() {
+ // Map containing environment variables used in testing.
+ var testEnvironment = map[string]string{
+ "SCHEMATICS_URL": "https://schematicsv1/api",
+ "SCHEMATICS_AUTH_TYPE": "noauth",
+ }
+
+ It(`Create service client using external config successfully`, func() {
+ SetTestEnvironment(testEnvironment)
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{})
+ Expect(schematicsService).ToNot(BeNil())
+ Expect(serviceErr).To(BeNil())
+ ClearTestEnvironment(testEnvironment)
+
+ clone := schematicsService.Clone()
+ Expect(clone).ToNot(BeNil())
+ Expect(clone.Service != schematicsService.Service).To(BeTrue())
+ Expect(clone.GetServiceURL()).To(Equal(schematicsService.GetServiceURL()))
+ Expect(clone.Service.Options.Authenticator).To(Equal(schematicsService.Service.Options.Authenticator))
+ })
+ It(`Create service client using external config and set url from constructor successfully`, func() {
+ SetTestEnvironment(testEnvironment)
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{
+ URL: "https://testService/api",
+ })
+ Expect(schematicsService).ToNot(BeNil())
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService.Service.GetServiceURL()).To(Equal("https://testService/api"))
+ ClearTestEnvironment(testEnvironment)
+
+ clone := schematicsService.Clone()
+ Expect(clone).ToNot(BeNil())
+ Expect(clone.Service != schematicsService.Service).To(BeTrue())
+ Expect(clone.GetServiceURL()).To(Equal(schematicsService.GetServiceURL()))
+ Expect(clone.Service.Options.Authenticator).To(Equal(schematicsService.Service.Options.Authenticator))
+ })
+ It(`Create service client using external config and set url programatically successfully`, func() {
+ SetTestEnvironment(testEnvironment)
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{})
+ err := schematicsService.SetServiceURL("https://testService/api")
+ Expect(err).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService.Service.GetServiceURL()).To(Equal("https://testService/api"))
+ ClearTestEnvironment(testEnvironment)
+
+ clone := schematicsService.Clone()
+ Expect(clone).ToNot(BeNil())
+ Expect(clone.Service != schematicsService.Service).To(BeTrue())
+ Expect(clone.GetServiceURL()).To(Equal(schematicsService.GetServiceURL()))
+ Expect(clone.Service.Options.Authenticator).To(Equal(schematicsService.Service.Options.Authenticator))
+ })
+ })
+ Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
+ // Map containing environment variables used in testing.
+ var testEnvironment = map[string]string{
+ "SCHEMATICS_URL": "https://schematicsv1/api",
+ "SCHEMATICS_AUTH_TYPE": "someOtherAuth",
+ }
+
+ SetTestEnvironment(testEnvironment)
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{})
+
+ It(`Instantiate service client with error`, func() {
+ Expect(schematicsService).To(BeNil())
+ Expect(serviceErr).ToNot(BeNil())
+ ClearTestEnvironment(testEnvironment)
+ })
+ })
+ Context(`Using external config, construct service client instances with error: Invalid URL`, func() {
+ // Map containing environment variables used in testing.
+ var testEnvironment = map[string]string{
+ "SCHEMATICS_AUTH_TYPE": "NOAuth",
+ }
+
+ SetTestEnvironment(testEnvironment)
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1UsingExternalConfig(&schematicsv1.SchematicsV1Options{
+ URL: "{BAD_URL_STRING",
+ })
+
+ It(`Instantiate service client with error`, func() {
+ Expect(schematicsService).To(BeNil())
+ Expect(serviceErr).ToNot(BeNil())
+ ClearTestEnvironment(testEnvironment)
+ })
+ })
+ })
+ Describe(`Regional endpoint tests`, func() {
+ It(`GetServiceURLForRegion(region string)`, func() {
+ var url string
+ var err error
+ url, err = schematicsv1.GetServiceURLForRegion("INVALID_REGION")
+ Expect(url).To(BeEmpty())
+ Expect(err).ToNot(BeNil())
+ fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
+ })
+ })
+ Describe(`ListSchematicsLocation(listSchematicsLocationOptions *ListSchematicsLocationOptions) - Operation response error`, func() {
+ listSchematicsLocationPath := "/v1/locations"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listSchematicsLocationPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListSchematicsLocation with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListSchematicsLocationOptions model
+ listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
+ listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListSchematicsLocation(listSchematicsLocationOptions *ListSchematicsLocationOptions)`, func() {
+ listSchematicsLocationPath := "/v1/locations"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listSchematicsLocationPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"name": "Name", "id": "ID", "country": "Country", "geography": "Geography", "geography_code": "GeographyCode", "metro": "Metro", "multizone_metro": "MultizoneMetro", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]`)
+ }))
+ })
+ It(`Invoke ListSchematicsLocation successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListSchematicsLocationOptions model
+ listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
+ listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListSchematicsLocationWithContext(ctx, listSchematicsLocationOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListSchematicsLocationWithContext(ctx, listSchematicsLocationOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listSchematicsLocationPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"name": "Name", "id": "ID", "country": "Country", "geography": "Geography", "geography_code": "GeographyCode", "metro": "Metro", "multizone_metro": "MultizoneMetro", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]`)
+ }))
+ })
+ It(`Invoke ListSchematicsLocation successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListSchematicsLocation(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListSchematicsLocationOptions model
+ listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
+ listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListSchematicsLocation with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListSchematicsLocationOptions model
+ listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
+ listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListSchematicsLocation successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListSchematicsLocationOptions model
+ listSchematicsLocationOptionsModel := new(schematicsv1.ListSchematicsLocationOptions)
+ listSchematicsLocationOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListSchematicsLocation(listSchematicsLocationOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListResourceGroup(listResourceGroupOptions *ListResourceGroupOptions) - Operation response error`, func() {
+ listResourceGroupPath := "/v1/resource_groups"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listResourceGroupPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListResourceGroup with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListResourceGroupOptions model
+ listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
+ listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListResourceGroup(listResourceGroupOptions *ListResourceGroupOptions)`, func() {
+ listResourceGroupPath := "/v1/resource_groups"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listResourceGroupPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"account_id": "AccountID", "crn": "Crn", "default": false, "name": "Name", "resource_group_id": "ResourceGroupID", "state": "State"}]`)
+ }))
+ })
+ It(`Invoke ListResourceGroup successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListResourceGroupOptions model
+ listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
+ listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListResourceGroupWithContext(ctx, listResourceGroupOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListResourceGroupWithContext(ctx, listResourceGroupOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listResourceGroupPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"account_id": "AccountID", "crn": "Crn", "default": false, "name": "Name", "resource_group_id": "ResourceGroupID", "state": "State"}]`)
+ }))
+ })
+ It(`Invoke ListResourceGroup successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListResourceGroup(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListResourceGroupOptions model
+ listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
+ listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListResourceGroup with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListResourceGroupOptions model
+ listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
+ listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListResourceGroup successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListResourceGroupOptions model
+ listResourceGroupOptionsModel := new(schematicsv1.ListResourceGroupOptions)
+ listResourceGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListResourceGroup(listResourceGroupOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetSchematicsVersion(getSchematicsVersionOptions *GetSchematicsVersionOptions) - Operation response error`, func() {
+ getSchematicsVersionPath := "/v1/version"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getSchematicsVersionPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetSchematicsVersion with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetSchematicsVersionOptions model
+ getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
+ getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetSchematicsVersion(getSchematicsVersionOptions *GetSchematicsVersionOptions)`, func() {
+ getSchematicsVersionPath := "/v1/version"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getSchematicsVersionPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"builddate": "Builddate", "buildno": "Buildno", "commitsha": "Commitsha", "helm_provider_version": "HelmProviderVersion", "helm_version": "HelmVersion", "supported_template_types": {"anyKey": "anyValue"}, "terraform_provider_version": "TerraformProviderVersion", "terraform_version": "TerraformVersion"}`)
+ }))
+ })
+ It(`Invoke GetSchematicsVersion successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetSchematicsVersionOptions model
+ getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
+ getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetSchematicsVersionWithContext(ctx, getSchematicsVersionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetSchematicsVersionWithContext(ctx, getSchematicsVersionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getSchematicsVersionPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"builddate": "Builddate", "buildno": "Buildno", "commitsha": "Commitsha", "helm_provider_version": "HelmProviderVersion", "helm_version": "HelmVersion", "supported_template_types": {"anyKey": "anyValue"}, "terraform_provider_version": "TerraformProviderVersion", "terraform_version": "TerraformVersion"}`)
+ }))
+ })
+ It(`Invoke GetSchematicsVersion successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetSchematicsVersion(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetSchematicsVersionOptions model
+ getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
+ getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetSchematicsVersion with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetSchematicsVersionOptions model
+ getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
+ getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetSchematicsVersion successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetSchematicsVersionOptions model
+ getSchematicsVersionOptionsModel := new(schematicsv1.GetSchematicsVersionOptions)
+ getSchematicsVersionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetSchematicsVersion(getSchematicsVersionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListLocations(listLocationsOptions *ListLocationsOptions) - Operation response error`, func() {
+ listLocationsPath := "/v2/locations"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listLocationsPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListLocations with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListLocationsOptions model
+ listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
+ listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListLocations(listLocationsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListLocations(listLocationsOptions *ListLocationsOptions)`, func() {
+ listLocationsPath := "/v2/locations"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listLocationsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"locations": [{"region": "Region", "metro": "Metro", "geography_code": "GeographyCode", "geography": "Geography", "country": "Country", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]}`)
+ }))
+ })
+ It(`Invoke ListLocations successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListLocationsOptions model
+ listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
+ listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListLocationsWithContext(ctx, listLocationsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListLocationsWithContext(ctx, listLocationsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listLocationsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"locations": [{"region": "Region", "metro": "Metro", "geography_code": "GeographyCode", "geography": "Geography", "country": "Country", "kind": "Kind", "paired_region": ["PairedRegion"], "restricted": true}]}`)
+ }))
+ })
+ It(`Invoke ListLocations successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListLocations(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListLocationsOptions model
+ listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
+ listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListLocations(listLocationsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListLocations with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListLocationsOptions model
+ listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
+ listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListLocations successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListLocationsOptions model
+ listLocationsOptionsModel := new(schematicsv1.ListLocationsOptions)
+ listLocationsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListLocations(listLocationsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ProcessTemplateMetaData(processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions) - Operation response error`, func() {
+ processTemplateMetaDataPath := "/v2/template_metadata_processor"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(processTemplateMetaDataPath))
+ Expect(req.Method).To(Equal("POST"))
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ProcessTemplateMetaData with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the ProcessTemplateMetaDataOptions model
+ processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
+ processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Source = externalSourceModel
+ processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
+ processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ProcessTemplateMetaData(processTemplateMetaDataOptions *ProcessTemplateMetaDataOptions)`, func() {
+ processTemplateMetaDataPath := "/v2/template_metadata_processor"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(processTemplateMetaDataPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "Type", "variables": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}]}`)
+ }))
+ })
+ It(`Invoke ProcessTemplateMetaData successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the ProcessTemplateMetaDataOptions model
+ processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
+ processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Source = externalSourceModel
+ processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
+ processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ProcessTemplateMetaDataWithContext(ctx, processTemplateMetaDataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ProcessTemplateMetaDataWithContext(ctx, processTemplateMetaDataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(processTemplateMetaDataPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "Type", "variables": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}]}`)
+ }))
+ })
+ It(`Invoke ProcessTemplateMetaData successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ProcessTemplateMetaData(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the ProcessTemplateMetaDataOptions model
+ processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
+ processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Source = externalSourceModel
+ processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
+ processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ProcessTemplateMetaData with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the ProcessTemplateMetaDataOptions model
+ processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
+ processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Source = externalSourceModel
+ processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
+ processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ProcessTemplateMetaDataOptions model with no property values
+ processTemplateMetaDataOptionsModelNew := new(schematicsv1.ProcessTemplateMetaDataOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ProcessTemplateMetaData successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the ProcessTemplateMetaDataOptions model
+ processTemplateMetaDataOptionsModel := new(schematicsv1.ProcessTemplateMetaDataOptions)
+ processTemplateMetaDataOptionsModel.TemplateType = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Source = externalSourceModel
+ processTemplateMetaDataOptionsModel.Region = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.SourceType = core.StringPtr("local")
+ processTemplateMetaDataOptionsModel.XGithubToken = core.StringPtr("testString")
+ processTemplateMetaDataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ProcessTemplateMetaData(processTemplateMetaDataOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListWorkspaces(listWorkspacesOptions *ListWorkspacesOptions) - Operation response error`, func() {
+ listWorkspacesPath := "/v1/workspaces"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listWorkspacesPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListWorkspaces with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListWorkspacesOptions model
+ listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
+ listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListWorkspaces(listWorkspacesOptions *ListWorkspacesOptions)`, func() {
+ listWorkspacesPath := "/v1/workspaces"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listWorkspacesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"count": 5, "limit": 5, "offset": 6, "workspaces": [{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}]}`)
+ }))
+ })
+ It(`Invoke ListWorkspaces successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListWorkspacesOptions model
+ listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
+ listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListWorkspacesWithContext(ctx, listWorkspacesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListWorkspacesWithContext(ctx, listWorkspacesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listWorkspacesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"count": 5, "limit": 5, "offset": 6, "workspaces": [{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}]}`)
+ }))
+ })
+ It(`Invoke ListWorkspaces successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListWorkspaces(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListWorkspacesOptions model
+ listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
+ listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListWorkspaces with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListWorkspacesOptions model
+ listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
+ listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListWorkspaces successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListWorkspacesOptions model
+ listWorkspacesOptionsModel := new(schematicsv1.ListWorkspacesOptions)
+ listWorkspacesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspacesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspacesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListWorkspaces(listWorkspacesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateWorkspace(createWorkspaceOptions *CreateWorkspaceOptions) - Operation response error`, func() {
+ createWorkspacePath := "/v1/workspaces"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createWorkspacePath))
+ Expect(req.Method).To(Equal("POST"))
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke CreateWorkspace with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoRequest model
+ templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
+ templateRepoRequestModel.Branch = core.StringPtr("testString")
+ templateRepoRequestModel.Release = core.StringPtr("testString")
+ templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusRequest model
+ workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
+ workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateWorkspaceOptions model
+ createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
+ createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
+ createWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ createWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Location = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ createWorkspaceOptionsModel.Tags = []string{"testString"}
+ createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
+ createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
+ createWorkspaceOptionsModel.Type = []string{"testString"}
+ createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
+ createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateWorkspace(createWorkspaceOptions *CreateWorkspaceOptions)`, func() {
+ createWorkspacePath := "/v1/workspaces"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createWorkspacePath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke CreateWorkspace successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoRequest model
+ templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
+ templateRepoRequestModel.Branch = core.StringPtr("testString")
+ templateRepoRequestModel.Release = core.StringPtr("testString")
+ templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusRequest model
+ workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
+ workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateWorkspaceOptions model
+ createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
+ createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
+ createWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ createWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Location = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ createWorkspaceOptionsModel.Tags = []string{"testString"}
+ createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
+ createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
+ createWorkspaceOptionsModel.Type = []string{"testString"}
+ createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
+ createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.CreateWorkspaceWithContext(ctx, createWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.CreateWorkspaceWithContext(ctx, createWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createWorkspacePath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke CreateWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.CreateWorkspace(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoRequest model
+ templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
+ templateRepoRequestModel.Branch = core.StringPtr("testString")
+ templateRepoRequestModel.Release = core.StringPtr("testString")
+ templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusRequest model
+ workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
+ workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateWorkspaceOptions model
+ createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
+ createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
+ createWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ createWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Location = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ createWorkspaceOptionsModel.Tags = []string{"testString"}
+ createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
+ createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
+ createWorkspaceOptionsModel.Type = []string{"testString"}
+ createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
+ createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke CreateWorkspace with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoRequest model
+ templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
+ templateRepoRequestModel.Branch = core.StringPtr("testString")
+ templateRepoRequestModel.Release = core.StringPtr("testString")
+ templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusRequest model
+ workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
+ workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateWorkspaceOptions model
+ createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
+ createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
+ createWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ createWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Location = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ createWorkspaceOptionsModel.Tags = []string{"testString"}
+ createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
+ createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
+ createWorkspaceOptionsModel.Type = []string{"testString"}
+ createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
+ createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(201)
+ }))
+ })
+ It(`Invoke CreateWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoRequest model
+ templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
+ templateRepoRequestModel.Branch = core.StringPtr("testString")
+ templateRepoRequestModel.Release = core.StringPtr("testString")
+ templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusRequest model
+ workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
+ workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateWorkspaceOptions model
+ createWorkspaceOptionsModel := new(schematicsv1.CreateWorkspaceOptions)
+ createWorkspaceOptionsModel.AppliedShareddataIds = []string{"testString"}
+ createWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ createWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Location = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ createWorkspaceOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ createWorkspaceOptionsModel.Tags = []string{"testString"}
+ createWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ createWorkspaceOptionsModel.TemplateRef = core.StringPtr("testString")
+ createWorkspaceOptionsModel.TemplateRepo = templateRepoRequestModel
+ createWorkspaceOptionsModel.Type = []string{"testString"}
+ createWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusRequestModel
+ createWorkspaceOptionsModel.XGithubToken = core.StringPtr("testString")
+ createWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.CreateWorkspace(createWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspace(getWorkspaceOptions *GetWorkspaceOptions) - Operation response error`, func() {
+ getWorkspacePath := "/v1/workspaces/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspacePath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspace with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceOptions model
+ getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
+ getWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspace(getWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspace(getWorkspaceOptions *GetWorkspaceOptions)`, func() {
+ getWorkspacePath := "/v1/workspaces/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspacePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke GetWorkspace successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceOptions model
+ getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
+ getWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceWithContext(ctx, getWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceWithContext(ctx, getWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspacePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke GetWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspace(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceOptions model
+ getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
+ getWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspace(getWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspace with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceOptions model
+ getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
+ getWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceOptions model with no property values
+ getWorkspaceOptionsModelNew := new(schematicsv1.GetWorkspaceOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspace(getWorkspaceOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceOptions model
+ getWorkspaceOptionsModel := new(schematicsv1.GetWorkspaceOptions)
+ getWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspace(getWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceWorkspace(replaceWorkspaceOptions *ReplaceWorkspaceOptions) - Operation response error`, func() {
+ replaceWorkspacePath := "/v1/workspaces/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspacePath))
+ Expect(req.Method).To(Equal("PUT"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ReplaceWorkspace with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceOptions model
+ replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
+ replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ replaceWorkspaceOptionsModel.Tags = []string{"testString"}
+ replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ replaceWorkspaceOptionsModel.Type = []string{"testString"}
+ replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceWorkspace(replaceWorkspaceOptions *ReplaceWorkspaceOptions)`, func() {
+ replaceWorkspacePath := "/v1/workspaces/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspacePath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke ReplaceWorkspace successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceOptions model
+ replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
+ replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ replaceWorkspaceOptionsModel.Tags = []string{"testString"}
+ replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ replaceWorkspaceOptionsModel.Type = []string{"testString"}
+ replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ReplaceWorkspaceWithContext(ctx, replaceWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ReplaceWorkspaceWithContext(ctx, replaceWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspacePath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke ReplaceWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ReplaceWorkspace(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceOptions model
+ replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
+ replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ replaceWorkspaceOptionsModel.Tags = []string{"testString"}
+ replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ replaceWorkspaceOptionsModel.Type = []string{"testString"}
+ replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ReplaceWorkspace with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceOptions model
+ replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
+ replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ replaceWorkspaceOptionsModel.Tags = []string{"testString"}
+ replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ replaceWorkspaceOptionsModel.Type = []string{"testString"}
+ replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ReplaceWorkspaceOptions model with no property values
+ replaceWorkspaceOptionsModelNew := new(schematicsv1.ReplaceWorkspaceOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ReplaceWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceOptions model
+ replaceWorkspaceOptionsModel := new(schematicsv1.ReplaceWorkspaceOptions)
+ replaceWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ replaceWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ replaceWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ replaceWorkspaceOptionsModel.Tags = []string{"testString"}
+ replaceWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ replaceWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ replaceWorkspaceOptionsModel.Type = []string{"testString"}
+ replaceWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ replaceWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ replaceWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ReplaceWorkspace(replaceWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DeleteWorkspace(deleteWorkspaceOptions *DeleteWorkspaceOptions)`, func() {
+ deleteWorkspacePath := "/v1/workspaces/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspacePath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // TODO: Add check for destroy_resources query parameter
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `"OperationResponse"`)
+ }))
+ })
+ It(`Invoke DeleteWorkspace successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the DeleteWorkspaceOptions model
+ deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
+ deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
+ deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.DeleteWorkspaceWithContext(ctx, deleteWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.DeleteWorkspaceWithContext(ctx, deleteWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspacePath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // TODO: Add check for destroy_resources query parameter
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `"OperationResponse"`)
+ }))
+ })
+ It(`Invoke DeleteWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.DeleteWorkspace(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the DeleteWorkspaceOptions model
+ deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
+ deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
+ deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke DeleteWorkspace with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteWorkspaceOptions model
+ deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
+ deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
+ deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the DeleteWorkspaceOptions model with no property values
+ deleteWorkspaceOptionsModelNew := new(schematicsv1.DeleteWorkspaceOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke DeleteWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteWorkspaceOptions model
+ deleteWorkspaceOptionsModel := new(schematicsv1.DeleteWorkspaceOptions)
+ deleteWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.DestroyResources = core.BoolPtr(true)
+ deleteWorkspaceOptionsModel.RefreshToken = core.StringPtr("testString")
+ deleteWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.DeleteWorkspace(deleteWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateWorkspace(updateWorkspaceOptions *UpdateWorkspaceOptions) - Operation response error`, func() {
+ updateWorkspacePath := "/v1/workspaces/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateWorkspacePath))
+ Expect(req.Method).To(Equal("PATCH"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke UpdateWorkspace with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateWorkspaceOptions model
+ updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
+ updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ updateWorkspaceOptionsModel.Tags = []string{"testString"}
+ updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ updateWorkspaceOptionsModel.Type = []string{"testString"}
+ updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateWorkspace(updateWorkspaceOptions *UpdateWorkspaceOptions)`, func() {
+ updateWorkspacePath := "/v1/workspaces/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateWorkspacePath))
+ Expect(req.Method).To(Equal("PATCH"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke UpdateWorkspace successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateWorkspaceOptions model
+ updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
+ updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ updateWorkspaceOptionsModel.Tags = []string{"testString"}
+ updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ updateWorkspaceOptionsModel.Type = []string{"testString"}
+ updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.UpdateWorkspaceWithContext(ctx, updateWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.UpdateWorkspaceWithContext(ctx, updateWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateWorkspacePath))
+ Expect(req.Method).To(Equal("PATCH"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"applied_shareddata_ids": ["AppliedShareddataIds"], "catalog_ref": {"dry_run": true, "owning_account": "OwningAccount", "item_icon_url": "ItemIconURL", "item_id": "ItemID", "item_name": "ItemName", "item_readme_url": "ItemReadmeURL", "item_url": "ItemURL", "launch_url": "LaunchURL", "offering_version": "OfferingVersion"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "crn": "Crn", "description": "Description", "id": "ID", "last_health_check_at": "2019-01-01T12:00:00.000Z", "location": "Location", "name": "Name", "resource_group": "ResourceGroup", "runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_id": "ClusterID", "cluster_name": "ClusterName", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID"}, "status": "Status", "tags": ["Tags"], "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}], "template_ref": "TemplateRef", "template_repo": {"branch": "Branch", "full_url": "FullURL", "has_uploadedgitrepotar": false, "release": "Release", "repo_sha_value": "RepoShaValue", "repo_url": "RepoURL", "url": "URL"}, "type": ["Type"], "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "workspace_status": {"frozen": true, "frozen_at": "2019-01-01T12:00:00.000Z", "frozen_by": "FrozenBy", "locked": true, "locked_by": "LockedBy", "locked_time": "2019-01-01T12:00:00.000Z"}, "workspace_status_msg": {"status_code": "StatusCode", "status_msg": "StatusMsg"}}`)
+ }))
+ })
+ It(`Invoke UpdateWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.UpdateWorkspace(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateWorkspaceOptions model
+ updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
+ updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ updateWorkspaceOptionsModel.Tags = []string{"testString"}
+ updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ updateWorkspaceOptionsModel.Type = []string{"testString"}
+ updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke UpdateWorkspace with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateWorkspaceOptions model
+ updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
+ updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ updateWorkspaceOptionsModel.Tags = []string{"testString"}
+ updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ updateWorkspaceOptionsModel.Type = []string{"testString"}
+ updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the UpdateWorkspaceOptions model with no property values
+ updateWorkspaceOptionsModelNew := new(schematicsv1.UpdateWorkspaceOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.UpdateWorkspace(updateWorkspaceOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke UpdateWorkspace successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateWorkspaceOptions model
+ updateWorkspaceOptionsModel := new(schematicsv1.UpdateWorkspaceOptions)
+ updateWorkspaceOptionsModel.WID = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.CatalogRef = catalogRefModel
+ updateWorkspaceOptionsModel.Description = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.Name = core.StringPtr("testString")
+ updateWorkspaceOptionsModel.SharedData = sharedTargetDataModel
+ updateWorkspaceOptionsModel.Tags = []string{"testString"}
+ updateWorkspaceOptionsModel.TemplateData = []schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}
+ updateWorkspaceOptionsModel.TemplateRepo = templateRepoUpdateRequestModel
+ updateWorkspaceOptionsModel.Type = []string{"testString"}
+ updateWorkspaceOptionsModel.WorkspaceStatus = workspaceStatusUpdateRequestModel
+ updateWorkspaceOptionsModel.WorkspaceStatusMsg = workspaceStatusMessageModel
+ updateWorkspaceOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.UpdateWorkspace(updateWorkspaceOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceReadme(getWorkspaceReadmeOptions *GetWorkspaceReadmeOptions) - Operation response error`, func() {
+ getWorkspaceReadmePath := "/v1/workspaces/testString/templates/readme"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceReadmePath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["ref"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["formatted"]).To(Equal([]string{"markdown"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceReadme with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceReadmeOptions model
+ getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
+ getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
+ getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceReadme(getWorkspaceReadmeOptions *GetWorkspaceReadmeOptions)`, func() {
+ getWorkspaceReadmePath := "/v1/workspaces/testString/templates/readme"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceReadmePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["ref"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["formatted"]).To(Equal([]string{"markdown"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"readme": "Readme"}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceReadme successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceReadmeOptions model
+ getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
+ getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
+ getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceReadmeWithContext(ctx, getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceReadmeWithContext(ctx, getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceReadmePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["ref"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["formatted"]).To(Equal([]string{"markdown"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"readme": "Readme"}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceReadme successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceReadme(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceReadmeOptions model
+ getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
+ getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
+ getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceReadme with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceReadmeOptions model
+ getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
+ getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
+ getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceReadmeOptions model with no property values
+ getWorkspaceReadmeOptionsModelNew := new(schematicsv1.GetWorkspaceReadmeOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceReadme successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceReadmeOptions model
+ getWorkspaceReadmeOptionsModel := new(schematicsv1.GetWorkspaceReadmeOptions)
+ getWorkspaceReadmeOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Ref = core.StringPtr("testString")
+ getWorkspaceReadmeOptionsModel.Formatted = core.StringPtr("markdown")
+ getWorkspaceReadmeOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceReadme(getWorkspaceReadmeOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`TemplateRepoUpload(templateRepoUploadOptions *TemplateRepoUploadOptions) - Operation response error`, func() {
+ templateRepoUploadPath := "/v1/workspaces/testString/template_data/testString/template_repo_upload"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(templateRepoUploadPath))
+ Expect(req.Method).To(Equal("PUT"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke TemplateRepoUpload with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the TemplateRepoUploadOptions model
+ templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
+ templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
+ templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`TemplateRepoUpload(templateRepoUploadOptions *TemplateRepoUploadOptions)`, func() {
+ templateRepoUploadPath := "/v1/workspaces/testString/template_data/testString/template_repo_upload"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(templateRepoUploadPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
+ }))
+ })
+ It(`Invoke TemplateRepoUpload successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the TemplateRepoUploadOptions model
+ templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
+ templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
+ templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.TemplateRepoUploadWithContext(ctx, templateRepoUploadOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.TemplateRepoUploadWithContext(ctx, templateRepoUploadOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(templateRepoUploadPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
+ }))
+ })
+ It(`Invoke TemplateRepoUpload successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.TemplateRepoUpload(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the TemplateRepoUploadOptions model
+ templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
+ templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
+ templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke TemplateRepoUpload with error: Param validation error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the TemplateRepoUploadOptions model
+ templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
+ // Invoke operation with invalid options model (negative test)
+ result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ It(`Invoke TemplateRepoUpload with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the TemplateRepoUploadOptions model
+ templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
+ templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
+ templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the TemplateRepoUploadOptions model with no property values
+ templateRepoUploadOptionsModelNew := new(schematicsv1.TemplateRepoUploadOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke TemplateRepoUpload successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the TemplateRepoUploadOptions model
+ templateRepoUploadOptionsModel := new(schematicsv1.TemplateRepoUploadOptions)
+ templateRepoUploadOptionsModel.WID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.TID = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.File = CreateMockReader("This is a mock file.")
+ templateRepoUploadOptionsModel.FileContentType = core.StringPtr("testString")
+ templateRepoUploadOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.TemplateRepoUpload(templateRepoUploadOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceInputs(getWorkspaceInputsOptions *GetWorkspaceInputsOptions) - Operation response error`, func() {
+ getWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceInputs with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceInputsOptions model
+ getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
+ getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceInputs(getWorkspaceInputsOptions *GetWorkspaceInputsOptions)`, func() {
+ getWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"values_metadata": [{"anyKey": "anyValue"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceInputs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceInputsOptions model
+ getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
+ getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceInputsWithContext(ctx, getWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceInputsWithContext(ctx, getWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"values_metadata": [{"anyKey": "anyValue"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceInputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceInputs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceInputsOptions model
+ getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
+ getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceInputs with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceInputsOptions model
+ getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
+ getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceInputsOptions model with no property values
+ getWorkspaceInputsOptionsModelNew := new(schematicsv1.GetWorkspaceInputsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceInputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceInputsOptions model
+ getWorkspaceInputsOptionsModel := new(schematicsv1.GetWorkspaceInputsOptions)
+ getWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceInputs(getWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions *ReplaceWorkspaceInputsOptions) - Operation response error`, func() {
+ replaceWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("PUT"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ReplaceWorkspaceInputs with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceInputsOptions model
+ replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
+ replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceWorkspaceInputs(replaceWorkspaceInputsOptions *ReplaceWorkspaceInputsOptions)`, func() {
+ replaceWorkspaceInputsPath := "/v1/workspaces/testString/template_data/testString/values"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"env_values": [{"anyKey": "anyValue"}], "values": "Values", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}`)
+ }))
+ })
+ It(`Invoke ReplaceWorkspaceInputs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceInputsOptions model
+ replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
+ replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ReplaceWorkspaceInputsWithContext(ctx, replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ReplaceWorkspaceInputsWithContext(ctx, replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"env_values": [{"anyKey": "anyValue"}], "values": "Values", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}`)
+ }))
+ })
+ It(`Invoke ReplaceWorkspaceInputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceInputsOptions model
+ replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
+ replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ReplaceWorkspaceInputs with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceInputsOptions model
+ replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
+ replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ReplaceWorkspaceInputsOptions model with no property values
+ replaceWorkspaceInputsOptionsModelNew := new(schematicsv1.ReplaceWorkspaceInputsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ReplaceWorkspaceInputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+
+ // Construct an instance of the ReplaceWorkspaceInputsOptions model
+ replaceWorkspaceInputsOptionsModel := new(schematicsv1.ReplaceWorkspaceInputsOptions)
+ replaceWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.TID = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ replaceWorkspaceInputsOptionsModel.Values = core.StringPtr("testString")
+ replaceWorkspaceInputsOptionsModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ replaceWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ReplaceWorkspaceInputs(replaceWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetAllWorkspaceInputs(getAllWorkspaceInputsOptions *GetAllWorkspaceInputsOptions) - Operation response error`, func() {
+ getAllWorkspaceInputsPath := "/v1/workspaces/testString/templates/values"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getAllWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetAllWorkspaceInputs with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetAllWorkspaceInputsOptions model
+ getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
+ getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetAllWorkspaceInputs(getAllWorkspaceInputsOptions *GetAllWorkspaceInputsOptions)`, func() {
+ getAllWorkspaceInputsPath := "/v1/workspaces/testString/templates/values"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getAllWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_created_on": "ClusterCreatedOn", "cluster_id": "ClusterID", "cluster_name": "ClusterName", "cluster_type": "ClusterType", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID", "worker_count": 11, "worker_machine_type": "WorkerMachineType"}, "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}]}`)
+ }))
+ })
+ It(`Invoke GetAllWorkspaceInputs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetAllWorkspaceInputsOptions model
+ getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
+ getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetAllWorkspaceInputsWithContext(ctx, getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetAllWorkspaceInputsWithContext(ctx, getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getAllWorkspaceInputsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_cmd": "EngineCmd", "engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL", "output_values": [{"anyKey": "anyValue"}], "resources": [[{"anyKey": "anyValue"}]], "state_store_url": "StateStoreURL"}], "shared_data": {"cluster_created_on": "ClusterCreatedOn", "cluster_id": "ClusterID", "cluster_name": "ClusterName", "cluster_type": "ClusterType", "entitlement_keys": [{"anyKey": "anyValue"}], "namespace": "Namespace", "region": "Region", "resource_group_id": "ResourceGroupID", "worker_count": 11, "worker_machine_type": "WorkerMachineType"}, "template_data": [{"env_values": [{"hidden": true, "name": "Name", "secure": true, "value": "Value"}], "folder": "Folder", "compact": false, "has_githubtoken": true, "id": "ID", "type": "Type", "uninstall_script_name": "UninstallScriptName", "values": "Values", "values_metadata": [{"anyKey": "anyValue"}], "values_url": "ValuesURL", "variablestore": [{"description": "Description", "name": "Name", "secure": true, "type": "Type", "value": "Value"}]}]}`)
+ }))
+ })
+ It(`Invoke GetAllWorkspaceInputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetAllWorkspaceInputs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetAllWorkspaceInputsOptions model
+ getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
+ getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetAllWorkspaceInputs with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetAllWorkspaceInputsOptions model
+ getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
+ getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetAllWorkspaceInputsOptions model with no property values
+ getAllWorkspaceInputsOptionsModelNew := new(schematicsv1.GetAllWorkspaceInputsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetAllWorkspaceInputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetAllWorkspaceInputsOptions model
+ getAllWorkspaceInputsOptionsModel := new(schematicsv1.GetAllWorkspaceInputsOptions)
+ getAllWorkspaceInputsOptionsModel.WID = core.StringPtr("testString")
+ getAllWorkspaceInputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetAllWorkspaceInputs(getAllWorkspaceInputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptions *GetWorkspaceInputMetadataOptions)`, func() {
+ getWorkspaceInputMetadataPath := "/v1/workspaces/testString/template_data/testString/values_metadata"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputMetadataPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceInputMetadata successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceInputMetadataOptions model
+ getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
+ getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceInputMetadataWithContext(ctx, getWorkspaceInputMetadataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceInputMetadataWithContext(ctx, getWorkspaceInputMetadataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceInputMetadataPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceInputMetadata successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceInputMetadataOptions model
+ getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
+ getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceInputMetadata with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceInputMetadataOptions model
+ getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
+ getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceInputMetadataOptions model with no property values
+ getWorkspaceInputMetadataOptionsModelNew := new(schematicsv1.GetWorkspaceInputMetadataOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceInputMetadata successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceInputMetadataOptions model
+ getWorkspaceInputMetadataOptionsModel := new(schematicsv1.GetWorkspaceInputMetadataOptions)
+ getWorkspaceInputMetadataOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceInputMetadataOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceInputMetadata(getWorkspaceInputMetadataOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceOutputs(getWorkspaceOutputsOptions *GetWorkspaceOutputsOptions) - Operation response error`, func() {
+ getWorkspaceOutputsPath := "/v1/workspaces/testString/output_values"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceOutputsPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceOutputs with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceOutputsOptions model
+ getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
+ getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceOutputs(getWorkspaceOutputsOptions *GetWorkspaceOutputsOptions)`, func() {
+ getWorkspaceOutputsPath := "/v1/workspaces/testString/output_values"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceOutputsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "output_values": [{"anyKey": "anyValue"}], "value_type": "ValueType"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceOutputs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceOutputsOptions model
+ getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
+ getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceOutputsWithContext(ctx, getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceOutputsWithContext(ctx, getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceOutputsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "output_values": [{"anyKey": "anyValue"}], "value_type": "ValueType"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceOutputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceOutputs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceOutputsOptions model
+ getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
+ getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceOutputs with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceOutputsOptions model
+ getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
+ getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceOutputsOptions model with no property values
+ getWorkspaceOutputsOptionsModelNew := new(schematicsv1.GetWorkspaceOutputsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceOutputs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceOutputsOptions model
+ getWorkspaceOutputsOptionsModel := new(schematicsv1.GetWorkspaceOutputsOptions)
+ getWorkspaceOutputsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceOutputsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceOutputs(getWorkspaceOutputsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceResources(getWorkspaceResourcesOptions *GetWorkspaceResourcesOptions) - Operation response error`, func() {
+ getWorkspaceResourcesPath := "/v1/workspaces/testString/resources"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceResourcesPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceResources with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceResourcesOptions model
+ getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
+ getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceResources(getWorkspaceResourcesOptions *GetWorkspaceResourcesOptions)`, func() {
+ getWorkspaceResourcesPath := "/v1/workspaces/testString/resources"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceResourcesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "null_resources": [{"anyKey": "anyValue"}], "related_resources": [{"anyKey": "anyValue"}], "resources": [{"anyKey": "anyValue"}], "resources_count": 14, "template_type": "TemplateType"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceResources successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceResourcesOptions model
+ getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
+ getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceResourcesWithContext(ctx, getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceResourcesWithContext(ctx, getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceResourcesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"folder": "Folder", "id": "ID", "null_resources": [{"anyKey": "anyValue"}], "related_resources": [{"anyKey": "anyValue"}], "resources": [{"anyKey": "anyValue"}], "resources_count": 14, "template_type": "TemplateType"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceResources successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceResources(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceResourcesOptions model
+ getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
+ getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceResources with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceResourcesOptions model
+ getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
+ getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceResourcesOptions model with no property values
+ getWorkspaceResourcesOptionsModelNew := new(schematicsv1.GetWorkspaceResourcesOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceResources successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceResourcesOptions model
+ getWorkspaceResourcesOptionsModel := new(schematicsv1.GetWorkspaceResourcesOptions)
+ getWorkspaceResourcesOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceResourcesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceResources(getWorkspaceResourcesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceState(getWorkspaceStateOptions *GetWorkspaceStateOptions) - Operation response error`, func() {
+ getWorkspaceStatePath := "/v1/workspaces/testString/state_stores"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceStatePath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceState with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceStateOptions model
+ getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
+ getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceState(getWorkspaceStateOptions *GetWorkspaceStateOptions)`, func() {
+ getWorkspaceStatePath := "/v1/workspaces/testString/state_stores"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceStatePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "state_store_url": "StateStoreURL"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceState successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceStateOptions model
+ getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
+ getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceStateWithContext(ctx, getWorkspaceStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceStateWithContext(ctx, getWorkspaceStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceStatePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "state_store_url": "StateStoreURL"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceState successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceState(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceStateOptions model
+ getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
+ getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceState with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceStateOptions model
+ getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
+ getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceStateOptions model with no property values
+ getWorkspaceStateOptionsModelNew := new(schematicsv1.GetWorkspaceStateOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceState successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceStateOptions model
+ getWorkspaceStateOptionsModel := new(schematicsv1.GetWorkspaceStateOptions)
+ getWorkspaceStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceState(getWorkspaceStateOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceTemplateState(getWorkspaceTemplateStateOptions *GetWorkspaceTemplateStateOptions)`, func() {
+ getWorkspaceTemplateStatePath := "/v1/workspaces/testString/runtime_data/testString/state_store"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceTemplateStatePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceTemplateState successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceTemplateStateOptions model
+ getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
+ getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceTemplateStateWithContext(ctx, getWorkspaceTemplateStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceTemplateStateWithContext(ctx, getWorkspaceTemplateStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceTemplateStatePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `[{"anyKey": "anyValue"}]`)
+ }))
+ })
+ It(`Invoke GetWorkspaceTemplateState successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceTemplateState(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceTemplateStateOptions model
+ getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
+ getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceTemplateState with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceTemplateStateOptions model
+ getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
+ getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceTemplateStateOptions model with no property values
+ getWorkspaceTemplateStateOptionsModelNew := new(schematicsv1.GetWorkspaceTemplateStateOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceTemplateState successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceTemplateStateOptions model
+ getWorkspaceTemplateStateOptionsModel := new(schematicsv1.GetWorkspaceTemplateStateOptions)
+ getWorkspaceTemplateStateOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.TID = core.StringPtr("testString")
+ getWorkspaceTemplateStateOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceTemplateState(getWorkspaceTemplateStateOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptions *GetWorkspaceActivityLogsOptions) - Operation response error`, func() {
+ getWorkspaceActivityLogsPath := "/v1/workspaces/testString/actions/testString/logs"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivityLogs with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityLogsOptions model
+ getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
+ getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptions *GetWorkspaceActivityLogsOptions)`, func() {
+ getWorkspaceActivityLogsPath := "/v1/workspaces/testString/actions/testString/logs"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "name": "Name", "templates": [{"log_url": "LogURL", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivityLogs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceActivityLogsOptions model
+ getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
+ getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceActivityLogsWithContext(ctx, getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceActivityLogsWithContext(ctx, getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "name": "Name", "templates": [{"log_url": "LogURL", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivityLogs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityLogsOptions model
+ getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
+ getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceActivityLogs with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityLogsOptions model
+ getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
+ getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceActivityLogsOptions model with no property values
+ getWorkspaceActivityLogsOptionsModelNew := new(schematicsv1.GetWorkspaceActivityLogsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivityLogs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityLogsOptions model
+ getWorkspaceActivityLogsOptionsModel := new(schematicsv1.GetWorkspaceActivityLogsOptions)
+ getWorkspaceActivityLogsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceActivityLogs(getWorkspaceActivityLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceLogUrls(getWorkspaceLogUrlsOptions *GetWorkspaceLogUrlsOptions) - Operation response error`, func() {
+ getWorkspaceLogUrlsPath := "/v1/workspaces/testString/log_stores"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceLogUrlsPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceLogUrls with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceLogUrlsOptions model
+ getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
+ getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceLogUrls(getWorkspaceLogUrlsOptions *GetWorkspaceLogUrlsOptions)`, func() {
+ getWorkspaceLogUrlsPath := "/v1/workspaces/testString/log_stores"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceLogUrlsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceLogUrls successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceLogUrlsOptions model
+ getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
+ getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceLogUrlsWithContext(ctx, getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceLogUrlsWithContext(ctx, getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceLogUrlsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"runtime_data": [{"engine_name": "EngineName", "engine_version": "EngineVersion", "id": "ID", "log_store_url": "LogStoreURL"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceLogUrls successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceLogUrls(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceLogUrlsOptions model
+ getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
+ getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceLogUrls with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceLogUrlsOptions model
+ getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
+ getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceLogUrlsOptions model with no property values
+ getWorkspaceLogUrlsOptionsModelNew := new(schematicsv1.GetWorkspaceLogUrlsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceLogUrls successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceLogUrlsOptions model
+ getWorkspaceLogUrlsOptionsModel := new(schematicsv1.GetWorkspaceLogUrlsOptions)
+ getWorkspaceLogUrlsOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceLogUrlsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceLogUrls(getWorkspaceLogUrlsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetTemplateLogs(getTemplateLogsOptions *GetTemplateLogsOptions)`, func() {
+ getTemplateLogsPath := "/v1/workspaces/testString/runtime_data/testString/log_store"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getTemplateLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // TODO: Add check for log_tf_cmd query parameter
+ // TODO: Add check for log_tf_prefix query parameter
+ // TODO: Add check for log_tf_null_resource query parameter
+ // TODO: Add check for log_tf_ansible query parameter
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `"OperationResponse"`)
+ }))
+ })
+ It(`Invoke GetTemplateLogs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetTemplateLogsOptions model
+ getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
+ getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetTemplateLogsWithContext(ctx, getTemplateLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetTemplateLogsWithContext(ctx, getTemplateLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getTemplateLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // TODO: Add check for log_tf_cmd query parameter
+ // TODO: Add check for log_tf_prefix query parameter
+ // TODO: Add check for log_tf_null_resource query parameter
+ // TODO: Add check for log_tf_ansible query parameter
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `"OperationResponse"`)
+ }))
+ })
+ It(`Invoke GetTemplateLogs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetTemplateLogs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetTemplateLogsOptions model
+ getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
+ getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetTemplateLogs with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetTemplateLogsOptions model
+ getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
+ getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetTemplateLogsOptions model with no property values
+ getTemplateLogsOptionsModelNew := new(schematicsv1.GetTemplateLogsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetTemplateLogs(getTemplateLogsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetTemplateLogs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetTemplateLogsOptions model
+ getTemplateLogsOptionsModel := new(schematicsv1.GetTemplateLogsOptions)
+ getTemplateLogsOptionsModel.WID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.TID = core.StringPtr("testString")
+ getTemplateLogsOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetTemplateLogs(getTemplateLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetTemplateActivityLog(getTemplateActivityLogOptions *GetTemplateActivityLogOptions)`, func() {
+ getTemplateActivityLogPath := "/v1/workspaces/testString/runtime_data/testString/log_store/actions/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getTemplateActivityLogPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // TODO: Add check for log_tf_cmd query parameter
+ // TODO: Add check for log_tf_prefix query parameter
+ // TODO: Add check for log_tf_null_resource query parameter
+ // TODO: Add check for log_tf_ansible query parameter
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `"OperationResponse"`)
+ }))
+ })
+ It(`Invoke GetTemplateActivityLog successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetTemplateActivityLogOptions model
+ getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
+ getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetTemplateActivityLogWithContext(ctx, getTemplateActivityLogOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetTemplateActivityLogWithContext(ctx, getTemplateActivityLogOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getTemplateActivityLogPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // TODO: Add check for log_tf_cmd query parameter
+ // TODO: Add check for log_tf_prefix query parameter
+ // TODO: Add check for log_tf_null_resource query parameter
+ // TODO: Add check for log_tf_ansible query parameter
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `"OperationResponse"`)
+ }))
+ })
+ It(`Invoke GetTemplateActivityLog successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetTemplateActivityLog(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetTemplateActivityLogOptions model
+ getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
+ getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetTemplateActivityLog with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetTemplateActivityLogOptions model
+ getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
+ getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetTemplateActivityLogOptions model with no property values
+ getTemplateActivityLogOptionsModelNew := new(schematicsv1.GetTemplateActivityLogOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetTemplateActivityLog successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetTemplateActivityLogOptions model
+ getTemplateActivityLogOptionsModel := new(schematicsv1.GetTemplateActivityLogOptions)
+ getTemplateActivityLogOptionsModel.WID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.TID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.ActivityID = core.StringPtr("testString")
+ getTemplateActivityLogOptionsModel.LogTfCmd = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfPrefix = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfNullResource = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.LogTfAnsible = core.BoolPtr(true)
+ getTemplateActivityLogOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetTemplateActivityLog(getTemplateActivityLogOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListActions(listActionsOptions *ListActionsOptions) - Operation response error`, func() {
+ listActionsPath := "/v2/actions"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listActionsPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListActions with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListActionsOptions model
+ listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
+ listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listActionsOptionsModel.Sort = core.StringPtr("testString")
+ listActionsOptionsModel.Profile = core.StringPtr("ids")
+ listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListActions(listActionsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListActions(listActionsOptions *ListActionsOptions)`, func() {
+ listActionsPath := "/v2/actions"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listActionsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "actions": [{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "id": "ID", "crn": "Crn", "location": "us-south", "resource_group": "ResourceGroup", "namespace": "Namespace", "tags": ["Tags"], "playbook_name": "PlaybookName", "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "state": {"status_code": "normal", "status_message": "StatusMessage"}, "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy"}]}`)
+ }))
+ })
+ It(`Invoke ListActions successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListActionsOptions model
+ listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
+ listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listActionsOptionsModel.Sort = core.StringPtr("testString")
+ listActionsOptionsModel.Profile = core.StringPtr("ids")
+ listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListActionsWithContext(ctx, listActionsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListActionsWithContext(ctx, listActionsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listActionsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "actions": [{"name": "Stop Action", "description": "This Action can be used to Stop the targets", "id": "ID", "crn": "Crn", "location": "us-south", "resource_group": "ResourceGroup", "namespace": "Namespace", "tags": ["Tags"], "playbook_name": "PlaybookName", "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "state": {"status_code": "normal", "status_message": "StatusMessage"}, "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}, "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy"}]}`)
+ }))
+ })
+ It(`Invoke ListActions successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListActions(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListActionsOptions model
+ listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
+ listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listActionsOptionsModel.Sort = core.StringPtr("testString")
+ listActionsOptionsModel.Profile = core.StringPtr("ids")
+ listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListActions(listActionsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListActions with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListActionsOptions model
+ listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
+ listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listActionsOptionsModel.Sort = core.StringPtr("testString")
+ listActionsOptionsModel.Profile = core.StringPtr("ids")
+ listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListActions successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListActionsOptions model
+ listActionsOptionsModel := new(schematicsv1.ListActionsOptions)
+ listActionsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listActionsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listActionsOptionsModel.Sort = core.StringPtr("testString")
+ listActionsOptionsModel.Profile = core.StringPtr("ids")
+ listActionsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListActions(listActionsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateAction(createActionOptions *CreateActionOptions) - Operation response error`, func() {
+ createActionPath := "/v2/actions"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createActionPath))
+ Expect(req.Method).To(Equal("POST"))
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke CreateAction with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateActionOptions model
+ createActionOptionsModel := new(schematicsv1.CreateActionOptions)
+ createActionOptionsModel.Name = core.StringPtr("Stop Action")
+ createActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ createActionOptionsModel.Location = core.StringPtr("us-south")
+ createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createActionOptionsModel.Tags = []string{"testString"}
+ createActionOptionsModel.UserState = userStateModel
+ createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ createActionOptionsModel.Source = externalSourceModel
+ createActionOptionsModel.SourceType = core.StringPtr("local")
+ createActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ createActionOptionsModel.Inventory = core.StringPtr("testString")
+ createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ createActionOptionsModel.BastionCredential = variableDataModel
+ createActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.State = actionStateModel
+ createActionOptionsModel.SysLock = systemLockModel
+ createActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.CreateAction(createActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateAction(createActionOptions *CreateActionOptions)`, func() {
+ createActionPath := "/v2/actions"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createActionPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "inventory": "Inventory", "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "bastion": {"name": "Name", "host": "Host"}, "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "targets_ini": "TargetsIni", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke CreateAction successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateActionOptions model
+ createActionOptionsModel := new(schematicsv1.CreateActionOptions)
+ createActionOptionsModel.Name = core.StringPtr("Stop Action")
+ createActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ createActionOptionsModel.Location = core.StringPtr("us-south")
+ createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createActionOptionsModel.Tags = []string{"testString"}
+ createActionOptionsModel.UserState = userStateModel
+ createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ createActionOptionsModel.Source = externalSourceModel
+ createActionOptionsModel.SourceType = core.StringPtr("local")
+ createActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ createActionOptionsModel.Inventory = core.StringPtr("testString")
+ createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ createActionOptionsModel.BastionCredential = variableDataModel
+ createActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.State = actionStateModel
+ createActionOptionsModel.SysLock = systemLockModel
+ createActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.CreateActionWithContext(ctx, createActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.CreateActionWithContext(ctx, createActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createActionPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "inventory": "Inventory", "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "bastion": {"name": "Name", "host": "Host"}, "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "targets_ini": "TargetsIni", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke CreateAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.CreateAction(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateActionOptions model
+ createActionOptionsModel := new(schematicsv1.CreateActionOptions)
+ createActionOptionsModel.Name = core.StringPtr("Stop Action")
+ createActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ createActionOptionsModel.Location = core.StringPtr("us-south")
+ createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createActionOptionsModel.Tags = []string{"testString"}
+ createActionOptionsModel.UserState = userStateModel
+ createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ createActionOptionsModel.Source = externalSourceModel
+ createActionOptionsModel.SourceType = core.StringPtr("local")
+ createActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ createActionOptionsModel.Inventory = core.StringPtr("testString")
+ createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ createActionOptionsModel.BastionCredential = variableDataModel
+ createActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.State = actionStateModel
+ createActionOptionsModel.SysLock = systemLockModel
+ createActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.CreateAction(createActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke CreateAction with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateActionOptions model
+ createActionOptionsModel := new(schematicsv1.CreateActionOptions)
+ createActionOptionsModel.Name = core.StringPtr("Stop Action")
+ createActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ createActionOptionsModel.Location = core.StringPtr("us-south")
+ createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createActionOptionsModel.Tags = []string{"testString"}
+ createActionOptionsModel.UserState = userStateModel
+ createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ createActionOptionsModel.Source = externalSourceModel
+ createActionOptionsModel.SourceType = core.StringPtr("local")
+ createActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ createActionOptionsModel.Inventory = core.StringPtr("testString")
+ createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ createActionOptionsModel.BastionCredential = variableDataModel
+ createActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.State = actionStateModel
+ createActionOptionsModel.SysLock = systemLockModel
+ createActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(201)
+ }))
+ })
+ It(`Invoke CreateAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the CreateActionOptions model
+ createActionOptionsModel := new(schematicsv1.CreateActionOptions)
+ createActionOptionsModel.Name = core.StringPtr("Stop Action")
+ createActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ createActionOptionsModel.Location = core.StringPtr("us-south")
+ createActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createActionOptionsModel.Tags = []string{"testString"}
+ createActionOptionsModel.UserState = userStateModel
+ createActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ createActionOptionsModel.Source = externalSourceModel
+ createActionOptionsModel.SourceType = core.StringPtr("local")
+ createActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ createActionOptionsModel.Inventory = core.StringPtr("testString")
+ createActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ createActionOptionsModel.BastionCredential = variableDataModel
+ createActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ createActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createActionOptionsModel.State = actionStateModel
+ createActionOptionsModel.SysLock = systemLockModel
+ createActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ createActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.CreateAction(createActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetAction(getActionOptions *GetActionOptions) - Operation response error`, func() {
+ getActionPath := "/v2/actions/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getActionPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetAction with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetActionOptions model
+ getActionOptionsModel := new(schematicsv1.GetActionOptions)
+ getActionOptionsModel.ActionID = core.StringPtr("testString")
+ getActionOptionsModel.Profile = core.StringPtr("summary")
+ getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetAction(getActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetAction(getActionOptions *GetActionOptions)`, func() {
+ getActionPath := "/v2/actions/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getActionPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "inventory": "Inventory", "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "bastion": {"name": "Name", "host": "Host"}, "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "targets_ini": "TargetsIni", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke GetAction successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetActionOptions model
+ getActionOptionsModel := new(schematicsv1.GetActionOptions)
+ getActionOptionsModel.ActionID = core.StringPtr("testString")
+ getActionOptionsModel.Profile = core.StringPtr("summary")
+ getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetActionWithContext(ctx, getActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetActionWithContext(ctx, getActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getActionPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "inventory": "Inventory", "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "bastion": {"name": "Name", "host": "Host"}, "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "targets_ini": "TargetsIni", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke GetAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetAction(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetActionOptions model
+ getActionOptionsModel := new(schematicsv1.GetActionOptions)
+ getActionOptionsModel.ActionID = core.StringPtr("testString")
+ getActionOptionsModel.Profile = core.StringPtr("summary")
+ getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetAction(getActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetAction with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetActionOptions model
+ getActionOptionsModel := new(schematicsv1.GetActionOptions)
+ getActionOptionsModel.ActionID = core.StringPtr("testString")
+ getActionOptionsModel.Profile = core.StringPtr("summary")
+ getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetActionOptions model with no property values
+ getActionOptionsModelNew := new(schematicsv1.GetActionOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetAction(getActionOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetActionOptions model
+ getActionOptionsModel := new(schematicsv1.GetActionOptions)
+ getActionOptionsModel.ActionID = core.StringPtr("testString")
+ getActionOptionsModel.Profile = core.StringPtr("summary")
+ getActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetAction(getActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DeleteAction(deleteActionOptions *DeleteActionOptions)`, func() {
+ deleteActionPath := "/v2/actions/testString"
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteActionPath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ Expect(req.Header["Force"]).ToNot(BeNil())
+ Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ Expect(req.Header["Propagate"]).ToNot(BeNil())
+ Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ res.WriteHeader(204)
+ }))
+ })
+ It(`Invoke DeleteAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ response, operationErr := schematicsService.DeleteAction(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+
+ // Construct an instance of the DeleteActionOptions model
+ deleteActionOptionsModel := new(schematicsv1.DeleteActionOptions)
+ deleteActionOptionsModel.ActionID = core.StringPtr("testString")
+ deleteActionOptionsModel.Force = core.BoolPtr(true)
+ deleteActionOptionsModel.Propagate = core.BoolPtr(true)
+ deleteActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ response, operationErr = schematicsService.DeleteAction(deleteActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ })
+ It(`Invoke DeleteAction with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteActionOptions model
+ deleteActionOptionsModel := new(schematicsv1.DeleteActionOptions)
+ deleteActionOptionsModel.ActionID = core.StringPtr("testString")
+ deleteActionOptionsModel.Force = core.BoolPtr(true)
+ deleteActionOptionsModel.Propagate = core.BoolPtr(true)
+ deleteActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ response, operationErr := schematicsService.DeleteAction(deleteActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ // Construct a second instance of the DeleteActionOptions model with no property values
+ deleteActionOptionsModelNew := new(schematicsv1.DeleteActionOptions)
+ // Invoke operation with invalid model (negative test)
+ response, operationErr = schematicsService.DeleteAction(deleteActionOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateAction(updateActionOptions *UpdateActionOptions) - Operation response error`, func() {
+ updateActionPath := "/v2/actions/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateActionPath))
+ Expect(req.Method).To(Equal("PATCH"))
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke UpdateAction with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the UpdateActionOptions model
+ updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
+ updateActionOptionsModel.ActionID = core.StringPtr("testString")
+ updateActionOptionsModel.Name = core.StringPtr("Stop Action")
+ updateActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ updateActionOptionsModel.Location = core.StringPtr("us-south")
+ updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateActionOptionsModel.Tags = []string{"testString"}
+ updateActionOptionsModel.UserState = userStateModel
+ updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ updateActionOptionsModel.Source = externalSourceModel
+ updateActionOptionsModel.SourceType = core.StringPtr("local")
+ updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateActionOptionsModel.Inventory = core.StringPtr("testString")
+ updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateActionOptionsModel.BastionCredential = variableDataModel
+ updateActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.State = actionStateModel
+ updateActionOptionsModel.SysLock = systemLockModel
+ updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.UpdateAction(updateActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateAction(updateActionOptions *UpdateActionOptions)`, func() {
+ updateActionPath := "/v2/actions/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateActionPath))
+ Expect(req.Method).To(Equal("PATCH"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "inventory": "Inventory", "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "bastion": {"name": "Name", "host": "Host"}, "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "targets_ini": "TargetsIni", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke UpdateAction successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the UpdateActionOptions model
+ updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
+ updateActionOptionsModel.ActionID = core.StringPtr("testString")
+ updateActionOptionsModel.Name = core.StringPtr("Stop Action")
+ updateActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ updateActionOptionsModel.Location = core.StringPtr("us-south")
+ updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateActionOptionsModel.Tags = []string{"testString"}
+ updateActionOptionsModel.UserState = userStateModel
+ updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ updateActionOptionsModel.Source = externalSourceModel
+ updateActionOptionsModel.SourceType = core.StringPtr("local")
+ updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateActionOptionsModel.Inventory = core.StringPtr("testString")
+ updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateActionOptionsModel.BastionCredential = variableDataModel
+ updateActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.State = actionStateModel
+ updateActionOptionsModel.SysLock = systemLockModel
+ updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.UpdateActionWithContext(ctx, updateActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.UpdateActionWithContext(ctx, updateActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateActionPath))
+ Expect(req.Method).To(Equal("PATCH"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["X-Github-Token"]).ToNot(BeNil())
+ Expect(req.Header["X-Github-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Stop Action", "description": "The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.", "location": "us-south", "resource_group": "ResourceGroup", "tags": ["Tags"], "user_state": {"state": "draft", "set_by": "SetBy", "set_at": "2019-01-01T12:00:00.000Z"}, "source_readme_url": "SourceReadmeURL", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "source_type": "local", "command_parameter": "CommandParameter", "inventory": "Inventory", "credentials": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "bastion": {"name": "Name", "host": "Host"}, "bastion_credential": {"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}, "targets_ini": "TargetsIni", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "id": "ID", "crn": "Crn", "account": "Account", "source_created_at": "2019-01-01T12:00:00.000Z", "source_created_by": "SourceCreatedBy", "source_updated_at": "2019-01-01T12:00:00.000Z", "source_updated_by": "SourceUpdatedBy", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "state": {"status_code": "normal", "status_job_id": "StatusJobID", "status_message": "StatusMessage"}, "playbook_names": ["PlaybookNames"], "sys_lock": {"sys_locked": false, "sys_locked_by": "SysLockedBy", "sys_locked_at": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke UpdateAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.UpdateAction(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the UpdateActionOptions model
+ updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
+ updateActionOptionsModel.ActionID = core.StringPtr("testString")
+ updateActionOptionsModel.Name = core.StringPtr("Stop Action")
+ updateActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ updateActionOptionsModel.Location = core.StringPtr("us-south")
+ updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateActionOptionsModel.Tags = []string{"testString"}
+ updateActionOptionsModel.UserState = userStateModel
+ updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ updateActionOptionsModel.Source = externalSourceModel
+ updateActionOptionsModel.SourceType = core.StringPtr("local")
+ updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateActionOptionsModel.Inventory = core.StringPtr("testString")
+ updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateActionOptionsModel.BastionCredential = variableDataModel
+ updateActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.State = actionStateModel
+ updateActionOptionsModel.SysLock = systemLockModel
+ updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.UpdateAction(updateActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke UpdateAction with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the UpdateActionOptions model
+ updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
+ updateActionOptionsModel.ActionID = core.StringPtr("testString")
+ updateActionOptionsModel.Name = core.StringPtr("Stop Action")
+ updateActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ updateActionOptionsModel.Location = core.StringPtr("us-south")
+ updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateActionOptionsModel.Tags = []string{"testString"}
+ updateActionOptionsModel.UserState = userStateModel
+ updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ updateActionOptionsModel.Source = externalSourceModel
+ updateActionOptionsModel.SourceType = core.StringPtr("local")
+ updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateActionOptionsModel.Inventory = core.StringPtr("testString")
+ updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateActionOptionsModel.BastionCredential = variableDataModel
+ updateActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.State = actionStateModel
+ updateActionOptionsModel.SysLock = systemLockModel
+ updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the UpdateActionOptions model with no property values
+ updateActionOptionsModelNew := new(schematicsv1.UpdateActionOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.UpdateAction(updateActionOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke UpdateAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the UpdateActionOptions model
+ updateActionOptionsModel := new(schematicsv1.UpdateActionOptions)
+ updateActionOptionsModel.ActionID = core.StringPtr("testString")
+ updateActionOptionsModel.Name = core.StringPtr("Stop Action")
+ updateActionOptionsModel.Description = core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ updateActionOptionsModel.Location = core.StringPtr("us-south")
+ updateActionOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateActionOptionsModel.Tags = []string{"testString"}
+ updateActionOptionsModel.UserState = userStateModel
+ updateActionOptionsModel.SourceReadmeURL = core.StringPtr("testString")
+ updateActionOptionsModel.Source = externalSourceModel
+ updateActionOptionsModel.SourceType = core.StringPtr("local")
+ updateActionOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateActionOptionsModel.Inventory = core.StringPtr("testString")
+ updateActionOptionsModel.Credentials = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateActionOptionsModel.BastionCredential = variableDataModel
+ updateActionOptionsModel.TargetsIni = core.StringPtr("testString")
+ updateActionOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateActionOptionsModel.State = actionStateModel
+ updateActionOptionsModel.SysLock = systemLockModel
+ updateActionOptionsModel.XGithubToken = core.StringPtr("testString")
+ updateActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.UpdateAction(updateActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UploadTemplateTarAction(uploadTemplateTarActionOptions *UploadTemplateTarActionOptions) - Operation response error`, func() {
+ uploadTemplateTarActionPath := "/v2/actions/testString/template_repo_upload"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(uploadTemplateTarActionPath))
+ Expect(req.Method).To(Equal("PUT"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke UploadTemplateTarAction with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UploadTemplateTarActionOptions model
+ uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
+ uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
+ uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UploadTemplateTarAction(uploadTemplateTarActionOptions *UploadTemplateTarActionOptions)`, func() {
+ uploadTemplateTarActionPath := "/v2/actions/testString/template_repo_upload"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(uploadTemplateTarActionPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
+ }))
+ })
+ It(`Invoke UploadTemplateTarAction successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the UploadTemplateTarActionOptions model
+ uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
+ uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
+ uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.UploadTemplateTarActionWithContext(ctx, uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.UploadTemplateTarActionWithContext(ctx, uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(uploadTemplateTarActionPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"file_value": "FileValue", "has_received_file": false, "id": "ID"}`)
+ }))
+ })
+ It(`Invoke UploadTemplateTarAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.UploadTemplateTarAction(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the UploadTemplateTarActionOptions model
+ uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
+ uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
+ uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke UploadTemplateTarAction with error: Param validation error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UploadTemplateTarActionOptions model
+ uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
+ // Invoke operation with invalid options model (negative test)
+ result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ It(`Invoke UploadTemplateTarAction with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UploadTemplateTarActionOptions model
+ uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
+ uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
+ uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the UploadTemplateTarActionOptions model with no property values
+ uploadTemplateTarActionOptionsModelNew := new(schematicsv1.UploadTemplateTarActionOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke UploadTemplateTarAction successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UploadTemplateTarActionOptions model
+ uploadTemplateTarActionOptionsModel := new(schematicsv1.UploadTemplateTarActionOptions)
+ uploadTemplateTarActionOptionsModel.ActionID = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.File = CreateMockReader("This is a mock file.")
+ uploadTemplateTarActionOptionsModel.FileContentType = core.StringPtr("testString")
+ uploadTemplateTarActionOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.UploadTemplateTarAction(uploadTemplateTarActionOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListWorkspaceActivities(listWorkspaceActivitiesOptions *ListWorkspaceActivitiesOptions) - Operation response error`, func() {
+ listWorkspaceActivitiesPath := "/v1/workspaces/testString/actions"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listWorkspaceActivitiesPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListWorkspaceActivities with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListWorkspaceActivitiesOptions model
+ listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
+ listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
+ listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListWorkspaceActivities(listWorkspaceActivitiesOptions *ListWorkspaceActivitiesOptions)`, func() {
+ listWorkspaceActivitiesPath := "/v1/workspaces/testString/actions"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listWorkspaceActivitiesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"actions": [{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}], "workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName"}`)
+ }))
+ })
+ It(`Invoke ListWorkspaceActivities successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListWorkspaceActivitiesOptions model
+ listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
+ listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
+ listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListWorkspaceActivitiesWithContext(ctx, listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListWorkspaceActivitiesWithContext(ctx, listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listWorkspaceActivitiesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"actions": [{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}], "workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName"}`)
+ }))
+ })
+ It(`Invoke ListWorkspaceActivities successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListWorkspaceActivities(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListWorkspaceActivitiesOptions model
+ listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
+ listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
+ listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListWorkspaceActivities with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListWorkspaceActivitiesOptions model
+ listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
+ listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
+ listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ListWorkspaceActivitiesOptions model with no property values
+ listWorkspaceActivitiesOptionsModelNew := new(schematicsv1.ListWorkspaceActivitiesOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListWorkspaceActivities successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListWorkspaceActivitiesOptions model
+ listWorkspaceActivitiesOptionsModel := new(schematicsv1.ListWorkspaceActivitiesOptions)
+ listWorkspaceActivitiesOptionsModel.WID = core.StringPtr("testString")
+ listWorkspaceActivitiesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listWorkspaceActivitiesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listWorkspaceActivitiesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListWorkspaceActivities(listWorkspaceActivitiesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceActivity(getWorkspaceActivityOptions *GetWorkspaceActivityOptions) - Operation response error`, func() {
+ getWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivity with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityOptions model
+ getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
+ getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceActivity(getWorkspaceActivityOptions *GetWorkspaceActivityOptions)`, func() {
+ getWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivity successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceActivityOptions model
+ getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
+ getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceActivityWithContext(ctx, getWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceActivityWithContext(ctx, getWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceActivityPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"action_id": "ActionID", "message": ["Message"], "name": "Name", "performed_at": "2019-01-01T12:00:00.000Z", "performed_by": "PerformedBy", "status": "Status", "templates": [{"end_time": "2019-01-01T12:00:00.000Z", "log_summary": {"activity_status": "ActivityStatus", "detected_template_type": "DetectedTemplateType", "discarded_files": 14, "error": "Error", "resources_added": 14, "resources_destroyed": 18, "resources_modified": 17, "scanned_files": 12, "template_variable_count": 21, "time_taken": 9}, "log_url": "LogURL", "message": "Message", "start_time": "2019-01-01T12:00:00.000Z", "status": "Status", "template_id": "TemplateID", "template_type": "TemplateType"}]}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivity successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceActivity(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityOptions model
+ getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
+ getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceActivity with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityOptions model
+ getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
+ getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceActivityOptions model with no property values
+ getWorkspaceActivityOptionsModelNew := new(schematicsv1.GetWorkspaceActivityOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceActivity successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceActivityOptions model
+ getWorkspaceActivityOptionsModel := new(schematicsv1.GetWorkspaceActivityOptions)
+ getWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ getWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceActivity(getWorkspaceActivityOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DeleteWorkspaceActivity(deleteWorkspaceActivityOptions *DeleteWorkspaceActivityOptions) - Operation response error`, func() {
+ deleteWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspaceActivityPath))
+ Expect(req.Method).To(Equal("DELETE"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke DeleteWorkspaceActivity with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteWorkspaceActivityOptions model
+ deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
+ deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DeleteWorkspaceActivity(deleteWorkspaceActivityOptions *DeleteWorkspaceActivityOptions)`, func() {
+ deleteWorkspaceActivityPath := "/v1/workspaces/testString/actions/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspaceActivityPath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke DeleteWorkspaceActivity successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the DeleteWorkspaceActivityOptions model
+ deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
+ deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.DeleteWorkspaceActivityWithContext(ctx, deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.DeleteWorkspaceActivityWithContext(ctx, deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteWorkspaceActivityPath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke DeleteWorkspaceActivity successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.DeleteWorkspaceActivity(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the DeleteWorkspaceActivityOptions model
+ deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
+ deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke DeleteWorkspaceActivity with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteWorkspaceActivityOptions model
+ deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
+ deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the DeleteWorkspaceActivityOptions model with no property values
+ deleteWorkspaceActivityOptionsModelNew := new(schematicsv1.DeleteWorkspaceActivityOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(202)
+ }))
+ })
+ It(`Invoke DeleteWorkspaceActivity successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteWorkspaceActivityOptions model
+ deleteWorkspaceActivityOptionsModel := new(schematicsv1.DeleteWorkspaceActivityOptions)
+ deleteWorkspaceActivityOptionsModel.WID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.ActivityID = core.StringPtr("testString")
+ deleteWorkspaceActivityOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.DeleteWorkspaceActivity(deleteWorkspaceActivityOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`RunWorkspaceCommands(runWorkspaceCommandsOptions *RunWorkspaceCommandsOptions) - Operation response error`, func() {
+ runWorkspaceCommandsPath := "/v1/workspaces/testString/commands"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(runWorkspaceCommandsPath))
+ Expect(req.Method).To(Equal("PUT"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke RunWorkspaceCommands with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the TerraformCommand model
+ terraformCommandModel := new(schematicsv1.TerraformCommand)
+ terraformCommandModel.Command = core.StringPtr("testString")
+ terraformCommandModel.CommandParams = core.StringPtr("testString")
+ terraformCommandModel.CommandName = core.StringPtr("testString")
+ terraformCommandModel.CommandDesc = core.StringPtr("testString")
+ terraformCommandModel.CommandOnError = core.StringPtr("testString")
+ terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
+ terraformCommandModel.CommandStatus = core.StringPtr("testString")
+
+ // Construct an instance of the RunWorkspaceCommandsOptions model
+ runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
+ runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
+ runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`RunWorkspaceCommands(runWorkspaceCommandsOptions *RunWorkspaceCommandsOptions)`, func() {
+ runWorkspaceCommandsPath := "/v1/workspaces/testString/commands"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(runWorkspaceCommandsPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke RunWorkspaceCommands successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the TerraformCommand model
+ terraformCommandModel := new(schematicsv1.TerraformCommand)
+ terraformCommandModel.Command = core.StringPtr("testString")
+ terraformCommandModel.CommandParams = core.StringPtr("testString")
+ terraformCommandModel.CommandName = core.StringPtr("testString")
+ terraformCommandModel.CommandDesc = core.StringPtr("testString")
+ terraformCommandModel.CommandOnError = core.StringPtr("testString")
+ terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
+ terraformCommandModel.CommandStatus = core.StringPtr("testString")
+
+ // Construct an instance of the RunWorkspaceCommandsOptions model
+ runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
+ runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
+ runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.RunWorkspaceCommandsWithContext(ctx, runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.RunWorkspaceCommandsWithContext(ctx, runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(runWorkspaceCommandsPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke RunWorkspaceCommands successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.RunWorkspaceCommands(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the TerraformCommand model
+ terraformCommandModel := new(schematicsv1.TerraformCommand)
+ terraformCommandModel.Command = core.StringPtr("testString")
+ terraformCommandModel.CommandParams = core.StringPtr("testString")
+ terraformCommandModel.CommandName = core.StringPtr("testString")
+ terraformCommandModel.CommandDesc = core.StringPtr("testString")
+ terraformCommandModel.CommandOnError = core.StringPtr("testString")
+ terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
+ terraformCommandModel.CommandStatus = core.StringPtr("testString")
+
+ // Construct an instance of the RunWorkspaceCommandsOptions model
+ runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
+ runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
+ runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke RunWorkspaceCommands with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the TerraformCommand model
+ terraformCommandModel := new(schematicsv1.TerraformCommand)
+ terraformCommandModel.Command = core.StringPtr("testString")
+ terraformCommandModel.CommandParams = core.StringPtr("testString")
+ terraformCommandModel.CommandName = core.StringPtr("testString")
+ terraformCommandModel.CommandDesc = core.StringPtr("testString")
+ terraformCommandModel.CommandOnError = core.StringPtr("testString")
+ terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
+ terraformCommandModel.CommandStatus = core.StringPtr("testString")
+
+ // Construct an instance of the RunWorkspaceCommandsOptions model
+ runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
+ runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
+ runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the RunWorkspaceCommandsOptions model with no property values
+ runWorkspaceCommandsOptionsModelNew := new(schematicsv1.RunWorkspaceCommandsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke RunWorkspaceCommands successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the TerraformCommand model
+ terraformCommandModel := new(schematicsv1.TerraformCommand)
+ terraformCommandModel.Command = core.StringPtr("testString")
+ terraformCommandModel.CommandParams = core.StringPtr("testString")
+ terraformCommandModel.CommandName = core.StringPtr("testString")
+ terraformCommandModel.CommandDesc = core.StringPtr("testString")
+ terraformCommandModel.CommandOnError = core.StringPtr("testString")
+ terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
+ terraformCommandModel.CommandStatus = core.StringPtr("testString")
+
+ // Construct an instance of the RunWorkspaceCommandsOptions model
+ runWorkspaceCommandsOptionsModel := new(schematicsv1.RunWorkspaceCommandsOptions)
+ runWorkspaceCommandsOptionsModel.WID = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.RefreshToken = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Commands = []schematicsv1.TerraformCommand{*terraformCommandModel}
+ runWorkspaceCommandsOptionsModel.OperationName = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Description = core.StringPtr("testString")
+ runWorkspaceCommandsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.RunWorkspaceCommands(runWorkspaceCommandsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ApplyWorkspaceCommand(applyWorkspaceCommandOptions *ApplyWorkspaceCommandOptions) - Operation response error`, func() {
+ applyWorkspaceCommandPath := "/v1/workspaces/testString/apply"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(applyWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ApplyWorkspaceCommand with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the ApplyWorkspaceCommandOptions model
+ applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
+ applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ applyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ApplyWorkspaceCommand(applyWorkspaceCommandOptions *ApplyWorkspaceCommandOptions)`, func() {
+ applyWorkspaceCommandPath := "/v1/workspaces/testString/apply"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(applyWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke ApplyWorkspaceCommand successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the ApplyWorkspaceCommandOptions model
+ applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
+ applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ applyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ApplyWorkspaceCommandWithContext(ctx, applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ApplyWorkspaceCommandWithContext(ctx, applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(applyWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke ApplyWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ApplyWorkspaceCommand(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the ApplyWorkspaceCommandOptions model
+ applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
+ applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ applyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ApplyWorkspaceCommand with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the ApplyWorkspaceCommandOptions model
+ applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
+ applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ applyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ApplyWorkspaceCommandOptions model with no property values
+ applyWorkspaceCommandOptionsModelNew := new(schematicsv1.ApplyWorkspaceCommandOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(202)
+ }))
+ })
+ It(`Invoke ApplyWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the ApplyWorkspaceCommandOptions model
+ applyWorkspaceCommandOptionsModel := new(schematicsv1.ApplyWorkspaceCommandOptions)
+ applyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ applyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ applyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ApplyWorkspaceCommand(applyWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DestroyWorkspaceCommand(destroyWorkspaceCommandOptions *DestroyWorkspaceCommandOptions) - Operation response error`, func() {
+ destroyWorkspaceCommandPath := "/v1/workspaces/testString/destroy"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(destroyWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke DestroyWorkspaceCommand with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the DestroyWorkspaceCommandOptions model
+ destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
+ destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ destroyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DestroyWorkspaceCommand(destroyWorkspaceCommandOptions *DestroyWorkspaceCommandOptions)`, func() {
+ destroyWorkspaceCommandPath := "/v1/workspaces/testString/destroy"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(destroyWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke DestroyWorkspaceCommand successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the DestroyWorkspaceCommandOptions model
+ destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
+ destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ destroyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.DestroyWorkspaceCommandWithContext(ctx, destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.DestroyWorkspaceCommandWithContext(ctx, destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(destroyWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke DestroyWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.DestroyWorkspaceCommand(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the DestroyWorkspaceCommandOptions model
+ destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
+ destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ destroyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke DestroyWorkspaceCommand with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the DestroyWorkspaceCommandOptions model
+ destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
+ destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ destroyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the DestroyWorkspaceCommandOptions model with no property values
+ destroyWorkspaceCommandOptionsModelNew := new(schematicsv1.DestroyWorkspaceCommandOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(202)
+ }))
+ })
+ It(`Invoke DestroyWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+
+ // Construct an instance of the DestroyWorkspaceCommandOptions model
+ destroyWorkspaceCommandOptionsModel := new(schematicsv1.DestroyWorkspaceCommandOptions)
+ destroyWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.ActionOptions = workspaceActivityOptionsTemplateModel
+ destroyWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ destroyWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.DestroyWorkspaceCommand(destroyWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`PlanWorkspaceCommand(planWorkspaceCommandOptions *PlanWorkspaceCommandOptions) - Operation response error`, func() {
+ planWorkspaceCommandPath := "/v1/workspaces/testString/plan"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(planWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("POST"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke PlanWorkspaceCommand with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the PlanWorkspaceCommandOptions model
+ planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
+ planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`PlanWorkspaceCommand(planWorkspaceCommandOptions *PlanWorkspaceCommandOptions)`, func() {
+ planWorkspaceCommandPath := "/v1/workspaces/testString/plan"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(planWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke PlanWorkspaceCommand successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the PlanWorkspaceCommandOptions model
+ planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
+ planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.PlanWorkspaceCommandWithContext(ctx, planWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.PlanWorkspaceCommandWithContext(ctx, planWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(planWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke PlanWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.PlanWorkspaceCommand(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the PlanWorkspaceCommandOptions model
+ planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
+ planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke PlanWorkspaceCommand with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the PlanWorkspaceCommandOptions model
+ planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
+ planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the PlanWorkspaceCommandOptions model with no property values
+ planWorkspaceCommandOptionsModelNew := new(schematicsv1.PlanWorkspaceCommandOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(202)
+ }))
+ })
+ It(`Invoke PlanWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the PlanWorkspaceCommandOptions model
+ planWorkspaceCommandOptionsModel := new(schematicsv1.PlanWorkspaceCommandOptions)
+ planWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ planWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.PlanWorkspaceCommand(planWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`RefreshWorkspaceCommand(refreshWorkspaceCommandOptions *RefreshWorkspaceCommandOptions) - Operation response error`, func() {
+ refreshWorkspaceCommandPath := "/v1/workspaces/testString/refresh"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(refreshWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke RefreshWorkspaceCommand with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the RefreshWorkspaceCommandOptions model
+ refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
+ refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`RefreshWorkspaceCommand(refreshWorkspaceCommandOptions *RefreshWorkspaceCommandOptions)`, func() {
+ refreshWorkspaceCommandPath := "/v1/workspaces/testString/refresh"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(refreshWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke RefreshWorkspaceCommand successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the RefreshWorkspaceCommandOptions model
+ refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
+ refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.RefreshWorkspaceCommandWithContext(ctx, refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.RefreshWorkspaceCommandWithContext(ctx, refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(refreshWorkspaceCommandPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Delegated_token"]).ToNot(BeNil())
+ Expect(req.Header["Delegated_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(202)
+ fmt.Fprintf(res, "%s", `{"activityid": "Activityid"}`)
+ }))
+ })
+ It(`Invoke RefreshWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.RefreshWorkspaceCommand(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the RefreshWorkspaceCommandOptions model
+ refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
+ refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke RefreshWorkspaceCommand with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the RefreshWorkspaceCommandOptions model
+ refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
+ refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the RefreshWorkspaceCommandOptions model with no property values
+ refreshWorkspaceCommandOptionsModelNew := new(schematicsv1.RefreshWorkspaceCommandOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(202)
+ }))
+ })
+ It(`Invoke RefreshWorkspaceCommand successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the RefreshWorkspaceCommandOptions model
+ refreshWorkspaceCommandOptionsModel := new(schematicsv1.RefreshWorkspaceCommandOptions)
+ refreshWorkspaceCommandOptionsModel.WID = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.RefreshToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.DelegatedToken = core.StringPtr("testString")
+ refreshWorkspaceCommandOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.RefreshWorkspaceCommand(refreshWorkspaceCommandOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListJobs(listJobsOptions *ListJobsOptions) - Operation response error`, func() {
+ listJobsPath := "/v2/jobs"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listJobsPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ Expect(req.URL.Query()["resource"]).To(Equal([]string{"workspace"}))
+ Expect(req.URL.Query()["resource_id"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["action_id"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["list"]).To(Equal([]string{"all"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListJobs with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListJobsOptions model
+ listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
+ listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listJobsOptionsModel.Sort = core.StringPtr("testString")
+ listJobsOptionsModel.Profile = core.StringPtr("ids")
+ listJobsOptionsModel.Resource = core.StringPtr("workspace")
+ listJobsOptionsModel.ResourceID = core.StringPtr("testString")
+ listJobsOptionsModel.ActionID = core.StringPtr("testString")
+ listJobsOptionsModel.List = core.StringPtr("all")
+ listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListJobs(listJobsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListJobs(listJobsOptions *ListJobsOptions)`, func() {
+ listJobsPath := "/v2/jobs"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listJobsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ Expect(req.URL.Query()["resource"]).To(Equal([]string{"workspace"}))
+ Expect(req.URL.Query()["resource_id"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["action_id"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["list"]).To(Equal([]string{"all"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "jobs": [{"id": "ID", "name": "Name", "description": "Description", "command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "tags": ["Tags"], "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "duration": "Duration", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "updated_at": "2019-01-01T12:00:00.000Z"}]}`)
+ }))
+ })
+ It(`Invoke ListJobs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListJobsOptions model
+ listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
+ listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listJobsOptionsModel.Sort = core.StringPtr("testString")
+ listJobsOptionsModel.Profile = core.StringPtr("ids")
+ listJobsOptionsModel.Resource = core.StringPtr("workspace")
+ listJobsOptionsModel.ResourceID = core.StringPtr("testString")
+ listJobsOptionsModel.ActionID = core.StringPtr("testString")
+ listJobsOptionsModel.List = core.StringPtr("all")
+ listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListJobsWithContext(ctx, listJobsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListJobsWithContext(ctx, listJobsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listJobsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ Expect(req.URL.Query()["resource"]).To(Equal([]string{"workspace"}))
+ Expect(req.URL.Query()["resource_id"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["action_id"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["list"]).To(Equal([]string{"all"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "jobs": [{"id": "ID", "name": "Name", "description": "Description", "command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "tags": ["Tags"], "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "duration": "Duration", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "updated_at": "2019-01-01T12:00:00.000Z"}]}`)
+ }))
+ })
+ It(`Invoke ListJobs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListJobs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListJobsOptions model
+ listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
+ listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listJobsOptionsModel.Sort = core.StringPtr("testString")
+ listJobsOptionsModel.Profile = core.StringPtr("ids")
+ listJobsOptionsModel.Resource = core.StringPtr("workspace")
+ listJobsOptionsModel.ResourceID = core.StringPtr("testString")
+ listJobsOptionsModel.ActionID = core.StringPtr("testString")
+ listJobsOptionsModel.List = core.StringPtr("all")
+ listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListJobs(listJobsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListJobs with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListJobsOptions model
+ listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
+ listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listJobsOptionsModel.Sort = core.StringPtr("testString")
+ listJobsOptionsModel.Profile = core.StringPtr("ids")
+ listJobsOptionsModel.Resource = core.StringPtr("workspace")
+ listJobsOptionsModel.ResourceID = core.StringPtr("testString")
+ listJobsOptionsModel.ActionID = core.StringPtr("testString")
+ listJobsOptionsModel.List = core.StringPtr("all")
+ listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListJobs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListJobsOptions model
+ listJobsOptionsModel := new(schematicsv1.ListJobsOptions)
+ listJobsOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listJobsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listJobsOptionsModel.Sort = core.StringPtr("testString")
+ listJobsOptionsModel.Profile = core.StringPtr("ids")
+ listJobsOptionsModel.Resource = core.StringPtr("workspace")
+ listJobsOptionsModel.ResourceID = core.StringPtr("testString")
+ listJobsOptionsModel.ActionID = core.StringPtr("testString")
+ listJobsOptionsModel.List = core.StringPtr("all")
+ listJobsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListJobs(listJobsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateJob(createJobOptions *CreateJobOptions) - Operation response error`, func() {
+ createJobPath := "/v2/jobs"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createJobPath))
+ Expect(req.Method).To(Equal("POST"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke CreateJob with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the CreateJobOptions model
+ createJobOptionsModel := new(schematicsv1.CreateJobOptions)
+ createJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ createJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ createJobOptionsModel.CommandOptions = []string{"testString"}
+ createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Tags = []string{"testString"}
+ createJobOptionsModel.Location = core.StringPtr("us-south")
+ createJobOptionsModel.Status = jobStatusModel
+ createJobOptionsModel.Data = jobDataModel
+ createJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ createJobOptionsModel.LogSummary = jobLogSummaryModel
+ createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.CreateJob(createJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateJob(createJobOptions *CreateJobOptions)`, func() {
+ createJobPath := "/v2/jobs"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createJobPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"command_object_id": "CommandObjectID", "command_object_name": "CommandObjectName", "layers": "Layers", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "last_job": {"command_object": "workspace", "command_object_name": "CommandObjectName", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "job_id": "JobID", "job_status": "job_pending"}, "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke CreateJob successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the CreateJobOptions model
+ createJobOptionsModel := new(schematicsv1.CreateJobOptions)
+ createJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ createJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ createJobOptionsModel.CommandOptions = []string{"testString"}
+ createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Tags = []string{"testString"}
+ createJobOptionsModel.Location = core.StringPtr("us-south")
+ createJobOptionsModel.Status = jobStatusModel
+ createJobOptionsModel.Data = jobDataModel
+ createJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ createJobOptionsModel.LogSummary = jobLogSummaryModel
+ createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.CreateJobWithContext(ctx, createJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.CreateJobWithContext(ctx, createJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createJobPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(201)
+ fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"command_object_id": "CommandObjectID", "command_object_name": "CommandObjectName", "layers": "Layers", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "last_job": {"command_object": "workspace", "command_object_name": "CommandObjectName", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "job_id": "JobID", "job_status": "job_pending"}, "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke CreateJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.CreateJob(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the CreateJobOptions model
+ createJobOptionsModel := new(schematicsv1.CreateJobOptions)
+ createJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ createJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ createJobOptionsModel.CommandOptions = []string{"testString"}
+ createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Tags = []string{"testString"}
+ createJobOptionsModel.Location = core.StringPtr("us-south")
+ createJobOptionsModel.Status = jobStatusModel
+ createJobOptionsModel.Data = jobDataModel
+ createJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ createJobOptionsModel.LogSummary = jobLogSummaryModel
+ createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.CreateJob(createJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke CreateJob with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the CreateJobOptions model
+ createJobOptionsModel := new(schematicsv1.CreateJobOptions)
+ createJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ createJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ createJobOptionsModel.CommandOptions = []string{"testString"}
+ createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Tags = []string{"testString"}
+ createJobOptionsModel.Location = core.StringPtr("us-south")
+ createJobOptionsModel.Status = jobStatusModel
+ createJobOptionsModel.Data = jobDataModel
+ createJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ createJobOptionsModel.LogSummary = jobLogSummaryModel
+ createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the CreateJobOptions model with no property values
+ createJobOptionsModelNew := new(schematicsv1.CreateJobOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.CreateJob(createJobOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(201)
+ }))
+ })
+ It(`Invoke CreateJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the CreateJobOptions model
+ createJobOptionsModel := new(schematicsv1.CreateJobOptions)
+ createJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ createJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ createJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ createJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ createJobOptionsModel.CommandOptions = []string{"testString"}
+ createJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ createJobOptionsModel.Tags = []string{"testString"}
+ createJobOptionsModel.Location = core.StringPtr("us-south")
+ createJobOptionsModel.Status = jobStatusModel
+ createJobOptionsModel.Data = jobDataModel
+ createJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ createJobOptionsModel.LogSummary = jobLogSummaryModel
+ createJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.CreateJob(createJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetJob(getJobOptions *GetJobOptions) - Operation response error`, func() {
+ getJobPath := "/v2/jobs/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getJobPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetJob with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetJobOptions model
+ getJobOptionsModel := new(schematicsv1.GetJobOptions)
+ getJobOptionsModel.JobID = core.StringPtr("testString")
+ getJobOptionsModel.Profile = core.StringPtr("summary")
+ getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetJob(getJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetJob(getJobOptions *GetJobOptions)`, func() {
+ getJobPath := "/v2/jobs/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getJobPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"command_object_id": "CommandObjectID", "command_object_name": "CommandObjectName", "layers": "Layers", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "last_job": {"command_object": "workspace", "command_object_name": "CommandObjectName", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "job_id": "JobID", "job_status": "job_pending"}, "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke GetJob successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetJobOptions model
+ getJobOptionsModel := new(schematicsv1.GetJobOptions)
+ getJobOptionsModel.JobID = core.StringPtr("testString")
+ getJobOptionsModel.Profile = core.StringPtr("summary")
+ getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetJobWithContext(ctx, getJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetJobWithContext(ctx, getJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getJobPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"summary"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"command_object_id": "CommandObjectID", "command_object_name": "CommandObjectName", "layers": "Layers", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "last_job": {"command_object": "workspace", "command_object_name": "CommandObjectName", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "job_id": "JobID", "job_status": "job_pending"}, "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke GetJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetJob(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetJobOptions model
+ getJobOptionsModel := new(schematicsv1.GetJobOptions)
+ getJobOptionsModel.JobID = core.StringPtr("testString")
+ getJobOptionsModel.Profile = core.StringPtr("summary")
+ getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetJob(getJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetJob with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetJobOptions model
+ getJobOptionsModel := new(schematicsv1.GetJobOptions)
+ getJobOptionsModel.JobID = core.StringPtr("testString")
+ getJobOptionsModel.Profile = core.StringPtr("summary")
+ getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetJobOptions model with no property values
+ getJobOptionsModelNew := new(schematicsv1.GetJobOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetJob(getJobOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetJobOptions model
+ getJobOptionsModel := new(schematicsv1.GetJobOptions)
+ getJobOptionsModel.JobID = core.StringPtr("testString")
+ getJobOptionsModel.Profile = core.StringPtr("summary")
+ getJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetJob(getJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateJob(updateJobOptions *UpdateJobOptions) - Operation response error`, func() {
+ updateJobPath := "/v2/jobs/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateJobPath))
+ Expect(req.Method).To(Equal("PUT"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke UpdateJob with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the UpdateJobOptions model
+ updateJobOptionsModel := new(schematicsv1.UpdateJobOptions)
+ updateJobOptionsModel.JobID = core.StringPtr("testString")
+ updateJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ updateJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ updateJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ updateJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ updateJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateJobOptionsModel.CommandOptions = []string{"testString"}
+ updateJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Tags = []string{"testString"}
+ updateJobOptionsModel.Location = core.StringPtr("us-south")
+ updateJobOptionsModel.Status = jobStatusModel
+ updateJobOptionsModel.Data = jobDataModel
+ updateJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateJobOptionsModel.LogSummary = jobLogSummaryModel
+ updateJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.UpdateJob(updateJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.UpdateJob(updateJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateJob(updateJobOptions *UpdateJobOptions)`, func() {
+ updateJobPath := "/v2/jobs/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateJobPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"command_object_id": "CommandObjectID", "command_object_name": "CommandObjectName", "layers": "Layers", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "last_job": {"command_object": "workspace", "command_object_name": "CommandObjectName", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "job_id": "JobID", "job_status": "job_pending"}, "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke UpdateJob successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the UpdateJobOptions model
+ updateJobOptionsModel := new(schematicsv1.UpdateJobOptions)
+ updateJobOptionsModel.JobID = core.StringPtr("testString")
+ updateJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ updateJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ updateJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ updateJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ updateJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateJobOptionsModel.CommandOptions = []string{"testString"}
+ updateJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Tags = []string{"testString"}
+ updateJobOptionsModel.Location = core.StringPtr("us-south")
+ updateJobOptionsModel.Status = jobStatusModel
+ updateJobOptionsModel.Data = jobDataModel
+ updateJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateJobOptionsModel.LogSummary = jobLogSummaryModel
+ updateJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.UpdateJobWithContext(ctx, updateJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.UpdateJob(updateJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.UpdateJobWithContext(ctx, updateJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateJobPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"command_object": "workspace", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "command_parameter": "CommandParameter", "command_options": ["CommandOptions"], "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "tags": ["Tags"], "id": "ID", "name": "Name", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "submitted_at": "2019-01-01T12:00:00.000Z", "submitted_by": "SubmittedBy", "start_at": "2019-01-01T12:00:00.000Z", "end_at": "2019-01-01T12:00:00.000Z", "duration": "Duration", "status": {"workspace_job_status": {"workspace_name": "WorkspaceName", "status_code": "job_pending", "status_message": "StatusMessage", "flow_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "template_status": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_status": {"action_name": "ActionName", "status_code": "job_pending", "status_message": "StatusMessage", "bastion_status_code": "none", "bastion_status_message": "BastionStatusMessage", "targets_status_code": "none", "targets_status_message": "TargetsStatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}, "system_job_status": {"system_status_message": "SystemStatusMessage", "system_status_code": "job_pending", "schematics_resource_status": [{"status_code": "job_pending", "status_message": "StatusMessage", "schematics_resource_id": "SchematicsResourceID", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_status": {"flow_id": "FlowID", "flow_name": "FlowName", "status_code": "job_pending", "status_message": "StatusMessage", "workitems": [{"workspace_id": "WorkspaceID", "workspace_name": "WorkspaceName", "job_id": "JobID", "status_code": "job_pending", "status_message": "StatusMessage", "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "data": {"job_type": "repo_download_job", "workspace_job_data": {"workspace_name": "WorkspaceName", "flow_id": "FlowID", "flow_name": "FlowName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "template_data": [{"template_id": "TemplateID", "template_name": "TemplateName", "flow_index": 9, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}, "action_job_data": {"action_name": "ActionName", "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "updated_at": "2019-01-01T12:00:00.000Z", "inventory_record": {"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}, "materialized_inventory": "MaterializedInventory"}, "system_job_data": {"key_id": "KeyID", "schematics_resource_id": ["SchematicsResourceID"], "updated_at": "2019-01-01T12:00:00.000Z"}, "flow_job_data": {"flow_id": "FlowID", "flow_name": "FlowName", "workitems": [{"command_object_id": "CommandObjectID", "command_object_name": "CommandObjectName", "layers": "Layers", "source_type": "local", "source": {"source_type": "local", "git": {"computed_git_repo_url": "ComputedGitRepoURL", "git_repo_url": "GitRepoURL", "git_token": "GitToken", "git_repo_folder": "GitRepoFolder", "git_release": "GitRelease", "git_branch": "GitBranch"}, "catalog": {"catalog_name": "CatalogName", "offering_name": "OfferingName", "offering_version": "OfferingVersion", "offering_kind": "OfferingKind", "offering_id": "OfferingID", "offering_version_id": "OfferingVersionID", "offering_repo_url": "OfferingRepoURL"}, "cos_bucket": {"cos_bucket_url": "CosBucketURL"}}, "inputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "outputs": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "settings": [{"name": "Name", "value": "Value", "metadata": {"type": "boolean", "aliases": ["Aliases"], "description": "Description", "default_value": "DefaultValue", "secure": true, "immutable": false, "hidden": true, "options": ["Options"], "min_value": 8, "max_value": 8, "min_length": 9, "max_length": 9, "matches": "Matches", "position": 8, "group_by": "GroupBy", "source": "Source"}, "link": "Link"}], "last_job": {"command_object": "workspace", "command_object_name": "CommandObjectName", "command_object_id": "CommandObjectID", "command_name": "workspace_plan", "job_id": "JobID", "job_status": "job_pending"}, "updated_at": "2019-01-01T12:00:00.000Z"}], "updated_at": "2019-01-01T12:00:00.000Z"}}, "bastion": {"name": "Name", "host": "Host"}, "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "log_store_url": "LogStoreURL", "state_store_url": "StateStoreURL", "results_url": "ResultsURL", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke UpdateJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.UpdateJob(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the UpdateJobOptions model
+ updateJobOptionsModel := new(schematicsv1.UpdateJobOptions)
+ updateJobOptionsModel.JobID = core.StringPtr("testString")
+ updateJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ updateJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ updateJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ updateJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ updateJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateJobOptionsModel.CommandOptions = []string{"testString"}
+ updateJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Tags = []string{"testString"}
+ updateJobOptionsModel.Location = core.StringPtr("us-south")
+ updateJobOptionsModel.Status = jobStatusModel
+ updateJobOptionsModel.Data = jobDataModel
+ updateJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateJobOptionsModel.LogSummary = jobLogSummaryModel
+ updateJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.UpdateJob(updateJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke UpdateJob with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the UpdateJobOptions model
+ updateJobOptionsModel := new(schematicsv1.UpdateJobOptions)
+ updateJobOptionsModel.JobID = core.StringPtr("testString")
+ updateJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ updateJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ updateJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ updateJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ updateJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateJobOptionsModel.CommandOptions = []string{"testString"}
+ updateJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Tags = []string{"testString"}
+ updateJobOptionsModel.Location = core.StringPtr("us-south")
+ updateJobOptionsModel.Status = jobStatusModel
+ updateJobOptionsModel.Data = jobDataModel
+ updateJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateJobOptionsModel.LogSummary = jobLogSummaryModel
+ updateJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.UpdateJob(updateJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the UpdateJobOptions model with no property values
+ updateJobOptionsModelNew := new(schematicsv1.UpdateJobOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.UpdateJob(updateJobOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke UpdateJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+
+ // Construct an instance of the UpdateJobOptions model
+ updateJobOptionsModel := new(schematicsv1.UpdateJobOptions)
+ updateJobOptionsModel.JobID = core.StringPtr("testString")
+ updateJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ updateJobOptionsModel.CommandObject = core.StringPtr("workspace")
+ updateJobOptionsModel.CommandObjectID = core.StringPtr("testString")
+ updateJobOptionsModel.CommandName = core.StringPtr("workspace_plan")
+ updateJobOptionsModel.CommandParameter = core.StringPtr("testString")
+ updateJobOptionsModel.CommandOptions = []string{"testString"}
+ updateJobOptionsModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ updateJobOptionsModel.Tags = []string{"testString"}
+ updateJobOptionsModel.Location = core.StringPtr("us-south")
+ updateJobOptionsModel.Status = jobStatusModel
+ updateJobOptionsModel.Data = jobDataModel
+ updateJobOptionsModel.Bastion = bastionResourceDefinitionModel
+ updateJobOptionsModel.LogSummary = jobLogSummaryModel
+ updateJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.UpdateJob(updateJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DeleteJob(deleteJobOptions *DeleteJobOptions)`, func() {
+ deleteJobPath := "/v2/jobs/testString"
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteJobPath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.Header["Force"]).ToNot(BeNil())
+ Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ Expect(req.Header["Propagate"]).ToNot(BeNil())
+ Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ res.WriteHeader(204)
+ }))
+ })
+ It(`Invoke DeleteJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ response, operationErr := schematicsService.DeleteJob(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+
+ // Construct an instance of the DeleteJobOptions model
+ deleteJobOptionsModel := new(schematicsv1.DeleteJobOptions)
+ deleteJobOptionsModel.JobID = core.StringPtr("testString")
+ deleteJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ deleteJobOptionsModel.Force = core.BoolPtr(true)
+ deleteJobOptionsModel.Propagate = core.BoolPtr(true)
+ deleteJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ response, operationErr = schematicsService.DeleteJob(deleteJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ })
+ It(`Invoke DeleteJob with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteJobOptions model
+ deleteJobOptionsModel := new(schematicsv1.DeleteJobOptions)
+ deleteJobOptionsModel.JobID = core.StringPtr("testString")
+ deleteJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ deleteJobOptionsModel.Force = core.BoolPtr(true)
+ deleteJobOptionsModel.Propagate = core.BoolPtr(true)
+ deleteJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ response, operationErr := schematicsService.DeleteJob(deleteJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ // Construct a second instance of the DeleteJobOptions model with no property values
+ deleteJobOptionsModelNew := new(schematicsv1.DeleteJobOptions)
+ // Invoke operation with invalid model (negative test)
+ response, operationErr = schematicsService.DeleteJob(deleteJobOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListJobLogs(listJobLogsOptions *ListJobLogsOptions) - Operation response error`, func() {
+ listJobLogsPath := "/v2/jobs/testString/logs"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listJobLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListJobLogs with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListJobLogsOptions model
+ listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
+ listJobLogsOptionsModel.JobID = core.StringPtr("testString")
+ listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListJobLogs(listJobLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListJobLogs(listJobLogsOptions *ListJobLogsOptions)`, func() {
+ listJobLogsPath := "/v2/jobs/testString/logs"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listJobLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"job_id": "JobID", "job_name": "JobName", "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "format": "json", "details": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke ListJobLogs successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListJobLogsOptions model
+ listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
+ listJobLogsOptionsModel.JobID = core.StringPtr("testString")
+ listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListJobLogsWithContext(ctx, listJobLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListJobLogsWithContext(ctx, listJobLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listJobLogsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"job_id": "JobID", "job_name": "JobName", "log_summary": {"job_id": "JobID", "job_type": "repo_download_job", "log_start_at": "2019-01-01T12:00:00.000Z", "log_analyzed_till": "2019-01-01T12:00:00.000Z", "elapsed_time": 11, "log_errors": [{"error_code": "ErrorCode", "error_msg": "ErrorMsg", "error_count": 10}], "repo_download_job": {"scanned_file_count": 16, "quarantined_file_count": 20, "detected_filetype": "DetectedFiletype", "inputs_count": "InputsCount", "outputs_count": "OutputsCount"}, "workspace_job": {"resources_add": 12, "resources_modify": 15, "resources_destroy": 16}, "flow_job": {"workitems_completed": 18, "workitems_pending": 16, "workitems_failed": 15, "workitems": [{"workspace_id": "WorkspaceID", "job_id": "JobID", "resources_add": 12, "resources_modify": 15, "resources_destroy": 16, "log_url": "LogURL"}]}, "action_job": {"target_count": 11, "task_count": 9, "play_count": 9, "recap": {"target": ["Target"], "ok": 2, "changed": 7, "failed": 6, "skipped": 7, "unreachable": 11}}, "system_job": {"target_count": 11, "success": 7, "failed": 6}}, "format": "json", "details": "VGhpcyBpcyBhbiBlbmNvZGVkIGJ5dGUgYXJyYXku", "updated_at": "2019-01-01T12:00:00.000Z"}`)
+ }))
+ })
+ It(`Invoke ListJobLogs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListJobLogs(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListJobLogsOptions model
+ listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
+ listJobLogsOptionsModel.JobID = core.StringPtr("testString")
+ listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListJobLogs(listJobLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListJobLogs with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListJobLogsOptions model
+ listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
+ listJobLogsOptionsModel.JobID = core.StringPtr("testString")
+ listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ListJobLogsOptions model with no property values
+ listJobLogsOptionsModelNew := new(schematicsv1.ListJobLogsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ListJobLogs(listJobLogsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListJobLogs successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListJobLogsOptions model
+ listJobLogsOptionsModel := new(schematicsv1.ListJobLogsOptions)
+ listJobLogsOptionsModel.JobID = core.StringPtr("testString")
+ listJobLogsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListJobLogs(listJobLogsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptions *CreateWorkspaceDeletionJobOptions) - Operation response error`, func() {
+ createWorkspaceDeletionJobPath := "/v1/workspace_jobs"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createWorkspaceDeletionJobPath))
+ Expect(req.Method).To(Equal("POST"))
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.URL.Query()["destroy_resources"]).To(Equal([]string{"testString"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke CreateWorkspaceDeletionJob with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CreateWorkspaceDeletionJobOptions model
+ createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
+ createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
+ createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptions *CreateWorkspaceDeletionJobOptions)`, func() {
+ createWorkspaceDeletionJobPath := "/v1/workspace_jobs"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createWorkspaceDeletionJobPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.URL.Query()["destroy_resources"]).To(Equal([]string{"testString"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"job": "Job", "job_id": "JobID"}`)
+ }))
+ })
+ It(`Invoke CreateWorkspaceDeletionJob successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the CreateWorkspaceDeletionJobOptions model
+ createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
+ createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
+ createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.CreateWorkspaceDeletionJobWithContext(ctx, createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.CreateWorkspaceDeletionJobWithContext(ctx, createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createWorkspaceDeletionJobPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ Expect(req.Header["Refresh_token"]).ToNot(BeNil())
+ Expect(req.Header["Refresh_token"][0]).To(Equal(fmt.Sprintf("%v", "testString")))
+ Expect(req.URL.Query()["destroy_resources"]).To(Equal([]string{"testString"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"job": "Job", "job_id": "JobID"}`)
+ }))
+ })
+ It(`Invoke CreateWorkspaceDeletionJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the CreateWorkspaceDeletionJobOptions model
+ createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
+ createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
+ createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke CreateWorkspaceDeletionJob with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CreateWorkspaceDeletionJobOptions model
+ createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
+ createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
+ createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the CreateWorkspaceDeletionJobOptions model with no property values
+ createWorkspaceDeletionJobOptionsModelNew := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke CreateWorkspaceDeletionJob successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CreateWorkspaceDeletionJobOptions model
+ createWorkspaceDeletionJobOptionsModel := new(schematicsv1.CreateWorkspaceDeletionJobOptions)
+ createWorkspaceDeletionJobOptionsModel.RefreshToken = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewDestroyResources = core.BoolPtr(true)
+ createWorkspaceDeletionJobOptionsModel.NewJob = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewVersion = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.NewWorkspaces = []string{"testString"}
+ createWorkspaceDeletionJobOptionsModel.DestroyResources = core.StringPtr("testString")
+ createWorkspaceDeletionJobOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.CreateWorkspaceDeletionJob(createWorkspaceDeletionJobOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptions *GetWorkspaceDeletionJobStatusOptions) - Operation response error`, func() {
+ getWorkspaceDeletionJobStatusPath := "/v1/workspace_jobs/testString/status"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceDeletionJobStatusPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetWorkspaceDeletionJobStatus with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
+ getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
+ getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
+ getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptions *GetWorkspaceDeletionJobStatusOptions)`, func() {
+ getWorkspaceDeletionJobStatusPath := "/v1/workspace_jobs/testString/status"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceDeletionJobStatusPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"job_status": {"failed": ["Failed"], "in_progress": ["InProgress"], "success": ["Success"], "last_updated_on": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceDeletionJobStatus successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
+ getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
+ getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
+ getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetWorkspaceDeletionJobStatusWithContext(ctx, getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetWorkspaceDeletionJobStatusWithContext(ctx, getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getWorkspaceDeletionJobStatusPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"job_status": {"failed": ["Failed"], "in_progress": ["InProgress"], "success": ["Success"], "last_updated_on": "2019-01-01T12:00:00.000Z"}}`)
+ }))
+ })
+ It(`Invoke GetWorkspaceDeletionJobStatus successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
+ getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
+ getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
+ getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetWorkspaceDeletionJobStatus with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
+ getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
+ getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
+ getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetWorkspaceDeletionJobStatusOptions model with no property values
+ getWorkspaceDeletionJobStatusOptionsModelNew := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetWorkspaceDeletionJobStatus successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
+ getWorkspaceDeletionJobStatusOptionsModel := new(schematicsv1.GetWorkspaceDeletionJobStatusOptions)
+ getWorkspaceDeletionJobStatusOptionsModel.WjID = core.StringPtr("testString")
+ getWorkspaceDeletionJobStatusOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetWorkspaceDeletionJobStatus(getWorkspaceDeletionJobStatusOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListInventories(listInventoriesOptions *ListInventoriesOptions) - Operation response error`, func() {
+ listInventoriesPath := "/v2/inventories"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listInventoriesPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListInventories with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListInventoriesOptions model
+ listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
+ listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listInventoriesOptionsModel.Sort = core.StringPtr("testString")
+ listInventoriesOptionsModel.Profile = core.StringPtr("ids")
+ listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListInventories(listInventoriesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListInventories(listInventoriesOptions *ListInventoriesOptions)`, func() {
+ listInventoriesPath := "/v2/inventories"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listInventoriesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
+ }))
+ })
+ It(`Invoke ListInventories successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListInventoriesOptions model
+ listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
+ listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listInventoriesOptionsModel.Sort = core.StringPtr("testString")
+ listInventoriesOptionsModel.Profile = core.StringPtr("ids")
+ listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListInventoriesWithContext(ctx, listInventoriesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListInventoriesWithContext(ctx, listInventoriesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listInventoriesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
+ }))
+ })
+ It(`Invoke ListInventories successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListInventories(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListInventoriesOptions model
+ listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
+ listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listInventoriesOptionsModel.Sort = core.StringPtr("testString")
+ listInventoriesOptionsModel.Profile = core.StringPtr("ids")
+ listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListInventories(listInventoriesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListInventories with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListInventoriesOptions model
+ listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
+ listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listInventoriesOptionsModel.Sort = core.StringPtr("testString")
+ listInventoriesOptionsModel.Profile = core.StringPtr("ids")
+ listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListInventories successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListInventoriesOptions model
+ listInventoriesOptionsModel := new(schematicsv1.ListInventoriesOptions)
+ listInventoriesOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listInventoriesOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listInventoriesOptionsModel.Sort = core.StringPtr("testString")
+ listInventoriesOptionsModel.Profile = core.StringPtr("ids")
+ listInventoriesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListInventories(listInventoriesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateInventory(createInventoryOptions *CreateInventoryOptions) - Operation response error`, func() {
+ createInventoryPath := "/v2/inventories"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createInventoryPath))
+ Expect(req.Method).To(Equal("POST"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke CreateInventory with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CreateInventoryOptions model
+ createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
+ createInventoryOptionsModel.Name = core.StringPtr("testString")
+ createInventoryOptionsModel.Description = core.StringPtr("testString")
+ createInventoryOptionsModel.Location = core.StringPtr("us-south")
+ createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ createInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.CreateInventory(createInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateInventory(createInventoryOptions *CreateInventoryOptions)`, func() {
+ createInventoryPath := "/v2/inventories"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createInventoryPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke CreateInventory successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the CreateInventoryOptions model
+ createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
+ createInventoryOptionsModel.Name = core.StringPtr("testString")
+ createInventoryOptionsModel.Description = core.StringPtr("testString")
+ createInventoryOptionsModel.Location = core.StringPtr("us-south")
+ createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ createInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.CreateInventoryWithContext(ctx, createInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.CreateInventoryWithContext(ctx, createInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createInventoryPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke CreateInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.CreateInventory(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the CreateInventoryOptions model
+ createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
+ createInventoryOptionsModel.Name = core.StringPtr("testString")
+ createInventoryOptionsModel.Description = core.StringPtr("testString")
+ createInventoryOptionsModel.Location = core.StringPtr("us-south")
+ createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ createInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.CreateInventory(createInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke CreateInventory with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CreateInventoryOptions model
+ createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
+ createInventoryOptionsModel.Name = core.StringPtr("testString")
+ createInventoryOptionsModel.Description = core.StringPtr("testString")
+ createInventoryOptionsModel.Location = core.StringPtr("us-south")
+ createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ createInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke CreateInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the CreateInventoryOptions model
+ createInventoryOptionsModel := new(schematicsv1.CreateInventoryOptions)
+ createInventoryOptionsModel.Name = core.StringPtr("testString")
+ createInventoryOptionsModel.Description = core.StringPtr("testString")
+ createInventoryOptionsModel.Location = core.StringPtr("us-south")
+ createInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ createInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ createInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ createInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.CreateInventory(createInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetInventory(getInventoryOptions *GetInventoryOptions) - Operation response error`, func() {
+ getInventoryPath := "/v2/inventories/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getInventoryPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetInventory with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetInventoryOptions model
+ getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
+ getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetInventory(getInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetInventory(getInventoryOptions *GetInventoryOptions)`, func() {
+ getInventoryPath := "/v2/inventories/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getInventoryPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke GetInventory successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetInventoryOptions model
+ getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
+ getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetInventoryWithContext(ctx, getInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetInventoryWithContext(ctx, getInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getInventoryPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke GetInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetInventory(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetInventoryOptions model
+ getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
+ getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetInventory(getInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetInventory with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetInventoryOptions model
+ getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
+ getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetInventoryOptions model with no property values
+ getInventoryOptionsModelNew := new(schematicsv1.GetInventoryOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetInventory(getInventoryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetInventoryOptions model
+ getInventoryOptionsModel := new(schematicsv1.GetInventoryOptions)
+ getInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetInventory(getInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceInventory(replaceInventoryOptions *ReplaceInventoryOptions) - Operation response error`, func() {
+ replaceInventoryPath := "/v2/inventories/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceInventoryPath))
+ Expect(req.Method).To(Equal("PUT"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ReplaceInventory with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ReplaceInventoryOptions model
+ replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
+ replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Name = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Description = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
+ replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceInventory(replaceInventoryOptions *ReplaceInventoryOptions)`, func() {
+ replaceInventoryPath := "/v2/inventories/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceInventoryPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke ReplaceInventory successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ReplaceInventoryOptions model
+ replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
+ replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Name = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Description = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
+ replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ReplaceInventoryWithContext(ctx, replaceInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ReplaceInventoryWithContext(ctx, replaceInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceInventoryPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke ReplaceInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ReplaceInventory(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ReplaceInventoryOptions model
+ replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
+ replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Name = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Description = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
+ replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ReplaceInventory with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ReplaceInventoryOptions model
+ replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
+ replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Name = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Description = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
+ replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ReplaceInventoryOptions model with no property values
+ replaceInventoryOptionsModelNew := new(schematicsv1.ReplaceInventoryOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ReplaceInventory(replaceInventoryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ReplaceInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ReplaceInventoryOptions model
+ replaceInventoryOptionsModel := new(schematicsv1.ReplaceInventoryOptions)
+ replaceInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Name = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Description = core.StringPtr("testString")
+ replaceInventoryOptionsModel.Location = core.StringPtr("us-south")
+ replaceInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ replaceInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ replaceInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ replaceInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ReplaceInventory(replaceInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DeleteInventory(deleteInventoryOptions *DeleteInventoryOptions)`, func() {
+ deleteInventoryPath := "/v2/inventories/testString"
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteInventoryPath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ Expect(req.Header["Force"]).ToNot(BeNil())
+ Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ Expect(req.Header["Propagate"]).ToNot(BeNil())
+ Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ res.WriteHeader(204)
+ }))
+ })
+ It(`Invoke DeleteInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ response, operationErr := schematicsService.DeleteInventory(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+
+ // Construct an instance of the DeleteInventoryOptions model
+ deleteInventoryOptionsModel := new(schematicsv1.DeleteInventoryOptions)
+ deleteInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ deleteInventoryOptionsModel.Force = core.BoolPtr(true)
+ deleteInventoryOptionsModel.Propagate = core.BoolPtr(true)
+ deleteInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ response, operationErr = schematicsService.DeleteInventory(deleteInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ })
+ It(`Invoke DeleteInventory with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteInventoryOptions model
+ deleteInventoryOptionsModel := new(schematicsv1.DeleteInventoryOptions)
+ deleteInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ deleteInventoryOptionsModel.Force = core.BoolPtr(true)
+ deleteInventoryOptionsModel.Propagate = core.BoolPtr(true)
+ deleteInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ response, operationErr := schematicsService.DeleteInventory(deleteInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ // Construct a second instance of the DeleteInventoryOptions model with no property values
+ deleteInventoryOptionsModelNew := new(schematicsv1.DeleteInventoryOptions)
+ // Invoke operation with invalid model (negative test)
+ response, operationErr = schematicsService.DeleteInventory(deleteInventoryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateInventory(updateInventoryOptions *UpdateInventoryOptions) - Operation response error`, func() {
+ updateInventoryPath := "/v2/inventories/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateInventoryPath))
+ Expect(req.Method).To(Equal("PATCH"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke UpdateInventory with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UpdateInventoryOptions model
+ updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
+ updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ updateInventoryOptionsModel.Name = core.StringPtr("testString")
+ updateInventoryOptionsModel.Description = core.StringPtr("testString")
+ updateInventoryOptionsModel.Location = core.StringPtr("us-south")
+ updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.UpdateInventory(updateInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateInventory(updateInventoryOptions *UpdateInventoryOptions)`, func() {
+ updateInventoryPath := "/v2/inventories/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateInventoryPath))
+ Expect(req.Method).To(Equal("PATCH"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke UpdateInventory successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the UpdateInventoryOptions model
+ updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
+ updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ updateInventoryOptionsModel.Name = core.StringPtr("testString")
+ updateInventoryOptionsModel.Description = core.StringPtr("testString")
+ updateInventoryOptionsModel.Location = core.StringPtr("us-south")
+ updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.UpdateInventoryWithContext(ctx, updateInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.UpdateInventoryWithContext(ctx, updateInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateInventoryPath))
+ Expect(req.Method).To(Equal("PATCH"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke UpdateInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.UpdateInventory(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the UpdateInventoryOptions model
+ updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
+ updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ updateInventoryOptionsModel.Name = core.StringPtr("testString")
+ updateInventoryOptionsModel.Description = core.StringPtr("testString")
+ updateInventoryOptionsModel.Location = core.StringPtr("us-south")
+ updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.UpdateInventory(updateInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke UpdateInventory with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UpdateInventoryOptions model
+ updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
+ updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ updateInventoryOptionsModel.Name = core.StringPtr("testString")
+ updateInventoryOptionsModel.Description = core.StringPtr("testString")
+ updateInventoryOptionsModel.Location = core.StringPtr("us-south")
+ updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the UpdateInventoryOptions model with no property values
+ updateInventoryOptionsModelNew := new(schematicsv1.UpdateInventoryOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.UpdateInventory(updateInventoryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke UpdateInventory successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the UpdateInventoryOptions model
+ updateInventoryOptionsModel := new(schematicsv1.UpdateInventoryOptions)
+ updateInventoryOptionsModel.InventoryID = core.StringPtr("testString")
+ updateInventoryOptionsModel.Name = core.StringPtr("testString")
+ updateInventoryOptionsModel.Description = core.StringPtr("testString")
+ updateInventoryOptionsModel.Location = core.StringPtr("us-south")
+ updateInventoryOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateInventoryOptionsModel.InventoriesIni = core.StringPtr("testString")
+ updateInventoryOptionsModel.ResourceQueries = []string{"testString"}
+ updateInventoryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.UpdateInventory(updateInventoryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListInventoryValues(listInventoryValuesOptions *ListInventoryValuesOptions) - Operation response error`, func() {
+ listInventoryValuesPath := "/v2/inventories/testString/variables"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listInventoryValuesPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListInventoryValues with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListInventoryValuesOptions model
+ listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
+ listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
+ listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListInventoryValues(listInventoryValuesOptions *ListInventoryValuesOptions)`, func() {
+ listInventoryValuesPath := "/v2/inventories/testString/variables"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listInventoryValuesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
+ }))
+ })
+ It(`Invoke ListInventoryValues successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListInventoryValuesOptions model
+ listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
+ listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
+ listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListInventoryValuesWithContext(ctx, listInventoryValuesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListInventoryValuesWithContext(ctx, listInventoryValuesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listInventoryValuesPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "inventories": [{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}]}`)
+ }))
+ })
+ It(`Invoke ListInventoryValues successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListInventoryValues(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListInventoryValuesOptions model
+ listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
+ listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
+ listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListInventoryValues with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListInventoryValuesOptions model
+ listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
+ listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
+ listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ListInventoryValuesOptions model with no property values
+ listInventoryValuesOptionsModelNew := new(schematicsv1.ListInventoryValuesOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ListInventoryValues(listInventoryValuesOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListInventoryValues successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListInventoryValuesOptions model
+ listInventoryValuesOptionsModel := new(schematicsv1.ListInventoryValuesOptions)
+ listInventoryValuesOptionsModel.InventoryID = core.StringPtr("testString")
+ listInventoryValuesOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListInventoryValues(listInventoryValuesOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetInventoryValue(getInventoryValueOptions *GetInventoryValueOptions) - Operation response error`, func() {
+ getInventoryValuePath := "/v2/inventories/testString/variables/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getInventoryValuePath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetInventoryValue with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetInventoryValueOptions model
+ getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
+ getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
+ getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetInventoryValue(getInventoryValueOptions *GetInventoryValueOptions)`, func() {
+ getInventoryValuePath := "/v2/inventories/testString/variables/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getInventoryValuePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke GetInventoryValue successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetInventoryValueOptions model
+ getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
+ getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
+ getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetInventoryValueWithContext(ctx, getInventoryValueOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetInventoryValueWithContext(ctx, getInventoryValueOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getInventoryValuePath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"name": "Name", "id": "ID", "description": "Description", "location": "us-south", "resource_group": "ResourceGroup", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "inventories_ini": "InventoriesIni", "resource_queries": ["ResourceQueries"]}`)
+ }))
+ })
+ It(`Invoke GetInventoryValue successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetInventoryValue(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetInventoryValueOptions model
+ getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
+ getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
+ getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetInventoryValue with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetInventoryValueOptions model
+ getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
+ getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
+ getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetInventoryValueOptions model with no property values
+ getInventoryValueOptionsModelNew := new(schematicsv1.GetInventoryValueOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetInventoryValue(getInventoryValueOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetInventoryValue successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetInventoryValueOptions model
+ getInventoryValueOptionsModel := new(schematicsv1.GetInventoryValueOptions)
+ getInventoryValueOptionsModel.InventoryID = core.StringPtr("testString")
+ getInventoryValueOptionsModel.VarName = core.StringPtr("testString")
+ getInventoryValueOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetInventoryValue(getInventoryValueOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListResourceQuery(listResourceQueryOptions *ListResourceQueryOptions) - Operation response error`, func() {
+ listResourceQueryPath := "/v2/resources_query"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listResourceQueryPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListResourceQuery with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListResourceQueryOptions model
+ listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
+ listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
+ listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
+ listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListResourceQuery(listResourceQueryOptions *ListResourceQueryOptions)`, func() {
+ listResourceQueryPath := "/v2/resources_query"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listResourceQueryPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "resource_queries": [{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}]}`)
+ }))
+ })
+ It(`Invoke ListResourceQuery successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListResourceQueryOptions model
+ listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
+ listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
+ listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
+ listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListResourceQueryWithContext(ctx, listResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListResourceQueryWithContext(ctx, listResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listResourceQueryPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["offset"]).To(Equal([]string{fmt.Sprint(int64(0))}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["profile"]).To(Equal([]string{"ids"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "resource_queries": [{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}]}`)
+ }))
+ })
+ It(`Invoke ListResourceQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListResourceQuery(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListResourceQueryOptions model
+ listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
+ listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
+ listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
+ listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListResourceQuery with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListResourceQueryOptions model
+ listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
+ listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
+ listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
+ listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListResourceQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListResourceQueryOptions model
+ listResourceQueryOptionsModel := new(schematicsv1.ListResourceQueryOptions)
+ listResourceQueryOptionsModel.Offset = core.Int64Ptr(int64(0))
+ listResourceQueryOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listResourceQueryOptionsModel.Sort = core.StringPtr("testString")
+ listResourceQueryOptionsModel.Profile = core.StringPtr("ids")
+ listResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListResourceQuery(listResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateResourceQuery(createResourceQueryOptions *CreateResourceQueryOptions) - Operation response error`, func() {
+ createResourceQueryPath := "/v2/resources_query"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createResourceQueryPath))
+ Expect(req.Method).To(Equal("POST"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke CreateResourceQuery with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the CreateResourceQueryOptions model
+ createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
+ createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
+ createResourceQueryOptionsModel.Name = core.StringPtr("testString")
+ createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`CreateResourceQuery(createResourceQueryOptions *CreateResourceQueryOptions)`, func() {
+ createResourceQueryPath := "/v2/resources_query"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createResourceQueryPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
+ }))
+ })
+ It(`Invoke CreateResourceQuery successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the CreateResourceQueryOptions model
+ createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
+ createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
+ createResourceQueryOptionsModel.Name = core.StringPtr("testString")
+ createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.CreateResourceQueryWithContext(ctx, createResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.CreateResourceQueryWithContext(ctx, createResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(createResourceQueryPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
+ }))
+ })
+ It(`Invoke CreateResourceQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.CreateResourceQuery(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the CreateResourceQueryOptions model
+ createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
+ createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
+ createResourceQueryOptionsModel.Name = core.StringPtr("testString")
+ createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke CreateResourceQuery with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the CreateResourceQueryOptions model
+ createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
+ createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
+ createResourceQueryOptionsModel.Name = core.StringPtr("testString")
+ createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke CreateResourceQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the CreateResourceQueryOptions model
+ createResourceQueryOptionsModel := new(schematicsv1.CreateResourceQueryOptions)
+ createResourceQueryOptionsModel.Type = core.StringPtr("vsi")
+ createResourceQueryOptionsModel.Name = core.StringPtr("testString")
+ createResourceQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ createResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.CreateResourceQuery(createResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetResourcesQuery(getResourcesQueryOptions *GetResourcesQueryOptions) - Operation response error`, func() {
+ getResourcesQueryPath := "/v2/resources_query/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getResourcesQueryPath))
+ Expect(req.Method).To(Equal("GET"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetResourcesQuery with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetResourcesQueryOptions model
+ getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
+ getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetResourcesQuery(getResourcesQueryOptions *GetResourcesQueryOptions)`, func() {
+ getResourcesQueryPath := "/v2/resources_query/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getResourcesQueryPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
+ }))
+ })
+ It(`Invoke GetResourcesQuery successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetResourcesQueryOptions model
+ getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
+ getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetResourcesQueryWithContext(ctx, getResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetResourcesQueryWithContext(ctx, getResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getResourcesQueryPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
+ }))
+ })
+ It(`Invoke GetResourcesQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetResourcesQuery(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetResourcesQueryOptions model
+ getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
+ getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetResourcesQuery with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetResourcesQueryOptions model
+ getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
+ getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetResourcesQueryOptions model with no property values
+ getResourcesQueryOptionsModelNew := new(schematicsv1.GetResourcesQueryOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetResourcesQuery(getResourcesQueryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetResourcesQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetResourcesQueryOptions model
+ getResourcesQueryOptionsModel := new(schematicsv1.GetResourcesQueryOptions)
+ getResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ getResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetResourcesQuery(getResourcesQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceResourcesQuery(replaceResourcesQueryOptions *ReplaceResourcesQueryOptions) - Operation response error`, func() {
+ replaceResourcesQueryPath := "/v2/resources_query/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceResourcesQueryPath))
+ Expect(req.Method).To(Equal("PUT"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ReplaceResourcesQuery with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the ReplaceResourcesQueryOptions model
+ replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
+ replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
+ replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ReplaceResourcesQuery(replaceResourcesQueryOptions *ReplaceResourcesQueryOptions)`, func() {
+ replaceResourcesQueryPath := "/v2/resources_query/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceResourcesQueryPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
+ }))
+ })
+ It(`Invoke ReplaceResourcesQuery successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the ReplaceResourcesQueryOptions model
+ replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
+ replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
+ replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ReplaceResourcesQueryWithContext(ctx, replaceResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ReplaceResourcesQueryWithContext(ctx, replaceResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(replaceResourcesQueryPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"type": "vsi", "name": "Name", "id": "ID", "created_at": "2019-01-01T12:00:00.000Z", "created_by": "CreatedBy", "updated_at": "2019-01-01T12:00:00.000Z", "updated_by": "UpdatedBy", "queries": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"]}]}`)
+ }))
+ })
+ It(`Invoke ReplaceResourcesQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ReplaceResourcesQuery(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the ReplaceResourcesQueryOptions model
+ replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
+ replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
+ replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ReplaceResourcesQuery with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the ReplaceResourcesQueryOptions model
+ replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
+ replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
+ replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ReplaceResourcesQueryOptions model with no property values
+ replaceResourcesQueryOptionsModelNew := new(schematicsv1.ReplaceResourcesQueryOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ReplaceResourcesQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+
+ // Construct an instance of the ReplaceResourcesQueryOptions model
+ replaceResourcesQueryOptionsModel := new(schematicsv1.ReplaceResourcesQueryOptions)
+ replaceResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Type = core.StringPtr("vsi")
+ replaceResourcesQueryOptionsModel.Name = core.StringPtr("testString")
+ replaceResourcesQueryOptionsModel.Queries = []schematicsv1.ResourceQuery{*resourceQueryModel}
+ replaceResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ReplaceResourcesQuery(replaceResourcesQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ExecuteResourceQuery(executeResourceQueryOptions *ExecuteResourceQueryOptions) - Operation response error`, func() {
+ executeResourceQueryPath := "/v2/resources_query/testString"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(executeResourceQueryPath))
+ Expect(req.Method).To(Equal("POST"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ExecuteResourceQuery with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ExecuteResourceQueryOptions model
+ executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
+ executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
+ executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ExecuteResourceQuery(executeResourceQueryOptions *ExecuteResourceQueryOptions)`, func() {
+ executeResourceQueryPath := "/v2/resources_query/testString"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(executeResourceQueryPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"response": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"], "query_output": [{"name": "Name", "value": "Value"}]}]}`)
+ }))
+ })
+ It(`Invoke ExecuteResourceQuery successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ExecuteResourceQueryOptions model
+ executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
+ executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
+ executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ExecuteResourceQueryWithContext(ctx, executeResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ExecuteResourceQueryWithContext(ctx, executeResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(executeResourceQueryPath))
+ Expect(req.Method).To(Equal("POST"))
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"response": [{"query_type": "workspaces", "query_condition": [{"name": "Name", "value": "Value", "description": "Description"}], "query_select": ["QuerySelect"], "query_output": [{"name": "Name", "value": "Value"}]}]}`)
+ }))
+ })
+ It(`Invoke ExecuteResourceQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ExecuteResourceQuery(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ExecuteResourceQueryOptions model
+ executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
+ executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
+ executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ExecuteResourceQuery with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ExecuteResourceQueryOptions model
+ executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
+ executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
+ executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ExecuteResourceQueryOptions model with no property values
+ executeResourceQueryOptionsModelNew := new(schematicsv1.ExecuteResourceQueryOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ExecuteResourceQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ExecuteResourceQueryOptions model
+ executeResourceQueryOptionsModel := new(schematicsv1.ExecuteResourceQueryOptions)
+ executeResourceQueryOptionsModel.QueryID = core.StringPtr("testString")
+ executeResourceQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ExecuteResourceQuery(executeResourceQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`DeleteResourcesQuery(deleteResourcesQueryOptions *DeleteResourcesQueryOptions)`, func() {
+ deleteResourcesQueryPath := "/v2/resources_query/testString"
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(deleteResourcesQueryPath))
+ Expect(req.Method).To(Equal("DELETE"))
+
+ Expect(req.Header["Force"]).ToNot(BeNil())
+ Expect(req.Header["Force"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ Expect(req.Header["Propagate"]).ToNot(BeNil())
+ Expect(req.Header["Propagate"][0]).To(Equal(fmt.Sprintf("%v", true)))
+ res.WriteHeader(204)
+ }))
+ })
+ It(`Invoke DeleteResourcesQuery successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ response, operationErr := schematicsService.DeleteResourcesQuery(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+
+ // Construct an instance of the DeleteResourcesQueryOptions model
+ deleteResourcesQueryOptionsModel := new(schematicsv1.DeleteResourcesQueryOptions)
+ deleteResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ deleteResourcesQueryOptionsModel.Force = core.BoolPtr(true)
+ deleteResourcesQueryOptionsModel.Propagate = core.BoolPtr(true)
+ deleteResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ response, operationErr = schematicsService.DeleteResourcesQuery(deleteResourcesQueryOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ })
+ It(`Invoke DeleteResourcesQuery with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the DeleteResourcesQueryOptions model
+ deleteResourcesQueryOptionsModel := new(schematicsv1.DeleteResourcesQueryOptions)
+ deleteResourcesQueryOptionsModel.QueryID = core.StringPtr("testString")
+ deleteResourcesQueryOptionsModel.Force = core.BoolPtr(true)
+ deleteResourcesQueryOptionsModel.Propagate = core.BoolPtr(true)
+ deleteResourcesQueryOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ response, operationErr := schematicsService.DeleteResourcesQuery(deleteResourcesQueryOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ // Construct a second instance of the DeleteResourcesQueryOptions model with no property values
+ deleteResourcesQueryOptionsModelNew := new(schematicsv1.DeleteResourcesQueryOptions)
+ // Invoke operation with invalid model (negative test)
+ response, operationErr = schematicsService.DeleteResourcesQuery(deleteResourcesQueryOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetKmsSettings(getKmsSettingsOptions *GetKmsSettingsOptions) - Operation response error`, func() {
+ getKmsSettingsPath := "/v2/settings/kms"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getKmsSettingsPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke GetKmsSettings with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetKmsSettingsOptions model
+ getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
+ getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`GetKmsSettings(getKmsSettingsOptions *GetKmsSettingsOptions)`, func() {
+ getKmsSettingsPath := "/v2/settings/kms"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getKmsSettingsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
+ }))
+ })
+ It(`Invoke GetKmsSettings successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the GetKmsSettingsOptions model
+ getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
+ getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.GetKmsSettingsWithContext(ctx, getKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.GetKmsSettingsWithContext(ctx, getKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(getKmsSettingsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
+ }))
+ })
+ It(`Invoke GetKmsSettings successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.GetKmsSettings(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the GetKmsSettingsOptions model
+ getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
+ getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke GetKmsSettings with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetKmsSettingsOptions model
+ getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
+ getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the GetKmsSettingsOptions model with no property values
+ getKmsSettingsOptionsModelNew := new(schematicsv1.GetKmsSettingsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.GetKmsSettings(getKmsSettingsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke GetKmsSettings successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the GetKmsSettingsOptions model
+ getKmsSettingsOptionsModel := new(schematicsv1.GetKmsSettingsOptions)
+ getKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ getKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.GetKmsSettings(getKmsSettingsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateKmsSettings(updateKmsSettingsOptions *UpdateKmsSettingsOptions) - Operation response error`, func() {
+ updateKmsSettingsPath := "/v2/settings/kms"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateKmsSettingsPath))
+ Expect(req.Method).To(Equal("PUT"))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke UpdateKmsSettings with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the KMSSettingsPrimaryCrk model
+ kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
+ kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the KMSSettingsSecondaryCrk model
+ kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
+ kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateKmsSettingsOptions model
+ updateKmsSettingsOptionsModel := new(schematicsv1.UpdateKmsSettingsOptions)
+ updateKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
+ updateKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
+ updateKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.UpdateKmsSettings(updateKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.UpdateKmsSettings(updateKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`UpdateKmsSettings(updateKmsSettingsOptions *UpdateKmsSettingsOptions)`, func() {
+ updateKmsSettingsPath := "/v2/settings/kms"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateKmsSettingsPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
+ }))
+ })
+ It(`Invoke UpdateKmsSettings successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the KMSSettingsPrimaryCrk model
+ kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
+ kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the KMSSettingsSecondaryCrk model
+ kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
+ kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateKmsSettingsOptions model
+ updateKmsSettingsOptionsModel := new(schematicsv1.UpdateKmsSettingsOptions)
+ updateKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
+ updateKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
+ updateKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.UpdateKmsSettingsWithContext(ctx, updateKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.UpdateKmsSettings(updateKmsSettingsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.UpdateKmsSettingsWithContext(ctx, updateKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(updateKmsSettingsPath))
+ Expect(req.Method).To(Equal("PUT"))
+
+ // For gzip-disabled operation, verify Content-Encoding is not set.
+ Expect(req.Header.Get("Content-Encoding")).To(BeEmpty())
+
+ // If there is a body, then make sure we can read it
+ bodyBuf := new(bytes.Buffer)
+ if req.Header.Get("Content-Encoding") == "gzip" {
+ body, err := core.NewGzipDecompressionReader(req.Body)
+ Expect(err).To(BeNil())
+ _, err = bodyBuf.ReadFrom(body)
+ Expect(err).To(BeNil())
+ } else {
+ _, err := bodyBuf.ReadFrom(req.Body)
+ Expect(err).To(BeNil())
+ }
+ fmt.Fprintf(GinkgoWriter, " Request body: %s", bodyBuf.String())
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "primary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}, "secondary_crk": {"kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "key_crn": "KeyCrn"}}`)
+ }))
+ })
+ It(`Invoke UpdateKmsSettings successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.UpdateKmsSettings(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the KMSSettingsPrimaryCrk model
+ kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
+ kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the KMSSettingsSecondaryCrk model
+ kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
+ kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateKmsSettingsOptions model
+ updateKmsSettingsOptionsModel := new(schematicsv1.UpdateKmsSettingsOptions)
+ updateKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
+ updateKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
+ updateKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.UpdateKmsSettings(updateKmsSettingsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke UpdateKmsSettings with error: Operation request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the KMSSettingsPrimaryCrk model
+ kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
+ kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the KMSSettingsSecondaryCrk model
+ kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
+ kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateKmsSettingsOptions model
+ updateKmsSettingsOptionsModel := new(schematicsv1.UpdateKmsSettingsOptions)
+ updateKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
+ updateKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
+ updateKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.UpdateKmsSettings(updateKmsSettingsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke UpdateKmsSettings successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the KMSSettingsPrimaryCrk model
+ kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
+ kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the KMSSettingsSecondaryCrk model
+ kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
+ kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
+
+ // Construct an instance of the UpdateKmsSettingsOptions model
+ updateKmsSettingsOptionsModel := new(schematicsv1.UpdateKmsSettingsOptions)
+ updateKmsSettingsOptionsModel.Location = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ updateKmsSettingsOptionsModel.PrimaryCrk = kmsSettingsPrimaryCrkModel
+ updateKmsSettingsOptionsModel.SecondaryCrk = kmsSettingsSecondaryCrkModel
+ updateKmsSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.UpdateKmsSettings(updateKmsSettingsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListKms(listKmsOptions *ListKmsOptions) - Operation response error`, func() {
+ listKmsPath := "/v2/settings/kms_instances"
+ Context(`Using mock server endpoint with invalid JSON response`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listKmsPath))
+ Expect(req.Method).To(Equal("GET"))
+ Expect(req.URL.Query()["encryption_scheme"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["resource_group"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, `} this is not valid json {`)
+ }))
+ })
+ It(`Invoke ListKms with error: Operation response processing error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListKmsOptions model
+ listKmsOptionsModel := new(schematicsv1.ListKmsOptions)
+ listKmsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ listKmsOptionsModel.Location = core.StringPtr("testString")
+ listKmsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ listKmsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listKmsOptionsModel.Sort = core.StringPtr("testString")
+ listKmsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Expect response parsing to fail since we are receiving a text/plain response
+ result, response, operationErr := schematicsService.ListKms(listKmsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+
+ // Enable retries and test again
+ schematicsService.EnableRetries(0, 0)
+ result, response, operationErr = schematicsService.ListKms(listKmsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`ListKms(listKmsOptions *ListKmsOptions)`, func() {
+ listKmsPath := "/v2/settings/kms_instances"
+ Context(`Using mock server endpoint with timeout`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listKmsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["encryption_scheme"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["resource_group"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ // Sleep a short time to support a timeout test
+ time.Sleep(100 * time.Millisecond)
+
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "kms_instances": [{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "kms_crn": "KmsCrn", "kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "kms_public_endpoint": "KmsPublicEndpoint", "keys": [{"name": "Name", "crn": "Crn", "error": "Error"}]}]}`)
+ }))
+ })
+ It(`Invoke ListKms successfully with retries`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+ schematicsService.EnableRetries(0, 0)
+
+ // Construct an instance of the ListKmsOptions model
+ listKmsOptionsModel := new(schematicsv1.ListKmsOptions)
+ listKmsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ listKmsOptionsModel.Location = core.StringPtr("testString")
+ listKmsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ listKmsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listKmsOptionsModel.Sort = core.StringPtr("testString")
+ listKmsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with a Context to test a timeout error
+ ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc()
+ _, _, operationErr := schematicsService.ListKmsWithContext(ctx, listKmsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+
+ // Disable retries and test again
+ schematicsService.DisableRetries()
+ result, response, operationErr := schematicsService.ListKms(listKmsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ // Re-test the timeout error with retries disabled
+ ctx, cancelFunc2 := context.WithTimeout(context.Background(), 80*time.Millisecond)
+ defer cancelFunc2()
+ _, _, operationErr = schematicsService.ListKmsWithContext(ctx, listKmsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded"))
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Verify the contents of the request
+ Expect(req.URL.EscapedPath()).To(Equal(listKmsPath))
+ Expect(req.Method).To(Equal("GET"))
+
+ Expect(req.URL.Query()["encryption_scheme"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["location"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["resource_group"]).To(Equal([]string{"testString"}))
+ Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(1))}))
+ Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
+ // Set mock response
+ res.Header().Set("Content-type", "application/json")
+ res.WriteHeader(200)
+ fmt.Fprintf(res, "%s", `{"total_count": 10, "limit": 5, "offset": 6, "kms_instances": [{"location": "Location", "encryption_scheme": "EncryptionScheme", "resource_group": "ResourceGroup", "kms_crn": "KmsCrn", "kms_name": "KmsName", "kms_private_endpoint": "KmsPrivateEndpoint", "kms_public_endpoint": "KmsPublicEndpoint", "keys": [{"name": "Name", "crn": "Crn", "error": "Error"}]}]}`)
+ }))
+ })
+ It(`Invoke ListKms successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Invoke operation with nil options model (negative test)
+ result, response, operationErr := schematicsService.ListKms(nil)
+ Expect(operationErr).NotTo(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+
+ // Construct an instance of the ListKmsOptions model
+ listKmsOptionsModel := new(schematicsv1.ListKmsOptions)
+ listKmsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ listKmsOptionsModel.Location = core.StringPtr("testString")
+ listKmsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ listKmsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listKmsOptionsModel.Sort = core.StringPtr("testString")
+ listKmsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation with valid options model (positive test)
+ result, response, operationErr = schematicsService.ListKms(listKmsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+ Expect(result).ToNot(BeNil())
+
+ })
+ It(`Invoke ListKms with error: Operation validation and request error`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListKmsOptions model
+ listKmsOptionsModel := new(schematicsv1.ListKmsOptions)
+ listKmsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ listKmsOptionsModel.Location = core.StringPtr("testString")
+ listKmsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ listKmsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listKmsOptionsModel.Sort = core.StringPtr("testString")
+ listKmsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+ // Invoke operation with empty URL (negative test)
+ err := schematicsService.SetServiceURL("")
+ Expect(err).To(BeNil())
+ result, response, operationErr := schematicsService.ListKms(listKmsOptionsModel)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING))
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ // Construct a second instance of the ListKmsOptions model with no property values
+ listKmsOptionsModelNew := new(schematicsv1.ListKmsOptions)
+ // Invoke operation with invalid model (negative test)
+ result, response, operationErr = schematicsService.ListKms(listKmsOptionsModelNew)
+ Expect(operationErr).ToNot(BeNil())
+ Expect(response).To(BeNil())
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ Context(`Using mock server endpoint with missing response body`, func() {
+ BeforeEach(func() {
+ testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
+ defer GinkgoRecover()
+
+ // Set success status code with no respoonse body
+ res.WriteHeader(200)
+ }))
+ })
+ It(`Invoke ListKms successfully`, func() {
+ schematicsService, serviceErr := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: testServer.URL,
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ Expect(serviceErr).To(BeNil())
+ Expect(schematicsService).ToNot(BeNil())
+
+ // Construct an instance of the ListKmsOptions model
+ listKmsOptionsModel := new(schematicsv1.ListKmsOptions)
+ listKmsOptionsModel.EncryptionScheme = core.StringPtr("testString")
+ listKmsOptionsModel.Location = core.StringPtr("testString")
+ listKmsOptionsModel.ResourceGroup = core.StringPtr("testString")
+ listKmsOptionsModel.Limit = core.Int64Ptr(int64(1))
+ listKmsOptionsModel.Sort = core.StringPtr("testString")
+ listKmsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
+
+ // Invoke operation
+ result, response, operationErr := schematicsService.ListKms(listKmsOptionsModel)
+ Expect(operationErr).To(BeNil())
+ Expect(response).ToNot(BeNil())
+
+ // Verify a nil result
+ Expect(result).To(BeNil())
+ })
+ AfterEach(func() {
+ testServer.Close()
+ })
+ })
+ })
+ Describe(`Model constructor tests`, func() {
+ Context(`Using a service client instance`, func() {
+ schematicsService, _ := schematicsv1.NewSchematicsV1(&schematicsv1.SchematicsV1Options{
+ URL: "http://schematicsv1modelgenerator.com",
+ Authenticator: &core.NoAuthAuthenticator{},
+ })
+ It(`Invoke NewApplyWorkspaceCommandOptions successfully`, func() {
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ Expect(workspaceActivityOptionsTemplateModel).ToNot(BeNil())
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+ Expect(workspaceActivityOptionsTemplateModel.Target).To(Equal([]string{"testString"}))
+ Expect(workspaceActivityOptionsTemplateModel.TfVars).To(Equal([]string{"testString"}))
+
+ // Construct an instance of the ApplyWorkspaceCommandOptions model
+ wID := "testString"
+ refreshToken := "testString"
+ applyWorkspaceCommandOptionsModel := schematicsService.NewApplyWorkspaceCommandOptions(wID, refreshToken)
+ applyWorkspaceCommandOptionsModel.SetWID("testString")
+ applyWorkspaceCommandOptionsModel.SetRefreshToken("testString")
+ applyWorkspaceCommandOptionsModel.SetActionOptions(workspaceActivityOptionsTemplateModel)
+ applyWorkspaceCommandOptionsModel.SetDelegatedToken("testString")
+ applyWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(applyWorkspaceCommandOptionsModel).ToNot(BeNil())
+ Expect(applyWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(applyWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(applyWorkspaceCommandOptionsModel.ActionOptions).To(Equal(workspaceActivityOptionsTemplateModel))
+ Expect(applyWorkspaceCommandOptionsModel.DelegatedToken).To(Equal(core.StringPtr("testString")))
+ Expect(applyWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewCreateActionOptions successfully`, func() {
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ Expect(userStateModel).ToNot(BeNil())
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(userStateModel.State).To(Equal(core.StringPtr("draft")))
+ Expect(userStateModel.SetBy).To(Equal(core.StringPtr("testString")))
+ Expect(userStateModel.SetAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ Expect(externalSourceGitModel).ToNot(BeNil())
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+ Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ Expect(externalSourceCatalogModel).ToNot(BeNil())
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+ Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ Expect(externalSourceCosBucketModel).ToNot(BeNil())
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+ Expect(externalSourceCosBucketModel.CosBucketURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ Expect(externalSourceModel).ToNot(BeNil())
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+ Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
+ Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
+ Expect(externalSourceModel.CosBucket).To(Equal(externalSourceCosBucketModel))
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ Expect(variableMetadataModel).ToNot(BeNil())
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+ Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
+ Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ Expect(variableDataModel).ToNot(BeNil())
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+ Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ Expect(bastionResourceDefinitionModel).ToNot(BeNil())
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+ Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ Expect(actionStateModel).ToNot(BeNil())
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+ Expect(actionStateModel.StatusCode).To(Equal(core.StringPtr("normal")))
+ Expect(actionStateModel.StatusJobID).To(Equal(core.StringPtr("testString")))
+ Expect(actionStateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ Expect(systemLockModel).ToNot(BeNil())
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(systemLockModel.SysLocked).To(Equal(core.BoolPtr(true)))
+ Expect(systemLockModel.SysLockedBy).To(Equal(core.StringPtr("testString")))
+ Expect(systemLockModel.SysLockedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the CreateActionOptions model
+ createActionOptionsModel := schematicsService.NewCreateActionOptions()
+ createActionOptionsModel.SetName("Stop Action")
+ createActionOptionsModel.SetDescription("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ createActionOptionsModel.SetLocation("us-south")
+ createActionOptionsModel.SetResourceGroup("testString")
+ createActionOptionsModel.SetTags([]string{"testString"})
+ createActionOptionsModel.SetUserState(userStateModel)
+ createActionOptionsModel.SetSourceReadmeURL("testString")
+ createActionOptionsModel.SetSource(externalSourceModel)
+ createActionOptionsModel.SetSourceType("local")
+ createActionOptionsModel.SetCommandParameter("testString")
+ createActionOptionsModel.SetInventory("testString")
+ createActionOptionsModel.SetCredentials([]schematicsv1.VariableData{*variableDataModel})
+ createActionOptionsModel.SetBastion(bastionResourceDefinitionModel)
+ createActionOptionsModel.SetBastionCredential(variableDataModel)
+ createActionOptionsModel.SetTargetsIni("testString")
+ createActionOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
+ createActionOptionsModel.SetOutputs([]schematicsv1.VariableData{*variableDataModel})
+ createActionOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
+ createActionOptionsModel.SetState(actionStateModel)
+ createActionOptionsModel.SetSysLock(systemLockModel)
+ createActionOptionsModel.SetXGithubToken("testString")
+ createActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(createActionOptionsModel).ToNot(BeNil())
+ Expect(createActionOptionsModel.Name).To(Equal(core.StringPtr("Stop Action")))
+ Expect(createActionOptionsModel.Description).To(Equal(core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")))
+ Expect(createActionOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(createActionOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(createActionOptionsModel.Tags).To(Equal([]string{"testString"}))
+ Expect(createActionOptionsModel.UserState).To(Equal(userStateModel))
+ Expect(createActionOptionsModel.SourceReadmeURL).To(Equal(core.StringPtr("testString")))
+ Expect(createActionOptionsModel.Source).To(Equal(externalSourceModel))
+ Expect(createActionOptionsModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(createActionOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
+ Expect(createActionOptionsModel.Inventory).To(Equal(core.StringPtr("testString")))
+ Expect(createActionOptionsModel.Credentials).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(createActionOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
+ Expect(createActionOptionsModel.BastionCredential).To(Equal(variableDataModel))
+ Expect(createActionOptionsModel.TargetsIni).To(Equal(core.StringPtr("testString")))
+ Expect(createActionOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(createActionOptionsModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(createActionOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(createActionOptionsModel.State).To(Equal(actionStateModel))
+ Expect(createActionOptionsModel.SysLock).To(Equal(systemLockModel))
+ Expect(createActionOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
+ Expect(createActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewCreateInventoryOptions successfully`, func() {
+ // Construct an instance of the CreateInventoryOptions model
+ createInventoryOptionsModel := schematicsService.NewCreateInventoryOptions()
+ createInventoryOptionsModel.SetName("testString")
+ createInventoryOptionsModel.SetDescription("testString")
+ createInventoryOptionsModel.SetLocation("us-south")
+ createInventoryOptionsModel.SetResourceGroup("testString")
+ createInventoryOptionsModel.SetInventoriesIni("testString")
+ createInventoryOptionsModel.SetResourceQueries([]string{"testString"})
+ createInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(createInventoryOptionsModel).ToNot(BeNil())
+ Expect(createInventoryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(createInventoryOptionsModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(createInventoryOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(createInventoryOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(createInventoryOptionsModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
+ Expect(createInventoryOptionsModel.ResourceQueries).To(Equal([]string{"testString"}))
+ Expect(createInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewCreateJobOptions successfully`, func() {
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ Expect(variableMetadataModel).ToNot(BeNil())
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+ Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
+ Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ Expect(variableDataModel).ToNot(BeNil())
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+ Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ Expect(jobStatusWorkitemModel).ToNot(BeNil())
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusWorkitemModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusWorkitemModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ Expect(jobStatusFlowModel).ToNot(BeNil())
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusFlowModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusFlowModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusFlowModel.Workitems).To(Equal([]schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}))
+ Expect(jobStatusFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ Expect(jobStatusTemplateModel).ToNot(BeNil())
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(jobStatusTemplateModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusTemplateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ Expect(jobStatusWorkspaceModel).ToNot(BeNil())
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkspaceModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusWorkspaceModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkspaceModel.FlowStatus).To(Equal(jobStatusFlowModel))
+ Expect(jobStatusWorkspaceModel.TemplateStatus).To(Equal([]schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}))
+ Expect(jobStatusWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ Expect(jobStatusActionModel).ToNot(BeNil())
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusActionModel.ActionName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusActionModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.BastionStatusCode).To(Equal(core.StringPtr("none")))
+ Expect(jobStatusActionModel.BastionStatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.TargetsStatusCode).To(Equal(core.StringPtr("none")))
+ Expect(jobStatusActionModel.TargetsStatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ Expect(jobStatusSchematicsResourcesModel).ToNot(BeNil())
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusSchematicsResourcesModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusSchematicsResourcesModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusSchematicsResourcesModel.SchematicsResourceID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusSchematicsResourcesModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ Expect(jobStatusSystemModel).ToNot(BeNil())
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusSystemModel.SystemStatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusSystemModel.SystemStatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusSystemModel.SchematicsResourceStatus).To(Equal([]schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}))
+ Expect(jobStatusSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ Expect(jobStatusModel).ToNot(BeNil())
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+ Expect(jobStatusModel.WorkspaceJobStatus).To(Equal(jobStatusWorkspaceModel))
+ Expect(jobStatusModel.ActionJobStatus).To(Equal(jobStatusActionModel))
+ Expect(jobStatusModel.SystemJobStatus).To(Equal(jobStatusSystemModel))
+ Expect(jobStatusModel.FlowJobStatus).To(Equal(jobStatusFlowModel))
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ Expect(jobDataTemplateModel).ToNot(BeNil())
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(jobDataTemplateModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataTemplateModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataTemplateModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ Expect(jobDataWorkspaceModel).ToNot(BeNil())
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkspaceModel.FlowID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkspaceModel.FlowName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkspaceModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkspaceModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkspaceModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkspaceModel.TemplateData).To(Equal([]schematicsv1.JobDataTemplate{*jobDataTemplateModel}))
+ Expect(jobDataWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ Expect(inventoryResourceRecordModel).ToNot(BeNil())
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+ Expect(inventoryResourceRecordModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(inventoryResourceRecordModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.ResourceQueries).To(Equal([]string{"testString"}))
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ Expect(jobDataActionModel).ToNot(BeNil())
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+ Expect(jobDataActionModel.ActionName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataActionModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataActionModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataActionModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+ Expect(jobDataActionModel.InventoryRecord).To(Equal(inventoryResourceRecordModel))
+ Expect(jobDataActionModel.MaterializedInventory).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ Expect(jobDataSystemModel).ToNot(BeNil())
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataSystemModel.KeyID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataSystemModel.SchematicsResourceID).To(Equal([]string{"testString"}))
+ Expect(jobDataSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ Expect(externalSourceGitModel).ToNot(BeNil())
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+ Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ Expect(externalSourceCatalogModel).ToNot(BeNil())
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+ Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ Expect(externalSourceCosBucketModel).ToNot(BeNil())
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+ Expect(externalSourceCosBucketModel.CosBucketURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ Expect(externalSourceModel).ToNot(BeNil())
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+ Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
+ Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
+ Expect(externalSourceModel.CosBucket).To(Equal(externalSourceCosBucketModel))
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ Expect(jobDataWorkItemLastJobModel).ToNot(BeNil())
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+ Expect(jobDataWorkItemLastJobModel.CommandObject).To(Equal(core.StringPtr("workspace")))
+ Expect(jobDataWorkItemLastJobModel.CommandObjectName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemLastJobModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemLastJobModel.CommandName).To(Equal(core.StringPtr("workspace_plan")))
+ Expect(jobDataWorkItemLastJobModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemLastJobModel.JobStatus).To(Equal(core.StringPtr("job_pending")))
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ Expect(jobDataWorkItemModel).ToNot(BeNil())
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataWorkItemModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemModel.CommandObjectName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemModel.Layers).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(jobDataWorkItemModel.Source).To(Equal(externalSourceModel))
+ Expect(jobDataWorkItemModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkItemModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkItemModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkItemModel.LastJob).To(Equal(jobDataWorkItemLastJobModel))
+ Expect(jobDataWorkItemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ Expect(jobDataFlowModel).ToNot(BeNil())
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataFlowModel.Workitems).To(Equal([]schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}))
+ Expect(jobDataFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ Expect(jobDataModel).ToNot(BeNil())
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+ Expect(jobDataModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
+ Expect(jobDataModel.WorkspaceJobData).To(Equal(jobDataWorkspaceModel))
+ Expect(jobDataModel.ActionJobData).To(Equal(jobDataActionModel))
+ Expect(jobDataModel.SystemJobData).To(Equal(jobDataSystemModel))
+ Expect(jobDataModel.FlowJobData).To(Equal(jobDataFlowModel))
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ Expect(bastionResourceDefinitionModel).ToNot(BeNil())
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+ Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+ Expect(jobLogSummaryRepoDownloadJobModel).ToNot(BeNil())
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+ Expect(jobLogSummaryWorkspaceJobModel).ToNot(BeNil())
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ Expect(jobLogSummaryWorkitemsModel).ToNot(BeNil())
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+ Expect(jobLogSummaryWorkitemsModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
+ Expect(jobLogSummaryWorkitemsModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(jobLogSummaryWorkitemsModel.LogURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ Expect(jobLogSummaryFlowJobModel).ToNot(BeNil())
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+ Expect(jobLogSummaryFlowJobModel.Workitems).To(Equal([]schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}))
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ Expect(jobLogSummaryActionJobRecapModel).ToNot(BeNil())
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+ Expect(jobLogSummaryActionJobRecapModel.Target).To(Equal([]string{"testString"}))
+ Expect(jobLogSummaryActionJobRecapModel.Ok).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Changed).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Skipped).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Unreachable).To(Equal(core.Float64Ptr(float64(72.5))))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ Expect(jobLogSummaryActionJobModel).ToNot(BeNil())
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+ Expect(jobLogSummaryActionJobModel.Recap).To(Equal(jobLogSummaryActionJobRecapModel))
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ Expect(jobLogSummarySystemJobModel).ToNot(BeNil())
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+ Expect(jobLogSummarySystemJobModel.Success).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummarySystemJobModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ Expect(jobLogSummaryModel).ToNot(BeNil())
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+ Expect(jobLogSummaryModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
+ Expect(jobLogSummaryModel.RepoDownloadJob).To(Equal(jobLogSummaryRepoDownloadJobModel))
+ Expect(jobLogSummaryModel.WorkspaceJob).To(Equal(jobLogSummaryWorkspaceJobModel))
+ Expect(jobLogSummaryModel.FlowJob).To(Equal(jobLogSummaryFlowJobModel))
+ Expect(jobLogSummaryModel.ActionJob).To(Equal(jobLogSummaryActionJobModel))
+ Expect(jobLogSummaryModel.SystemJob).To(Equal(jobLogSummarySystemJobModel))
+
+ // Construct an instance of the CreateJobOptions model
+ refreshToken := "testString"
+ createJobOptionsModel := schematicsService.NewCreateJobOptions(refreshToken)
+ createJobOptionsModel.SetRefreshToken("testString")
+ createJobOptionsModel.SetCommandObject("workspace")
+ createJobOptionsModel.SetCommandObjectID("testString")
+ createJobOptionsModel.SetCommandName("workspace_plan")
+ createJobOptionsModel.SetCommandParameter("testString")
+ createJobOptionsModel.SetCommandOptions([]string{"testString"})
+ createJobOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
+ createJobOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
+ createJobOptionsModel.SetTags([]string{"testString"})
+ createJobOptionsModel.SetLocation("us-south")
+ createJobOptionsModel.SetStatus(jobStatusModel)
+ createJobOptionsModel.SetData(jobDataModel)
+ createJobOptionsModel.SetBastion(bastionResourceDefinitionModel)
+ createJobOptionsModel.SetLogSummary(jobLogSummaryModel)
+ createJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(createJobOptionsModel).ToNot(BeNil())
+ Expect(createJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(createJobOptionsModel.CommandObject).To(Equal(core.StringPtr("workspace")))
+ Expect(createJobOptionsModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
+ Expect(createJobOptionsModel.CommandName).To(Equal(core.StringPtr("workspace_plan")))
+ Expect(createJobOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
+ Expect(createJobOptionsModel.CommandOptions).To(Equal([]string{"testString"}))
+ Expect(createJobOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(createJobOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(createJobOptionsModel.Tags).To(Equal([]string{"testString"}))
+ Expect(createJobOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(createJobOptionsModel.Status).To(Equal(jobStatusModel))
+ Expect(createJobOptionsModel.Data).To(Equal(jobDataModel))
+ Expect(createJobOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
+ Expect(createJobOptionsModel.LogSummary).To(Equal(jobLogSummaryModel))
+ Expect(createJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewCreateResourceQueryOptions successfully`, func() {
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ Expect(resourceQueryParamModel).ToNot(BeNil())
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+ Expect(resourceQueryParamModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(resourceQueryParamModel.Value).To(Equal(core.StringPtr("testString")))
+ Expect(resourceQueryParamModel.Description).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ Expect(resourceQueryModel).ToNot(BeNil())
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+ Expect(resourceQueryModel.QueryType).To(Equal(core.StringPtr("workspaces")))
+ Expect(resourceQueryModel.QueryCondition).To(Equal([]schematicsv1.ResourceQueryParam{*resourceQueryParamModel}))
+ Expect(resourceQueryModel.QuerySelect).To(Equal([]string{"testString"}))
+
+ // Construct an instance of the CreateResourceQueryOptions model
+ createResourceQueryOptionsModel := schematicsService.NewCreateResourceQueryOptions()
+ createResourceQueryOptionsModel.SetType("vsi")
+ createResourceQueryOptionsModel.SetName("testString")
+ createResourceQueryOptionsModel.SetQueries([]schematicsv1.ResourceQuery{*resourceQueryModel})
+ createResourceQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(createResourceQueryOptionsModel).ToNot(BeNil())
+ Expect(createResourceQueryOptionsModel.Type).To(Equal(core.StringPtr("vsi")))
+ Expect(createResourceQueryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(createResourceQueryOptionsModel.Queries).To(Equal([]schematicsv1.ResourceQuery{*resourceQueryModel}))
+ Expect(createResourceQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewCreateWorkspaceDeletionJobOptions successfully`, func() {
+ // Construct an instance of the CreateWorkspaceDeletionJobOptions model
+ refreshToken := "testString"
+ createWorkspaceDeletionJobOptionsModel := schematicsService.NewCreateWorkspaceDeletionJobOptions(refreshToken)
+ createWorkspaceDeletionJobOptionsModel.SetRefreshToken("testString")
+ createWorkspaceDeletionJobOptionsModel.SetNewDeleteWorkspaces(true)
+ createWorkspaceDeletionJobOptionsModel.SetNewDestroyResources(true)
+ createWorkspaceDeletionJobOptionsModel.SetNewJob("testString")
+ createWorkspaceDeletionJobOptionsModel.SetNewVersion("testString")
+ createWorkspaceDeletionJobOptionsModel.SetNewWorkspaces([]string{"testString"})
+ createWorkspaceDeletionJobOptionsModel.SetDestroyResources("testString")
+ createWorkspaceDeletionJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(createWorkspaceDeletionJobOptionsModel).ToNot(BeNil())
+ Expect(createWorkspaceDeletionJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceDeletionJobOptionsModel.NewDeleteWorkspaces).To(Equal(core.BoolPtr(true)))
+ Expect(createWorkspaceDeletionJobOptionsModel.NewDestroyResources).To(Equal(core.BoolPtr(true)))
+ Expect(createWorkspaceDeletionJobOptionsModel.NewJob).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceDeletionJobOptionsModel.NewVersion).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceDeletionJobOptionsModel.NewWorkspaces).To(Equal([]string{"testString"}))
+ Expect(createWorkspaceDeletionJobOptionsModel.DestroyResources).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceDeletionJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewCreateWorkspaceOptions successfully`, func() {
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ Expect(catalogRefModel).ToNot(BeNil())
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+ Expect(catalogRefModel.DryRun).To(Equal(core.BoolPtr(true)))
+ Expect(catalogRefModel.OwningAccount).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemIconURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemID).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemName).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemReadmeURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.LaunchURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ Expect(sharedTargetDataModel).ToNot(BeNil())
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+ Expect(sharedTargetDataModel.ClusterCreatedOn).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterID).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterName).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterType).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.EntitlementKeys).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(sharedTargetDataModel.Namespace).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.Region).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ResourceGroupID).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.WorkerCount).To(Equal(core.Int64Ptr(int64(26))))
+ Expect(sharedTargetDataModel.WorkerMachineType).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ Expect(workspaceVariableRequestModel).ToNot(BeNil())
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+ Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ Expect(templateSourceDataRequestModel).ToNot(BeNil())
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ Expect(templateSourceDataRequestModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(templateSourceDataRequestModel.Folder).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Compact).To(Equal(core.BoolPtr(true)))
+ Expect(templateSourceDataRequestModel.InitStateFile).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Type).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.UninstallScriptName).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Values).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.ValuesMetadata).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(templateSourceDataRequestModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
+
+ // Construct an instance of the TemplateRepoRequest model
+ templateRepoRequestModel := new(schematicsv1.TemplateRepoRequest)
+ Expect(templateRepoRequestModel).ToNot(BeNil())
+ templateRepoRequestModel.Branch = core.StringPtr("testString")
+ templateRepoRequestModel.Release = core.StringPtr("testString")
+ templateRepoRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoRequestModel.URL = core.StringPtr("testString")
+ Expect(templateRepoRequestModel.Branch).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoRequestModel.Release).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoRequestModel.RepoShaValue).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoRequestModel.RepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoRequestModel.URL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the WorkspaceStatusRequest model
+ workspaceStatusRequestModel := new(schematicsv1.WorkspaceStatusRequest)
+ Expect(workspaceStatusRequestModel).ToNot(BeNil())
+ workspaceStatusRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(workspaceStatusRequestModel.Frozen).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceStatusRequestModel.FrozenAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+ Expect(workspaceStatusRequestModel.FrozenBy).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusRequestModel.Locked).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceStatusRequestModel.LockedBy).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusRequestModel.LockedTime).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the CreateWorkspaceOptions model
+ createWorkspaceOptionsModel := schematicsService.NewCreateWorkspaceOptions()
+ createWorkspaceOptionsModel.SetAppliedShareddataIds([]string{"testString"})
+ createWorkspaceOptionsModel.SetCatalogRef(catalogRefModel)
+ createWorkspaceOptionsModel.SetDescription("testString")
+ createWorkspaceOptionsModel.SetLocation("testString")
+ createWorkspaceOptionsModel.SetName("testString")
+ createWorkspaceOptionsModel.SetResourceGroup("testString")
+ createWorkspaceOptionsModel.SetSharedData(sharedTargetDataModel)
+ createWorkspaceOptionsModel.SetTags([]string{"testString"})
+ createWorkspaceOptionsModel.SetTemplateData([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel})
+ createWorkspaceOptionsModel.SetTemplateRef("testString")
+ createWorkspaceOptionsModel.SetTemplateRepo(templateRepoRequestModel)
+ createWorkspaceOptionsModel.SetType([]string{"testString"})
+ createWorkspaceOptionsModel.SetWorkspaceStatus(workspaceStatusRequestModel)
+ createWorkspaceOptionsModel.SetXGithubToken("testString")
+ createWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(createWorkspaceOptionsModel).ToNot(BeNil())
+ Expect(createWorkspaceOptionsModel.AppliedShareddataIds).To(Equal([]string{"testString"}))
+ Expect(createWorkspaceOptionsModel.CatalogRef).To(Equal(catalogRefModel))
+ Expect(createWorkspaceOptionsModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceOptionsModel.Location).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceOptionsModel.SharedData).To(Equal(sharedTargetDataModel))
+ Expect(createWorkspaceOptionsModel.Tags).To(Equal([]string{"testString"}))
+ Expect(createWorkspaceOptionsModel.TemplateData).To(Equal([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}))
+ Expect(createWorkspaceOptionsModel.TemplateRef).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceOptionsModel.TemplateRepo).To(Equal(templateRepoRequestModel))
+ Expect(createWorkspaceOptionsModel.Type).To(Equal([]string{"testString"}))
+ Expect(createWorkspaceOptionsModel.WorkspaceStatus).To(Equal(workspaceStatusRequestModel))
+ Expect(createWorkspaceOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
+ Expect(createWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewDeleteActionOptions successfully`, func() {
+ // Construct an instance of the DeleteActionOptions model
+ actionID := "testString"
+ deleteActionOptionsModel := schematicsService.NewDeleteActionOptions(actionID)
+ deleteActionOptionsModel.SetActionID("testString")
+ deleteActionOptionsModel.SetForce(true)
+ deleteActionOptionsModel.SetPropagate(true)
+ deleteActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(deleteActionOptionsModel).ToNot(BeNil())
+ Expect(deleteActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
+ Expect(deleteActionOptionsModel.Force).To(Equal(core.BoolPtr(true)))
+ Expect(deleteActionOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
+ Expect(deleteActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewDeleteInventoryOptions successfully`, func() {
+ // Construct an instance of the DeleteInventoryOptions model
+ inventoryID := "testString"
+ deleteInventoryOptionsModel := schematicsService.NewDeleteInventoryOptions(inventoryID)
+ deleteInventoryOptionsModel.SetInventoryID("testString")
+ deleteInventoryOptionsModel.SetForce(true)
+ deleteInventoryOptionsModel.SetPropagate(true)
+ deleteInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(deleteInventoryOptionsModel).ToNot(BeNil())
+ Expect(deleteInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
+ Expect(deleteInventoryOptionsModel.Force).To(Equal(core.BoolPtr(true)))
+ Expect(deleteInventoryOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
+ Expect(deleteInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewDeleteJobOptions successfully`, func() {
+ // Construct an instance of the DeleteJobOptions model
+ jobID := "testString"
+ refreshToken := "testString"
+ deleteJobOptionsModel := schematicsService.NewDeleteJobOptions(jobID, refreshToken)
+ deleteJobOptionsModel.SetJobID("testString")
+ deleteJobOptionsModel.SetRefreshToken("testString")
+ deleteJobOptionsModel.SetForce(true)
+ deleteJobOptionsModel.SetPropagate(true)
+ deleteJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(deleteJobOptionsModel).ToNot(BeNil())
+ Expect(deleteJobOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(deleteJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(deleteJobOptionsModel.Force).To(Equal(core.BoolPtr(true)))
+ Expect(deleteJobOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
+ Expect(deleteJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewDeleteResourcesQueryOptions successfully`, func() {
+ // Construct an instance of the DeleteResourcesQueryOptions model
+ queryID := "testString"
+ deleteResourcesQueryOptionsModel := schematicsService.NewDeleteResourcesQueryOptions(queryID)
+ deleteResourcesQueryOptionsModel.SetQueryID("testString")
+ deleteResourcesQueryOptionsModel.SetForce(true)
+ deleteResourcesQueryOptionsModel.SetPropagate(true)
+ deleteResourcesQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(deleteResourcesQueryOptionsModel).ToNot(BeNil())
+ Expect(deleteResourcesQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
+ Expect(deleteResourcesQueryOptionsModel.Force).To(Equal(core.BoolPtr(true)))
+ Expect(deleteResourcesQueryOptionsModel.Propagate).To(Equal(core.BoolPtr(true)))
+ Expect(deleteResourcesQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewDeleteWorkspaceActivityOptions successfully`, func() {
+ // Construct an instance of the DeleteWorkspaceActivityOptions model
+ wID := "testString"
+ activityID := "testString"
+ deleteWorkspaceActivityOptionsModel := schematicsService.NewDeleteWorkspaceActivityOptions(wID, activityID)
+ deleteWorkspaceActivityOptionsModel.SetWID("testString")
+ deleteWorkspaceActivityOptionsModel.SetActivityID("testString")
+ deleteWorkspaceActivityOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(deleteWorkspaceActivityOptionsModel).ToNot(BeNil())
+ Expect(deleteWorkspaceActivityOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(deleteWorkspaceActivityOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
+ Expect(deleteWorkspaceActivityOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewDeleteWorkspaceOptions successfully`, func() {
+ // Construct an instance of the DeleteWorkspaceOptions model
+ wID := "testString"
+ deleteWorkspaceOptionsModel := schematicsService.NewDeleteWorkspaceOptions(wID)
+ deleteWorkspaceOptionsModel.SetWID("testString")
+ deleteWorkspaceOptionsModel.SetDestroyResources(true)
+ deleteWorkspaceOptionsModel.SetRefreshToken("testString")
+ deleteWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(deleteWorkspaceOptionsModel).ToNot(BeNil())
+ Expect(deleteWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(deleteWorkspaceOptionsModel.DestroyResources).To(Equal(core.BoolPtr(true)))
+ Expect(deleteWorkspaceOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(deleteWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewDestroyWorkspaceCommandOptions successfully`, func() {
+ // Construct an instance of the WorkspaceActivityOptionsTemplate model
+ workspaceActivityOptionsTemplateModel := new(schematicsv1.WorkspaceActivityOptionsTemplate)
+ Expect(workspaceActivityOptionsTemplateModel).ToNot(BeNil())
+ workspaceActivityOptionsTemplateModel.Target = []string{"testString"}
+ workspaceActivityOptionsTemplateModel.TfVars = []string{"testString"}
+ Expect(workspaceActivityOptionsTemplateModel.Target).To(Equal([]string{"testString"}))
+ Expect(workspaceActivityOptionsTemplateModel.TfVars).To(Equal([]string{"testString"}))
+
+ // Construct an instance of the DestroyWorkspaceCommandOptions model
+ wID := "testString"
+ refreshToken := "testString"
+ destroyWorkspaceCommandOptionsModel := schematicsService.NewDestroyWorkspaceCommandOptions(wID, refreshToken)
+ destroyWorkspaceCommandOptionsModel.SetWID("testString")
+ destroyWorkspaceCommandOptionsModel.SetRefreshToken("testString")
+ destroyWorkspaceCommandOptionsModel.SetActionOptions(workspaceActivityOptionsTemplateModel)
+ destroyWorkspaceCommandOptionsModel.SetDelegatedToken("testString")
+ destroyWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(destroyWorkspaceCommandOptionsModel).ToNot(BeNil())
+ Expect(destroyWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(destroyWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(destroyWorkspaceCommandOptionsModel.ActionOptions).To(Equal(workspaceActivityOptionsTemplateModel))
+ Expect(destroyWorkspaceCommandOptionsModel.DelegatedToken).To(Equal(core.StringPtr("testString")))
+ Expect(destroyWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewExecuteResourceQueryOptions successfully`, func() {
+ // Construct an instance of the ExecuteResourceQueryOptions model
+ queryID := "testString"
+ executeResourceQueryOptionsModel := schematicsService.NewExecuteResourceQueryOptions(queryID)
+ executeResourceQueryOptionsModel.SetQueryID("testString")
+ executeResourceQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(executeResourceQueryOptionsModel).ToNot(BeNil())
+ Expect(executeResourceQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
+ Expect(executeResourceQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewExternalSource successfully`, func() {
+ sourceType := "local"
+ _model, err := schematicsService.NewExternalSource(sourceType)
+ Expect(_model).ToNot(BeNil())
+ Expect(err).To(BeNil())
+ })
+ It(`Invoke NewGetActionOptions successfully`, func() {
+ // Construct an instance of the GetActionOptions model
+ actionID := "testString"
+ getActionOptionsModel := schematicsService.NewGetActionOptions(actionID)
+ getActionOptionsModel.SetActionID("testString")
+ getActionOptionsModel.SetProfile("summary")
+ getActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getActionOptionsModel).ToNot(BeNil())
+ Expect(getActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
+ Expect(getActionOptionsModel.Profile).To(Equal(core.StringPtr("summary")))
+ Expect(getActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetAllWorkspaceInputsOptions successfully`, func() {
+ // Construct an instance of the GetAllWorkspaceInputsOptions model
+ wID := "testString"
+ getAllWorkspaceInputsOptionsModel := schematicsService.NewGetAllWorkspaceInputsOptions(wID)
+ getAllWorkspaceInputsOptionsModel.SetWID("testString")
+ getAllWorkspaceInputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getAllWorkspaceInputsOptionsModel).ToNot(BeNil())
+ Expect(getAllWorkspaceInputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getAllWorkspaceInputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetInventoryOptions successfully`, func() {
+ // Construct an instance of the GetInventoryOptions model
+ inventoryID := "testString"
+ getInventoryOptionsModel := schematicsService.NewGetInventoryOptions(inventoryID)
+ getInventoryOptionsModel.SetInventoryID("testString")
+ getInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getInventoryOptionsModel).ToNot(BeNil())
+ Expect(getInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
+ Expect(getInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetInventoryValueOptions successfully`, func() {
+ // Construct an instance of the GetInventoryValueOptions model
+ inventoryID := "testString"
+ varName := "testString"
+ getInventoryValueOptionsModel := schematicsService.NewGetInventoryValueOptions(inventoryID, varName)
+ getInventoryValueOptionsModel.SetInventoryID("testString")
+ getInventoryValueOptionsModel.SetVarName("testString")
+ getInventoryValueOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getInventoryValueOptionsModel).ToNot(BeNil())
+ Expect(getInventoryValueOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
+ Expect(getInventoryValueOptionsModel.VarName).To(Equal(core.StringPtr("testString")))
+ Expect(getInventoryValueOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetJobOptions successfully`, func() {
+ // Construct an instance of the GetJobOptions model
+ jobID := "testString"
+ getJobOptionsModel := schematicsService.NewGetJobOptions(jobID)
+ getJobOptionsModel.SetJobID("testString")
+ getJobOptionsModel.SetProfile("summary")
+ getJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getJobOptionsModel).ToNot(BeNil())
+ Expect(getJobOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(getJobOptionsModel.Profile).To(Equal(core.StringPtr("summary")))
+ Expect(getJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetKmsSettingsOptions successfully`, func() {
+ // Construct an instance of the GetKmsSettingsOptions model
+ location := "testString"
+ getKmsSettingsOptionsModel := schematicsService.NewGetKmsSettingsOptions(location)
+ getKmsSettingsOptionsModel.SetLocation("testString")
+ getKmsSettingsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getKmsSettingsOptionsModel).ToNot(BeNil())
+ Expect(getKmsSettingsOptionsModel.Location).To(Equal(core.StringPtr("testString")))
+ Expect(getKmsSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetResourcesQueryOptions successfully`, func() {
+ // Construct an instance of the GetResourcesQueryOptions model
+ queryID := "testString"
+ getResourcesQueryOptionsModel := schematicsService.NewGetResourcesQueryOptions(queryID)
+ getResourcesQueryOptionsModel.SetQueryID("testString")
+ getResourcesQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getResourcesQueryOptionsModel).ToNot(BeNil())
+ Expect(getResourcesQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
+ Expect(getResourcesQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetSchematicsVersionOptions successfully`, func() {
+ // Construct an instance of the GetSchematicsVersionOptions model
+ getSchematicsVersionOptionsModel := schematicsService.NewGetSchematicsVersionOptions()
+ getSchematicsVersionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getSchematicsVersionOptionsModel).ToNot(BeNil())
+ Expect(getSchematicsVersionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetTemplateActivityLogOptions successfully`, func() {
+ // Construct an instance of the GetTemplateActivityLogOptions model
+ wID := "testString"
+ tID := "testString"
+ activityID := "testString"
+ getTemplateActivityLogOptionsModel := schematicsService.NewGetTemplateActivityLogOptions(wID, tID, activityID)
+ getTemplateActivityLogOptionsModel.SetWID("testString")
+ getTemplateActivityLogOptionsModel.SetTID("testString")
+ getTemplateActivityLogOptionsModel.SetActivityID("testString")
+ getTemplateActivityLogOptionsModel.SetLogTfCmd(true)
+ getTemplateActivityLogOptionsModel.SetLogTfPrefix(true)
+ getTemplateActivityLogOptionsModel.SetLogTfNullResource(true)
+ getTemplateActivityLogOptionsModel.SetLogTfAnsible(true)
+ getTemplateActivityLogOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getTemplateActivityLogOptionsModel).ToNot(BeNil())
+ Expect(getTemplateActivityLogOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getTemplateActivityLogOptionsModel.TID).To(Equal(core.StringPtr("testString")))
+ Expect(getTemplateActivityLogOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
+ Expect(getTemplateActivityLogOptionsModel.LogTfCmd).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateActivityLogOptionsModel.LogTfPrefix).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateActivityLogOptionsModel.LogTfNullResource).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateActivityLogOptionsModel.LogTfAnsible).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateActivityLogOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetTemplateLogsOptions successfully`, func() {
+ // Construct an instance of the GetTemplateLogsOptions model
+ wID := "testString"
+ tID := "testString"
+ getTemplateLogsOptionsModel := schematicsService.NewGetTemplateLogsOptions(wID, tID)
+ getTemplateLogsOptionsModel.SetWID("testString")
+ getTemplateLogsOptionsModel.SetTID("testString")
+ getTemplateLogsOptionsModel.SetLogTfCmd(true)
+ getTemplateLogsOptionsModel.SetLogTfPrefix(true)
+ getTemplateLogsOptionsModel.SetLogTfNullResource(true)
+ getTemplateLogsOptionsModel.SetLogTfAnsible(true)
+ getTemplateLogsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getTemplateLogsOptionsModel).ToNot(BeNil())
+ Expect(getTemplateLogsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getTemplateLogsOptionsModel.TID).To(Equal(core.StringPtr("testString")))
+ Expect(getTemplateLogsOptionsModel.LogTfCmd).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateLogsOptionsModel.LogTfPrefix).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateLogsOptionsModel.LogTfNullResource).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateLogsOptionsModel.LogTfAnsible).To(Equal(core.BoolPtr(true)))
+ Expect(getTemplateLogsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceActivityLogsOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceActivityLogsOptions model
+ wID := "testString"
+ activityID := "testString"
+ getWorkspaceActivityLogsOptionsModel := schematicsService.NewGetWorkspaceActivityLogsOptions(wID, activityID)
+ getWorkspaceActivityLogsOptionsModel.SetWID("testString")
+ getWorkspaceActivityLogsOptionsModel.SetActivityID("testString")
+ getWorkspaceActivityLogsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceActivityLogsOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceActivityLogsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceActivityLogsOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceActivityLogsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceActivityOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceActivityOptions model
+ wID := "testString"
+ activityID := "testString"
+ getWorkspaceActivityOptionsModel := schematicsService.NewGetWorkspaceActivityOptions(wID, activityID)
+ getWorkspaceActivityOptionsModel.SetWID("testString")
+ getWorkspaceActivityOptionsModel.SetActivityID("testString")
+ getWorkspaceActivityOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceActivityOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceActivityOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceActivityOptionsModel.ActivityID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceActivityOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceDeletionJobStatusOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceDeletionJobStatusOptions model
+ wjID := "testString"
+ getWorkspaceDeletionJobStatusOptionsModel := schematicsService.NewGetWorkspaceDeletionJobStatusOptions(wjID)
+ getWorkspaceDeletionJobStatusOptionsModel.SetWjID("testString")
+ getWorkspaceDeletionJobStatusOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceDeletionJobStatusOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceDeletionJobStatusOptionsModel.WjID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceDeletionJobStatusOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceInputMetadataOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceInputMetadataOptions model
+ wID := "testString"
+ tID := "testString"
+ getWorkspaceInputMetadataOptionsModel := schematicsService.NewGetWorkspaceInputMetadataOptions(wID, tID)
+ getWorkspaceInputMetadataOptionsModel.SetWID("testString")
+ getWorkspaceInputMetadataOptionsModel.SetTID("testString")
+ getWorkspaceInputMetadataOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceInputMetadataOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceInputMetadataOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceInputMetadataOptionsModel.TID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceInputMetadataOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceInputsOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceInputsOptions model
+ wID := "testString"
+ tID := "testString"
+ getWorkspaceInputsOptionsModel := schematicsService.NewGetWorkspaceInputsOptions(wID, tID)
+ getWorkspaceInputsOptionsModel.SetWID("testString")
+ getWorkspaceInputsOptionsModel.SetTID("testString")
+ getWorkspaceInputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceInputsOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceInputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceInputsOptionsModel.TID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceInputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceLogUrlsOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceLogUrlsOptions model
+ wID := "testString"
+ getWorkspaceLogUrlsOptionsModel := schematicsService.NewGetWorkspaceLogUrlsOptions(wID)
+ getWorkspaceLogUrlsOptionsModel.SetWID("testString")
+ getWorkspaceLogUrlsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceLogUrlsOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceLogUrlsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceLogUrlsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceOptions model
+ wID := "testString"
+ getWorkspaceOptionsModel := schematicsService.NewGetWorkspaceOptions(wID)
+ getWorkspaceOptionsModel.SetWID("testString")
+ getWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceOutputsOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceOutputsOptions model
+ wID := "testString"
+ getWorkspaceOutputsOptionsModel := schematicsService.NewGetWorkspaceOutputsOptions(wID)
+ getWorkspaceOutputsOptionsModel.SetWID("testString")
+ getWorkspaceOutputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceOutputsOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceOutputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceOutputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceReadmeOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceReadmeOptions model
+ wID := "testString"
+ getWorkspaceReadmeOptionsModel := schematicsService.NewGetWorkspaceReadmeOptions(wID)
+ getWorkspaceReadmeOptionsModel.SetWID("testString")
+ getWorkspaceReadmeOptionsModel.SetRef("testString")
+ getWorkspaceReadmeOptionsModel.SetFormatted("markdown")
+ getWorkspaceReadmeOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceReadmeOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceReadmeOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceReadmeOptionsModel.Ref).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceReadmeOptionsModel.Formatted).To(Equal(core.StringPtr("markdown")))
+ Expect(getWorkspaceReadmeOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceResourcesOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceResourcesOptions model
+ wID := "testString"
+ getWorkspaceResourcesOptionsModel := schematicsService.NewGetWorkspaceResourcesOptions(wID)
+ getWorkspaceResourcesOptionsModel.SetWID("testString")
+ getWorkspaceResourcesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceResourcesOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceResourcesOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceResourcesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceStateOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceStateOptions model
+ wID := "testString"
+ getWorkspaceStateOptionsModel := schematicsService.NewGetWorkspaceStateOptions(wID)
+ getWorkspaceStateOptionsModel.SetWID("testString")
+ getWorkspaceStateOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceStateOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceStateOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceStateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewGetWorkspaceTemplateStateOptions successfully`, func() {
+ // Construct an instance of the GetWorkspaceTemplateStateOptions model
+ wID := "testString"
+ tID := "testString"
+ getWorkspaceTemplateStateOptionsModel := schematicsService.NewGetWorkspaceTemplateStateOptions(wID, tID)
+ getWorkspaceTemplateStateOptionsModel.SetWID("testString")
+ getWorkspaceTemplateStateOptionsModel.SetTID("testString")
+ getWorkspaceTemplateStateOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(getWorkspaceTemplateStateOptionsModel).ToNot(BeNil())
+ Expect(getWorkspaceTemplateStateOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceTemplateStateOptionsModel.TID).To(Equal(core.StringPtr("testString")))
+ Expect(getWorkspaceTemplateStateOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewJobData successfully`, func() {
+ jobType := "repo_download_job"
+ _model, err := schematicsService.NewJobData(jobType)
+ Expect(_model).ToNot(BeNil())
+ Expect(err).To(BeNil())
+ })
+ It(`Invoke NewListActionsOptions successfully`, func() {
+ // Construct an instance of the ListActionsOptions model
+ listActionsOptionsModel := schematicsService.NewListActionsOptions()
+ listActionsOptionsModel.SetOffset(int64(0))
+ listActionsOptionsModel.SetLimit(int64(1))
+ listActionsOptionsModel.SetSort("testString")
+ listActionsOptionsModel.SetProfile("ids")
+ listActionsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listActionsOptionsModel).ToNot(BeNil())
+ Expect(listActionsOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
+ Expect(listActionsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
+ Expect(listActionsOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
+ Expect(listActionsOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
+ Expect(listActionsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListInventoriesOptions successfully`, func() {
+ // Construct an instance of the ListInventoriesOptions model
+ listInventoriesOptionsModel := schematicsService.NewListInventoriesOptions()
+ listInventoriesOptionsModel.SetOffset(int64(0))
+ listInventoriesOptionsModel.SetLimit(int64(1))
+ listInventoriesOptionsModel.SetSort("testString")
+ listInventoriesOptionsModel.SetProfile("ids")
+ listInventoriesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listInventoriesOptionsModel).ToNot(BeNil())
+ Expect(listInventoriesOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
+ Expect(listInventoriesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
+ Expect(listInventoriesOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
+ Expect(listInventoriesOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
+ Expect(listInventoriesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListInventoryValuesOptions successfully`, func() {
+ // Construct an instance of the ListInventoryValuesOptions model
+ inventoryID := "testString"
+ listInventoryValuesOptionsModel := schematicsService.NewListInventoryValuesOptions(inventoryID)
+ listInventoryValuesOptionsModel.SetInventoryID("testString")
+ listInventoryValuesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listInventoryValuesOptionsModel).ToNot(BeNil())
+ Expect(listInventoryValuesOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
+ Expect(listInventoryValuesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListJobLogsOptions successfully`, func() {
+ // Construct an instance of the ListJobLogsOptions model
+ jobID := "testString"
+ listJobLogsOptionsModel := schematicsService.NewListJobLogsOptions(jobID)
+ listJobLogsOptionsModel.SetJobID("testString")
+ listJobLogsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listJobLogsOptionsModel).ToNot(BeNil())
+ Expect(listJobLogsOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(listJobLogsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListJobsOptions successfully`, func() {
+ // Construct an instance of the ListJobsOptions model
+ listJobsOptionsModel := schematicsService.NewListJobsOptions()
+ listJobsOptionsModel.SetOffset(int64(0))
+ listJobsOptionsModel.SetLimit(int64(1))
+ listJobsOptionsModel.SetSort("testString")
+ listJobsOptionsModel.SetProfile("ids")
+ listJobsOptionsModel.SetResource("workspace")
+ listJobsOptionsModel.SetResourceID("testString")
+ listJobsOptionsModel.SetActionID("testString")
+ listJobsOptionsModel.SetList("all")
+ listJobsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listJobsOptionsModel).ToNot(BeNil())
+ Expect(listJobsOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
+ Expect(listJobsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
+ Expect(listJobsOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
+ Expect(listJobsOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
+ Expect(listJobsOptionsModel.Resource).To(Equal(core.StringPtr("workspace")))
+ Expect(listJobsOptionsModel.ResourceID).To(Equal(core.StringPtr("testString")))
+ Expect(listJobsOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
+ Expect(listJobsOptionsModel.List).To(Equal(core.StringPtr("all")))
+ Expect(listJobsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListKmsOptions successfully`, func() {
+ // Construct an instance of the ListKmsOptions model
+ encryptionScheme := "testString"
+ location := "testString"
+ listKmsOptionsModel := schematicsService.NewListKmsOptions(encryptionScheme, location)
+ listKmsOptionsModel.SetEncryptionScheme("testString")
+ listKmsOptionsModel.SetLocation("testString")
+ listKmsOptionsModel.SetResourceGroup("testString")
+ listKmsOptionsModel.SetLimit(int64(1))
+ listKmsOptionsModel.SetSort("testString")
+ listKmsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listKmsOptionsModel).ToNot(BeNil())
+ Expect(listKmsOptionsModel.EncryptionScheme).To(Equal(core.StringPtr("testString")))
+ Expect(listKmsOptionsModel.Location).To(Equal(core.StringPtr("testString")))
+ Expect(listKmsOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(listKmsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
+ Expect(listKmsOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
+ Expect(listKmsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListLocationsOptions successfully`, func() {
+ // Construct an instance of the ListLocationsOptions model
+ listLocationsOptionsModel := schematicsService.NewListLocationsOptions()
+ listLocationsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listLocationsOptionsModel).ToNot(BeNil())
+ Expect(listLocationsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListResourceGroupOptions successfully`, func() {
+ // Construct an instance of the ListResourceGroupOptions model
+ listResourceGroupOptionsModel := schematicsService.NewListResourceGroupOptions()
+ listResourceGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listResourceGroupOptionsModel).ToNot(BeNil())
+ Expect(listResourceGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListResourceQueryOptions successfully`, func() {
+ // Construct an instance of the ListResourceQueryOptions model
+ listResourceQueryOptionsModel := schematicsService.NewListResourceQueryOptions()
+ listResourceQueryOptionsModel.SetOffset(int64(0))
+ listResourceQueryOptionsModel.SetLimit(int64(1))
+ listResourceQueryOptionsModel.SetSort("testString")
+ listResourceQueryOptionsModel.SetProfile("ids")
+ listResourceQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listResourceQueryOptionsModel).ToNot(BeNil())
+ Expect(listResourceQueryOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
+ Expect(listResourceQueryOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
+ Expect(listResourceQueryOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
+ Expect(listResourceQueryOptionsModel.Profile).To(Equal(core.StringPtr("ids")))
+ Expect(listResourceQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListSchematicsLocationOptions successfully`, func() {
+ // Construct an instance of the ListSchematicsLocationOptions model
+ listSchematicsLocationOptionsModel := schematicsService.NewListSchematicsLocationOptions()
+ listSchematicsLocationOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listSchematicsLocationOptionsModel).ToNot(BeNil())
+ Expect(listSchematicsLocationOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListWorkspaceActivitiesOptions successfully`, func() {
+ // Construct an instance of the ListWorkspaceActivitiesOptions model
+ wID := "testString"
+ listWorkspaceActivitiesOptionsModel := schematicsService.NewListWorkspaceActivitiesOptions(wID)
+ listWorkspaceActivitiesOptionsModel.SetWID("testString")
+ listWorkspaceActivitiesOptionsModel.SetOffset(int64(0))
+ listWorkspaceActivitiesOptionsModel.SetLimit(int64(1))
+ listWorkspaceActivitiesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listWorkspaceActivitiesOptionsModel).ToNot(BeNil())
+ Expect(listWorkspaceActivitiesOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(listWorkspaceActivitiesOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
+ Expect(listWorkspaceActivitiesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
+ Expect(listWorkspaceActivitiesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewListWorkspacesOptions successfully`, func() {
+ // Construct an instance of the ListWorkspacesOptions model
+ listWorkspacesOptionsModel := schematicsService.NewListWorkspacesOptions()
+ listWorkspacesOptionsModel.SetOffset(int64(0))
+ listWorkspacesOptionsModel.SetLimit(int64(1))
+ listWorkspacesOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(listWorkspacesOptionsModel).ToNot(BeNil())
+ Expect(listWorkspacesOptionsModel.Offset).To(Equal(core.Int64Ptr(int64(0))))
+ Expect(listWorkspacesOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(1))))
+ Expect(listWorkspacesOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewPlanWorkspaceCommandOptions successfully`, func() {
+ // Construct an instance of the PlanWorkspaceCommandOptions model
+ wID := "testString"
+ refreshToken := "testString"
+ planWorkspaceCommandOptionsModel := schematicsService.NewPlanWorkspaceCommandOptions(wID, refreshToken)
+ planWorkspaceCommandOptionsModel.SetWID("testString")
+ planWorkspaceCommandOptionsModel.SetRefreshToken("testString")
+ planWorkspaceCommandOptionsModel.SetDelegatedToken("testString")
+ planWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(planWorkspaceCommandOptionsModel).ToNot(BeNil())
+ Expect(planWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(planWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(planWorkspaceCommandOptionsModel.DelegatedToken).To(Equal(core.StringPtr("testString")))
+ Expect(planWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewProcessTemplateMetaDataOptions successfully`, func() {
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ Expect(externalSourceGitModel).ToNot(BeNil())
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+ Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ Expect(externalSourceCatalogModel).ToNot(BeNil())
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+ Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ Expect(externalSourceCosBucketModel).ToNot(BeNil())
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+ Expect(externalSourceCosBucketModel.CosBucketURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ Expect(externalSourceModel).ToNot(BeNil())
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+ Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
+ Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
+ Expect(externalSourceModel.CosBucket).To(Equal(externalSourceCosBucketModel))
+
+ // Construct an instance of the ProcessTemplateMetaDataOptions model
+ processTemplateMetaDataOptionsTemplateType := "testString"
+ var processTemplateMetaDataOptionsSource *schematicsv1.ExternalSource = nil
+ processTemplateMetaDataOptionsModel := schematicsService.NewProcessTemplateMetaDataOptions(processTemplateMetaDataOptionsTemplateType, processTemplateMetaDataOptionsSource)
+ processTemplateMetaDataOptionsModel.SetTemplateType("testString")
+ processTemplateMetaDataOptionsModel.SetSource(externalSourceModel)
+ processTemplateMetaDataOptionsModel.SetRegion("testString")
+ processTemplateMetaDataOptionsModel.SetSourceType("local")
+ processTemplateMetaDataOptionsModel.SetXGithubToken("testString")
+ processTemplateMetaDataOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(processTemplateMetaDataOptionsModel).ToNot(BeNil())
+ Expect(processTemplateMetaDataOptionsModel.TemplateType).To(Equal(core.StringPtr("testString")))
+ Expect(processTemplateMetaDataOptionsModel.Source).To(Equal(externalSourceModel))
+ Expect(processTemplateMetaDataOptionsModel.Region).To(Equal(core.StringPtr("testString")))
+ Expect(processTemplateMetaDataOptionsModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(processTemplateMetaDataOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
+ Expect(processTemplateMetaDataOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewRefreshWorkspaceCommandOptions successfully`, func() {
+ // Construct an instance of the RefreshWorkspaceCommandOptions model
+ wID := "testString"
+ refreshToken := "testString"
+ refreshWorkspaceCommandOptionsModel := schematicsService.NewRefreshWorkspaceCommandOptions(wID, refreshToken)
+ refreshWorkspaceCommandOptionsModel.SetWID("testString")
+ refreshWorkspaceCommandOptionsModel.SetRefreshToken("testString")
+ refreshWorkspaceCommandOptionsModel.SetDelegatedToken("testString")
+ refreshWorkspaceCommandOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(refreshWorkspaceCommandOptionsModel).ToNot(BeNil())
+ Expect(refreshWorkspaceCommandOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(refreshWorkspaceCommandOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(refreshWorkspaceCommandOptionsModel.DelegatedToken).To(Equal(core.StringPtr("testString")))
+ Expect(refreshWorkspaceCommandOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewReplaceInventoryOptions successfully`, func() {
+ // Construct an instance of the ReplaceInventoryOptions model
+ inventoryID := "testString"
+ replaceInventoryOptionsModel := schematicsService.NewReplaceInventoryOptions(inventoryID)
+ replaceInventoryOptionsModel.SetInventoryID("testString")
+ replaceInventoryOptionsModel.SetName("testString")
+ replaceInventoryOptionsModel.SetDescription("testString")
+ replaceInventoryOptionsModel.SetLocation("us-south")
+ replaceInventoryOptionsModel.SetResourceGroup("testString")
+ replaceInventoryOptionsModel.SetInventoriesIni("testString")
+ replaceInventoryOptionsModel.SetResourceQueries([]string{"testString"})
+ replaceInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(replaceInventoryOptionsModel).ToNot(BeNil())
+ Expect(replaceInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
+ Expect(replaceInventoryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(replaceInventoryOptionsModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(replaceInventoryOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(replaceInventoryOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(replaceInventoryOptionsModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
+ Expect(replaceInventoryOptionsModel.ResourceQueries).To(Equal([]string{"testString"}))
+ Expect(replaceInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewReplaceResourcesQueryOptions successfully`, func() {
+ // Construct an instance of the ResourceQueryParam model
+ resourceQueryParamModel := new(schematicsv1.ResourceQueryParam)
+ Expect(resourceQueryParamModel).ToNot(BeNil())
+ resourceQueryParamModel.Name = core.StringPtr("testString")
+ resourceQueryParamModel.Value = core.StringPtr("testString")
+ resourceQueryParamModel.Description = core.StringPtr("testString")
+ Expect(resourceQueryParamModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(resourceQueryParamModel.Value).To(Equal(core.StringPtr("testString")))
+ Expect(resourceQueryParamModel.Description).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ResourceQuery model
+ resourceQueryModel := new(schematicsv1.ResourceQuery)
+ Expect(resourceQueryModel).ToNot(BeNil())
+ resourceQueryModel.QueryType = core.StringPtr("workspaces")
+ resourceQueryModel.QueryCondition = []schematicsv1.ResourceQueryParam{*resourceQueryParamModel}
+ resourceQueryModel.QuerySelect = []string{"testString"}
+ Expect(resourceQueryModel.QueryType).To(Equal(core.StringPtr("workspaces")))
+ Expect(resourceQueryModel.QueryCondition).To(Equal([]schematicsv1.ResourceQueryParam{*resourceQueryParamModel}))
+ Expect(resourceQueryModel.QuerySelect).To(Equal([]string{"testString"}))
+
+ // Construct an instance of the ReplaceResourcesQueryOptions model
+ queryID := "testString"
+ replaceResourcesQueryOptionsModel := schematicsService.NewReplaceResourcesQueryOptions(queryID)
+ replaceResourcesQueryOptionsModel.SetQueryID("testString")
+ replaceResourcesQueryOptionsModel.SetType("vsi")
+ replaceResourcesQueryOptionsModel.SetName("testString")
+ replaceResourcesQueryOptionsModel.SetQueries([]schematicsv1.ResourceQuery{*resourceQueryModel})
+ replaceResourcesQueryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(replaceResourcesQueryOptionsModel).ToNot(BeNil())
+ Expect(replaceResourcesQueryOptionsModel.QueryID).To(Equal(core.StringPtr("testString")))
+ Expect(replaceResourcesQueryOptionsModel.Type).To(Equal(core.StringPtr("vsi")))
+ Expect(replaceResourcesQueryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(replaceResourcesQueryOptionsModel.Queries).To(Equal([]schematicsv1.ResourceQuery{*resourceQueryModel}))
+ Expect(replaceResourcesQueryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewReplaceWorkspaceInputsOptions successfully`, func() {
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ Expect(workspaceVariableRequestModel).ToNot(BeNil())
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+ Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ReplaceWorkspaceInputsOptions model
+ wID := "testString"
+ tID := "testString"
+ replaceWorkspaceInputsOptionsModel := schematicsService.NewReplaceWorkspaceInputsOptions(wID, tID)
+ replaceWorkspaceInputsOptionsModel.SetWID("testString")
+ replaceWorkspaceInputsOptionsModel.SetTID("testString")
+ replaceWorkspaceInputsOptionsModel.SetEnvValues([]interface{}{map[string]interface{}{"anyKey": "anyValue"}})
+ replaceWorkspaceInputsOptionsModel.SetValues("testString")
+ replaceWorkspaceInputsOptionsModel.SetVariablestore([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel})
+ replaceWorkspaceInputsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(replaceWorkspaceInputsOptionsModel).ToNot(BeNil())
+ Expect(replaceWorkspaceInputsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(replaceWorkspaceInputsOptionsModel.TID).To(Equal(core.StringPtr("testString")))
+ Expect(replaceWorkspaceInputsOptionsModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(replaceWorkspaceInputsOptionsModel.Values).To(Equal(core.StringPtr("testString")))
+ Expect(replaceWorkspaceInputsOptionsModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
+ Expect(replaceWorkspaceInputsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewReplaceWorkspaceOptions successfully`, func() {
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ Expect(catalogRefModel).ToNot(BeNil())
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+ Expect(catalogRefModel.DryRun).To(Equal(core.BoolPtr(true)))
+ Expect(catalogRefModel.OwningAccount).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemIconURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemID).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemName).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemReadmeURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.LaunchURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ Expect(sharedTargetDataModel).ToNot(BeNil())
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+ Expect(sharedTargetDataModel.ClusterCreatedOn).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterID).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterName).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterType).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.EntitlementKeys).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(sharedTargetDataModel.Namespace).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.Region).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ResourceGroupID).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.WorkerCount).To(Equal(core.Int64Ptr(int64(26))))
+ Expect(sharedTargetDataModel.WorkerMachineType).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ Expect(workspaceVariableRequestModel).ToNot(BeNil())
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+ Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ Expect(templateSourceDataRequestModel).ToNot(BeNil())
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ Expect(templateSourceDataRequestModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(templateSourceDataRequestModel.Folder).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Compact).To(Equal(core.BoolPtr(true)))
+ Expect(templateSourceDataRequestModel.InitStateFile).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Type).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.UninstallScriptName).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Values).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.ValuesMetadata).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(templateSourceDataRequestModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ Expect(templateRepoUpdateRequestModel).ToNot(BeNil())
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+ Expect(templateRepoUpdateRequestModel.Branch).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.Release).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.RepoShaValue).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.RepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.URL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ Expect(workspaceStatusUpdateRequestModel).ToNot(BeNil())
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(workspaceStatusUpdateRequestModel.Frozen).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceStatusUpdateRequestModel.FrozenAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+ Expect(workspaceStatusUpdateRequestModel.FrozenBy).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusUpdateRequestModel.Locked).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceStatusUpdateRequestModel.LockedBy).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusUpdateRequestModel.LockedTime).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ Expect(workspaceStatusMessageModel).ToNot(BeNil())
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+ Expect(workspaceStatusMessageModel.StatusCode).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusMessageModel.StatusMsg).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ReplaceWorkspaceOptions model
+ wID := "testString"
+ replaceWorkspaceOptionsModel := schematicsService.NewReplaceWorkspaceOptions(wID)
+ replaceWorkspaceOptionsModel.SetWID("testString")
+ replaceWorkspaceOptionsModel.SetCatalogRef(catalogRefModel)
+ replaceWorkspaceOptionsModel.SetDescription("testString")
+ replaceWorkspaceOptionsModel.SetName("testString")
+ replaceWorkspaceOptionsModel.SetSharedData(sharedTargetDataModel)
+ replaceWorkspaceOptionsModel.SetTags([]string{"testString"})
+ replaceWorkspaceOptionsModel.SetTemplateData([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel})
+ replaceWorkspaceOptionsModel.SetTemplateRepo(templateRepoUpdateRequestModel)
+ replaceWorkspaceOptionsModel.SetType([]string{"testString"})
+ replaceWorkspaceOptionsModel.SetWorkspaceStatus(workspaceStatusUpdateRequestModel)
+ replaceWorkspaceOptionsModel.SetWorkspaceStatusMsg(workspaceStatusMessageModel)
+ replaceWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(replaceWorkspaceOptionsModel).ToNot(BeNil())
+ Expect(replaceWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(replaceWorkspaceOptionsModel.CatalogRef).To(Equal(catalogRefModel))
+ Expect(replaceWorkspaceOptionsModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(replaceWorkspaceOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(replaceWorkspaceOptionsModel.SharedData).To(Equal(sharedTargetDataModel))
+ Expect(replaceWorkspaceOptionsModel.Tags).To(Equal([]string{"testString"}))
+ Expect(replaceWorkspaceOptionsModel.TemplateData).To(Equal([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}))
+ Expect(replaceWorkspaceOptionsModel.TemplateRepo).To(Equal(templateRepoUpdateRequestModel))
+ Expect(replaceWorkspaceOptionsModel.Type).To(Equal([]string{"testString"}))
+ Expect(replaceWorkspaceOptionsModel.WorkspaceStatus).To(Equal(workspaceStatusUpdateRequestModel))
+ Expect(replaceWorkspaceOptionsModel.WorkspaceStatusMsg).To(Equal(workspaceStatusMessageModel))
+ Expect(replaceWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewRunWorkspaceCommandsOptions successfully`, func() {
+ // Construct an instance of the TerraformCommand model
+ terraformCommandModel := new(schematicsv1.TerraformCommand)
+ Expect(terraformCommandModel).ToNot(BeNil())
+ terraformCommandModel.Command = core.StringPtr("testString")
+ terraformCommandModel.CommandParams = core.StringPtr("testString")
+ terraformCommandModel.CommandName = core.StringPtr("testString")
+ terraformCommandModel.CommandDesc = core.StringPtr("testString")
+ terraformCommandModel.CommandOnError = core.StringPtr("testString")
+ terraformCommandModel.CommandDependsOn = core.StringPtr("testString")
+ terraformCommandModel.CommandStatus = core.StringPtr("testString")
+ Expect(terraformCommandModel.Command).To(Equal(core.StringPtr("testString")))
+ Expect(terraformCommandModel.CommandParams).To(Equal(core.StringPtr("testString")))
+ Expect(terraformCommandModel.CommandName).To(Equal(core.StringPtr("testString")))
+ Expect(terraformCommandModel.CommandDesc).To(Equal(core.StringPtr("testString")))
+ Expect(terraformCommandModel.CommandOnError).To(Equal(core.StringPtr("testString")))
+ Expect(terraformCommandModel.CommandDependsOn).To(Equal(core.StringPtr("testString")))
+ Expect(terraformCommandModel.CommandStatus).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the RunWorkspaceCommandsOptions model
+ wID := "testString"
+ refreshToken := "testString"
+ runWorkspaceCommandsOptionsModel := schematicsService.NewRunWorkspaceCommandsOptions(wID, refreshToken)
+ runWorkspaceCommandsOptionsModel.SetWID("testString")
+ runWorkspaceCommandsOptionsModel.SetRefreshToken("testString")
+ runWorkspaceCommandsOptionsModel.SetCommands([]schematicsv1.TerraformCommand{*terraformCommandModel})
+ runWorkspaceCommandsOptionsModel.SetOperationName("testString")
+ runWorkspaceCommandsOptionsModel.SetDescription("testString")
+ runWorkspaceCommandsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(runWorkspaceCommandsOptionsModel).ToNot(BeNil())
+ Expect(runWorkspaceCommandsOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(runWorkspaceCommandsOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(runWorkspaceCommandsOptionsModel.Commands).To(Equal([]schematicsv1.TerraformCommand{*terraformCommandModel}))
+ Expect(runWorkspaceCommandsOptionsModel.OperationName).To(Equal(core.StringPtr("testString")))
+ Expect(runWorkspaceCommandsOptionsModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(runWorkspaceCommandsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewTemplateRepoUploadOptions successfully`, func() {
+ // Construct an instance of the TemplateRepoUploadOptions model
+ wID := "testString"
+ tID := "testString"
+ templateRepoUploadOptionsModel := schematicsService.NewTemplateRepoUploadOptions(wID, tID)
+ templateRepoUploadOptionsModel.SetWID("testString")
+ templateRepoUploadOptionsModel.SetTID("testString")
+ templateRepoUploadOptionsModel.SetFile(CreateMockReader("This is a mock file."))
+ templateRepoUploadOptionsModel.SetFileContentType("testString")
+ templateRepoUploadOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(templateRepoUploadOptionsModel).ToNot(BeNil())
+ Expect(templateRepoUploadOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUploadOptionsModel.TID).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUploadOptionsModel.File).To(Equal(CreateMockReader("This is a mock file.")))
+ Expect(templateRepoUploadOptionsModel.FileContentType).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUploadOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewUpdateActionOptions successfully`, func() {
+ // Construct an instance of the UserState model
+ userStateModel := new(schematicsv1.UserState)
+ Expect(userStateModel).ToNot(BeNil())
+ userStateModel.State = core.StringPtr("draft")
+ userStateModel.SetBy = core.StringPtr("testString")
+ userStateModel.SetAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(userStateModel.State).To(Equal(core.StringPtr("draft")))
+ Expect(userStateModel.SetBy).To(Equal(core.StringPtr("testString")))
+ Expect(userStateModel.SetAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ Expect(externalSourceGitModel).ToNot(BeNil())
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+ Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ Expect(externalSourceCatalogModel).ToNot(BeNil())
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+ Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ Expect(externalSourceCosBucketModel).ToNot(BeNil())
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+ Expect(externalSourceCosBucketModel.CosBucketURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ Expect(externalSourceModel).ToNot(BeNil())
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+ Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
+ Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
+ Expect(externalSourceModel.CosBucket).To(Equal(externalSourceCosBucketModel))
+
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ Expect(variableMetadataModel).ToNot(BeNil())
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+ Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
+ Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ Expect(variableDataModel).ToNot(BeNil())
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+ Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ Expect(bastionResourceDefinitionModel).ToNot(BeNil())
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+ Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ActionState model
+ actionStateModel := new(schematicsv1.ActionState)
+ Expect(actionStateModel).ToNot(BeNil())
+ actionStateModel.StatusCode = core.StringPtr("normal")
+ actionStateModel.StatusJobID = core.StringPtr("testString")
+ actionStateModel.StatusMessage = core.StringPtr("testString")
+ Expect(actionStateModel.StatusCode).To(Equal(core.StringPtr("normal")))
+ Expect(actionStateModel.StatusJobID).To(Equal(core.StringPtr("testString")))
+ Expect(actionStateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the SystemLock model
+ systemLockModel := new(schematicsv1.SystemLock)
+ Expect(systemLockModel).ToNot(BeNil())
+ systemLockModel.SysLocked = core.BoolPtr(true)
+ systemLockModel.SysLockedBy = core.StringPtr("testString")
+ systemLockModel.SysLockedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(systemLockModel.SysLocked).To(Equal(core.BoolPtr(true)))
+ Expect(systemLockModel.SysLockedBy).To(Equal(core.StringPtr("testString")))
+ Expect(systemLockModel.SysLockedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the UpdateActionOptions model
+ actionID := "testString"
+ updateActionOptionsModel := schematicsService.NewUpdateActionOptions(actionID)
+ updateActionOptionsModel.SetActionID("testString")
+ updateActionOptionsModel.SetName("Stop Action")
+ updateActionOptionsModel.SetDescription("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")
+ updateActionOptionsModel.SetLocation("us-south")
+ updateActionOptionsModel.SetResourceGroup("testString")
+ updateActionOptionsModel.SetTags([]string{"testString"})
+ updateActionOptionsModel.SetUserState(userStateModel)
+ updateActionOptionsModel.SetSourceReadmeURL("testString")
+ updateActionOptionsModel.SetSource(externalSourceModel)
+ updateActionOptionsModel.SetSourceType("local")
+ updateActionOptionsModel.SetCommandParameter("testString")
+ updateActionOptionsModel.SetInventory("testString")
+ updateActionOptionsModel.SetCredentials([]schematicsv1.VariableData{*variableDataModel})
+ updateActionOptionsModel.SetBastion(bastionResourceDefinitionModel)
+ updateActionOptionsModel.SetBastionCredential(variableDataModel)
+ updateActionOptionsModel.SetTargetsIni("testString")
+ updateActionOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
+ updateActionOptionsModel.SetOutputs([]schematicsv1.VariableData{*variableDataModel})
+ updateActionOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
+ updateActionOptionsModel.SetState(actionStateModel)
+ updateActionOptionsModel.SetSysLock(systemLockModel)
+ updateActionOptionsModel.SetXGithubToken("testString")
+ updateActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(updateActionOptionsModel).ToNot(BeNil())
+ Expect(updateActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
+ Expect(updateActionOptionsModel.Name).To(Equal(core.StringPtr("Stop Action")))
+ Expect(updateActionOptionsModel.Description).To(Equal(core.StringPtr("The description of your action. The description can be up to 2048 characters long in size. **Example** you can use the description to stop the targets.")))
+ Expect(updateActionOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(updateActionOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(updateActionOptionsModel.Tags).To(Equal([]string{"testString"}))
+ Expect(updateActionOptionsModel.UserState).To(Equal(userStateModel))
+ Expect(updateActionOptionsModel.SourceReadmeURL).To(Equal(core.StringPtr("testString")))
+ Expect(updateActionOptionsModel.Source).To(Equal(externalSourceModel))
+ Expect(updateActionOptionsModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(updateActionOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
+ Expect(updateActionOptionsModel.Inventory).To(Equal(core.StringPtr("testString")))
+ Expect(updateActionOptionsModel.Credentials).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(updateActionOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
+ Expect(updateActionOptionsModel.BastionCredential).To(Equal(variableDataModel))
+ Expect(updateActionOptionsModel.TargetsIni).To(Equal(core.StringPtr("testString")))
+ Expect(updateActionOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(updateActionOptionsModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(updateActionOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(updateActionOptionsModel.State).To(Equal(actionStateModel))
+ Expect(updateActionOptionsModel.SysLock).To(Equal(systemLockModel))
+ Expect(updateActionOptionsModel.XGithubToken).To(Equal(core.StringPtr("testString")))
+ Expect(updateActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewUpdateInventoryOptions successfully`, func() {
+ // Construct an instance of the UpdateInventoryOptions model
+ inventoryID := "testString"
+ updateInventoryOptionsModel := schematicsService.NewUpdateInventoryOptions(inventoryID)
+ updateInventoryOptionsModel.SetInventoryID("testString")
+ updateInventoryOptionsModel.SetName("testString")
+ updateInventoryOptionsModel.SetDescription("testString")
+ updateInventoryOptionsModel.SetLocation("us-south")
+ updateInventoryOptionsModel.SetResourceGroup("testString")
+ updateInventoryOptionsModel.SetInventoriesIni("testString")
+ updateInventoryOptionsModel.SetResourceQueries([]string{"testString"})
+ updateInventoryOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(updateInventoryOptionsModel).ToNot(BeNil())
+ Expect(updateInventoryOptionsModel.InventoryID).To(Equal(core.StringPtr("testString")))
+ Expect(updateInventoryOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(updateInventoryOptionsModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(updateInventoryOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(updateInventoryOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(updateInventoryOptionsModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
+ Expect(updateInventoryOptionsModel.ResourceQueries).To(Equal([]string{"testString"}))
+ Expect(updateInventoryOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewUpdateJobOptions successfully`, func() {
+ // Construct an instance of the VariableMetadata model
+ variableMetadataModel := new(schematicsv1.VariableMetadata)
+ Expect(variableMetadataModel).ToNot(BeNil())
+ variableMetadataModel.Type = core.StringPtr("boolean")
+ variableMetadataModel.Aliases = []string{"testString"}
+ variableMetadataModel.Description = core.StringPtr("testString")
+ variableMetadataModel.DefaultValue = core.StringPtr("testString")
+ variableMetadataModel.Secure = core.BoolPtr(true)
+ variableMetadataModel.Immutable = core.BoolPtr(true)
+ variableMetadataModel.Hidden = core.BoolPtr(true)
+ variableMetadataModel.Options = []string{"testString"}
+ variableMetadataModel.MinValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxValue = core.Int64Ptr(int64(38))
+ variableMetadataModel.MinLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.MaxLength = core.Int64Ptr(int64(38))
+ variableMetadataModel.Matches = core.StringPtr("testString")
+ variableMetadataModel.Position = core.Int64Ptr(int64(38))
+ variableMetadataModel.GroupBy = core.StringPtr("testString")
+ variableMetadataModel.Source = core.StringPtr("testString")
+ Expect(variableMetadataModel.Type).To(Equal(core.StringPtr("boolean")))
+ Expect(variableMetadataModel.Aliases).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.DefaultValue).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Immutable).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Hidden).To(Equal(core.BoolPtr(true)))
+ Expect(variableMetadataModel.Options).To(Equal([]string{"testString"}))
+ Expect(variableMetadataModel.MinValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxValue).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MinLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.MaxLength).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.Matches).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Position).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(variableMetadataModel.GroupBy).To(Equal(core.StringPtr("testString")))
+ Expect(variableMetadataModel.Source).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the VariableData model
+ variableDataModel := new(schematicsv1.VariableData)
+ Expect(variableDataModel).ToNot(BeNil())
+ variableDataModel.Name = core.StringPtr("testString")
+ variableDataModel.Value = core.StringPtr("testString")
+ variableDataModel.Metadata = variableMetadataModel
+ Expect(variableDataModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Value).To(Equal(core.StringPtr("testString")))
+ Expect(variableDataModel.Metadata).To(Equal(variableMetadataModel))
+
+ // Construct an instance of the JobStatusWorkitem model
+ jobStatusWorkitemModel := new(schematicsv1.JobStatusWorkitem)
+ Expect(jobStatusWorkitemModel).ToNot(BeNil())
+ jobStatusWorkitemModel.WorkspaceID = core.StringPtr("testString")
+ jobStatusWorkitemModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkitemModel.JobID = core.StringPtr("testString")
+ jobStatusWorkitemModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkitemModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkitemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusWorkitemModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusWorkitemModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkitemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusFlow model
+ jobStatusFlowModel := new(schematicsv1.JobStatusFlow)
+ Expect(jobStatusFlowModel).ToNot(BeNil())
+ jobStatusFlowModel.FlowID = core.StringPtr("testString")
+ jobStatusFlowModel.FlowName = core.StringPtr("testString")
+ jobStatusFlowModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusFlowModel.StatusMessage = core.StringPtr("testString")
+ jobStatusFlowModel.Workitems = []schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}
+ jobStatusFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusFlowModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusFlowModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusFlowModel.Workitems).To(Equal([]schematicsv1.JobStatusWorkitem{*jobStatusWorkitemModel}))
+ Expect(jobStatusFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusTemplate model
+ jobStatusTemplateModel := new(schematicsv1.JobStatusTemplate)
+ Expect(jobStatusTemplateModel).ToNot(BeNil())
+ jobStatusTemplateModel.TemplateID = core.StringPtr("testString")
+ jobStatusTemplateModel.TemplateName = core.StringPtr("testString")
+ jobStatusTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobStatusTemplateModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusTemplateModel.StatusMessage = core.StringPtr("testString")
+ jobStatusTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(jobStatusTemplateModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusTemplateModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusWorkspace model
+ jobStatusWorkspaceModel := new(schematicsv1.JobStatusWorkspace)
+ Expect(jobStatusWorkspaceModel).ToNot(BeNil())
+ jobStatusWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobStatusWorkspaceModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusWorkspaceModel.StatusMessage = core.StringPtr("testString")
+ jobStatusWorkspaceModel.FlowStatus = jobStatusFlowModel
+ jobStatusWorkspaceModel.TemplateStatus = []schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}
+ jobStatusWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkspaceModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusWorkspaceModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusWorkspaceModel.FlowStatus).To(Equal(jobStatusFlowModel))
+ Expect(jobStatusWorkspaceModel.TemplateStatus).To(Equal([]schematicsv1.JobStatusTemplate{*jobStatusTemplateModel}))
+ Expect(jobStatusWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusAction model
+ jobStatusActionModel := new(schematicsv1.JobStatusAction)
+ Expect(jobStatusActionModel).ToNot(BeNil())
+ jobStatusActionModel.ActionName = core.StringPtr("testString")
+ jobStatusActionModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusActionModel.StatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.BastionStatusCode = core.StringPtr("none")
+ jobStatusActionModel.BastionStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.TargetsStatusCode = core.StringPtr("none")
+ jobStatusActionModel.TargetsStatusMessage = core.StringPtr("testString")
+ jobStatusActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusActionModel.ActionName).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusActionModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.BastionStatusCode).To(Equal(core.StringPtr("none")))
+ Expect(jobStatusActionModel.BastionStatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.TargetsStatusCode).To(Equal(core.StringPtr("none")))
+ Expect(jobStatusActionModel.TargetsStatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusSchematicsResources model
+ jobStatusSchematicsResourcesModel := new(schematicsv1.JobStatusSchematicsResources)
+ Expect(jobStatusSchematicsResourcesModel).ToNot(BeNil())
+ jobStatusSchematicsResourcesModel.StatusCode = core.StringPtr("job_pending")
+ jobStatusSchematicsResourcesModel.StatusMessage = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.SchematicsResourceID = core.StringPtr("testString")
+ jobStatusSchematicsResourcesModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusSchematicsResourcesModel.StatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusSchematicsResourcesModel.StatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusSchematicsResourcesModel.SchematicsResourceID).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusSchematicsResourcesModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatusSystem model
+ jobStatusSystemModel := new(schematicsv1.JobStatusSystem)
+ Expect(jobStatusSystemModel).ToNot(BeNil())
+ jobStatusSystemModel.SystemStatusMessage = core.StringPtr("testString")
+ jobStatusSystemModel.SystemStatusCode = core.StringPtr("job_pending")
+ jobStatusSystemModel.SchematicsResourceStatus = []schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}
+ jobStatusSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobStatusSystemModel.SystemStatusMessage).To(Equal(core.StringPtr("testString")))
+ Expect(jobStatusSystemModel.SystemStatusCode).To(Equal(core.StringPtr("job_pending")))
+ Expect(jobStatusSystemModel.SchematicsResourceStatus).To(Equal([]schematicsv1.JobStatusSchematicsResources{*jobStatusSchematicsResourcesModel}))
+ Expect(jobStatusSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobStatus model
+ jobStatusModel := new(schematicsv1.JobStatus)
+ Expect(jobStatusModel).ToNot(BeNil())
+ jobStatusModel.WorkspaceJobStatus = jobStatusWorkspaceModel
+ jobStatusModel.ActionJobStatus = jobStatusActionModel
+ jobStatusModel.SystemJobStatus = jobStatusSystemModel
+ jobStatusModel.FlowJobStatus = jobStatusFlowModel
+ Expect(jobStatusModel.WorkspaceJobStatus).To(Equal(jobStatusWorkspaceModel))
+ Expect(jobStatusModel.ActionJobStatus).To(Equal(jobStatusActionModel))
+ Expect(jobStatusModel.SystemJobStatus).To(Equal(jobStatusSystemModel))
+ Expect(jobStatusModel.FlowJobStatus).To(Equal(jobStatusFlowModel))
+
+ // Construct an instance of the JobDataTemplate model
+ jobDataTemplateModel := new(schematicsv1.JobDataTemplate)
+ Expect(jobDataTemplateModel).ToNot(BeNil())
+ jobDataTemplateModel.TemplateID = core.StringPtr("testString")
+ jobDataTemplateModel.TemplateName = core.StringPtr("testString")
+ jobDataTemplateModel.FlowIndex = core.Int64Ptr(int64(38))
+ jobDataTemplateModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataTemplateModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataTemplateModel.TemplateID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataTemplateModel.TemplateName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataTemplateModel.FlowIndex).To(Equal(core.Int64Ptr(int64(38))))
+ Expect(jobDataTemplateModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataTemplateModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataTemplateModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataTemplateModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobDataWorkspace model
+ jobDataWorkspaceModel := new(schematicsv1.JobDataWorkspace)
+ Expect(jobDataWorkspaceModel).ToNot(BeNil())
+ jobDataWorkspaceModel.WorkspaceName = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowID = core.StringPtr("testString")
+ jobDataWorkspaceModel.FlowName = core.StringPtr("testString")
+ jobDataWorkspaceModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkspaceModel.TemplateData = []schematicsv1.JobDataTemplate{*jobDataTemplateModel}
+ jobDataWorkspaceModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataWorkspaceModel.WorkspaceName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkspaceModel.FlowID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkspaceModel.FlowName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkspaceModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkspaceModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkspaceModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkspaceModel.TemplateData).To(Equal([]schematicsv1.JobDataTemplate{*jobDataTemplateModel}))
+ Expect(jobDataWorkspaceModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the InventoryResourceRecord model
+ inventoryResourceRecordModel := new(schematicsv1.InventoryResourceRecord)
+ Expect(inventoryResourceRecordModel).ToNot(BeNil())
+ inventoryResourceRecordModel.Name = core.StringPtr("testString")
+ inventoryResourceRecordModel.Description = core.StringPtr("testString")
+ inventoryResourceRecordModel.Location = core.StringPtr("us-south")
+ inventoryResourceRecordModel.ResourceGroup = core.StringPtr("testString")
+ inventoryResourceRecordModel.InventoriesIni = core.StringPtr("testString")
+ inventoryResourceRecordModel.ResourceQueries = []string{"testString"}
+ Expect(inventoryResourceRecordModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(inventoryResourceRecordModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.InventoriesIni).To(Equal(core.StringPtr("testString")))
+ Expect(inventoryResourceRecordModel.ResourceQueries).To(Equal([]string{"testString"}))
+
+ // Construct an instance of the JobDataAction model
+ jobDataActionModel := new(schematicsv1.JobDataAction)
+ Expect(jobDataActionModel).ToNot(BeNil())
+ jobDataActionModel.ActionName = core.StringPtr("testString")
+ jobDataActionModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataActionModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ jobDataActionModel.InventoryRecord = inventoryResourceRecordModel
+ jobDataActionModel.MaterializedInventory = core.StringPtr("testString")
+ Expect(jobDataActionModel.ActionName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataActionModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataActionModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataActionModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataActionModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+ Expect(jobDataActionModel.InventoryRecord).To(Equal(inventoryResourceRecordModel))
+ Expect(jobDataActionModel.MaterializedInventory).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the JobDataSystem model
+ jobDataSystemModel := new(schematicsv1.JobDataSystem)
+ Expect(jobDataSystemModel).ToNot(BeNil())
+ jobDataSystemModel.KeyID = core.StringPtr("testString")
+ jobDataSystemModel.SchematicsResourceID = []string{"testString"}
+ jobDataSystemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataSystemModel.KeyID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataSystemModel.SchematicsResourceID).To(Equal([]string{"testString"}))
+ Expect(jobDataSystemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the ExternalSourceGit model
+ externalSourceGitModel := new(schematicsv1.ExternalSourceGit)
+ Expect(externalSourceGitModel).ToNot(BeNil())
+ externalSourceGitModel.ComputedGitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoURL = core.StringPtr("testString")
+ externalSourceGitModel.GitToken = core.StringPtr("testString")
+ externalSourceGitModel.GitRepoFolder = core.StringPtr("testString")
+ externalSourceGitModel.GitRelease = core.StringPtr("testString")
+ externalSourceGitModel.GitBranch = core.StringPtr("testString")
+ Expect(externalSourceGitModel.ComputedGitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitToken).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRepoFolder).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitRelease).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceGitModel.GitBranch).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCatalog model
+ externalSourceCatalogModel := new(schematicsv1.ExternalSourceCatalog)
+ Expect(externalSourceCatalogModel).ToNot(BeNil())
+ externalSourceCatalogModel.CatalogName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingName = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersion = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingKind = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingVersionID = core.StringPtr("testString")
+ externalSourceCatalogModel.OfferingRepoURL = core.StringPtr("testString")
+ Expect(externalSourceCatalogModel.CatalogName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingName).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingKind).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingVersionID).To(Equal(core.StringPtr("testString")))
+ Expect(externalSourceCatalogModel.OfferingRepoURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSourceCosBucket model
+ externalSourceCosBucketModel := new(schematicsv1.ExternalSourceCosBucket)
+ Expect(externalSourceCosBucketModel).ToNot(BeNil())
+ externalSourceCosBucketModel.CosBucketURL = core.StringPtr("testString")
+ Expect(externalSourceCosBucketModel.CosBucketURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the ExternalSource model
+ externalSourceModel := new(schematicsv1.ExternalSource)
+ Expect(externalSourceModel).ToNot(BeNil())
+ externalSourceModel.SourceType = core.StringPtr("local")
+ externalSourceModel.Git = externalSourceGitModel
+ externalSourceModel.Catalog = externalSourceCatalogModel
+ externalSourceModel.CosBucket = externalSourceCosBucketModel
+ Expect(externalSourceModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(externalSourceModel.Git).To(Equal(externalSourceGitModel))
+ Expect(externalSourceModel.Catalog).To(Equal(externalSourceCatalogModel))
+ Expect(externalSourceModel.CosBucket).To(Equal(externalSourceCosBucketModel))
+
+ // Construct an instance of the JobDataWorkItemLastJob model
+ jobDataWorkItemLastJobModel := new(schematicsv1.JobDataWorkItemLastJob)
+ Expect(jobDataWorkItemLastJobModel).ToNot(BeNil())
+ jobDataWorkItemLastJobModel.CommandObject = core.StringPtr("workspace")
+ jobDataWorkItemLastJobModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.CommandName = core.StringPtr("workspace_plan")
+ jobDataWorkItemLastJobModel.JobID = core.StringPtr("testString")
+ jobDataWorkItemLastJobModel.JobStatus = core.StringPtr("job_pending")
+ Expect(jobDataWorkItemLastJobModel.CommandObject).To(Equal(core.StringPtr("workspace")))
+ Expect(jobDataWorkItemLastJobModel.CommandObjectName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemLastJobModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemLastJobModel.CommandName).To(Equal(core.StringPtr("workspace_plan")))
+ Expect(jobDataWorkItemLastJobModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemLastJobModel.JobStatus).To(Equal(core.StringPtr("job_pending")))
+
+ // Construct an instance of the JobDataWorkItem model
+ jobDataWorkItemModel := new(schematicsv1.JobDataWorkItem)
+ Expect(jobDataWorkItemModel).ToNot(BeNil())
+ jobDataWorkItemModel.CommandObjectID = core.StringPtr("testString")
+ jobDataWorkItemModel.CommandObjectName = core.StringPtr("testString")
+ jobDataWorkItemModel.Layers = core.StringPtr("testString")
+ jobDataWorkItemModel.SourceType = core.StringPtr("local")
+ jobDataWorkItemModel.Source = externalSourceModel
+ jobDataWorkItemModel.Inputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Outputs = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.Settings = []schematicsv1.VariableData{*variableDataModel}
+ jobDataWorkItemModel.LastJob = jobDataWorkItemLastJobModel
+ jobDataWorkItemModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataWorkItemModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemModel.CommandObjectName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemModel.Layers).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataWorkItemModel.SourceType).To(Equal(core.StringPtr("local")))
+ Expect(jobDataWorkItemModel.Source).To(Equal(externalSourceModel))
+ Expect(jobDataWorkItemModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkItemModel.Outputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkItemModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(jobDataWorkItemModel.LastJob).To(Equal(jobDataWorkItemLastJobModel))
+ Expect(jobDataWorkItemModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobDataFlow model
+ jobDataFlowModel := new(schematicsv1.JobDataFlow)
+ Expect(jobDataFlowModel).ToNot(BeNil())
+ jobDataFlowModel.FlowID = core.StringPtr("testString")
+ jobDataFlowModel.FlowName = core.StringPtr("testString")
+ jobDataFlowModel.Workitems = []schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}
+ jobDataFlowModel.UpdatedAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(jobDataFlowModel.FlowID).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataFlowModel.FlowName).To(Equal(core.StringPtr("testString")))
+ Expect(jobDataFlowModel.Workitems).To(Equal([]schematicsv1.JobDataWorkItem{*jobDataWorkItemModel}))
+ Expect(jobDataFlowModel.UpdatedAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the JobData model
+ jobDataModel := new(schematicsv1.JobData)
+ Expect(jobDataModel).ToNot(BeNil())
+ jobDataModel.JobType = core.StringPtr("repo_download_job")
+ jobDataModel.WorkspaceJobData = jobDataWorkspaceModel
+ jobDataModel.ActionJobData = jobDataActionModel
+ jobDataModel.SystemJobData = jobDataSystemModel
+ jobDataModel.FlowJobData = jobDataFlowModel
+ Expect(jobDataModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
+ Expect(jobDataModel.WorkspaceJobData).To(Equal(jobDataWorkspaceModel))
+ Expect(jobDataModel.ActionJobData).To(Equal(jobDataActionModel))
+ Expect(jobDataModel.SystemJobData).To(Equal(jobDataSystemModel))
+ Expect(jobDataModel.FlowJobData).To(Equal(jobDataFlowModel))
+
+ // Construct an instance of the BastionResourceDefinition model
+ bastionResourceDefinitionModel := new(schematicsv1.BastionResourceDefinition)
+ Expect(bastionResourceDefinitionModel).ToNot(BeNil())
+ bastionResourceDefinitionModel.Name = core.StringPtr("testString")
+ bastionResourceDefinitionModel.Host = core.StringPtr("testString")
+ Expect(bastionResourceDefinitionModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(bastionResourceDefinitionModel.Host).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the JobLogSummaryRepoDownloadJob model
+ jobLogSummaryRepoDownloadJobModel := new(schematicsv1.JobLogSummaryRepoDownloadJob)
+ Expect(jobLogSummaryRepoDownloadJobModel).ToNot(BeNil())
+
+ // Construct an instance of the JobLogSummaryWorkspaceJob model
+ jobLogSummaryWorkspaceJobModel := new(schematicsv1.JobLogSummaryWorkspaceJob)
+ Expect(jobLogSummaryWorkspaceJobModel).ToNot(BeNil())
+
+ // Construct an instance of the JobLogSummaryWorkitems model
+ jobLogSummaryWorkitemsModel := new(schematicsv1.JobLogSummaryWorkitems)
+ Expect(jobLogSummaryWorkitemsModel).ToNot(BeNil())
+ jobLogSummaryWorkitemsModel.WorkspaceID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.JobID = core.StringPtr("testString")
+ jobLogSummaryWorkitemsModel.LogURL = core.StringPtr("testString")
+ Expect(jobLogSummaryWorkitemsModel.WorkspaceID).To(Equal(core.StringPtr("testString")))
+ Expect(jobLogSummaryWorkitemsModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(jobLogSummaryWorkitemsModel.LogURL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the JobLogSummaryFlowJob model
+ jobLogSummaryFlowJobModel := new(schematicsv1.JobLogSummaryFlowJob)
+ Expect(jobLogSummaryFlowJobModel).ToNot(BeNil())
+ jobLogSummaryFlowJobModel.Workitems = []schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}
+ Expect(jobLogSummaryFlowJobModel.Workitems).To(Equal([]schematicsv1.JobLogSummaryWorkitems{*jobLogSummaryWorkitemsModel}))
+
+ // Construct an instance of the JobLogSummaryActionJobRecap model
+ jobLogSummaryActionJobRecapModel := new(schematicsv1.JobLogSummaryActionJobRecap)
+ Expect(jobLogSummaryActionJobRecapModel).ToNot(BeNil())
+ jobLogSummaryActionJobRecapModel.Target = []string{"testString"}
+ jobLogSummaryActionJobRecapModel.Ok = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Changed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Failed = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Skipped = core.Float64Ptr(float64(72.5))
+ jobLogSummaryActionJobRecapModel.Unreachable = core.Float64Ptr(float64(72.5))
+ Expect(jobLogSummaryActionJobRecapModel.Target).To(Equal([]string{"testString"}))
+ Expect(jobLogSummaryActionJobRecapModel.Ok).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Changed).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Skipped).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummaryActionJobRecapModel.Unreachable).To(Equal(core.Float64Ptr(float64(72.5))))
+
+ // Construct an instance of the JobLogSummaryActionJob model
+ jobLogSummaryActionJobModel := new(schematicsv1.JobLogSummaryActionJob)
+ Expect(jobLogSummaryActionJobModel).ToNot(BeNil())
+ jobLogSummaryActionJobModel.Recap = jobLogSummaryActionJobRecapModel
+ Expect(jobLogSummaryActionJobModel.Recap).To(Equal(jobLogSummaryActionJobRecapModel))
+
+ // Construct an instance of the JobLogSummarySystemJob model
+ jobLogSummarySystemJobModel := new(schematicsv1.JobLogSummarySystemJob)
+ Expect(jobLogSummarySystemJobModel).ToNot(BeNil())
+ jobLogSummarySystemJobModel.Success = core.Float64Ptr(float64(72.5))
+ jobLogSummarySystemJobModel.Failed = core.Float64Ptr(float64(72.5))
+ Expect(jobLogSummarySystemJobModel.Success).To(Equal(core.Float64Ptr(float64(72.5))))
+ Expect(jobLogSummarySystemJobModel.Failed).To(Equal(core.Float64Ptr(float64(72.5))))
+
+ // Construct an instance of the JobLogSummary model
+ jobLogSummaryModel := new(schematicsv1.JobLogSummary)
+ Expect(jobLogSummaryModel).ToNot(BeNil())
+ jobLogSummaryModel.JobType = core.StringPtr("repo_download_job")
+ jobLogSummaryModel.RepoDownloadJob = jobLogSummaryRepoDownloadJobModel
+ jobLogSummaryModel.WorkspaceJob = jobLogSummaryWorkspaceJobModel
+ jobLogSummaryModel.FlowJob = jobLogSummaryFlowJobModel
+ jobLogSummaryModel.ActionJob = jobLogSummaryActionJobModel
+ jobLogSummaryModel.SystemJob = jobLogSummarySystemJobModel
+ Expect(jobLogSummaryModel.JobType).To(Equal(core.StringPtr("repo_download_job")))
+ Expect(jobLogSummaryModel.RepoDownloadJob).To(Equal(jobLogSummaryRepoDownloadJobModel))
+ Expect(jobLogSummaryModel.WorkspaceJob).To(Equal(jobLogSummaryWorkspaceJobModel))
+ Expect(jobLogSummaryModel.FlowJob).To(Equal(jobLogSummaryFlowJobModel))
+ Expect(jobLogSummaryModel.ActionJob).To(Equal(jobLogSummaryActionJobModel))
+ Expect(jobLogSummaryModel.SystemJob).To(Equal(jobLogSummarySystemJobModel))
+
+ // Construct an instance of the UpdateJobOptions model
+ jobID := "testString"
+ refreshToken := "testString"
+ updateJobOptionsModel := schematicsService.NewUpdateJobOptions(jobID, refreshToken)
+ updateJobOptionsModel.SetJobID("testString")
+ updateJobOptionsModel.SetRefreshToken("testString")
+ updateJobOptionsModel.SetCommandObject("workspace")
+ updateJobOptionsModel.SetCommandObjectID("testString")
+ updateJobOptionsModel.SetCommandName("workspace_plan")
+ updateJobOptionsModel.SetCommandParameter("testString")
+ updateJobOptionsModel.SetCommandOptions([]string{"testString"})
+ updateJobOptionsModel.SetInputs([]schematicsv1.VariableData{*variableDataModel})
+ updateJobOptionsModel.SetSettings([]schematicsv1.VariableData{*variableDataModel})
+ updateJobOptionsModel.SetTags([]string{"testString"})
+ updateJobOptionsModel.SetLocation("us-south")
+ updateJobOptionsModel.SetStatus(jobStatusModel)
+ updateJobOptionsModel.SetData(jobDataModel)
+ updateJobOptionsModel.SetBastion(bastionResourceDefinitionModel)
+ updateJobOptionsModel.SetLogSummary(jobLogSummaryModel)
+ updateJobOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(updateJobOptionsModel).ToNot(BeNil())
+ Expect(updateJobOptionsModel.JobID).To(Equal(core.StringPtr("testString")))
+ Expect(updateJobOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString")))
+ Expect(updateJobOptionsModel.CommandObject).To(Equal(core.StringPtr("workspace")))
+ Expect(updateJobOptionsModel.CommandObjectID).To(Equal(core.StringPtr("testString")))
+ Expect(updateJobOptionsModel.CommandName).To(Equal(core.StringPtr("workspace_plan")))
+ Expect(updateJobOptionsModel.CommandParameter).To(Equal(core.StringPtr("testString")))
+ Expect(updateJobOptionsModel.CommandOptions).To(Equal([]string{"testString"}))
+ Expect(updateJobOptionsModel.Inputs).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(updateJobOptionsModel.Settings).To(Equal([]schematicsv1.VariableData{*variableDataModel}))
+ Expect(updateJobOptionsModel.Tags).To(Equal([]string{"testString"}))
+ Expect(updateJobOptionsModel.Location).To(Equal(core.StringPtr("us-south")))
+ Expect(updateJobOptionsModel.Status).To(Equal(jobStatusModel))
+ Expect(updateJobOptionsModel.Data).To(Equal(jobDataModel))
+ Expect(updateJobOptionsModel.Bastion).To(Equal(bastionResourceDefinitionModel))
+ Expect(updateJobOptionsModel.LogSummary).To(Equal(jobLogSummaryModel))
+ Expect(updateJobOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewUpdateKmsSettingsOptions successfully`, func() {
+ // Construct an instance of the KMSSettingsPrimaryCrk model
+ kmsSettingsPrimaryCrkModel := new(schematicsv1.KMSSettingsPrimaryCrk)
+ Expect(kmsSettingsPrimaryCrkModel).ToNot(BeNil())
+ kmsSettingsPrimaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsPrimaryCrkModel.KeyCrn = core.StringPtr("testString")
+ Expect(kmsSettingsPrimaryCrkModel.KmsName).To(Equal(core.StringPtr("testString")))
+ Expect(kmsSettingsPrimaryCrkModel.KmsPrivateEndpoint).To(Equal(core.StringPtr("testString")))
+ Expect(kmsSettingsPrimaryCrkModel.KeyCrn).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the KMSSettingsSecondaryCrk model
+ kmsSettingsSecondaryCrkModel := new(schematicsv1.KMSSettingsSecondaryCrk)
+ Expect(kmsSettingsSecondaryCrkModel).ToNot(BeNil())
+ kmsSettingsSecondaryCrkModel.KmsName = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint = core.StringPtr("testString")
+ kmsSettingsSecondaryCrkModel.KeyCrn = core.StringPtr("testString")
+ Expect(kmsSettingsSecondaryCrkModel.KmsName).To(Equal(core.StringPtr("testString")))
+ Expect(kmsSettingsSecondaryCrkModel.KmsPrivateEndpoint).To(Equal(core.StringPtr("testString")))
+ Expect(kmsSettingsSecondaryCrkModel.KeyCrn).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the UpdateKmsSettingsOptions model
+ updateKmsSettingsOptionsModel := schematicsService.NewUpdateKmsSettingsOptions()
+ updateKmsSettingsOptionsModel.SetLocation("testString")
+ updateKmsSettingsOptionsModel.SetEncryptionScheme("testString")
+ updateKmsSettingsOptionsModel.SetResourceGroup("testString")
+ updateKmsSettingsOptionsModel.SetPrimaryCrk(kmsSettingsPrimaryCrkModel)
+ updateKmsSettingsOptionsModel.SetSecondaryCrk(kmsSettingsSecondaryCrkModel)
+ updateKmsSettingsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(updateKmsSettingsOptionsModel).ToNot(BeNil())
+ Expect(updateKmsSettingsOptionsModel.Location).To(Equal(core.StringPtr("testString")))
+ Expect(updateKmsSettingsOptionsModel.EncryptionScheme).To(Equal(core.StringPtr("testString")))
+ Expect(updateKmsSettingsOptionsModel.ResourceGroup).To(Equal(core.StringPtr("testString")))
+ Expect(updateKmsSettingsOptionsModel.PrimaryCrk).To(Equal(kmsSettingsPrimaryCrkModel))
+ Expect(updateKmsSettingsOptionsModel.SecondaryCrk).To(Equal(kmsSettingsSecondaryCrkModel))
+ Expect(updateKmsSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewUpdateWorkspaceOptions successfully`, func() {
+ // Construct an instance of the CatalogRef model
+ catalogRefModel := new(schematicsv1.CatalogRef)
+ Expect(catalogRefModel).ToNot(BeNil())
+ catalogRefModel.DryRun = core.BoolPtr(true)
+ catalogRefModel.OwningAccount = core.StringPtr("testString")
+ catalogRefModel.ItemIconURL = core.StringPtr("testString")
+ catalogRefModel.ItemID = core.StringPtr("testString")
+ catalogRefModel.ItemName = core.StringPtr("testString")
+ catalogRefModel.ItemReadmeURL = core.StringPtr("testString")
+ catalogRefModel.ItemURL = core.StringPtr("testString")
+ catalogRefModel.LaunchURL = core.StringPtr("testString")
+ catalogRefModel.OfferingVersion = core.StringPtr("testString")
+ Expect(catalogRefModel.DryRun).To(Equal(core.BoolPtr(true)))
+ Expect(catalogRefModel.OwningAccount).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemIconURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemID).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemName).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemReadmeURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.ItemURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.LaunchURL).To(Equal(core.StringPtr("testString")))
+ Expect(catalogRefModel.OfferingVersion).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the SharedTargetData model
+ sharedTargetDataModel := new(schematicsv1.SharedTargetData)
+ Expect(sharedTargetDataModel).ToNot(BeNil())
+ sharedTargetDataModel.ClusterCreatedOn = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterID = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterName = core.StringPtr("testString")
+ sharedTargetDataModel.ClusterType = core.StringPtr("testString")
+ sharedTargetDataModel.EntitlementKeys = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ sharedTargetDataModel.Namespace = core.StringPtr("testString")
+ sharedTargetDataModel.Region = core.StringPtr("testString")
+ sharedTargetDataModel.ResourceGroupID = core.StringPtr("testString")
+ sharedTargetDataModel.WorkerCount = core.Int64Ptr(int64(26))
+ sharedTargetDataModel.WorkerMachineType = core.StringPtr("testString")
+ Expect(sharedTargetDataModel.ClusterCreatedOn).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterID).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterName).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ClusterType).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.EntitlementKeys).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(sharedTargetDataModel.Namespace).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.Region).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.ResourceGroupID).To(Equal(core.StringPtr("testString")))
+ Expect(sharedTargetDataModel.WorkerCount).To(Equal(core.Int64Ptr(int64(26))))
+ Expect(sharedTargetDataModel.WorkerMachineType).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the WorkspaceVariableRequest model
+ workspaceVariableRequestModel := new(schematicsv1.WorkspaceVariableRequest)
+ Expect(workspaceVariableRequestModel).ToNot(BeNil())
+ workspaceVariableRequestModel.Description = core.StringPtr("testString")
+ workspaceVariableRequestModel.Name = core.StringPtr("testString")
+ workspaceVariableRequestModel.Secure = core.BoolPtr(true)
+ workspaceVariableRequestModel.Type = core.StringPtr("testString")
+ workspaceVariableRequestModel.UseDefault = core.BoolPtr(true)
+ workspaceVariableRequestModel.Value = core.StringPtr("testString")
+ Expect(workspaceVariableRequestModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.Secure).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Type).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceVariableRequestModel.UseDefault).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceVariableRequestModel.Value).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the TemplateSourceDataRequest model
+ templateSourceDataRequestModel := new(schematicsv1.TemplateSourceDataRequest)
+ Expect(templateSourceDataRequestModel).ToNot(BeNil())
+ templateSourceDataRequestModel.EnvValues = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Folder = core.StringPtr("testString")
+ templateSourceDataRequestModel.Compact = core.BoolPtr(true)
+ templateSourceDataRequestModel.InitStateFile = core.StringPtr("testString")
+ templateSourceDataRequestModel.Type = core.StringPtr("testString")
+ templateSourceDataRequestModel.UninstallScriptName = core.StringPtr("testString")
+ templateSourceDataRequestModel.Values = core.StringPtr("testString")
+ templateSourceDataRequestModel.ValuesMetadata = []interface{}{map[string]interface{}{"anyKey": "anyValue"}}
+ templateSourceDataRequestModel.Variablestore = []schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}
+ Expect(templateSourceDataRequestModel.EnvValues).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(templateSourceDataRequestModel.Folder).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Compact).To(Equal(core.BoolPtr(true)))
+ Expect(templateSourceDataRequestModel.InitStateFile).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Type).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.UninstallScriptName).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.Values).To(Equal(core.StringPtr("testString")))
+ Expect(templateSourceDataRequestModel.ValuesMetadata).To(Equal([]interface{}{map[string]interface{}{"anyKey": "anyValue"}}))
+ Expect(templateSourceDataRequestModel.Variablestore).To(Equal([]schematicsv1.WorkspaceVariableRequest{*workspaceVariableRequestModel}))
+
+ // Construct an instance of the TemplateRepoUpdateRequest model
+ templateRepoUpdateRequestModel := new(schematicsv1.TemplateRepoUpdateRequest)
+ Expect(templateRepoUpdateRequestModel).ToNot(BeNil())
+ templateRepoUpdateRequestModel.Branch = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.Release = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoShaValue = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.RepoURL = core.StringPtr("testString")
+ templateRepoUpdateRequestModel.URL = core.StringPtr("testString")
+ Expect(templateRepoUpdateRequestModel.Branch).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.Release).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.RepoShaValue).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.RepoURL).To(Equal(core.StringPtr("testString")))
+ Expect(templateRepoUpdateRequestModel.URL).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the WorkspaceStatusUpdateRequest model
+ workspaceStatusUpdateRequestModel := new(schematicsv1.WorkspaceStatusUpdateRequest)
+ Expect(workspaceStatusUpdateRequestModel).ToNot(BeNil())
+ workspaceStatusUpdateRequestModel.Frozen = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.FrozenAt = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ workspaceStatusUpdateRequestModel.FrozenBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.Locked = core.BoolPtr(true)
+ workspaceStatusUpdateRequestModel.LockedBy = core.StringPtr("testString")
+ workspaceStatusUpdateRequestModel.LockedTime = CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(workspaceStatusUpdateRequestModel.Frozen).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceStatusUpdateRequestModel.FrozenAt).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+ Expect(workspaceStatusUpdateRequestModel.FrozenBy).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusUpdateRequestModel.Locked).To(Equal(core.BoolPtr(true)))
+ Expect(workspaceStatusUpdateRequestModel.LockedBy).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusUpdateRequestModel.LockedTime).To(Equal(CreateMockDateTime("2019-01-01T12:00:00.000Z")))
+
+ // Construct an instance of the WorkspaceStatusMessage model
+ workspaceStatusMessageModel := new(schematicsv1.WorkspaceStatusMessage)
+ Expect(workspaceStatusMessageModel).ToNot(BeNil())
+ workspaceStatusMessageModel.StatusCode = core.StringPtr("testString")
+ workspaceStatusMessageModel.StatusMsg = core.StringPtr("testString")
+ Expect(workspaceStatusMessageModel.StatusCode).To(Equal(core.StringPtr("testString")))
+ Expect(workspaceStatusMessageModel.StatusMsg).To(Equal(core.StringPtr("testString")))
+
+ // Construct an instance of the UpdateWorkspaceOptions model
+ wID := "testString"
+ updateWorkspaceOptionsModel := schematicsService.NewUpdateWorkspaceOptions(wID)
+ updateWorkspaceOptionsModel.SetWID("testString")
+ updateWorkspaceOptionsModel.SetCatalogRef(catalogRefModel)
+ updateWorkspaceOptionsModel.SetDescription("testString")
+ updateWorkspaceOptionsModel.SetName("testString")
+ updateWorkspaceOptionsModel.SetSharedData(sharedTargetDataModel)
+ updateWorkspaceOptionsModel.SetTags([]string{"testString"})
+ updateWorkspaceOptionsModel.SetTemplateData([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel})
+ updateWorkspaceOptionsModel.SetTemplateRepo(templateRepoUpdateRequestModel)
+ updateWorkspaceOptionsModel.SetType([]string{"testString"})
+ updateWorkspaceOptionsModel.SetWorkspaceStatus(workspaceStatusUpdateRequestModel)
+ updateWorkspaceOptionsModel.SetWorkspaceStatusMsg(workspaceStatusMessageModel)
+ updateWorkspaceOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(updateWorkspaceOptionsModel).ToNot(BeNil())
+ Expect(updateWorkspaceOptionsModel.WID).To(Equal(core.StringPtr("testString")))
+ Expect(updateWorkspaceOptionsModel.CatalogRef).To(Equal(catalogRefModel))
+ Expect(updateWorkspaceOptionsModel.Description).To(Equal(core.StringPtr("testString")))
+ Expect(updateWorkspaceOptionsModel.Name).To(Equal(core.StringPtr("testString")))
+ Expect(updateWorkspaceOptionsModel.SharedData).To(Equal(sharedTargetDataModel))
+ Expect(updateWorkspaceOptionsModel.Tags).To(Equal([]string{"testString"}))
+ Expect(updateWorkspaceOptionsModel.TemplateData).To(Equal([]schematicsv1.TemplateSourceDataRequest{*templateSourceDataRequestModel}))
+ Expect(updateWorkspaceOptionsModel.TemplateRepo).To(Equal(templateRepoUpdateRequestModel))
+ Expect(updateWorkspaceOptionsModel.Type).To(Equal([]string{"testString"}))
+ Expect(updateWorkspaceOptionsModel.WorkspaceStatus).To(Equal(workspaceStatusUpdateRequestModel))
+ Expect(updateWorkspaceOptionsModel.WorkspaceStatusMsg).To(Equal(workspaceStatusMessageModel))
+ Expect(updateWorkspaceOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ It(`Invoke NewUploadTemplateTarActionOptions successfully`, func() {
+ // Construct an instance of the UploadTemplateTarActionOptions model
+ actionID := "testString"
+ uploadTemplateTarActionOptionsModel := schematicsService.NewUploadTemplateTarActionOptions(actionID)
+ uploadTemplateTarActionOptionsModel.SetActionID("testString")
+ uploadTemplateTarActionOptionsModel.SetFile(CreateMockReader("This is a mock file."))
+ uploadTemplateTarActionOptionsModel.SetFileContentType("testString")
+ uploadTemplateTarActionOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
+ Expect(uploadTemplateTarActionOptionsModel).ToNot(BeNil())
+ Expect(uploadTemplateTarActionOptionsModel.ActionID).To(Equal(core.StringPtr("testString")))
+ Expect(uploadTemplateTarActionOptionsModel.File).To(Equal(CreateMockReader("This is a mock file.")))
+ Expect(uploadTemplateTarActionOptionsModel.FileContentType).To(Equal(core.StringPtr("testString")))
+ Expect(uploadTemplateTarActionOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
+ })
+ })
+ })
+ Describe(`Utility function tests`, func() {
+ It(`Invoke CreateMockByteArray() successfully`, func() {
+ mockByteArray := CreateMockByteArray("This is a test")
+ Expect(mockByteArray).ToNot(BeNil())
+ })
+ It(`Invoke CreateMockUUID() successfully`, func() {
+ mockUUID := CreateMockUUID("9fab83da-98cb-4f18-a7ba-b6f0435c9673")
+ Expect(mockUUID).ToNot(BeNil())
+ })
+ It(`Invoke CreateMockReader() successfully`, func() {
+ mockReader := CreateMockReader("This is a test.")
+ Expect(mockReader).ToNot(BeNil())
+ })
+ It(`Invoke CreateMockDate() successfully`, func() {
+ mockDate := CreateMockDate("2019-01-01")
+ Expect(mockDate).ToNot(BeNil())
+ })
+ It(`Invoke CreateMockDateTime() successfully`, func() {
+ mockDateTime := CreateMockDateTime("2019-01-01T12:00:00.000Z")
+ Expect(mockDateTime).ToNot(BeNil())
+ })
+ })
+})
+
+//
+// Utility functions used by the generated test code
+//
+
+func CreateMockByteArray(mockData string) *[]byte {
+ ba := make([]byte, 0)
+ ba = append(ba, mockData...)
+ return &ba
+}
+
+func CreateMockUUID(mockData string) *strfmt.UUID {
+ uuid := strfmt.UUID(mockData)
+ return &uuid
+}
+
+func CreateMockReader(mockData string) io.ReadCloser {
+ return ioutil.NopCloser(bytes.NewReader([]byte(mockData)))
+}
+
+func CreateMockDate(mockData string) *strfmt.Date {
+ d, err := core.ParseDate(mockData)
+ if err != nil {
+ return nil
+ }
+ return &d
+}
+
+func CreateMockDateTime(mockData string) *strfmt.DateTime {
+ d, err := core.ParseDateTime(mockData)
+ if err != nil {
+ return nil
+ }
+ return &d
+}
+
+func SetTestEnvironment(testEnvironment map[string]string) {
+ for key, value := range testEnvironment {
+ os.Setenv(key, value)
+ }
+}
+
+func ClearTestEnvironment(testEnvironment map[string]string) {
+ for key := range testEnvironment {
+ os.Unsetenv(key)
+ }
+}