# frozen_string_literal: true module Files class SftpHostKey attr_reader :options, :attributes def initialize(attributes = {}, options = {}) @attributes = attributes || {} @options = options || {} end # int64 - SFTP Host Key ID def id @attributes[:id] end def id=(value) @attributes[:id] = value end # string - The friendly name of this SFTP Host Key. def name @attributes[:name] end def name=(value) @attributes[:name] = value end # string - MD5 Fingerprint of the public key def fingerprint_md5 @attributes[:fingerprint_md5] end def fingerprint_md5=(value) @attributes[:fingerprint_md5] = value end # string - SHA256 Fingerprint of the public key def fingerprint_sha256 @attributes[:fingerprint_sha256] end def fingerprint_sha256=(value) @attributes[:fingerprint_sha256] = value end # string - The private key data. def private_key @attributes[:private_key] end def private_key=(value) @attributes[:private_key] = value end # Parameters: # name - string - The friendly name of this SFTP Host Key. # private_key - string - The private key data. def update(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: private_key must be an String") if params[:private_key] and !params[:private_key].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/sftp_host_keys/#{@attributes[:id]}", :patch, params, @options) end def delete(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/sftp_host_keys/#{@attributes[:id]}", :delete, params, @options) end def destroy(params = {}) delete(params) nil end def save if @attributes[:id] new_obj = update(@attributes) else new_obj = SftpHostKey.create(@attributes, @options) end @attributes = new_obj.attributes true end # Parameters: # cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination. # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended). def self.list(params = {}, options = {}) raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer) List.new(SftpHostKey, params) do Api.send_request("/sftp_host_keys", :get, params, options) end end def self.all(params = {}, options = {}) list(params, options) end # Parameters: # id (required) - int64 - Sftp Host Key ID. def self.find(id, params = {}, options = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, options = Api.send_request("/sftp_host_keys/#{params[:id]}", :get, params, options) SftpHostKey.new(response.data, options) end def self.get(id, params = {}, options = {}) find(id, params, options) end # Parameters: # name - string - The friendly name of this SFTP Host Key. # private_key - string - The private key data. def self.create(params = {}, options = {}) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: private_key must be an String") if params[:private_key] and !params[:private_key].is_a?(String) response, options = Api.send_request("/sftp_host_keys", :post, params, options) SftpHostKey.new(response.data, options) end def self.create_export(params = {}, options = {}) response, options = Api.send_request("/sftp_host_keys/create_export", :post, params, options) Export.new(response.data, options) end # Parameters: # name - string - The friendly name of this SFTP Host Key. # private_key - string - The private key data. def self.update(id, params = {}, options = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: private_key must be an String") if params[:private_key] and !params[:private_key].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, options = Api.send_request("/sftp_host_keys/#{params[:id]}", :patch, params, options) SftpHostKey.new(response.data, options) end def self.delete(id, params = {}, options = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/sftp_host_keys/#{params[:id]}", :delete, params, options) nil end def self.destroy(id, params = {}, options = {}) delete(id, params, options) nil end end end