=begin
#Spinnaker API

#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)

OpenAPI spec version: 1.0.0

Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.7

=end

require 'uri'

module SwaggerClient
  class ExecutionsControllerApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Retrieves an ad-hoc collection of executions based on a number of user-supplied parameters. Either executionIds or pipelineConfigIds must be supplied in order to return any results. If both are supplied, an exception will be thrown.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :pipeline_config_ids A comma-separated list of pipeline configuration IDs to retrieve recent executions for. Either this OR pipelineConfigIds must be supplied, but not both.
    # @option opts [String] :execution_ids A comma-separated list of executions to retrieve. Either this OR pipelineConfigIds must be supplied, but not both.
    # @option opts [Integer] :limit The number of executions to return per pipeline configuration. Ignored if executionIds parameter is supplied. If this value is missing, it is defaulted to 1.
    # @option opts [String] :statuses A comma-separated list of execution statuses to filter by. Ignored if executionIds parameter is supplied. If this value is missing, it is defaulted to all statuses.
    # @option opts [BOOLEAN] :expand Expands each execution object in the resulting list. If this value is missing, it is defaulted to true. (default to true)
    # @return [Array<Object>]
    def get_latest_executions_by_config_ids_using_get(opts = {})
      data, _status_code, _headers = get_latest_executions_by_config_ids_using_get_with_http_info(opts)
      data
    end

    # Retrieves an ad-hoc collection of executions based on a number of user-supplied parameters. Either executionIds or pipelineConfigIds must be supplied in order to return any results. If both are supplied, an exception will be thrown.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :pipeline_config_ids A comma-separated list of pipeline configuration IDs to retrieve recent executions for. Either this OR pipelineConfigIds must be supplied, but not both.
    # @option opts [String] :execution_ids A comma-separated list of executions to retrieve. Either this OR pipelineConfigIds must be supplied, but not both.
    # @option opts [Integer] :limit The number of executions to return per pipeline configuration. Ignored if executionIds parameter is supplied. If this value is missing, it is defaulted to 1.
    # @option opts [String] :statuses A comma-separated list of execution statuses to filter by. Ignored if executionIds parameter is supplied. If this value is missing, it is defaulted to all statuses.
    # @option opts [BOOLEAN] :expand Expands each execution object in the resulting list. If this value is missing, it is defaulted to true.
    # @return [Array<(Array<Object>, Fixnum, Hash)>] Array<Object> data, response status code and response headers
    def get_latest_executions_by_config_ids_using_get_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ExecutionsControllerApi.get_latest_executions_by_config_ids_using_get ...'
      end
      # resource path
      local_var_path = '/executions'

      # query parameters
      query_params = {}
      query_params[:'pipelineConfigIds'] = opts[:'pipeline_config_ids'] if !opts[:'pipeline_config_ids'].nil?
      query_params[:'executionIds'] = opts[:'execution_ids'] if !opts[:'execution_ids'].nil?
      query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
      query_params[:'statuses'] = opts[:'statuses'] if !opts[:'statuses'].nil?
      query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?

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

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = []
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'Array<Object>')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: ExecutionsControllerApi#get_latest_executions_by_config_ids_using_get\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Search for pipeline executions using a combination of criteria. The returned list is sorted by buildTime (trigger time) in reverse order so that newer executions are first in the list.
    # @param application Only includes executions that are part of this application. If this value is \&quot;*\&quot;, results will include executions of all applications.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :trigger_types Only includes executions that were triggered by a trigger with a type that is equal to a type provided in this field. The list of trigger types should be a comma-delimited string. If this value is missing, results will includes executions of all trigger types.
    # @option opts [String] :pipeline_name Only includes executions that with this pipeline name.
    # @option opts [String] :event_id Only includes executions that were triggered by a trigger with this eventId.
    # @option opts [String] :trigger Only includes executions that were triggered by a trigger that matches the subset of fields provided by this value. This value should be a base64-encoded string of a JSON representation of a trigger object. The comparison succeeds if the execution trigger contains all the fields of the input trigger, the fields are of the same type, and each value of the field \&quot;matches\&quot;. The term \&quot;matches\&quot; is specific for each field&#39;s type: - For Strings: A String value in the execution&#39;s trigger matches the input trigger&#39;s String value if the former equals the latter (case-insensitive) OR if the former matches the latter as a regular expression. - For Maps: A Map value in the execution&#39;s trigger matches the input trigger&#39;s Map value if the former contains all keys of the latter and their values match. - For Collections: A Collection value in the execution&#39;s trigger matches the input trigger&#39;s Collection value if the former has a unique element that matches each element of the latter. - Every other value is compared using the Java \&quot;equals\&quot; method (Groovy \&quot;&#x3D;&#x3D;\&quot; operator)
    # @option opts [Integer] :trigger_time_start_boundary Only includes executions that were built at or after the given time, represented as a Unix timestamp in ms (UTC). This value must be &gt;&#x3D; 0 and &lt;&#x3D; the value of [triggerTimeEndBoundary], if provided. If this value is missing, it is defaulted to 0. (default to 0)
    # @option opts [Integer] :trigger_time_end_boundary Only includes executions that were built at or before the given time, represented as a Unix timestamp in ms (UTC). This value must be &lt;&#x3D; 9223372036854775807 (Long.MAX_VALUE) and &gt;&#x3D; the value of [triggerTimeStartBoundary], if provided. If this value is missing, it is defaulted to 9223372036854775807.
    # @option opts [String] :statuses Only includes executions with a status that is equal to a status provided in this field. The list of statuses should be given as a comma-delimited string. If this value is missing, includes executions of all statuses. Allowed statuses are: NOT_STARTED, RUNNING, PAUSED, SUSPENDED, SUCCEEDED, FAILED_CONTINUE, TERMINAL, CANCELED, REDIRECT, STOPPED, SKIPPED, BUFFERED.
    # @option opts [Integer] :start_index Sets the first item of the resulting list for pagination. The list is 0-indexed. This value must be &gt;&#x3D; 0. If this value is missing, it is defaulted to 0. (default to 0)
    # @option opts [Integer] :size Sets the size of the resulting list for pagination. This value must be &gt; 0. If this value is missing, it is defaulted to 10. (default to 10)
    # @option opts [BOOLEAN] :reverse Reverses the resulting list before it is paginated. If this value is missing, it is defaulted to false. (default to false)
    # @option opts [BOOLEAN] :expand Expands each execution object in the resulting list. If this value is missing, it is defaulted to false. (default to false)
    # @return [Array<Object>]
    def search_for_pipeline_executions_by_trigger_using_get(application, opts = {})
      data, _status_code, _headers = search_for_pipeline_executions_by_trigger_using_get_with_http_info(application, opts)
      data
    end

    # Search for pipeline executions using a combination of criteria. The returned list is sorted by buildTime (trigger time) in reverse order so that newer executions are first in the list.
    # @param application Only includes executions that are part of this application. If this value is \&quot;*\&quot;, results will include executions of all applications.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :trigger_types Only includes executions that were triggered by a trigger with a type that is equal to a type provided in this field. The list of trigger types should be a comma-delimited string. If this value is missing, results will includes executions of all trigger types.
    # @option opts [String] :pipeline_name Only includes executions that with this pipeline name.
    # @option opts [String] :event_id Only includes executions that were triggered by a trigger with this eventId.
    # @option opts [String] :trigger Only includes executions that were triggered by a trigger that matches the subset of fields provided by this value. This value should be a base64-encoded string of a JSON representation of a trigger object. The comparison succeeds if the execution trigger contains all the fields of the input trigger, the fields are of the same type, and each value of the field \&quot;matches\&quot;. The term \&quot;matches\&quot; is specific for each field&#39;s type: - For Strings: A String value in the execution&#39;s trigger matches the input trigger&#39;s String value if the former equals the latter (case-insensitive) OR if the former matches the latter as a regular expression. - For Maps: A Map value in the execution&#39;s trigger matches the input trigger&#39;s Map value if the former contains all keys of the latter and their values match. - For Collections: A Collection value in the execution&#39;s trigger matches the input trigger&#39;s Collection value if the former has a unique element that matches each element of the latter. - Every other value is compared using the Java \&quot;equals\&quot; method (Groovy \&quot;&#x3D;&#x3D;\&quot; operator)
    # @option opts [Integer] :trigger_time_start_boundary Only includes executions that were built at or after the given time, represented as a Unix timestamp in ms (UTC). This value must be &gt;&#x3D; 0 and &lt;&#x3D; the value of [triggerTimeEndBoundary], if provided. If this value is missing, it is defaulted to 0.
    # @option opts [Integer] :trigger_time_end_boundary Only includes executions that were built at or before the given time, represented as a Unix timestamp in ms (UTC). This value must be &lt;&#x3D; 9223372036854775807 (Long.MAX_VALUE) and &gt;&#x3D; the value of [triggerTimeStartBoundary], if provided. If this value is missing, it is defaulted to 9223372036854775807.
    # @option opts [String] :statuses Only includes executions with a status that is equal to a status provided in this field. The list of statuses should be given as a comma-delimited string. If this value is missing, includes executions of all statuses. Allowed statuses are: NOT_STARTED, RUNNING, PAUSED, SUSPENDED, SUCCEEDED, FAILED_CONTINUE, TERMINAL, CANCELED, REDIRECT, STOPPED, SKIPPED, BUFFERED.
    # @option opts [Integer] :start_index Sets the first item of the resulting list for pagination. The list is 0-indexed. This value must be &gt;&#x3D; 0. If this value is missing, it is defaulted to 0.
    # @option opts [Integer] :size Sets the size of the resulting list for pagination. This value must be &gt; 0. If this value is missing, it is defaulted to 10.
    # @option opts [BOOLEAN] :reverse Reverses the resulting list before it is paginated. If this value is missing, it is defaulted to false.
    # @option opts [BOOLEAN] :expand Expands each execution object in the resulting list. If this value is missing, it is defaulted to false.
    # @return [Array<(Array<Object>, Fixnum, Hash)>] Array<Object> data, response status code and response headers
    def search_for_pipeline_executions_by_trigger_using_get_with_http_info(application, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ExecutionsControllerApi.search_for_pipeline_executions_by_trigger_using_get ...'
      end
      # verify the required parameter 'application' is set
      if @api_client.config.client_side_validation && application.nil?
        fail ArgumentError, "Missing the required parameter 'application' when calling ExecutionsControllerApi.search_for_pipeline_executions_by_trigger_using_get"
      end
      # resource path
      local_var_path = '/applications/{application}/executions/search'.sub('{' + 'application' + '}', application.to_s)

      # query parameters
      query_params = {}
      query_params[:'triggerTypes'] = opts[:'trigger_types'] if !opts[:'trigger_types'].nil?
      query_params[:'pipelineName'] = opts[:'pipeline_name'] if !opts[:'pipeline_name'].nil?
      query_params[:'eventId'] = opts[:'event_id'] if !opts[:'event_id'].nil?
      query_params[:'trigger'] = opts[:'trigger'] if !opts[:'trigger'].nil?
      query_params[:'triggerTimeStartBoundary'] = opts[:'trigger_time_start_boundary'] if !opts[:'trigger_time_start_boundary'].nil?
      query_params[:'triggerTimeEndBoundary'] = opts[:'trigger_time_end_boundary'] if !opts[:'trigger_time_end_boundary'].nil?
      query_params[:'statuses'] = opts[:'statuses'] if !opts[:'statuses'].nil?
      query_params[:'startIndex'] = opts[:'start_index'] if !opts[:'start_index'].nil?
      query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
      query_params[:'reverse'] = opts[:'reverse'] if !opts[:'reverse'].nil?
      query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil?

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

      # form parameters
      form_params = {}

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