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

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Create a filter
    # Create a new filter
    # @param tenant [String] The tenant id
    # @param v1_create_filter_request [V1CreateFilterRequest] The input to the filter creation
    # @param [Hash] opts the optional parameters
    # @return [V1Filter]
    def v1_filter_create(tenant, v1_create_filter_request, opts = {})
      data, _status_code, _headers = v1_filter_create_with_http_info(tenant, v1_create_filter_request, opts)
      data
    end

    # Create a filter
    # Create a new filter
    # @param tenant [String] The tenant id
    # @param v1_create_filter_request [V1CreateFilterRequest] The input to the filter creation
    # @param [Hash] opts the optional parameters
    # @return [Array<(V1Filter, Integer, Hash)>] V1Filter data, response status code and response headers
    def v1_filter_create_with_http_info(tenant, v1_create_filter_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: FilterApi.v1_filter_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 FilterApi.v1_filter_create"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling FilterApi.v1_filter_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 FilterApi.v1_filter_create, the character length must be greater than or equal to 36.'
      end

      # verify the required parameter 'v1_create_filter_request' is set
      if @api_client.config.client_side_validation && v1_create_filter_request.nil?
        fail ArgumentError, "Missing the required parameter 'v1_create_filter_request' when calling FilterApi.v1_filter_create"
      end
      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/filters'.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_create_filter_request)

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

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

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

    # Delete a filter
    # @param tenant [String] The tenant id
    # @param v1_filter [String] The filter id to delete
    # @param [Hash] opts the optional parameters
    # @return [V1Filter]
    def v1_filter_delete(tenant, v1_filter, opts = {})
      data, _status_code, _headers = v1_filter_delete_with_http_info(tenant, v1_filter, opts)
      data
    end

    # Delete a filter
    # @param tenant [String] The tenant id
    # @param v1_filter [String] The filter id to delete
    # @param [Hash] opts the optional parameters
    # @return [Array<(V1Filter, Integer, Hash)>] V1Filter data, response status code and response headers
    def v1_filter_delete_with_http_info(tenant, v1_filter, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: FilterApi.v1_filter_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 FilterApi.v1_filter_delete"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling FilterApi.v1_filter_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 FilterApi.v1_filter_delete, the character length must be greater than or equal to 36.'
      end

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

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

      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/filters/{v1-filter}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'v1-filter' + '}', CGI.escape(v1_filter.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] || 'V1Filter'

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

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

    # Get a filter
    # Get a filter by its id
    # @param tenant [String] The tenant id
    # @param v1_filter [String] The filter id
    # @param [Hash] opts the optional parameters
    # @return [V1Filter]
    def v1_filter_get(tenant, v1_filter, opts = {})
      data, _status_code, _headers = v1_filter_get_with_http_info(tenant, v1_filter, opts)
      data
    end

    # Get a filter
    # Get a filter by its id
    # @param tenant [String] The tenant id
    # @param v1_filter [String] The filter id
    # @param [Hash] opts the optional parameters
    # @return [Array<(V1Filter, Integer, Hash)>] V1Filter data, response status code and response headers
    def v1_filter_get_with_http_info(tenant, v1_filter, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: FilterApi.v1_filter_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 FilterApi.v1_filter_get"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling FilterApi.v1_filter_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 FilterApi.v1_filter_get, the character length must be greater than or equal to 36.'
      end

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

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

      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/filters/{v1-filter}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'v1-filter' + '}', CGI.escape(v1_filter.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] || 'V1Filter'

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

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

    # List filters
    # Lists all filters 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 [Array<String>] :workflow_ids The workflow ids to filter by
    # @option opts [Array<String>] :scopes The scopes to subset candidate filters by
    # @return [V1FilterList]
    def v1_filter_list(tenant, opts = {})
      data, _status_code, _headers = v1_filter_list_with_http_info(tenant, opts)
      data
    end

    # List filters
    # Lists all filters 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 [Array<String>] :workflow_ids The workflow ids to filter by
    # @option opts [Array<String>] :scopes The scopes to subset candidate filters by
    # @return [Array<(V1FilterList, Integer, Hash)>] V1FilterList data, response status code and response headers
    def v1_filter_list_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: FilterApi.v1_filter_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 FilterApi.v1_filter_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling FilterApi.v1_filter_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 FilterApi.v1_filter_list, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/filters'.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[:'workflowIds'] = @api_client.build_collection_param(opts[:'workflow_ids'], :multi) if !opts[:'workflow_ids'].nil?
      query_params[:'scopes'] = @api_client.build_collection_param(opts[:'scopes'], :multi) if !opts[:'scopes'].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] || 'V1FilterList'

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

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

    # Update a filter
    # @param tenant [String] The tenant id
    # @param v1_filter [String] The filter id to update
    # @param v1_update_filter_request [V1UpdateFilterRequest] The input to the filter update
    # @param [Hash] opts the optional parameters
    # @return [V1Filter]
    def v1_filter_update(tenant, v1_filter, v1_update_filter_request, opts = {})
      data, _status_code, _headers = v1_filter_update_with_http_info(tenant, v1_filter, v1_update_filter_request, opts)
      data
    end

    # Update a filter
    # @param tenant [String] The tenant id
    # @param v1_filter [String] The filter id to update
    # @param v1_update_filter_request [V1UpdateFilterRequest] The input to the filter update
    # @param [Hash] opts the optional parameters
    # @return [Array<(V1Filter, Integer, Hash)>] V1Filter data, response status code and response headers
    def v1_filter_update_with_http_info(tenant, v1_filter, v1_update_filter_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: FilterApi.v1_filter_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 FilterApi.v1_filter_update"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling FilterApi.v1_filter_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 FilterApi.v1_filter_update, the character length must be greater than or equal to 36.'
      end

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

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

      # verify the required parameter 'v1_update_filter_request' is set
      if @api_client.config.client_side_validation && v1_update_filter_request.nil?
        fail ArgumentError, "Missing the required parameter 'v1_update_filter_request' when calling FilterApi.v1_filter_update"
      end
      # resource path
      local_var_path = '/api/v1/stable/tenants/{tenant}/filters/{v1-filter}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'v1-filter' + '}', CGI.escape(v1_filter.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_update_filter_request)

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

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

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