lib/ruby_nsx_cli/nsx_objects/nsxobject.rb
def put(api_endpoint:, payload:)
      @logger.info("Updating NSX object (HTTP put): #{self.class}")
      @logger.debug("Payload is: \n#{payload}")
      @logger.debug("API endpoint is: #{api_endpoint}")
      @logger.debug("Sending request to: #{@nsx_manager_url}...")


      begin
        resp = create_new_request(api_endpoint, XML_HEADER).put(payload)

        if resp.code >= 200 && resp.code < 300
          @logger.info("Successfully put NSX object: #{self.class}")
          return resp
        else
          raise "Unexpected return code during NSX object put: #{self.class} returned #{resp.code}"
        end

      rescue RestClient::ExceptionWithResponse => err
        @logger.error("Failed to put NSX object: #{self.class}")
        @logger.error("Response code: #{err.http_code}")
        @logger.error("Response: #{err.message}")
        return resp
      end

    end
# Sends a post request to the NSX API. Usually to update an object.
#
# @param api_endpoint [String] the NSX endpoint to send the request
# @param payload [String] the payload to send to the `api_endpoint`
# @return [RestClient::Response] the response from the NSX API.
Sends a post request to the NSX API. Usually to update an object.
Sends a post request to the NSX API . Usually to update an object .
def put(api_endpoint:, payload:)
      @logger.info("Updating NSX object (HTTP put): #{self.class}")
      @logger.debug("Payload is: \n#{payload}")
      @logger.debug("API endpoint is: #{api_endpoint}")
      @logger.debug("Sending request to: #{@nsx_manager_url}...")
      begin
        resp = create_new_request(api_endpoint, XML_HEADER).put(payload)
        if resp.code >= 200 && resp.code < 300
          @logger.info("Successfully put NSX object: #{self.class}")
          return resp
        else
          raise "Unexpected return code during NSX object put: #{self.class} returned #{resp.code}"
        end
      rescue RestClient::ExceptionWithResponse => err
        @logger.error("Failed to put NSX object: #{self.class}")
        @logger.error("Response code: #{err.http_code}")
        @logger.error("Response: #{err.message}")
        return resp
      end
    end
def put ( api_endpoint : , payload : ) @logger . info ( "Updating NSX object (HTTP put): #{self.class}" ) @logger . debug ( "Payload is: \n#{payload}" ) @logger . debug ( "API endpoint is: #{api_endpoint}" ) @logger . debug ( "Sending request to: #{@nsx_manager_url}..." ) begin resp = create_new_request ( api_endpoint , XML_HEADER ) . put ( payload ) if resp . code >= 200 && resp . code < 300 @logger . info ( "Successfully put NSX object: #{self.class}" ) return resp else raise "Unexpected return code during NSX object put: #{self.class} returned #{resp.code}" end rescue RestClient :: ExceptionWithResponse => err @logger . error ( "Failed to put NSX object: #{self.class}" ) @logger . error ( "Response code: #{err.http_code}" ) @logger . error ( "Response: #{err.message}" ) return resp end end
Sends a post request to the NSX API.
Sends a post request to the NSX API .
the response from the NSX API.
the response from the NSX API .
RestClient::Response
api_endpoint
the NSX endpoint to send the request
the NSX endpoint to send the request
payload
the payload to send to the `api_endpoint`
the payload to send to the ` api_endpoint `