=begin
#Hatchet API

#The Hatchet API

The version of the OpenAPI document: 1.0.0

Generated by: https://openapi-generator.tech
Generator version: 7.14.0

=end

require 'cgi'

module HatchetSdkRest
  class WorkflowApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Get cron job workflows
    # Get all cron job workflow triggers for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :workflow_name The workflow name to get runs for.
    # @option opts [String] :cron_name The cron name to get runs for.
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [CronWorkflowsOrderByField] :order_by_field The order by field
    # @option opts [WorkflowRunOrderByDirection] :order_by_direction The order by direction
    # @return [CronWorkflowsList]
    def cron_workflow_list(tenant, opts = {})
      data, _status_code, _headers = cron_workflow_list_with_http_info(tenant, opts)
      data
    end

    # Get cron job workflows
    # Get all cron job workflow triggers for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :workflow_name The workflow name to get runs for.
    # @option opts [String] :cron_name The cron name to get runs for.
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [CronWorkflowsOrderByField] :order_by_field The order by field
    # @option opts [WorkflowRunOrderByDirection] :order_by_direction The order by direction
    # @return [Array<(CronWorkflowsList, Integer, Hash)>] CronWorkflowsList data, response status code and response headers
    def cron_workflow_list_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.cron_workflow_list ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.cron_workflow_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.cron_workflow_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.cron_workflow_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.cron_workflow_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.cron_workflow_list, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/crons'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
      query_params[:'workflowId'] = opts[:'workflow_id'] if !opts[:'workflow_id'].nil?
      query_params[:'workflowName'] = opts[:'workflow_name'] if !opts[:'workflow_name'].nil?
      query_params[:'cronName'] = opts[:'cron_name'] if !opts[:'cron_name'].nil?
      query_params[:'additionalMetadata'] = @api_client.build_collection_param(opts[:'additional_metadata'], :multi) if !opts[:'additional_metadata'].nil?
      query_params[:'orderByField'] = opts[:'order_by_field'] if !opts[:'order_by_field'].nil?
      query_params[:'orderByDirection'] = opts[:'order_by_direction'] if !opts[:'order_by_direction'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'CronWorkflowsList'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.cron_workflow_list",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#cron_workflow_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow metrics
    # Get the queue metrics for the tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :workflows A list of workflow IDs to filter by
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @return [TenantQueueMetrics]
    def tenant_get_queue_metrics(tenant, opts = {})
      data, _status_code, _headers = tenant_get_queue_metrics_with_http_info(tenant, opts)
      data
    end

    # Get workflow metrics
    # Get the queue metrics for the tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :workflows A list of workflow IDs to filter by
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @return [Array<(TenantQueueMetrics, Integer, Hash)>] TenantQueueMetrics data, response status code and response headers
    def tenant_get_queue_metrics_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.tenant_get_queue_metrics ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.tenant_get_queue_metrics"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.tenant_get_queue_metrics, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.tenant_get_queue_metrics, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/queue-metrics'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'workflows'] = @api_client.build_collection_param(opts[:'workflows'], :multi) if !opts[:'workflows'].nil?
      query_params[:'additionalMetadata'] = @api_client.build_collection_param(opts[:'additional_metadata'], :multi) if !opts[:'additional_metadata'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'TenantQueueMetrics'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.tenant_get_queue_metrics",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#tenant_get_queue_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Delete cron job workflow run
    # Delete a cron job workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param cron_workflow [String] The cron job id
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def workflow_cron_delete(tenant, cron_workflow, opts = {})
      workflow_cron_delete_with_http_info(tenant, cron_workflow, opts)
      nil
    end

    # Delete cron job workflow run
    # Delete a cron job workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param cron_workflow [String] The cron job id
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def workflow_cron_delete_with_http_info(tenant, cron_workflow, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_cron_delete ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_cron_delete"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_cron_delete, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_cron_delete, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'cron_workflow' is set
      if @api_client.config.client_side_validation && cron_workflow.nil?
        fail ArgumentError, "Missing the required parameter 'cron_workflow' when calling WorkflowApi.workflow_cron_delete"
      end
      if @api_client.config.client_side_validation && cron_workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "cron_workflow" when calling WorkflowApi.workflow_cron_delete, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && cron_workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "cron_workflow" when calling WorkflowApi.workflow_cron_delete, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/crons/{cron-workflow}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'cron-workflow' + '}', CGI.escape(cron_workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_cron_delete",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_cron_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get cron job workflow run
    # Get a cron job workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param cron_workflow [String] The cron job id
    # @param [Hash] opts the optional parameters
    # @return [CronWorkflows]
    def workflow_cron_get(tenant, cron_workflow, opts = {})
      data, _status_code, _headers = workflow_cron_get_with_http_info(tenant, cron_workflow, opts)
      data
    end

    # Get cron job workflow run
    # Get a cron job workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param cron_workflow [String] The cron job id
    # @param [Hash] opts the optional parameters
    # @return [Array<(CronWorkflows, Integer, Hash)>] CronWorkflows data, response status code and response headers
    def workflow_cron_get_with_http_info(tenant, cron_workflow, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_cron_get ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_cron_get"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_cron_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_cron_get, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'cron_workflow' is set
      if @api_client.config.client_side_validation && cron_workflow.nil?
        fail ArgumentError, "Missing the required parameter 'cron_workflow' when calling WorkflowApi.workflow_cron_get"
      end
      if @api_client.config.client_side_validation && cron_workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "cron_workflow" when calling WorkflowApi.workflow_cron_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && cron_workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "cron_workflow" when calling WorkflowApi.workflow_cron_get, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/crons/{cron-workflow}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'cron-workflow' + '}', CGI.escape(cron_workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'CronWorkflows'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_cron_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_cron_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Update cron job workflow run
    # Update a cron workflow for a tenant
    # @param tenant [String] The tenant id
    # @param cron_workflow [String] The cron job id
    # @param update_cron_workflow_trigger_request [UpdateCronWorkflowTriggerRequest] The input for updates
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def workflow_cron_update(tenant, cron_workflow, update_cron_workflow_trigger_request, opts = {})
      workflow_cron_update_with_http_info(tenant, cron_workflow, update_cron_workflow_trigger_request, opts)
      nil
    end

    # Update cron job workflow run
    # Update a cron workflow for a tenant
    # @param tenant [String] The tenant id
    # @param cron_workflow [String] The cron job id
    # @param update_cron_workflow_trigger_request [UpdateCronWorkflowTriggerRequest] The input for updates
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def workflow_cron_update_with_http_info(tenant, cron_workflow, update_cron_workflow_trigger_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_cron_update ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_cron_update"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_cron_update, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_cron_update, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'cron_workflow' is set
      if @api_client.config.client_side_validation && cron_workflow.nil?
        fail ArgumentError, "Missing the required parameter 'cron_workflow' when calling WorkflowApi.workflow_cron_update"
      end
      if @api_client.config.client_side_validation && cron_workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "cron_workflow" when calling WorkflowApi.workflow_cron_update, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && cron_workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "cron_workflow" when calling WorkflowApi.workflow_cron_update, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'update_cron_workflow_trigger_request' is set
      if @api_client.config.client_side_validation && update_cron_workflow_trigger_request.nil?
        fail ArgumentError, "Missing the required parameter 'update_cron_workflow_trigger_request' when calling WorkflowApi.workflow_cron_update"
      end
      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/crons/{cron-workflow}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'cron-workflow' + '}', CGI.escape(cron_workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(update_cron_workflow_trigger_request)

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_cron_update",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_cron_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Delete workflow
    # Delete a workflow for a tenant
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def workflow_delete(workflow, opts = {})
      workflow_delete_with_http_info(workflow, opts)
      nil
    end

    # Delete workflow
    # Delete a workflow for a tenant
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def workflow_delete_with_http_info(workflow, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_delete ...'
      end
      # verify the required parameter 'workflow' is set
      if @api_client.config.client_side_validation && workflow.nil?
        fail ArgumentError, "Missing the required parameter 'workflow' when calling WorkflowApi.workflow_delete"
      end
      if @api_client.config.client_side_validation && workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_delete, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_delete, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/workflows/{workflow}'.sub('{' + 'workflow' + '}', CGI.escape(workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_delete",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow
    # Get a workflow for a tenant
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @return [Workflow]
    def workflow_get(workflow, opts = {})
      data, _status_code, _headers = workflow_get_with_http_info(workflow, opts)
      data
    end

    # Get workflow
    # Get a workflow for a tenant
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @return [Array<(Workflow, Integer, Hash)>] Workflow data, response status code and response headers
    def workflow_get_with_http_info(workflow, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_get ...'
      end
      # verify the required parameter 'workflow' is set
      if @api_client.config.client_side_validation && workflow.nil?
        fail ArgumentError, "Missing the required parameter 'workflow' when calling WorkflowApi.workflow_get"
      end
      if @api_client.config.client_side_validation && workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_get, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/workflows/{workflow}'.sub('{' + 'workflow' + '}', CGI.escape(workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'Workflow'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow metrics
    # Get the metrics for a workflow version
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @option opts [WorkflowRunStatus] :status A status of workflow run statuses to filter by
    # @option opts [String] :group_key A group key to filter metrics by
    # @return [WorkflowMetrics]
    def workflow_get_metrics(workflow, opts = {})
      data, _status_code, _headers = workflow_get_metrics_with_http_info(workflow, opts)
      data
    end

    # Get workflow metrics
    # Get the metrics for a workflow version
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @option opts [WorkflowRunStatus] :status A status of workflow run statuses to filter by
    # @option opts [String] :group_key A group key to filter metrics by
    # @return [Array<(WorkflowMetrics, Integer, Hash)>] WorkflowMetrics data, response status code and response headers
    def workflow_get_metrics_with_http_info(workflow, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_get_metrics ...'
      end
      # verify the required parameter 'workflow' is set
      if @api_client.config.client_side_validation && workflow.nil?
        fail ArgumentError, "Missing the required parameter 'workflow' when calling WorkflowApi.workflow_get_metrics"
      end
      if @api_client.config.client_side_validation && workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_get_metrics, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_get_metrics, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/workflows/{workflow}/metrics'.sub('{' + 'workflow' + '}', CGI.escape(workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
      query_params[:'groupKey'] = opts[:'group_key'] if !opts[:'group_key'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowMetrics'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_get_metrics",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_get_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow worker count
    # Get a count of the workers available for workflow
    # @param tenant [String] The tenant id
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @return [WorkflowWorkersCount]
    def workflow_get_workers_count(tenant, workflow, opts = {})
      data, _status_code, _headers = workflow_get_workers_count_with_http_info(tenant, workflow, opts)
      data
    end

    # Get workflow worker count
    # Get a count of the workers available for workflow
    # @param tenant [String] The tenant id
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @return [Array<(WorkflowWorkersCount, Integer, Hash)>] WorkflowWorkersCount data, response status code and response headers
    def workflow_get_workers_count_with_http_info(tenant, workflow, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_get_workers_count ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_get_workers_count"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_get_workers_count, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_get_workers_count, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'workflow' is set
      if @api_client.config.client_side_validation && workflow.nil?
        fail ArgumentError, "Missing the required parameter 'workflow' when calling WorkflowApi.workflow_get_workers_count"
      end
      if @api_client.config.client_side_validation && workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_get_workers_count, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_get_workers_count, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/{workflow}/worker-count'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'workflow' + '}', CGI.escape(workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowWorkersCount'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_get_workers_count",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_get_workers_count\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflows
    # Get all workflows for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip (default to 0)
    # @option opts [Integer] :limit The number to limit by (default to 50)
    # @option opts [String] :name Search by name
    # @return [WorkflowList]
    def workflow_list(tenant, opts = {})
      data, _status_code, _headers = workflow_list_with_http_info(tenant, opts)
      data
    end

    # Get workflows
    # Get all workflows for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip (default to 0)
    # @option opts [Integer] :limit The number to limit by (default to 50)
    # @option opts [String] :name Search by name
    # @return [Array<(WorkflowList, Integer, Hash)>] WorkflowList data, response status code and response headers
    def workflow_list_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_list ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_list, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
      query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowList'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_list",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow run
    # Get a workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param workflow_run [String] The workflow run id
    # @param [Hash] opts the optional parameters
    # @return [WorkflowRun]
    def workflow_run_get(tenant, workflow_run, opts = {})
      data, _status_code, _headers = workflow_run_get_with_http_info(tenant, workflow_run, opts)
      data
    end

    # Get workflow run
    # Get a workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param workflow_run [String] The workflow run id
    # @param [Hash] opts the optional parameters
    # @return [Array<(WorkflowRun, Integer, Hash)>] WorkflowRun data, response status code and response headers
    def workflow_run_get_with_http_info(tenant, workflow_run, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_run_get ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_run_get"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_get, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'workflow_run' is set
      if @api_client.config.client_side_validation && workflow_run.nil?
        fail ArgumentError, "Missing the required parameter 'workflow_run' when calling WorkflowApi.workflow_run_get"
      end
      if @api_client.config.client_side_validation && workflow_run.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow_run" when calling WorkflowApi.workflow_run_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow_run.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow_run" when calling WorkflowApi.workflow_run_get, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'workflow-run' + '}', CGI.escape(workflow_run.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowRun'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_run_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_run_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow runs metrics
    # Get a summary of  workflow run metrics for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [String] :event_id The event id to get runs for.
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :parent_workflow_run_id The parent workflow run id
    # @option opts [String] :parent_step_run_id The parent step run id
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [Time] :created_after The time after the workflow run was created
    # @option opts [Time] :created_before The time before the workflow run was created
    # @return [WorkflowRunsMetrics]
    def workflow_run_get_metrics(tenant, opts = {})
      data, _status_code, _headers = workflow_run_get_metrics_with_http_info(tenant, opts)
      data
    end

    # Get workflow runs metrics
    # Get a summary of  workflow run metrics for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [String] :event_id The event id to get runs for.
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :parent_workflow_run_id The parent workflow run id
    # @option opts [String] :parent_step_run_id The parent step run id
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [Time] :created_after The time after the workflow run was created
    # @option opts [Time] :created_before The time before the workflow run was created
    # @return [Array<(WorkflowRunsMetrics, Integer, Hash)>] WorkflowRunsMetrics data, response status code and response headers
    def workflow_run_get_metrics_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_run_get_metrics ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_run_get_metrics"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_get_metrics, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_get_metrics, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'event_id'].nil? && opts[:'event_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"event_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'event_id'].nil? && opts[:'event_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"event_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_workflow_run_id'].nil? && opts[:'parent_workflow_run_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"parent_workflow_run_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_workflow_run_id'].nil? && opts[:'parent_workflow_run_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"parent_workflow_run_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_step_run_id'].nil? && opts[:'parent_step_run_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"parent_step_run_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_step_run_id'].nil? && opts[:'parent_step_run_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"parent_step_run_id"]" when calling WorkflowApi.workflow_run_get_metrics, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/runs/metrics'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'eventId'] = opts[:'event_id'] if !opts[:'event_id'].nil?
      query_params[:'workflowId'] = opts[:'workflow_id'] if !opts[:'workflow_id'].nil?
      query_params[:'parentWorkflowRunId'] = opts[:'parent_workflow_run_id'] if !opts[:'parent_workflow_run_id'].nil?
      query_params[:'parentStepRunId'] = opts[:'parent_step_run_id'] if !opts[:'parent_step_run_id'].nil?
      query_params[:'additionalMetadata'] = @api_client.build_collection_param(opts[:'additional_metadata'], :multi) if !opts[:'additional_metadata'].nil?
      query_params[:'createdAfter'] = opts[:'created_after'] if !opts[:'created_after'].nil?
      query_params[:'createdBefore'] = opts[:'created_before'] if !opts[:'created_before'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowRunsMetrics'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_run_get_metrics",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_run_get_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow run
    # Get a workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param workflow_run [String] The workflow run id
    # @param [Hash] opts the optional parameters
    # @return [WorkflowRunShape]
    def workflow_run_get_shape(tenant, workflow_run, opts = {})
      data, _status_code, _headers = workflow_run_get_shape_with_http_info(tenant, workflow_run, opts)
      data
    end

    # Get workflow run
    # Get a workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param workflow_run [String] The workflow run id
    # @param [Hash] opts the optional parameters
    # @return [Array<(WorkflowRunShape, Integer, Hash)>] WorkflowRunShape data, response status code and response headers
    def workflow_run_get_shape_with_http_info(tenant, workflow_run, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_run_get_shape ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_run_get_shape"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_get_shape, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_get_shape, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'workflow_run' is set
      if @api_client.config.client_side_validation && workflow_run.nil?
        fail ArgumentError, "Missing the required parameter 'workflow_run' when calling WorkflowApi.workflow_run_get_shape"
      end
      if @api_client.config.client_side_validation && workflow_run.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow_run" when calling WorkflowApi.workflow_run_get_shape, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow_run.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow_run" when calling WorkflowApi.workflow_run_get_shape, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflow-runs/{workflow-run}/shape'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'workflow-run' + '}', CGI.escape(workflow_run.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowRunShape'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_run_get_shape",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_run_get_shape\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow runs
    # Get all workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @option opts [String] :event_id The event id to get runs for.
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :parent_workflow_run_id The parent workflow run id
    # @option opts [String] :parent_step_run_id The parent step run id
    # @option opts [Array<WorkflowRunStatus>] :statuses A list of workflow run statuses to filter by
    # @option opts [Array<WorkflowKind>] :kinds A list of workflow kinds to filter by
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [Time] :created_after The time after the workflow run was created
    # @option opts [Time] :created_before The time before the workflow run was created
    # @option opts [Time] :finished_after The time after the workflow run was finished
    # @option opts [Time] :finished_before The time before the workflow run was finished
    # @option opts [WorkflowRunOrderByField] :order_by_field The order by field
    # @option opts [WorkflowRunOrderByDirection] :order_by_direction The order by direction
    # @return [WorkflowRunList]
    def workflow_run_list(tenant, opts = {})
      data, _status_code, _headers = workflow_run_list_with_http_info(tenant, opts)
      data
    end

    # Get workflow runs
    # Get all workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @option opts [String] :event_id The event id to get runs for.
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :parent_workflow_run_id The parent workflow run id
    # @option opts [String] :parent_step_run_id The parent step run id
    # @option opts [Array<WorkflowRunStatus>] :statuses A list of workflow run statuses to filter by
    # @option opts [Array<WorkflowKind>] :kinds A list of workflow kinds to filter by
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [Time] :created_after The time after the workflow run was created
    # @option opts [Time] :created_before The time before the workflow run was created
    # @option opts [Time] :finished_after The time after the workflow run was finished
    # @option opts [Time] :finished_before The time before the workflow run was finished
    # @option opts [WorkflowRunOrderByField] :order_by_field The order by field
    # @option opts [WorkflowRunOrderByDirection] :order_by_direction The order by direction
    # @return [Array<(WorkflowRunList, Integer, Hash)>] WorkflowRunList data, response status code and response headers
    def workflow_run_list_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_run_list ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_run_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_run_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'event_id'].nil? && opts[:'event_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"event_id"]" when calling WorkflowApi.workflow_run_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'event_id'].nil? && opts[:'event_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"event_id"]" when calling WorkflowApi.workflow_run_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.workflow_run_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.workflow_run_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_workflow_run_id'].nil? && opts[:'parent_workflow_run_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"parent_workflow_run_id"]" when calling WorkflowApi.workflow_run_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_workflow_run_id'].nil? && opts[:'parent_workflow_run_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"parent_workflow_run_id"]" when calling WorkflowApi.workflow_run_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_step_run_id'].nil? && opts[:'parent_step_run_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"parent_step_run_id"]" when calling WorkflowApi.workflow_run_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_step_run_id'].nil? && opts[:'parent_step_run_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"parent_step_run_id"]" when calling WorkflowApi.workflow_run_list, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/runs'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
      query_params[:'eventId'] = opts[:'event_id'] if !opts[:'event_id'].nil?
      query_params[:'workflowId'] = opts[:'workflow_id'] if !opts[:'workflow_id'].nil?
      query_params[:'parentWorkflowRunId'] = opts[:'parent_workflow_run_id'] if !opts[:'parent_workflow_run_id'].nil?
      query_params[:'parentStepRunId'] = opts[:'parent_step_run_id'] if !opts[:'parent_step_run_id'].nil?
      query_params[:'statuses'] = @api_client.build_collection_param(opts[:'statuses'], :multi) if !opts[:'statuses'].nil?
      query_params[:'kinds'] = @api_client.build_collection_param(opts[:'kinds'], :multi) if !opts[:'kinds'].nil?
      query_params[:'additionalMetadata'] = @api_client.build_collection_param(opts[:'additional_metadata'], :multi) if !opts[:'additional_metadata'].nil?
      query_params[:'createdAfter'] = opts[:'created_after'] if !opts[:'created_after'].nil?
      query_params[:'createdBefore'] = opts[:'created_before'] if !opts[:'created_before'].nil?
      query_params[:'finishedAfter'] = opts[:'finished_after'] if !opts[:'finished_after'].nil?
      query_params[:'finishedBefore'] = opts[:'finished_before'] if !opts[:'finished_before'].nil?
      query_params[:'orderByField'] = opts[:'order_by_field'] if !opts[:'order_by_field'].nil?
      query_params[:'orderByDirection'] = opts[:'order_by_direction'] if !opts[:'order_by_direction'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowRunList'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_run_list",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_run_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Bulk delete scheduled workflow runs
    # Bulk delete scheduled workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflows_bulk_delete_request [ScheduledWorkflowsBulkDeleteRequest] The input to bulk delete scheduled workflow runs
    # @param [Hash] opts the optional parameters
    # @return [ScheduledWorkflowsBulkDeleteResponse]
    def workflow_scheduled_bulk_delete(tenant, scheduled_workflows_bulk_delete_request, opts = {})
      data, _status_code, _headers = workflow_scheduled_bulk_delete_with_http_info(tenant, scheduled_workflows_bulk_delete_request, opts)
      data
    end

    # Bulk delete scheduled workflow runs
    # Bulk delete scheduled workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflows_bulk_delete_request [ScheduledWorkflowsBulkDeleteRequest] The input to bulk delete scheduled workflow runs
    # @param [Hash] opts the optional parameters
    # @return [Array<(ScheduledWorkflowsBulkDeleteResponse, Integer, Hash)>] ScheduledWorkflowsBulkDeleteResponse data, response status code and response headers
    def workflow_scheduled_bulk_delete_with_http_info(tenant, scheduled_workflows_bulk_delete_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_scheduled_bulk_delete ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_scheduled_bulk_delete"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_bulk_delete, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_bulk_delete, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'scheduled_workflows_bulk_delete_request' is set
      if @api_client.config.client_side_validation && scheduled_workflows_bulk_delete_request.nil?
        fail ArgumentError, "Missing the required parameter 'scheduled_workflows_bulk_delete_request' when calling WorkflowApi.workflow_scheduled_bulk_delete"
      end
      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/scheduled/bulk-delete'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(scheduled_workflows_bulk_delete_request)

      # return_type
      return_type = opts[:debug_return_type] || 'ScheduledWorkflowsBulkDeleteResponse'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_scheduled_bulk_delete",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_scheduled_bulk_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Bulk update scheduled workflow runs
    # Bulk update (reschedule) scheduled workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflows_bulk_update_request [ScheduledWorkflowsBulkUpdateRequest] The input to bulk update scheduled workflow runs
    # @param [Hash] opts the optional parameters
    # @return [ScheduledWorkflowsBulkUpdateResponse]
    def workflow_scheduled_bulk_update(tenant, scheduled_workflows_bulk_update_request, opts = {})
      data, _status_code, _headers = workflow_scheduled_bulk_update_with_http_info(tenant, scheduled_workflows_bulk_update_request, opts)
      data
    end

    # Bulk update scheduled workflow runs
    # Bulk update (reschedule) scheduled workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflows_bulk_update_request [ScheduledWorkflowsBulkUpdateRequest] The input to bulk update scheduled workflow runs
    # @param [Hash] opts the optional parameters
    # @return [Array<(ScheduledWorkflowsBulkUpdateResponse, Integer, Hash)>] ScheduledWorkflowsBulkUpdateResponse data, response status code and response headers
    def workflow_scheduled_bulk_update_with_http_info(tenant, scheduled_workflows_bulk_update_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_scheduled_bulk_update ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_scheduled_bulk_update"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_bulk_update, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_bulk_update, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'scheduled_workflows_bulk_update_request' is set
      if @api_client.config.client_side_validation && scheduled_workflows_bulk_update_request.nil?
        fail ArgumentError, "Missing the required parameter 'scheduled_workflows_bulk_update_request' when calling WorkflowApi.workflow_scheduled_bulk_update"
      end
      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/scheduled/bulk-update'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(scheduled_workflows_bulk_update_request)

      # return_type
      return_type = opts[:debug_return_type] || 'ScheduledWorkflowsBulkUpdateResponse'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_scheduled_bulk_update",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_scheduled_bulk_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Delete scheduled workflow run
    # Delete a scheduled workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflow_run [String] The scheduled workflow id
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def workflow_scheduled_delete(tenant, scheduled_workflow_run, opts = {})
      workflow_scheduled_delete_with_http_info(tenant, scheduled_workflow_run, opts)
      nil
    end

    # Delete scheduled workflow run
    # Delete a scheduled workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflow_run [String] The scheduled workflow id
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def workflow_scheduled_delete_with_http_info(tenant, scheduled_workflow_run, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_scheduled_delete ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_scheduled_delete"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_delete, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_delete, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'scheduled_workflow_run' is set
      if @api_client.config.client_side_validation && scheduled_workflow_run.nil?
        fail ArgumentError, "Missing the required parameter 'scheduled_workflow_run' when calling WorkflowApi.workflow_scheduled_delete"
      end
      if @api_client.config.client_side_validation && scheduled_workflow_run.to_s.length > 36
        fail ArgumentError, 'invalid value for "scheduled_workflow_run" when calling WorkflowApi.workflow_scheduled_delete, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && scheduled_workflow_run.to_s.length < 36
        fail ArgumentError, 'invalid value for "scheduled_workflow_run" when calling WorkflowApi.workflow_scheduled_delete, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'scheduled-workflow-run' + '}', CGI.escape(scheduled_workflow_run.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type]

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_scheduled_delete",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_scheduled_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get scheduled workflow run
    # Get a scheduled workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflow_run [String] The scheduled workflow id
    # @param [Hash] opts the optional parameters
    # @return [ScheduledWorkflows]
    def workflow_scheduled_get(tenant, scheduled_workflow_run, opts = {})
      data, _status_code, _headers = workflow_scheduled_get_with_http_info(tenant, scheduled_workflow_run, opts)
      data
    end

    # Get scheduled workflow run
    # Get a scheduled workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflow_run [String] The scheduled workflow id
    # @param [Hash] opts the optional parameters
    # @return [Array<(ScheduledWorkflows, Integer, Hash)>] ScheduledWorkflows data, response status code and response headers
    def workflow_scheduled_get_with_http_info(tenant, scheduled_workflow_run, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_scheduled_get ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_scheduled_get"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_get, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'scheduled_workflow_run' is set
      if @api_client.config.client_side_validation && scheduled_workflow_run.nil?
        fail ArgumentError, "Missing the required parameter 'scheduled_workflow_run' when calling WorkflowApi.workflow_scheduled_get"
      end
      if @api_client.config.client_side_validation && scheduled_workflow_run.to_s.length > 36
        fail ArgumentError, 'invalid value for "scheduled_workflow_run" when calling WorkflowApi.workflow_scheduled_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && scheduled_workflow_run.to_s.length < 36
        fail ArgumentError, 'invalid value for "scheduled_workflow_run" when calling WorkflowApi.workflow_scheduled_get, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'scheduled-workflow-run' + '}', CGI.escape(scheduled_workflow_run.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'ScheduledWorkflows'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_scheduled_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_scheduled_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get scheduled workflow runs
    # Get all scheduled workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @option opts [ScheduledWorkflowsOrderByField] :order_by_field The order by field
    # @option opts [WorkflowRunOrderByDirection] :order_by_direction The order by direction
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :parent_workflow_run_id The parent workflow run id
    # @option opts [String] :parent_step_run_id The parent step run id
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [Array<ScheduledRunStatus>] :statuses A list of scheduled run statuses to filter by
    # @return [ScheduledWorkflowsList]
    def workflow_scheduled_list(tenant, opts = {})
      data, _status_code, _headers = workflow_scheduled_list_with_http_info(tenant, opts)
      data
    end

    # Get scheduled workflow runs
    # Get all scheduled workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @option opts [ScheduledWorkflowsOrderByField] :order_by_field The order by field
    # @option opts [WorkflowRunOrderByDirection] :order_by_direction The order by direction
    # @option opts [String] :workflow_id The workflow id to get runs for.
    # @option opts [String] :parent_workflow_run_id The parent workflow run id
    # @option opts [String] :parent_step_run_id The parent step run id
    # @option opts [Array<String>] :additional_metadata A list of metadata key value pairs to filter by
    # @option opts [Array<ScheduledRunStatus>] :statuses A list of scheduled run statuses to filter by
    # @return [Array<(ScheduledWorkflowsList, Integer, Hash)>] ScheduledWorkflowsList data, response status code and response headers
    def workflow_scheduled_list_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_scheduled_list ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_scheduled_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.workflow_scheduled_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'workflow_id'].nil? && opts[:'workflow_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"workflow_id"]" when calling WorkflowApi.workflow_scheduled_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_workflow_run_id'].nil? && opts[:'parent_workflow_run_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"parent_workflow_run_id"]" when calling WorkflowApi.workflow_scheduled_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_workflow_run_id'].nil? && opts[:'parent_workflow_run_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"parent_workflow_run_id"]" when calling WorkflowApi.workflow_scheduled_list, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_step_run_id'].nil? && opts[:'parent_step_run_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"parent_step_run_id"]" when calling WorkflowApi.workflow_scheduled_list, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'parent_step_run_id'].nil? && opts[:'parent_step_run_id'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"parent_step_run_id"]" when calling WorkflowApi.workflow_scheduled_list, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/scheduled'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
      query_params[:'orderByField'] = opts[:'order_by_field'] if !opts[:'order_by_field'].nil?
      query_params[:'orderByDirection'] = opts[:'order_by_direction'] if !opts[:'order_by_direction'].nil?
      query_params[:'workflowId'] = opts[:'workflow_id'] if !opts[:'workflow_id'].nil?
      query_params[:'parentWorkflowRunId'] = opts[:'parent_workflow_run_id'] if !opts[:'parent_workflow_run_id'].nil?
      query_params[:'parentStepRunId'] = opts[:'parent_step_run_id'] if !opts[:'parent_step_run_id'].nil?
      query_params[:'additionalMetadata'] = @api_client.build_collection_param(opts[:'additional_metadata'], :multi) if !opts[:'additional_metadata'].nil?
      query_params[:'statuses'] = @api_client.build_collection_param(opts[:'statuses'], :multi) if !opts[:'statuses'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'ScheduledWorkflowsList'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_scheduled_list",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_scheduled_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Update scheduled workflow run
    # Update (reschedule) a scheduled workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflow_run [String] The scheduled workflow id
    # @param update_scheduled_workflow_run_request [UpdateScheduledWorkflowRunRequest] The input to reschedule the workflow run
    # @param [Hash] opts the optional parameters
    # @return [ScheduledWorkflows]
    def workflow_scheduled_update(tenant, scheduled_workflow_run, update_scheduled_workflow_run_request, opts = {})
      data, _status_code, _headers = workflow_scheduled_update_with_http_info(tenant, scheduled_workflow_run, update_scheduled_workflow_run_request, opts)
      data
    end

    # Update scheduled workflow run
    # Update (reschedule) a scheduled workflow run for a tenant
    # @param tenant [String] The tenant id
    # @param scheduled_workflow_run [String] The scheduled workflow id
    # @param update_scheduled_workflow_run_request [UpdateScheduledWorkflowRunRequest] The input to reschedule the workflow run
    # @param [Hash] opts the optional parameters
    # @return [Array<(ScheduledWorkflows, Integer, Hash)>] ScheduledWorkflows data, response status code and response headers
    def workflow_scheduled_update_with_http_info(tenant, scheduled_workflow_run, update_scheduled_workflow_run_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_scheduled_update ...'
      end
      # verify the required parameter 'tenant' is set
      if @api_client.config.client_side_validation && tenant.nil?
        fail ArgumentError, "Missing the required parameter 'tenant' when calling WorkflowApi.workflow_scheduled_update"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_update, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && tenant.to_s.length < 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowApi.workflow_scheduled_update, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'scheduled_workflow_run' is set
      if @api_client.config.client_side_validation && scheduled_workflow_run.nil?
        fail ArgumentError, "Missing the required parameter 'scheduled_workflow_run' when calling WorkflowApi.workflow_scheduled_update"
      end
      if @api_client.config.client_side_validation && scheduled_workflow_run.to_s.length > 36
        fail ArgumentError, 'invalid value for "scheduled_workflow_run" when calling WorkflowApi.workflow_scheduled_update, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && scheduled_workflow_run.to_s.length < 36
        fail ArgumentError, 'invalid value for "scheduled_workflow_run" when calling WorkflowApi.workflow_scheduled_update, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'update_scheduled_workflow_run_request' is set
      if @api_client.config.client_side_validation && update_scheduled_workflow_run_request.nil?
        fail ArgumentError, "Missing the required parameter 'update_scheduled_workflow_run_request' when calling WorkflowApi.workflow_scheduled_update"
      end
      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/workflows/scheduled/{scheduled-workflow-run}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'scheduled-workflow-run' + '}', CGI.escape(scheduled_workflow_run.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(update_scheduled_workflow_run_request)

      # return_type
      return_type = opts[:debug_return_type] || 'ScheduledWorkflows'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_scheduled_update",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_scheduled_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Update workflow
    # Update a workflow for a tenant
    # @param workflow [String] The workflow id
    # @param workflow_update_request [WorkflowUpdateRequest] The input to update the workflow
    # @param [Hash] opts the optional parameters
    # @return [Workflow]
    def workflow_update(workflow, workflow_update_request, opts = {})
      data, _status_code, _headers = workflow_update_with_http_info(workflow, workflow_update_request, opts)
      data
    end

    # Update workflow
    # Update a workflow for a tenant
    # @param workflow [String] The workflow id
    # @param workflow_update_request [WorkflowUpdateRequest] The input to update the workflow
    # @param [Hash] opts the optional parameters
    # @return [Array<(Workflow, Integer, Hash)>] Workflow data, response status code and response headers
    def workflow_update_with_http_info(workflow, workflow_update_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_update ...'
      end
      # verify the required parameter 'workflow' is set
      if @api_client.config.client_side_validation && workflow.nil?
        fail ArgumentError, "Missing the required parameter 'workflow' when calling WorkflowApi.workflow_update"
      end
      if @api_client.config.client_side_validation && workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_update, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_update, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'workflow_update_request' is set
      if @api_client.config.client_side_validation && workflow_update_request.nil?
        fail ArgumentError, "Missing the required parameter 'workflow_update_request' when calling WorkflowApi.workflow_update"
      end
      # resource path
      local_var_path = '/api/v1/workflows/{workflow}'.sub('{' + 'workflow' + '}', CGI.escape(workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
      # HTTP header 'Content-Type'
      content_type = @api_client.select_header_content_type(['application/json'])
      if !content_type.nil?
          header_params['Content-Type'] = content_type
      end

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body] || @api_client.object_to_http_body(workflow_update_request)

      # return_type
      return_type = opts[:debug_return_type] || 'Workflow'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_update",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow version
    # Get a workflow version for a tenant
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @option opts [String] :version The workflow version. If not supplied, the latest version is fetched.
    # @return [WorkflowVersion]
    def workflow_version_get(workflow, opts = {})
      data, _status_code, _headers = workflow_version_get_with_http_info(workflow, opts)
      data
    end

    # Get workflow version
    # Get a workflow version for a tenant
    # @param workflow [String] The workflow id
    # @param [Hash] opts the optional parameters
    # @option opts [String] :version The workflow version. If not supplied, the latest version is fetched.
    # @return [Array<(WorkflowVersion, Integer, Hash)>] WorkflowVersion data, response status code and response headers
    def workflow_version_get_with_http_info(workflow, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowApi.workflow_version_get ...'
      end
      # verify the required parameter 'workflow' is set
      if @api_client.config.client_side_validation && workflow.nil?
        fail ArgumentError, "Missing the required parameter 'workflow' when calling WorkflowApi.workflow_version_get"
      end
      if @api_client.config.client_side_validation && workflow.to_s.length > 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_version_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && workflow.to_s.length < 36
        fail ArgumentError, 'invalid value for "workflow" when calling WorkflowApi.workflow_version_get, the character length must be greater than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'version'].nil? && opts[:'version'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"version"]" when calling WorkflowApi.workflow_version_get, the character length must be smaller than or equal to 36.'
      end

      if @api_client.config.client_side_validation && !opts[:'version'].nil? && opts[:'version'].to_s.length < 36
        fail ArgumentError, 'invalid value for "opts[:"version"]" when calling WorkflowApi.workflow_version_get, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/workflows/{workflow}/versions'.sub('{' + 'workflow' + '}', CGI.escape(workflow.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'version'] = opts[:'version'] if !opts[:'version'].nil?

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

      # form parameters
      form_params = opts[:form_params] || {}

      # http body (model)
      post_body = opts[:debug_body]

      # return_type
      return_type = opts[:debug_return_type] || 'WorkflowVersion'

      # auth_names
      auth_names = opts[:debug_auth_names] || ['cookieAuth', 'bearerAuth']

      new_options = opts.merge(
        :operation => :"WorkflowApi.workflow_version_get",
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => return_type
      )

      data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: WorkflowApi#workflow_version_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
