Class: PEClient::Resource::PuppetDB::AdminV1::Archive
- Defined in:
- lib/pe_client/resources/puppet_db/admin.v1/archive.rb
Overview
The archive endpoint can be used for importing and exporting PuppetDB archives.
Constant Summary collapse
- BASE_PATH =
The base path for PuppetDB Admin v1 Archive endpoints.
"#{AdminV1::BASE_PATH}/archive".freeze
Instance Method Summary collapse
-
#export(path:, anonymization_profile: nil) ⇒ String
This endpoint can be used to stream a tarred, gzipped backup archive of PuppetDB to your local machine.
-
#import(archive:) ⇒ Hash
This endpoint can be used for streaming a PuppetDB archive into PuppetDB.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PEClient::Resource::Base
Instance Method Details
#export(path:, anonymization_profile: nil) ⇒ String
This endpoint can be used to stream a tarred, gzipped backup archive of PuppetDB to your local machine.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/pe_client/resources/puppet_db/admin.v1/archive.rb', line 52 def export(path:, anonymization_profile: nil) response = nil File.open(path, "wb") do |file| # Using the Connection object directly to stream the response to a file. response = @client.connection.get BASE_PATH, {anonymization_profile:}.compact, {Accept: "application/octet-stream"} do |req| req..on_data = proc do |chunk, _overall_received_bytes| file.write(chunk) end end end @client.handle_response response, headers_only: true path end |
#import(archive:) ⇒ Hash
This endpoint can be used for streaming a PuppetDB archive into PuppetDB.
39 40 41 42 |
# File 'lib/pe_client/resources/puppet_db/admin.v1/archive.rb', line 39 def import(archive:) @client.post BASE_PATH, body: {archive: Faraday::Multipart::FilePart.new(archive, "application/octet-stream", File.basename(archive))} end |