Class: VSphereAutomation::CIS::TasksApi

Inherits:
Object
  • Object
show all
Defined in:
lib/vsphere-automation-cis/api/tasks_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ TasksApi

Returns a new instance of TasksApi.



16
17
18
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 16

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



14
15
16
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 14

def api_client
  @api_client
end

Instance Method Details

#cancel(task, action, opts = {}) ⇒ |VapiStdErrorsUnsupportedError|VapiStdErrorsUnauthenticatedError|VapiStdErrorsUnauthorizedError|VapiStdErrorsNotFoundError|VapiStdErrorsServiceUnavailableError|nil

Cancel a running operation associated with the task. This is the best effort attempt. Operation may not be cancelled anymore once it reaches certain stage.

Parameters:

  • task

    Task identifier. The parameter must be an identifier for the resource type: cis.task.

  • action

    action=cancel

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



24
25
26
27
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 24

def cancel(task, action, opts = {})
  cancel_with_http_info(task, action, opts)
  nil
end

#cancel_with_http_info(task, action, opts = {}) ⇒ Array<(|VapiStdErrorsUnsupportedError|VapiStdErrorsUnauthenticatedError|VapiStdErrorsUnauthorizedError|VapiStdErrorsNotFoundError|VapiStdErrorsServiceUnavailableError|nil, Fixnum, Hash)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Cancel a running operation associated with the task. This is the best effort attempt. Operation may not be cancelled anymore once it reaches certain stage.

Parameters:

  • task

    Task identifier. The parameter must be an identifier for the resource type: cis.task.

  • action

    action&#x3D;cancel

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 35

