=begin
#NSX-T Manager API

#VMware NSX-T Manager REST API

OpenAPI spec version: 2.5.1.0.0

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

=end

require 'uri'

module NSXT
  class ManagementPlaneApiUpgradeNodesApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end
    # Get list of nodes across all types
    # Get list of nodes. If request parameter component type is specified, then all nodes for that component will be returned. If request parameter component version is specified, then all nodes at that version will be returned. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :component_type Component type based on which nodes will be filtered
    # @option opts [String] :component_version Component version based on which nodes will be filtered
    # @option opts [String] :cursor Opaque cursor to be used for getting next page of records (supplied by current result page)
    # @option opts [String] :included_fields Comma separated list of fields that should be included in query result
    # @option opts [Integer] :page_size Maximum number of results to return in this page (server may return fewer) (default to 1000)
    # @option opts [BOOLEAN] :sort_ascending 
    # @option opts [String] :sort_by Field by which records are sorted
    # @return [NodeInfoListResult]
    def get_nodes(opts = {})
      data, _status_code, _headers = get_nodes_with_http_info(opts)
      data
    end

    # Get list of nodes across all types
    # Get list of nodes. If request parameter component type is specified, then all nodes for that component will be returned. If request parameter component version is specified, then all nodes at that version will be returned. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :component_type Component type based on which nodes will be filtered
    # @option opts [String] :component_version Component version based on which nodes will be filtered
    # @option opts [String] :cursor Opaque cursor to be used for getting next page of records (supplied by current result page)
    # @option opts [String] :included_fields Comma separated list of fields that should be included in query result
    # @option opts [Integer] :page_size Maximum number of results to return in this page (server may return fewer)
    # @option opts [BOOLEAN] :sort_ascending 
    # @option opts [String] :sort_by Field by which records are sorted
    # @return [Array<(NodeInfoListResult, Fixnum, Hash)>] NodeInfoListResult data, response status code and response headers
    def get_nodes_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ManagementPlaneApiUpgradeNodesApi.get_nodes ...'
      end
      if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000
        fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ManagementPlaneApiUpgradeNodesApi.get_nodes, must be smaller than or equal to 1000.'
      end

      if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0
        fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ManagementPlaneApiUpgradeNodesApi.get_nodes, must be greater than or equal to 0.'
      end

      # resource path
      local_var_path = '/upgrade/nodes'

      # query parameters
      query_params = {}
      query_params[:'component_type'] = opts[:'component_type'] if !opts[:'component_type'].nil?
      query_params[:'component_version'] = opts[:'component_version'] if !opts[:'component_version'].nil?
      query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
      query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?
      query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?
      query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?
      query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?

      # header parameters
      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 = {}

      # http body (model)
      post_body = nil
      auth_names = ['BasicAuth']
      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 => 'NodeInfoListResult')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: ManagementPlaneApiUpgradeNodesApi#get_nodes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Get summary of nodes
    # Get summary of nodes, which includes node count for each type and component version.
    # @param [Hash] opts the optional parameters
    # @return [NodeSummaryList]
    def get_nodes_summary(opts = {})
      data, _status_code, _headers = get_nodes_summary_with_http_info(opts)
      data
    end

    # Get summary of nodes
    # Get summary of nodes, which includes node count for each type and component version.
    # @param [Hash] opts the optional parameters
    # @return [Array<(NodeSummaryList, Fixnum, Hash)>] NodeSummaryList data, response status code and response headers
    def get_nodes_summary_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ManagementPlaneApiUpgradeNodesApi.get_nodes_summary ...'
      end
      # resource path
      local_var_path = '/upgrade/nodes-summary'

      # query parameters
      query_params = {}

      # header parameters
      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 = {}

      # http body (model)
      post_body = nil
      auth_names = ['BasicAuth']
      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 => 'NodeSummaryList')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: ManagementPlaneApiUpgradeNodesApi#get_nodes_summary\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Get the version whitelist
    # Get whitelist of versions for different components
    # @param [Hash] opts the optional parameters
    # @return [AcceptableComponentVersionList]
    def get_version_whitelist(opts = {})
      data, _status_code, _headers = get_version_whitelist_with_http_info(opts)
      data
    end

    # Get the version whitelist
    # Get whitelist of versions for different components
    # @param [Hash] opts the optional parameters
    # @return [Array<(AcceptableComponentVersionList, Fixnum, Hash)>] AcceptableComponentVersionList data, response status code and response headers
    def get_version_whitelist_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ManagementPlaneApiUpgradeNodesApi.get_version_whitelist ...'
      end
      # resource path
      local_var_path = '/upgrade/version-whitelist'

      # query parameters
      query_params = {}

      # header parameters
      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 = {}

      # http body (model)
      post_body = nil
      auth_names = ['BasicAuth']
      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 => 'AcceptableComponentVersionList')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: ManagementPlaneApiUpgradeNodesApi#get_version_whitelist\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Get the version whitelist for the specified component
    # Get whitelist of versions for a component. Component can include HOST, EDGE, CCP, MP
    # @param component_type 
    # @param [Hash] opts the optional parameters
    # @return [AcceptableComponentVersion]
    def get_version_whitelist_by_component(component_type, opts = {})
      data, _status_code, _headers = get_version_whitelist_by_component_with_http_info(component_type, opts)
      data
    end

    # Get the version whitelist for the specified component
    # Get whitelist of versions for a component. Component can include HOST, EDGE, CCP, MP
    # @param component_type 
    # @param [Hash] opts the optional parameters
    # @return [Array<(AcceptableComponentVersion, Fixnum, Hash)>] AcceptableComponentVersion data, response status code and response headers
    def get_version_whitelist_by_component_with_http_info(component_type, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ManagementPlaneApiUpgradeNodesApi.get_version_whitelist_by_component ...'
      end
      # verify the required parameter 'component_type' is set
      if @api_client.config.client_side_validation && component_type.nil?
        fail ArgumentError, "Missing the required parameter 'component_type' when calling ManagementPlaneApiUpgradeNodesApi.get_version_whitelist_by_component"
      end
      # resource path
      local_var_path = '/upgrade/version-whitelist/{component_type}'.sub('{' + 'component_type' + '}', component_type.to_s)

      # query parameters
      query_params = {}

      # header parameters
      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 = {}

      # http body (model)
      post_body = nil
      auth_names = ['BasicAuth']
      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 => 'AcceptableComponentVersion')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: ManagementPlaneApiUpgradeNodesApi#get_version_whitelist_by_component\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Update the version whitelist for the specified component type
    # Update the version whitelist for the specified component type (HOST, EDGE, CCP, MP).
    # @param component_type 
    # @param version_list 
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def update_version_whitelist(component_type, version_list, opts = {})
      update_version_whitelist_with_http_info(component_type, version_list, opts)
      nil
    end

    # Update the version whitelist for the specified component type
    # Update the version whitelist for the specified component type (HOST, EDGE, CCP, MP).
    # @param component_type 
    # @param version_list 
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def update_version_whitelist_with_http_info(component_type, version_list, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: ManagementPlaneApiUpgradeNodesApi.update_version_whitelist ...'
      end
      # verify the required parameter 'component_type' is set
      if @api_client.config.client_side_validation && component_type.nil?
        fail ArgumentError, "Missing the required parameter 'component_type' when calling ManagementPlaneApiUpgradeNodesApi.update_version_whitelist"
      end
      # verify the required parameter 'version_list' is set
      if @api_client.config.client_side_validation && version_list.nil?
        fail ArgumentError, "Missing the required parameter 'version_list' when calling ManagementPlaneApiUpgradeNodesApi.update_version_whitelist"
      end
      # resource path
      local_var_path = '/upgrade/version-whitelist/{component_type}'.sub('{' + 'component_type' + '}', component_type.to_s)

      # query parameters
      query_params = {}

      # header parameters
      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 = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(version_list)
      auth_names = ['BasicAuth']
      data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names)
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: ManagementPlaneApiUpgradeNodesApi#update_version_whitelist\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
