Method: Puppet::HTTP::Service::Compiler#post_catalog4
- Defined in:
- lib/puppet/http/service/compiler.rb
#post_catalog4(certname, persistence:, environment:, facts: nil, trusted_facts: nil, transaction_uuid: nil, job_id: nil, options: nil) ⇒ Array<Puppet::HTTP::Response, Puppet::Resource::Catalog, Array<String>>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a POST request to request a catalog to the server using v4 endpoint
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/puppet/http/service/compiler.rb', line 162 def post_catalog4(certname, persistence:, environment:, facts: nil, trusted_facts: nil, transaction_uuid: nil, job_id: nil, options: nil) unless persistence.is_a?(Hash) && (missing = [:facts, :catalog] - persistence.keys.map(&:to_sym)).empty? raise ArgumentError.new("The 'persistence' hash is missing the keys: #{missing.join(', ')}") end raise ArgumentError.new("Facts must be a Hash not a #{facts.class}") unless facts.nil? || facts.is_a?(Hash) body = { certname: certname, persistence: persistence, environment: environment, transaction_uuid: transaction_uuid, job_id: job_id, options: } body[:facts] = { values: facts } unless facts.nil? body[:trusted_facts] = { values: trusted_facts } unless trusted_facts.nil? headers = add_puppet_headers( 'Accept' => get_mime_types(Puppet::Resource::Catalog).join(', '), 'Content-Type' => 'application/json' ) url = URI::HTTPS.build(host: @url.host, port: @url.port, path: Puppet::Util.uri_encode("/puppet/v4/catalog")) response = @client.post( url, body.to_json, headers: headers ) process_response(response) begin response_body = JSON.parse(response.body) catalog = Puppet::Resource::Catalog.from_data_hash(response_body['catalog']) rescue => err raise Puppet::HTTP::SerializationError.new("Failed to deserialize catalog from puppetserver response: #{err.message}", err) end logs = response_body['logs'] || [] [response, catalog, logs] end |