Class: PEClient::Resource::PuppetV3::FileMetadata

Inherits:
Base
  • Object
show all
Defined in:
lib/pe_client/resources/puppet.v3/file_metadata.rb

Overview

This endpoint returns select metadata for a single file or many files. Although the term “file_path” is used generically in the endpoint name and documentation, each returned item can be one of the following three types:

- File
- Directory
- Symbolic link

Constant Summary collapse

BASE_PATH =

The base path for Puppet API v3 File Metadata endpoints.

"#{PuppetV3::BASE_PATH}/file_metadata".freeze
SEARCH_BASE_PATH =

Search base path for Puppet API v3 File Metadata endpoints.

"#{BASE_PATH}s".freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PEClient::Resource::Base

Instance Method Details

#find(mount:, file_path:, environment:, links: nil, checksum_type: nil, source_permissions: nil) ⇒ Hash

Get file metadata for a single file

Parameters:

  • mount (String)

    One of the following types:

    • Custom file serving mounts as specified in fileserver.conf

    • ‘modules/<MODULE>` — a semi-magical mount point which allows access to the files subdirectory of <MODULE>

    • plugins — a highly magical mount point which merges the lib directory of every module together. Used for syncing plugins; not intended for general consumption. Per-module sub-paths can not be specified.

    • pluginfacts — a highly magical mount point which merges the facts.d directory of every module together. Used for syncing external facts; not intended for general consumption. Per-module sub-paths can not be specified.

    • ‘tasks/<MODULE>` — a semi-magical mount point which allows access to files in the tasks subdirectory of <MODULE>

  • file_path (String)

    The path to the file.

  • environment (String)

    The environment to use when retrieving the file metadata.

  • links (String) (defaults to: nil)

    either “manage” (default) or “follow”.

  • checksum_type (String) (defaults to: nil)

    the checksum type to calculate the checksum value for the result metadata; one of “md5” (default), “md5lite”, “sha256”, “sha256lite”, “mtime”, “ctime”, and “none”.

  • source_permissions (String) (defaults to: nil)

    whether (and how) Puppet should copy owner, group, and mode permissions; one of

    • “ignore” (the default) will never apply the owner, group, or mode from the source when managing a file. When creating new files without explicit permissions, the permissions they receive will depend on platform-specific behavior. On POSIX, Puppet will use the umask of the user it is running as. On Windows, Puppet will use the default DACL associated with the user it is running as.

    • “use” will cause Puppet to apply the owner, group, and mode from the source to any files it is managing.

    • “use_when_creating” will only apply the owner, group, and mode from the source when creating a file; existing files will not have their permissions overwritten.

Returns:

  • (Hash)


60
61
62
# File 'lib/pe_client/resources/puppet.v3/file_metadata.rb', line 60

def find(mount:, file_path:, environment:, links: nil, checksum_type: nil, source_permissions: nil)
  @client.get File.join(BASE_PATH, mount, file_path), params: {environment:, links:, checksum_type:, source_permissions:}.compact
end

#search(file_path:, environment:, recurse: "yes", ignore: nil, links: nil, checksum_type: nil, source_permissions: nil) ⇒ Array<Hash>

Get a list of metadata for multiple files

Parameters:

  • file_path (String)

    The path to the file.

  • environment (String)

    The environment to use when retrieving the file metadata.

  • recurse (String) (defaults to: "yes")

    Should always be set to “yes”; unfortunately the default is “no”, which causes a search to behave like a find operation.

  • ignore (Array<String>) (defaults to: nil)

    File or directory regex to ignore.

  • links (String) (defaults to: nil)

    either “manage” (default) or “follow”.

  • checksum_type (String) (defaults to: nil)

    the checksum type to calculate the checksum value for the result metadata; one of “md5” (default), “md5lite”, “sha256”, “sha256lite”, “mtime”, “ctime”, and “none”.

  • source_permissions (String) (defaults to: nil)

    whether (and how) Puppet should copy owner, group, and mode permissions; one of

    • “ignore” (the default) will never apply the owner, group, or mode from the source when managing a file. When creating new files without explicit permissions, the permissions they receive will depend on platform-specific behavior. On POSIX, Puppet will use the umask of the user it is running as. On Windows, Puppet will use the default DACL associated with the user it is running as.

    • “use” will cause Puppet to apply the owner, group, and mode from the source to any files it is managing.

    • “use_when_creating” will only apply the owner, group, and mode from the source when creating a file; existing files will not have their permissions overwritten.

Returns:

  • (Array<Hash>)


81
82
83
# File 'lib/pe_client/resources/puppet.v3/file_metadata.rb', line 81

def search(file_path:, environment:, recurse: "yes", ignore: nil, links: nil, checksum_type: nil, source_permissions: nil)
  @client.get File.join(SEARCH_BASE_PATH, file_path), params: {environment:, recurse:, ignore:, links:, checksum_type:, source_permissions:}.compact
end