Class: Puppet::HTTP::Service::FileServer Private

Inherits:
Puppet::HTTP::Service show all
Defined in:
lib/puppet/http/service/file_server.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The FileServer service is used to retrieve file metadata and content

Constant Summary collapse

API =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns Default API for the FileServer service.

'/puppet/v3'.freeze
PATH_REGEX =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns RegEx used to determine if a path contains a leading slash.

/^\//

Constants inherited from Puppet::HTTP::Service

EXCLUDED_FORMATS, SERVICE_NAMES

Instance Attribute Summary

Attributes inherited from Puppet::HTTP::Service

#url

Instance Method Summary collapse

Methods inherited from Puppet::HTTP::Service

#connect, create_service, valid_name?, #with_base_url

Constructor Details

#initialize(client, session, server, port) ⇒ FileServer

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.

Returns a new instance of FileServer.


29
30
31
32
# File 'lib/puppet/http/service/file_server.rb', line 29

def initialize(client, session, server, port)
  url = build_url(API, server || Puppet[:server], port || Puppet[:masterport])
  super(client, session, url)
end

Instance Method Details

#get_file_content(path:, environment:) {|Sting| ... } ⇒ Puppet::HTTP::Response

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 GET request to the server to retrieve content of a file

Yields:

  • (Sting)

    Yields the body of the response returned from the server


145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/puppet/http/service/file_server.rb', line 145

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>

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 GET request to the server to retrieve the metadata for a specified file


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/puppet/http/service/file_server.rb', line 56

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: source_permissions,
      environment: environment
    }
  )

  process_response(response)

  [response, deserialize(response, Puppet::FileServing::Metadata)]
end

#get_file_metadatas(path: nil, environment:, recurse: :false, recurselimit: nil, ignore: nil, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore) ⇒ Array<Puppet::HTTP::Response, Array<Puppet::FileServing::Metadata>>

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 GET request to the server to retrieve the metadata for multiple files


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/puppet/http/service/file_server.rb', line 109

def get_file_metadatas(path: nil, environment:, recurse: :false, recurselimit: nil, ignore: nil, 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_metadatas#{path}"),
    headers: headers,
    params: {
      recurse: recurse,
      recurselimit: recurselimit,
      ignore: ignore,
      links: links,
      checksum_type: checksum_type,
      source_permissions: 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

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 GET request to

Yields:

  • (String)

    Yields the body of the response returned


179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/puppet/http/service/file_server.rb', line 179

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