=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 WorkflowRunsApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Create workflow run
    # Trigger a new workflow run
    # @param tenant [String] The tenant id
    # @param v1_trigger_workflow_run_request [V1TriggerWorkflowRunRequest] The workflow run to create
    # @param [Hash] opts the optional parameters
    # @return [V1WorkflowRunDetails]
    def v1_workflow_run_create(tenant, v1_trigger_workflow_run_request, opts = {})
      data, _status_code, _headers = v1_workflow_run_create_with_http_info(tenant, v1_trigger_workflow_run_request, opts)
      data
    end

    # Create workflow run
    # Trigger a new workflow run
    # @param tenant [String] The tenant id
    # @param v1_trigger_workflow_run_request [V1TriggerWorkflowRunRequest] The workflow run to create
    # @param [Hash] opts the optional parameters
    # @return [Array<(V1WorkflowRunDetails, Integer, Hash)>] V1WorkflowRunDetails data, response status code and response headers
    def v1_workflow_run_create_with_http_info(tenant, v1_trigger_workflow_run_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowRunsApi.v1_workflow_run_create ...'
      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 WorkflowRunsApi.v1_workflow_run_create"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowRunsApi.v1_workflow_run_create, 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 WorkflowRunsApi.v1_workflow_run_create, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'v1_trigger_workflow_run_request' is set
      if @api_client.config.client_side_validation && v1_trigger_workflow_run_request.nil?
        fail ArgumentError, "Missing the required parameter 'v1_trigger_workflow_run_request' when calling WorkflowRunsApi.v1_workflow_run_create"
      end
      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/workflow-runs/trigger'.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(v1_trigger_workflow_run_request)

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

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_workflow_run_create",
        :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: WorkflowRunsApi#v1_workflow_run_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List workflow runs
    # Lists displayable names of workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param external_ids [Array<String>] The external ids of the workflow runs to get display names for
    # @param [Hash] opts the optional parameters
    # @return [V1WorkflowRunDisplayNameList]
    def v1_workflow_run_display_names_list(tenant, external_ids, opts = {})
      data, _status_code, _headers = v1_workflow_run_display_names_list_with_http_info(tenant, external_ids, opts)
      data
    end

    # List workflow runs
    # Lists displayable names of workflow runs for a tenant
    # @param tenant [String] The tenant id
    # @param external_ids [Array<String>] The external ids of the workflow runs to get display names for
    # @param [Hash] opts the optional parameters
    # @return [Array<(V1WorkflowRunDisplayNameList, Integer, Hash)>] V1WorkflowRunDisplayNameList data, response status code and response headers
    def v1_workflow_run_display_names_list_with_http_info(tenant, external_ids, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowRunsApi.v1_workflow_run_display_names_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 WorkflowRunsApi.v1_workflow_run_display_names_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowRunsApi.v1_workflow_run_display_names_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 WorkflowRunsApi.v1_workflow_run_display_names_list, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'external_ids' is set
      if @api_client.config.client_side_validation && external_ids.nil?
        fail ArgumentError, "Missing the required parameter 'external_ids' when calling WorkflowRunsApi.v1_workflow_run_display_names_list"
      end
      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/workflow-runs/display-names'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'external_ids'] = @api_client.build_collection_param(external_ids, :multi)

      # 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] || 'V1WorkflowRunDisplayNameList'

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_workflow_run_display_names_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: WorkflowRunsApi#v1_workflow_run_display_names_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List workflow run external ids
    # Lists external ids for workflow runs matching filters
    # @param tenant [String] The tenant id
    # @param since [Time] The earliest date to filter by
    # @param [Hash] opts the optional parameters
    # @option opts [Array<V1TaskStatus>] :statuses A list of statuses to filter by
    # @option opts [Time] :_until The latest date to filter by
    # @option opts [Array<String>] :additional_metadata Additional metadata k-v pairs to filter by
    # @option opts [Array<String>] :workflow_ids The workflow ids to find runs for
    # @return [Array<String>]
    def v1_workflow_run_external_ids_list(tenant, since, opts = {})
      data, _status_code, _headers = v1_workflow_run_external_ids_list_with_http_info(tenant, since, opts)
      data
    end

    # List workflow run external ids
    # Lists external ids for workflow runs matching filters
    # @param tenant [String] The tenant id
    # @param since [Time] The earliest date to filter by
    # @param [Hash] opts the optional parameters
    # @option opts [Array<V1TaskStatus>] :statuses A list of statuses to filter by
    # @option opts [Time] :_until The latest date to filter by
    # @option opts [Array<String>] :additional_metadata Additional metadata k-v pairs to filter by
    # @option opts [Array<String>] :workflow_ids The workflow ids to find runs for
    # @return [Array<(Array<String>, Integer, Hash)>] Array<String> data, response status code and response headers
    def v1_workflow_run_external_ids_list_with_http_info(tenant, since, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowRunsApi.v1_workflow_run_external_ids_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 WorkflowRunsApi.v1_workflow_run_external_ids_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowRunsApi.v1_workflow_run_external_ids_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 WorkflowRunsApi.v1_workflow_run_external_ids_list, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'since' is set
      if @api_client.config.client_side_validation && since.nil?
        fail ArgumentError, "Missing the required parameter 'since' when calling WorkflowRunsApi.v1_workflow_run_external_ids_list"
      end
      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/workflow-runs/external-ids'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'since'] = since
      query_params[:'statuses'] = @api_client.build_collection_param(opts[:'statuses'], :multi) if !opts[:'statuses'].nil?
      query_params[:'until'] = opts[:'_until'] if !opts[:'_until'].nil?
      query_params[:'additional_metadata'] = @api_client.build_collection_param(opts[:'additional_metadata'], :multi) if !opts[:'additional_metadata'].nil?
      query_params[:'workflow_ids'] = @api_client.build_collection_param(opts[:'workflow_ids'], :multi) if !opts[:'workflow_ids'].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] || 'Array<String>'

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_workflow_run_external_ids_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: WorkflowRunsApi#v1_workflow_run_external_ids_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List tasks
    # Get a workflow run and its metadata to display on the \"detail\" page
    # @param v1_workflow_run [String] The workflow run id to get
    # @param [Hash] opts the optional parameters
    # @return [V1WorkflowRunDetails]
    def v1_workflow_run_get(v1_workflow_run, opts = {})
      data, _status_code, _headers = v1_workflow_run_get_with_http_info(v1_workflow_run, opts)
      data
    end

    # List tasks
    # Get a workflow run and its metadata to display on the \&quot;detail\&quot; page
    # @param v1_workflow_run [String] The workflow run id to get
    # @param [Hash] opts the optional parameters
    # @return [Array<(V1WorkflowRunDetails, Integer, Hash)>] V1WorkflowRunDetails data, response status code and response headers
    def v1_workflow_run_get_with_http_info(v1_workflow_run, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowRunsApi.v1_workflow_run_get ...'
      end
      # verify the required parameter 'v1_workflow_run' is set
      if @api_client.config.client_side_validation && v1_workflow_run.nil?
        fail ArgumentError, "Missing the required parameter 'v1_workflow_run' when calling WorkflowRunsApi.v1_workflow_run_get"
      end
      if @api_client.config.client_side_validation && v1_workflow_run.to_s.length > 36
        fail ArgumentError, 'invalid value for "v1_workflow_run" when calling WorkflowRunsApi.v1_workflow_run_get, the character length must be smaller than or equal to 36.'
      end

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

      # resource path
      local_var_path = '/api/v1/stable/workflow-runs/{v1-workflow-run}'.sub('{' + 'v1-workflow-run' + '}', CGI.escape(v1_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] || 'V1WorkflowRunDetails'

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_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: WorkflowRunsApi#v1_workflow_run_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Get workflow run status
    # Get the status of a workflow run.
    # @param v1_workflow_run [String] The workflow run id to get the status for
    # @param [Hash] opts the optional parameters
    # @return [V1TaskStatus]
    def v1_workflow_run_get_status(v1_workflow_run, opts = {})
      data, _status_code, _headers = v1_workflow_run_get_status_with_http_info(v1_workflow_run, opts)
      data
    end

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

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

      # resource path
      local_var_path = '/api/v1/stable/workflow-runs/{v1-workflow-run}/status'.sub('{' + 'v1-workflow-run' + '}', CGI.escape(v1_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] || 'V1TaskStatus'

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_workflow_run_get_status",
        :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: WorkflowRunsApi#v1_workflow_run_get_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List timings for a workflow run
    # Get the timings for a workflow run
    # @param v1_workflow_run [String] The workflow run id to get
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :depth The depth to retrieve children
    # @return [V1TaskTimingList]
    def v1_workflow_run_get_timings(v1_workflow_run, opts = {})
      data, _status_code, _headers = v1_workflow_run_get_timings_with_http_info(v1_workflow_run, opts)
      data
    end

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

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

      # resource path
      local_var_path = '/api/v1/stable/workflow-runs/{v1-workflow-run}/task-timings'.sub('{' + 'v1-workflow-run' + '}', CGI.escape(v1_workflow_run.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'depth'] = opts[:'depth'] if !opts[:'depth'].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] || 'V1TaskTimingList'

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_workflow_run_get_timings",
        :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: WorkflowRunsApi#v1_workflow_run_get_timings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List workflow runs
    # Lists workflow runs for a tenant.
    # @param tenant [String] The tenant id
    # @param since [Time] The earliest date to filter by
    # @param only_tasks [Boolean] Whether to include DAGs or only to include tasks
    # @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 [Array<V1TaskStatus>] :statuses A list of statuses to filter by
    # @option opts [Time] :_until The latest date to filter by
    # @option opts [Array<String>] :additional_metadata Additional metadata k-v pairs to filter by
    # @option opts [Array<String>] :workflow_ids The workflow ids to find runs for
    # @option opts [String] :worker_id The worker id to filter by
    # @option opts [String] :parent_task_external_id The parent task external id to filter by
    # @option opts [String] :triggering_event_external_id The external id of the event that triggered the workflow run
    # @option opts [Boolean] :include_payloads A flag for whether or not to include the input and output payloads in the response. Defaults to &#x60;true&#x60; if unset.
    # @return [V1TaskSummaryList]
    def v1_workflow_run_list(tenant, since, only_tasks, opts = {})
      data, _status_code, _headers = v1_workflow_run_list_with_http_info(tenant, since, only_tasks, opts)
      data
    end

    # List workflow runs
    # Lists workflow runs for a tenant.
    # @param tenant [String] The tenant id
    # @param since [Time] The earliest date to filter by
    # @param only_tasks [Boolean] Whether to include DAGs or only to include tasks
    # @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 [Array<V1TaskStatus>] :statuses A list of statuses to filter by
    # @option opts [Time] :_until The latest date to filter by
    # @option opts [Array<String>] :additional_metadata Additional metadata k-v pairs to filter by
    # @option opts [Array<String>] :workflow_ids The workflow ids to find runs for
    # @option opts [String] :worker_id The worker id to filter by
    # @option opts [String] :parent_task_external_id The parent task external id to filter by
    # @option opts [String] :triggering_event_external_id The external id of the event that triggered the workflow run
    # @option opts [Boolean] :include_payloads A flag for whether or not to include the input and output payloads in the response. Defaults to &#x60;true&#x60; if unset.
    # @return [Array<(V1TaskSummaryList, Integer, Hash)>] V1TaskSummaryList data, response status code and response headers
    def v1_workflow_run_list_with_http_info(tenant, since, only_tasks, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowRunsApi.v1_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 WorkflowRunsApi.v1_workflow_run_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling WorkflowRunsApi.v1_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 WorkflowRunsApi.v1_workflow_run_list, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'since' is set
      if @api_client.config.client_side_validation && since.nil?
        fail ArgumentError, "Missing the required parameter 'since' when calling WorkflowRunsApi.v1_workflow_run_list"
      end
      # verify the required parameter 'only_tasks' is set
      if @api_client.config.client_side_validation && only_tasks.nil?
        fail ArgumentError, "Missing the required parameter 'only_tasks' when calling WorkflowRunsApi.v1_workflow_run_list"
      end
      if @api_client.config.client_side_validation && !opts[:'worker_id'].nil? && opts[:'worker_id'].to_s.length > 36
        fail ArgumentError, 'invalid value for "opts[:"worker_id"]" when calling WorkflowRunsApi.v1_workflow_run_list, the character length must be smaller than or equal to 36.'
      end

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

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

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

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

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

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

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'since'] = since
      query_params[:'only_tasks'] = only_tasks
      query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
      query_params[:'statuses'] = @api_client.build_collection_param(opts[:'statuses'], :multi) if !opts[:'statuses'].nil?
      query_params[:'until'] = opts[:'_until'] if !opts[:'_until'].nil?
      query_params[:'additional_metadata'] = @api_client.build_collection_param(opts[:'additional_metadata'], :multi) if !opts[:'additional_metadata'].nil?
      query_params[:'workflow_ids'] = @api_client.build_collection_param(opts[:'workflow_ids'], :multi) if !opts[:'workflow_ids'].nil?
      query_params[:'worker_id'] = opts[:'worker_id'] if !opts[:'worker_id'].nil?
      query_params[:'parent_task_external_id'] = opts[:'parent_task_external_id'] if !opts[:'parent_task_external_id'].nil?
      query_params[:'triggering_event_external_id'] = opts[:'triggering_event_external_id'] if !opts[:'triggering_event_external_id'].nil?
      query_params[:'include_payloads'] = opts[:'include_payloads'] if !opts[:'include_payloads'].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] || 'V1TaskSummaryList'

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_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: WorkflowRunsApi#v1_workflow_run_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List tasks
    # List all tasks for a workflow run
    # @param v1_workflow_run [String] The workflow run id to find runs for
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @return [V1TaskEventList]
    def v1_workflow_run_task_events_list(v1_workflow_run, opts = {})
      data, _status_code, _headers = v1_workflow_run_task_events_list_with_http_info(v1_workflow_run, opts)
      data
    end

    # List tasks
    # List all tasks for a workflow run
    # @param v1_workflow_run [String] The workflow run id to find runs for
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :offset The number to skip
    # @option opts [Integer] :limit The number to limit by
    # @return [Array<(V1TaskEventList, Integer, Hash)>] V1TaskEventList data, response status code and response headers
    def v1_workflow_run_task_events_list_with_http_info(v1_workflow_run, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: WorkflowRunsApi.v1_workflow_run_task_events_list ...'
      end
      # verify the required parameter 'v1_workflow_run' is set
      if @api_client.config.client_side_validation && v1_workflow_run.nil?
        fail ArgumentError, "Missing the required parameter 'v1_workflow_run' when calling WorkflowRunsApi.v1_workflow_run_task_events_list"
      end
      if @api_client.config.client_side_validation && v1_workflow_run.to_s.length > 36
        fail ArgumentError, 'invalid value for "v1_workflow_run" when calling WorkflowRunsApi.v1_workflow_run_task_events_list, the character length must be smaller than or equal to 36.'
      end

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

      # resource path
      local_var_path = '/api/v1/stable/workflow-runs/{v1-workflow-run}/task-events'.sub('{' + 'v1-workflow-run' + '}', CGI.escape(v1_workflow_run.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?

      # 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] || 'V1TaskEventList'

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

      new_options = opts.merge(
        :operation => :"WorkflowRunsApi.v1_workflow_run_task_events_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: WorkflowRunsApi#v1_workflow_run_task_events_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