def cancel_with_http_info(task, action, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TasksApi.cancel ...'
  end
  # verify the required parameter 'task' is set
  if @api_client.config.client_side_validation && task.nil?
    fail ArgumentError, "Missing the required parameter 'task' when calling TasksApi.cancel"
  end
  # verify the required parameter 'action' is set
  if @api_client.config.client_side_validation && action.nil?
    fail ArgumentError, "Missing the required parameter 'action' when calling TasksApi.cancel"
  end
  # verify enum value
  if @api_client.config.client_side_validation && !['cancel'].include?(action)
    fail ArgumentError, "invalid value for 'action', must be one of cancel"
  end
  # resource path
  local_var_path = '/cis/tasks/{task}'.sub('{' + 'task' + '}', task.to_s)

  # query parameters
  query_params = {}
  query_params[:'action'] = action

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:POST, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TasksApi#cancel\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get(task, opts = {}) ⇒ CisTasksResult|VapiStdErrorsResourceInaccessibleError|VapiStdErrorsUnauthenticatedError|VapiStdErrorsUnauthorizedError|VapiStdErrorsNotFoundError|VapiStdErrorsServiceUnavailableError|

Returns information about a task.

Parameters:

  • task

    Task identifier. The parameter must be an identifier for the resource type: cis.task.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :spec_return_all (Boolean)

    If true, all data, including operation-specific data, will be returned, otherwise only the data described in Info will be returned. If unset, only the data described in Info will be returned.

  • :spec_exclude_result (Boolean)

    If true, the result will not be included in the task information, otherwise it will be included. If unset, the result of the operation will be included in the task information.

Returns:



86
87
88
89
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 86

def get(task, opts = {})
  data, _status_code, _headers = get_with_http_info(task, opts)
  data
end

#get_with_http_info(task, opts = {}) ⇒ Array<(CisTasksResult|VapiStdErrorsResourceInaccessibleError|VapiStdErrorsUnauthenticatedError|VapiStdErrorsUnauthorizedError|VapiStdErrorsNotFoundError|VapiStdErrorsServiceUnavailableError|, Fixnum, Hash)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns information about a task.

Parameters:

  • task

    Task identifier. The parameter must be an identifier for the resource type: cis.task.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :spec_return_all (Boolean)

    If true, all data, including operation-specific data, will be returned, otherwise only the data described in Info will be returned. If unset, only the data described in Info will be returned.

  • :spec_exclude_result (Boolean)

    If true, the result will not be included in the task information, otherwise it will be included. If unset, the result of the operation will be included in the task information.

Returns:



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 98

def get_with_http_info(task, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TasksApi.get ...'
  end
  # verify the required parameter 'task' is set
  if @api_client.config.client_side_validation && task.nil?
    fail ArgumentError, "Missing the required parameter 'task' when calling TasksApi.get"
  end
  # resource path
  local_var_path = '/cis/tasks/{task}'.sub('{' + 'task' + '}', task.to_s)

  # query parameters
  query_params = {}
  query_params[:'spec.return_all'] = opts[:'spec_return_all'] if !opts[:'spec_return_all'].nil?
  query_params[:'spec.exclude_result'] = opts[:'spec_exclude_result'] if !opts[:'spec_exclude_result'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
	:return_type => {
	  '200' => 'CIS::CisTasksResult',
	  '400' => 'CIS::VapiStdErrorsResourceInaccessibleError',
	  '401' => 'CIS::VapiStdErrorsUnauthenticatedError',
	  '403' => 'CIS::VapiStdErrorsUnauthorizedError',
	  '404' => 'CIS::VapiStdErrorsNotFoundError',
	  '503' => 'CIS::VapiStdErrorsServiceUnavailableError',
	})
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TasksApi#get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list(opts = {}) ⇒ CisTasksListResult|VapiStdErrorsResourceInaccessibleError|VapiStdErrorsUnauthenticatedError|VapiStdErrorsUnauthorizedError|VapiStdErrorsServiceUnavailableError|

Returns information about at most 1000 visible (subject to permission checks) tasks matching the Tasks.FilterSpec. All tasks must be in the same provider.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :filter_spec_tasks (Array<String>)

    Identifiers of tasks that can match the filter. This field may be unset if Tasks.FilterSpec.services is specified. Currently all tasks must be from the same provider. If unset or empty, tasks with any identifier will match the filter. When clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: cis.task. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: cis.task.

  • :result_spec_return_all (Boolean)

    If true, all data, including operation-specific data, will be returned, otherwise only the data described in Info will be returned. If unset, only the data described in Info will be returned.

  • :result_spec_exclude_result (Boolean)

    If true, the result will not be included in the task information, otherwise it will be included. If unset, the result of the operation will be included in the task information.

  • :filter_spec_services (Array<String>)

    Identifiers of services. Tasks created by operations in these services match the filter (see CommonInfo.service). This field may be unset if Tasks.FilterSpec.tasks is specified. Currently all services must be from the same provider. If this field is unset or empty, tasks for all services will match the filter. When clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: vapi.service. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: vapi.service.

  • :filter_spec_status (Array<String>)

    Status that a task must have to match the filter (see CommonInfo.status). If unset or empty, tasks with any status match the filter.

  • :filter_spec_targets (Array<Object>)

    Identifiers of the targets the operation for the associated task created or was performed on (see CommonInfo.target). If unset or empty, tasks associated with operations on any target match the filter.

  • :filter_spec_users (Array<String>)

    Users who must have initiated the operation for the associated task to match the filter (see CommonInfo.user). If unset or empty, tasks associated with operations initiated by any user match the filter.

Returns:



154
155
156
157
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 154

def list(opts = {})
  data, _status_code, _headers = list_with_http_info(opts)
  data
end

#list_with_http_info(opts = {}) ⇒ Array<(CisTasksListResult|VapiStdErrorsResourceInaccessibleError|VapiStdErrorsUnauthenticatedError|VapiStdErrorsUnauthorizedError|VapiStdErrorsServiceUnavailableError|, Fixnum, Hash)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns information about at most 1000 visible (subject to permission checks) tasks matching the Tasks.FilterSpec. All tasks must be in the same provider.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :filter_spec_tasks (Array<String>)

    Identifiers of tasks that can match the filter. This field may be unset if Tasks.FilterSpec.services is specified. Currently all tasks must be from the same provider. If unset or empty, tasks with any identifier will match the filter. When clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: cis.task. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: cis.task.

  • :result_spec_return_all (Boolean)

    If true, all data, including operation-specific data, will be returned, otherwise only the data described in Info will be returned. If unset, only the data described in Info will be returned.

  • :result_spec_exclude_result (Boolean)

    If true, the result will not be included in the task information, otherwise it will be included. If unset, the result of the operation will be included in the task information.

  • :filter_spec_services (Array<String>)

    Identifiers of services. Tasks created by operations in these services match the filter (see CommonInfo.service). This field may be unset if Tasks.FilterSpec.tasks is specified. Currently all services must be from the same provider. If this field is unset or empty, tasks for all services will match the filter. When clients pass a value of this structure as a parameter, the field must contain identifiers for the resource type: vapi.service. When operations return a value of this structure as a result, the field will contain identifiers for the resource type: vapi.service.

  • :filter_spec_status (Array<String>)

    Status that a task must have to match the filter (see CommonInfo.status). If unset or empty, tasks with any status match the filter.

  • :filter_spec_targets (Array<Object>)

    Identifiers of the targets the operation for the associated task created or was performed on (see CommonInfo.target). If unset or empty, tasks associated with operations on any target match the filter.

  • :filter_spec_users (Array<String>)

    Users who must have initiated the operation for the associated task to match the filter (see CommonInfo.user). If unset or empty, tasks associated with operations initiated by any user match the filter.

Returns:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/vsphere-automation-cis/api/tasks_api.rb', line 170

def list_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: TasksApi.list ...'
  end
  if @api_client.config.client_side_validation && opts[:'filter_spec_status'] && !opts[:'filter_spec_status'].all? { |item| ['PENDING', 'RUNNING', 'BLOCKED', 'SUCCEEDED', 'FAILED'].include?(item) }
    fail ArgumentError, 'invalid value for "filter_spec_status", must include one of PENDING, RUNNING, BLOCKED, SUCCEEDED, FAILED'
  end
  # resource path
  local_var_path = '/cis/tasks'

  # query parameters
  query_params = {}
  query_params[:'filter_spec.tasks'] = @api_client.build_collection_param(opts[:'filter_spec_tasks'], :multi) if !opts[:'filter_spec_tasks'].nil?
  query_params[:'result_spec.return_all'] = opts[:'result_spec_return_all'] if !opts[:'result_spec_return_all'].nil?
  query_params[:'result_spec.exclude_result'] = opts[:'result_spec_exclude_result'] if !opts[:'result_spec_exclude_result'].nil?
  query_params[:'filter_spec.services'] = @api_client.build_collection_param(opts[:'filter_spec_services'], :multi) if !opts[:'filter_spec_services'].nil?
  query_params[:'filter_spec.status'] = @api_client.build_collection_param(opts[:'filter_spec_status'], :multi) if !opts[:'filter_spec_status'].nil?
  query_params[:'filter_spec.targets'] = @api_client.build_collection_param(opts[:'filter_spec_targets'], :multi) if !opts[:'filter_spec_targets'].nil?
  query_params[:'filter_spec.users'] = @api_client.build_collection_param(opts[:'filter_spec_users'], :multi) if !opts[:'filter_spec_users'].nil?

  # header parameters
  header_params = {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = {}

  # http body (model)
  post_body = nil
  auth_names = ['api_key']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
	:return_type => {
	  '200' => 'CIS::CisTasksListResult',
	  '400' => 'CIS::VapiStdErrorsResourceInaccessibleError',
	  '401' => 'CIS::VapiStdErrorsUnauthenticatedError',
	  '403' => 'CIS::VapiStdErrorsUnauthorizedError',
	  '503' => 'CIS::VapiStdErrorsServiceUnavailableError',
	})
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: TasksApi#list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end