Class: PEClient::Resource::PuppetV3::FileBucket
- Defined in:
- lib/pe_client/resources/puppet.v3/file_bucket.rb
Overview
Manages the contents of files in the file bucket. All access to files is managed with the md5 checksum of the file contents, represented as :md5. Where used, :filename means the full absolute path of the file on the client system. This is usually optional and used as an error check to make sure correct file is retrieved. The environment is required in all requests but ignored, as the file bucket does not distinguish between environments.
Constant Summary collapse
- BASE_PATH =
The base path for Puppet API v3 File Bucket endpoints.
"#{PuppetV3::BASE_PATH}/file_bucket_file".freeze
- HEADERS =
Common headers for file bucket requests
{"Content-Type": "application/octet-stream", Accept: "application/octet-stream"}.freeze
Instance Method Summary collapse
-
#get(md5:, environment:, filename: nil) ⇒ String
Retrieve the contents of a file.
-
#head(md5:, environment:, filename: nil) ⇒ Hash
Check if a file is present in the filebucket This behaves identically to #get, only returning headers.
-
#save(md5:, file:, environment:, filename: nil) ⇒ String
Save a file to the filebucket The body should contain the file contents.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PEClient::Resource::Base
Instance Method Details
#get(md5:, environment:, filename: nil) ⇒ String
Retrieve the contents of a file.
43 44 45 |
# File 'lib/pe_client/resources/puppet.v3/file_bucket.rb', line 43 def get(md5:, environment:, filename: nil) @client.get path(md5, filename), params: {environment:}, headers: HEADERS end |
#head(md5:, environment:, filename: nil) ⇒ Hash
Check if a file is present in the filebucket This behaves identically to #get, only returning headers.
55 56 57 |
# File 'lib/pe_client/resources/puppet.v3/file_bucket.rb', line 55 def head(md5:, environment:, filename: nil) @client.head path(md5, filename), params: {environment:}, headers: HEADERS end |
#save(md5:, file:, environment:, filename: nil) ⇒ String
Save a file to the filebucket The body should contain the file contents. This saves the file using the md5 sum of the file contents. If :filename is provided, it adds the path to a list for the given file. If the md5 sum in the request is incorrect, the file will be instead saved under the correct checksum.
70 71 72 |
# File 'lib/pe_client/resources/puppet.v3/file_bucket.rb', line 70 def save(md5:, file:, environment:, filename: nil) @client.put path(md5, filename), body: file, params: {environment:}, headers: HEADERS end |