Class: Puppet::HTTP::Service::FileServer
- Inherits:
-
Puppet::HTTP::Service
- Object
- Puppet::HTTP::Service
- Puppet::HTTP::Service::FileServer
- Defined in:
- lib/puppet/http/service/file_server.rb
Overview
The FileServer service is used to retrieve file metadata and content.
Constant Summary collapse
- API =
Returns Default API for the FileServer service.
'/puppet/v3'
- PATH_REGEX =
Returns RegEx used to determine if a path contains a leading slash.
%r{^/}
Constants inherited from Puppet::HTTP::Service
EXCLUDED_FORMATS, SERVICE_NAMES
Instance Attribute Summary
Attributes inherited from Puppet::HTTP::Service
Instance Method Summary collapse
-
#get_file_content(path:, environment:) {|Sting| ... } ⇒ Puppet::HTTP::Response
Submit a GET request to the server to retrieve content of a file.
-
#get_file_metadata(path:, environment:, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore) ⇒ Array<Puppet::HTTP::Response, Puppet::FileServing::Metadata>
Submit a GET request to the server to retrieve the metadata for a specified file.
-
#get_file_metadatas(environment:, path: nil, recurse: :false, recurselimit: nil, max_files: nil, ignore: nil, links: :manage, checksum_type: , source_permissions: :ignore) ⇒ Array<Puppet::HTTP::Response, Array<Puppet::FileServing::Metadata>>
Submit a GET request to the server to retrieve the metadata for multiple files.
-
#get_static_file_content(path:, environment:, code_id:) {|String| ... } ⇒ Puppet::HTTP::Response
Submit a GET request to retrieve file content using the ‘static_file_content` API uniquely identified by (`code_id`, `environment`, `path`).
-
#initialize(client, session, server, port) ⇒ FileServer
constructor
Use ‘Puppet::HTTP::Session.route_to(:fileserver)` to create or get an instance of this class.
Methods inherited from Puppet::HTTP::Service
#connect, create_service, valid_name?, #with_base_url
Constructor Details
#initialize(client, session, server, port) ⇒ FileServer
Use ‘Puppet::HTTP::Session.route_to(:fileserver)` to create or get an instance of this class.
27 28 29 30 |
# File 'lib/puppet/http/service/file_server.rb', line 27 def initialize(client, session, server, port) url = build_url(API, server || Puppet[:server], port || Puppet[:serverport]) super(client, session, url) end |
Instance Method Details
#get_file_content(path:, environment:) {|Sting| ... } ⇒ Puppet::HTTP::Response
Submit a GET request to the server to retrieve content of a file.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/puppet/http/service/file_server.rb', line 139 def get_file_content(path:, environment:, &block) validate_path(path) headers = add_puppet_headers('Accept' => 'application/octet-stream') response = @client.get( with_base_url("/file_content#{path}"), headers: headers, params: { environment: environment } ) do |res| if res.success? res.read_body(&block) end end process_response(response) response end |
#get_file_metadata(path:, environment:, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore) ⇒ Array<Puppet::HTTP::Response, Puppet::FileServing::Metadata>
Submit a GET request to the server to retrieve the metadata for a specified file.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/puppet/http/service/file_server.rb', line 51 def (path:, environment:, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore) validate_path(path) headers = add_puppet_headers('Accept' => get_mime_types(Puppet::FileServing::Metadata).join(', ')) response = @client.get( with_base_url("/file_metadata#{path}"), headers: headers, params: { links: links, checksum_type: checksum_type, source_permissions: , environment: environment } ) process_response(response) [response, deserialize(response, Puppet::FileServing::Metadata)] end |
#get_file_metadatas(environment:, path: nil, recurse: :false, recurselimit: nil, max_files: nil, ignore: nil, links: :manage, checksum_type: , source_permissions: :ignore) ⇒ Array<Puppet::HTTP::Response, Array<Puppet::FileServing::Metadata>>
Submit a GET request to the server to retrieve the metadata for multiple files
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/puppet/http/service/file_server.rb', line 103 def (environment:, path: nil, recurse: :false, recurselimit: nil, max_files: nil, ignore: nil, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore) # rubocop:disable Lint/BooleanSymbol validate_path(path) headers = add_puppet_headers('Accept' => get_mime_types(Puppet::FileServing::Metadata).join(', ')) response = @client.get( with_base_url("/file_metadatas#{path}"), headers: headers, params: { recurse: recurse, recurselimit: recurselimit, max_files: max_files, ignore: ignore, links: links, checksum_type: checksum_type, source_permissions: , environment: environment, } ) process_response(response) [response, deserialize_multiple(response, Puppet::FileServing::Metadata)] end |
#get_static_file_content(path:, environment:, code_id:) {|String| ... } ⇒ Puppet::HTTP::Response
Submit a GET request to retrieve file content using the ‘static_file_content` API uniquely identified by (`code_id`, `environment`, `path`).
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/puppet/http/service/file_server.rb', line 173 def get_static_file_content(path:, environment:, code_id:, &block) validate_path(path) headers = add_puppet_headers('Accept' => 'application/octet-stream') response = @client.get( with_base_url("/static_file_content#{path}"), headers: headers, params: { environment: environment, code_id: code_id, } ) do |res| if res.success? res.read_body(&block) end end process_response(response) response end |