=begin
#Metal API

#This is the API for Equinix Metal Product. Interact with your devices, user account, and projects.

The version of the OpenAPI document: 1.0.0
Contact: support@equinixmetal.com
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.1.0-SNAPSHOT

=end

require 'cgi'

module OpenapiClient
  class BGPApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Create a BGP session
    # Creates a BGP session.
    # @param id [String] Device UUID
    # @param bgp_session [BGPSessionInput] BGP session to create
    # @param [Hash] opts the optional parameters
    # @return [BgpSession]
    def create_bgp_session(id, bgp_session, opts = {})
      data, _status_code, _headers = create_bgp_session_with_http_info(id, bgp_session, opts)
      data
    end

    # Create a BGP session
    # Creates a BGP session.
    # @param id [String] Device UUID
    # @param bgp_session [BGPSessionInput] BGP session to create
    # @param [Hash] opts the optional parameters
    # @return [Array<(BgpSession, Integer, Hash)>] BgpSession data, response status code and response headers
    def create_bgp_session_with_http_info(id, bgp_session, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.create_bgp_session ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.create_bgp_session"
      end
      # verify the required parameter 'bgp_session' is set
      if @api_client.config.client_side_validation && bgp_session.nil?
        fail ArgumentError, "Missing the required parameter 'bgp_session' when calling BGPApi.create_bgp_session"
      end
      # resource path
      local_var_path = '/devices/{id}/bgp/sessions'.sub('{' + 'id' + '}', CGI.escape(id.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'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

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

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

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

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

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

    # Delete the BGP session
    # Deletes the BGP session.
    # @param id [String] BGP session UUID
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def delete_bgp_session(id, opts = {})
      delete_bgp_session_with_http_info(id, opts)
      nil
    end

    # Delete the BGP session
    # Deletes the BGP session.
    # @param id [String] BGP session UUID
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def delete_bgp_session_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.delete_bgp_session ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.delete_bgp_session"
      end
      # resource path
      local_var_path = '/bgp/sessions/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

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

      # header parameters
      header_params = opts[:header_params] || {}

      # 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] || ['x_auth_token']

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

    # Retrieve a bgp config
    # Returns a bgp config
    # @param id [String] Project UUID
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :include Nested attributes to include. Included objects will return their full attributes. Attribute names can be dotted (up to 3 levels) to included deeply nested objects.
    # @option opts [Array<String>] :exclude Nested attributes to exclude. Excluded objects will return only the href attribute. Attribute names can be dotted (up to 3 levels) to exclude deeply nested objects.
    # @return [BgpConfig]
    def find_bgp_config_by_project(id, opts = {})
      data, _status_code, _headers = find_bgp_config_by_project_with_http_info(id, opts)
      data
    end

    # Retrieve a bgp config
    # Returns a bgp config
    # @param id [String] Project UUID
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :include Nested attributes to include. Included objects will return their full attributes. Attribute names can be dotted (up to 3 levels) to included deeply nested objects.
    # @option opts [Array<String>] :exclude Nested attributes to exclude. Excluded objects will return only the href attribute. Attribute names can be dotted (up to 3 levels) to exclude deeply nested objects.
    # @return [Array<(BgpConfig, Integer, Hash)>] BgpConfig data, response status code and response headers
    def find_bgp_config_by_project_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.find_bgp_config_by_project ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.find_bgp_config_by_project"
      end
      # resource path
      local_var_path = '/projects/{id}/bgp-config'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?
      query_params[:'exclude'] = @api_client.build_collection_param(opts[:'exclude'], :csv) if !opts[:'exclude'].nil?

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

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

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

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

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

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

    # Retrieve a BGP session
    # Returns a BGP session
    # @param id [String] BGP session UUID
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :include Nested attributes to include. Included objects will return their full attributes. Attribute names can be dotted (up to 3 levels) to included deeply nested objects.
    # @option opts [Array<String>] :exclude Nested attributes to exclude. Excluded objects will return only the href attribute. Attribute names can be dotted (up to 3 levels) to exclude deeply nested objects.
    # @return [BgpSession]
    def find_bgp_session_by_id(id, opts = {})
      data, _status_code, _headers = find_bgp_session_by_id_with_http_info(id, opts)
      data
    end

    # Retrieve a BGP session
    # Returns a BGP session
    # @param id [String] BGP session UUID
    # @param [Hash] opts the optional parameters
    # @option opts [Array<String>] :include Nested attributes to include. Included objects will return their full attributes. Attribute names can be dotted (up to 3 levels) to included deeply nested objects.
    # @option opts [Array<String>] :exclude Nested attributes to exclude. Excluded objects will return only the href attribute. Attribute names can be dotted (up to 3 levels) to exclude deeply nested objects.
    # @return [Array<(BgpSession, Integer, Hash)>] BgpSession data, response status code and response headers
    def find_bgp_session_by_id_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.find_bgp_session_by_id ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.find_bgp_session_by_id"
      end
      # resource path
      local_var_path = '/bgp/sessions/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

      # query parameters
      query_params = opts[:query_params] || {}
      query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?
      query_params[:'exclude'] = @api_client.build_collection_param(opts[:'exclude'], :csv) if !opts[:'exclude'].nil?

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

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

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

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

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

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

    # Retrieve all BGP sessions
    # Provides a listing of available BGP sessions for the device.
    # @param id [String] Device UUID
    # @param [Hash] opts the optional parameters
    # @return [BgpSessionList]
    def find_bgp_sessions(id, opts = {})
      data, _status_code, _headers = find_bgp_sessions_with_http_info(id, opts)
      data
    end

    # Retrieve all BGP sessions
    # Provides a listing of available BGP sessions for the device.
    # @param id [String] Device UUID
    # @param [Hash] opts the optional parameters
    # @return [Array<(BgpSessionList, Integer, Hash)>] BgpSessionList data, response status code and response headers
    def find_bgp_sessions_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.find_bgp_sessions ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.find_bgp_sessions"
      end
      # resource path
      local_var_path = '/devices/{id}/bgp/sessions'.sub('{' + 'id' + '}', CGI.escape(id.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'])

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

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

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

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

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

    # Retrieve all BGP sessions for project
    # Provides a listing of available BGP sessions for the project.
    # @param id [String] Project UUID
    # @param [Hash] opts the optional parameters
    # @return [BgpSessionList]
    def find_project_bgp_sessions(id, opts = {})
      data, _status_code, _headers = find_project_bgp_sessions_with_http_info(id, opts)
      data
    end

    # Retrieve all BGP sessions for project
    # Provides a listing of available BGP sessions for the project.
    # @param id [String] Project UUID
    # @param [Hash] opts the optional parameters
    # @return [Array<(BgpSessionList, Integer, Hash)>] BgpSessionList data, response status code and response headers
    def find_project_bgp_sessions_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.find_project_bgp_sessions ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.find_project_bgp_sessions"
      end
      # resource path
      local_var_path = '/projects/{id}/bgp/sessions'.sub('{' + 'id' + '}', CGI.escape(id.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'])

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

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

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

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

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

    # Retrieve BGP neighbor data for this device
    # Provides a summary of the BGP neighbor data associated to the BGP sessions for this device.
    # @param id [String] Device UUID
    # @param [Hash] opts the optional parameters
    # @return [BgpSessionNeighbors]
    def get_bgp_neighbor_data(id, opts = {})
      data, _status_code, _headers = get_bgp_neighbor_data_with_http_info(id, opts)
      data
    end

    # Retrieve BGP neighbor data for this device
    # Provides a summary of the BGP neighbor data associated to the BGP sessions for this device.
    # @param id [String] Device UUID
    # @param [Hash] opts the optional parameters
    # @return [Array<(BgpSessionNeighbors, Integer, Hash)>] BgpSessionNeighbors data, response status code and response headers
    def get_bgp_neighbor_data_with_http_info(id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.get_bgp_neighbor_data ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.get_bgp_neighbor_data"
      end
      # resource path
      local_var_path = '/devices/{id}/bgp/neighbors'.sub('{' + 'id' + '}', CGI.escape(id.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'])

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

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

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

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

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

    # Requesting bgp config
    # Requests to enable bgp configuration for a project.
    # @param id [String] Project UUID
    # @param bgp_config_request [BgpConfigRequestInput] BGP config Request to create
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def request_bgp_config(id, bgp_config_request, opts = {})
      request_bgp_config_with_http_info(id, bgp_config_request, opts)
      nil
    end

    # Requesting bgp config
    # Requests to enable bgp configuration for a project.
    # @param id [String] Project UUID
    # @param bgp_config_request [BgpConfigRequestInput] BGP config Request to create
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def request_bgp_config_with_http_info(id, bgp_config_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.request_bgp_config ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.request_bgp_config"
      end
      # verify the required parameter 'bgp_config_request' is set
      if @api_client.config.client_side_validation && bgp_config_request.nil?
        fail ArgumentError, "Missing the required parameter 'bgp_config_request' when calling BGPApi.request_bgp_config"
      end
      # resource path
      local_var_path = '/projects/{id}/bgp-configs'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

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

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

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

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

      # return_type
      return_type = opts[:debug_return_type]

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

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

    # Update the BGP session
    # Updates the BGP session by either enabling or disabling the default route functionality.
    # @param id [String] BGP session UUID
    # @param default_route [Boolean] Default route
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def update_bgp_session(id, default_route, opts = {})
      update_bgp_session_with_http_info(id, default_route, opts)
      nil
    end

    # Update the BGP session
    # Updates the BGP session by either enabling or disabling the default route functionality.
    # @param id [String] BGP session UUID
    # @param default_route [Boolean] Default route
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
    def update_bgp_session_with_http_info(id, default_route, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: BGPApi.update_bgp_session ...'
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling BGPApi.update_bgp_session"
      end
      # verify the required parameter 'default_route' is set
      if @api_client.config.client_side_validation && default_route.nil?
        fail ArgumentError, "Missing the required parameter 'default_route' when calling BGPApi.update_bgp_session"
      end
      # resource path
      local_var_path = '/bgp/sessions/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

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

      # header parameters
      header_params = opts[:header_params] || {}
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

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

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

      # return_type
      return_type = opts[:debug_return_type]

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

      new_options = opts.merge(
        :operation => :"BGPApi.update_bgp_session",
        :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(:PUT, local_var_path, new_options)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: BGPApi#update_bgp_session\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
