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

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # We return the version for the currently running server
    # Get the version of the server
    # @param [Hash] opts the optional parameters
    # @return [InfoGetVersion200Response]
    def info_get_version(opts = {})
      data, _status_code, _headers = info_get_version_with_http_info(opts)
      data
    end

    # We return the version for the currently running server
    # Get the version of the server
    # @param [Hash] opts the optional parameters
    # @return [Array<(InfoGetVersion200Response, Integer, Hash)>] InfoGetVersion200Response data, response status code and response headers
    def info_get_version_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DefaultApi.info_get_version ...'
      end
      # resource path
      local_var_path = '/api/v1/version'

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

      # auth_names
      auth_names = opts[:debug_auth_names] || []

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

    # Detailed Health Probe For the Instance
    # Triggers a workflow to check the status of the instance
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def monitoring_post_run_probe(tenant, opts = {})
      monitoring_post_run_probe_with_http_info(tenant, opts)
      nil
    end

    # Detailed Health Probe For the Instance
    # Triggers a workflow to check the status of the instance
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def monitoring_post_run_probe_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DefaultApi.monitoring_post_run_probe ...'
      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 DefaultApi.monitoring_post_run_probe"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling DefaultApi.monitoring_post_run_probe, 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 DefaultApi.monitoring_post_run_probe, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/monitoring/{tenant}/probe'.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']

      # 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 => :"DefaultApi.monitoring_post_run_probe",
        :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: DefaultApi#monitoring_post_run_probe\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # Delete invite
    # Deletes a tenant invite
    # @param tenant [String] The tenant id
    # @param tenant_invite [String] The tenant invite id
    # @param [Hash] opts the optional parameters
    # @return [TenantInvite]
    def tenant_invite_delete(tenant, tenant_invite, opts = {})
      data, _status_code, _headers = tenant_invite_delete_with_http_info(tenant, tenant_invite, opts)
      data
    end

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

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

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

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/invites/{tenant-invite}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'tenant-invite' + '}', CGI.escape(tenant_invite.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] || 'TenantInvite'

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

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

    # Update invite
    # Updates a tenant invite
    # @param tenant [String] The tenant id
    # @param tenant_invite [String] The tenant invite id
    # @param update_tenant_invite_request [UpdateTenantInviteRequest] The tenant invite to update
    # @param [Hash] opts the optional parameters
    # @return [TenantInvite]
    def tenant_invite_update(tenant, tenant_invite, update_tenant_invite_request, opts = {})
      data, _status_code, _headers = tenant_invite_update_with_http_info(tenant, tenant_invite, update_tenant_invite_request, opts)
      data
    end

    # Update invite
    # Updates a tenant invite
    # @param tenant [String] The tenant id
    # @param tenant_invite [String] The tenant invite id
    # @param update_tenant_invite_request [UpdateTenantInviteRequest] The tenant invite to update
    # @param [Hash] opts the optional parameters
    # @return [Array<(TenantInvite, Integer, Hash)>] TenantInvite data, response status code and response headers
    def tenant_invite_update_with_http_info(tenant, tenant_invite, update_tenant_invite_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DefaultApi.tenant_invite_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 DefaultApi.tenant_invite_update"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling DefaultApi.tenant_invite_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 DefaultApi.tenant_invite_update, the character length must be greater than or equal to 36.'
      end

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

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

      # verify the required parameter 'update_tenant_invite_request' is set
      if @api_client.config.client_side_validation && update_tenant_invite_request.nil?
        fail ArgumentError, "Missing the required parameter 'update_tenant_invite_request' when calling DefaultApi.tenant_invite_update"
      end
      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/invites/{tenant-invite}'.sub('{' + 'tenant' + '}', CGI.escape(tenant.to_s)).sub('{' + 'tenant-invite' + '}', CGI.escape(tenant_invite.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_tenant_invite_request)

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

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

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

    # Create a webhook
    # Creates a webhook
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [WebhookWorkerCreateRequest] :webhook_worker_create_request
    # @return [WebhookWorkerCreated]
    def webhook_create(tenant, opts = {})
      data, _status_code, _headers = webhook_create_with_http_info(tenant, opts)
      data
    end

    # Create a webhook
    # Creates a webhook
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @option opts [WebhookWorkerCreateRequest] :webhook_worker_create_request
    # @return [Array<(WebhookWorkerCreated, Integer, Hash)>] WebhookWorkerCreated data, response status code and response headers
    def webhook_create_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DefaultApi.webhook_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 DefaultApi.webhook_create"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling DefaultApi.webhook_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 DefaultApi.webhook_create, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/webhook-workers'.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(opts[:'webhook_worker_create_request'])

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

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

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

    # Delete a webhook
    # Deletes a webhook
    # @param webhook [String] The webhook id
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def webhook_delete(webhook, opts = {})
      webhook_delete_with_http_info(webhook, opts)
      nil
    end

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

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

      # resource path
      local_var_path = '/api/v1/webhook-workers/{webhook}'.sub('{' + 'webhook' + '}', CGI.escape(webhook.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 => :"DefaultApi.webhook_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: DefaultApi#webhook_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end

    # List webhooks
    # Lists all webhooks
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @return [WebhookWorkerListResponse]
    def webhook_list(tenant, opts = {})
      data, _status_code, _headers = webhook_list_with_http_info(tenant, opts)
      data
    end

    # List webhooks
    # Lists all webhooks
    # @param tenant [String] The tenant id
    # @param [Hash] opts the optional parameters
    # @return [Array<(WebhookWorkerListResponse, Integer, Hash)>] WebhookWorkerListResponse data, response status code and response headers
    def webhook_list_with_http_info(tenant, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: DefaultApi.webhook_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 DefaultApi.webhook_list"
      end
      if @api_client.config.client_side_validation && tenant.to_s.length > 36
        fail ArgumentError, 'invalid value for "tenant" when calling DefaultApi.webhook_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 DefaultApi.webhook_list, the character length must be greater than or equal to 36.'
      end

      # resource path
      local_var_path = '/api/v1/tenants/{tenant}/webhook-workers'.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']

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

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

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

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

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

    # List webhook requests
    # Lists all requests for a webhook
    # @param webhook [String] The webhook id
    # @param [Hash] opts the optional parameters
    # @return [WebhookWorkerRequestListResponse]
    def webhook_requests_list(webhook, opts = {})
      data, _status_code, _headers = webhook_requests_list_with_http_info(webhook, opts)
      data
    end

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

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

      # resource path
      local_var_path = '/api/v1/webhook-workers/{webhook}/requests'.sub('{' + 'webhook' + '}', CGI.escape(webhook.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] || 'WebhookWorkerRequestListResponse'

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

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