Class: Artifactory::Resource::Repository

Inherits:
Base
  • Object
show all
Defined in:
lib/artifactory/resources/repository.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attribute, attributes, #attributes, #client, #client=, #client?, #extract_client!, extract_client!, find_from_config, #format_repos!, format_repos!, from_hash, from_url, has_attribute?, #initialize, #inspect, list_from_config, #set, #to_hash, #to_json, #to_matrix_properties, #to_query_string_parameters, #to_s, uri_parser, #url_safe, url_safe

Constructor Details

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

Class Method Details

.all(options = {}) ⇒ Array<Resource::Repository>

Get a list of all repositories in the system.

Parameters:

  • options (Hash) (defaults to: {})

    the list of options

Options Hash (options):

Returns:



32
33
34
35
36
37
# File 'lib/artifactory/resources/repository.rb', line 32

def all(options = {})
  client = extract_client!(options)
  client.get("/api/repositories").map do |hash|
    find(hash["key"], client: client)
  end.compact
end

.find(name, options = {}) ⇒ Resource::Repository?

Find (fetch) a repository by name.

Examples:

Find a repository by named key

Repository.find(name: 'libs-release-local') #=> #<Resource::Artifact>

Parameters:

  • options (Hash) (defaults to: {})

    the list of options

Options Hash (options):

  • :name (String)

    the name of the repository to find

  • :client (Artifactory::Client)

    the client object to make the request with

Returns:

  • (Resource::Repository, nil)

    an instance of the repository that matches the given name, or nil if one does not exist



57
58
59
60
61
62
63
64
65
66
# File 'lib/artifactory/resources/repository.rb', line 57

def find(name, options = {})
  client = extract_client!(options)

  response = client.get("/api/repositories/#{url_safe(name)}")
  from_hash(response, client: client)
rescue Error::HTTPError => e
  raise unless e.code == 400

  nil
end

Instance Method Details

#artifactsCollection::Artifact

The list of artifacts in this repository on the remote artifactory server.

Examples:

Get the list of artifacts for a repository

repo = Repository.new('libs-release-local')
repo.artifacts #=> [#<Resource::Artifacts>, ...]

Returns:

See Also:



159
160
161
162
163
# File 'lib/artifactory/resources/repository.rb', line 159

def artifacts
  @artifacts ||= Collection::Artifact.new(self, repos: key) do
    Resource::Artifact.search(name: ".*", repos: key)
  end
end

#blacked_outObject

Return this object’s blacked_out

Returns:

  • (Object)


69
# File 'lib/artifactory/resources/repository.rb', line 69

attribute :blacked_out, false

#blacked_out=(value) ⇒ Object

Set this object’s blacked_out

Parameters:

  • value (Object)

    the value to set for blacked_out

  • default (Object)

    the default value for this attribute



69
# File 'lib/artifactory/resources/repository.rb', line 69

attribute :blacked_out, false

#blacked_out?Boolean

Determines if the blacked_out value exists and is truthy

Returns:

  • (Boolean)


69
# File 'lib/artifactory/resources/repository.rb', line 69

attribute :blacked_out, false

#calculate_yum_metadataObject

Return this object’s calculate_yum_metadata

Returns:

  • (Object)


87
# File 'lib/artifactory/resources/repository.rb', line 87

attribute :calculate_yum_metadata, false

#calculate_yum_metadata=(value) ⇒ Object

Set this object’s calculate_yum_metadata

Parameters:

  • value (Object)

    the value to set for calculate_yum_metadata

  • default (Object)

    the default value for this attribute



87
# File 'lib/artifactory/resources/repository.rb', line 87

attribute :calculate_yum_metadata, false

#calculate_yum_metadata?Boolean

Determines if the calculate_yum_metadata value exists and is truthy

Returns:

  • (Boolean)


87
# File 'lib/artifactory/resources/repository.rb', line 87

attribute :calculate_yum_metadata, false

#checksum_policy_typeObject

Return this object’s checksum_policy_type

Returns:

  • (Object)


71
# File 'lib/artifactory/resources/repository.rb', line 71

attribute :checksum_policy_type, "client-checksums"

#checksum_policy_type=(value) ⇒ Object

Set this object’s checksum_policy_type

Parameters:

  • value (Object)

    the value to set for checksum_policy_type

  • default (Object)

    the default value for this attribute



71
# File 'lib/artifactory/resources/repository.rb', line 71

attribute :checksum_policy_type, "client-checksums"

#checksum_policy_type?Boolean

Determines if the checksum_policy_type value exists and is truthy

Returns:

  • (Boolean)


71
# File 'lib/artifactory/resources/repository.rb', line 71

attribute :checksum_policy_type, "client-checksums"

#client_tls_certificateObject

Return this object’s client_tls_certificate

Returns:

  • (Object)


90
# File 'lib/artifactory/resources/repository.rb', line 90

attribute :client_tls_certificate, ""

#client_tls_certificate=(value) ⇒ Object

Set this object’s client_tls_certificate

Parameters:

  • value (Object)

    the value to set for client_tls_certificate

  • default (Object)

    the default value for this attribute



90
# File 'lib/artifactory/resources/repository.rb', line 90

attribute :client_tls_certificate, ""

#client_tls_certificate?Boolean

Determines if the client_tls_certificate value exists and is truthy

Returns:

  • (Boolean)


90
# File 'lib/artifactory/resources/repository.rb', line 90

attribute :client_tls_certificate, ""

#deleteBoolean

Delete this repository from artifactory, suppressing any ResourceNotFound exceptions might occur.

Returns:

  • (Boolean)

    true if the object was deleted successfully, false otherwise



186
187
188
189
190
191
# File 'lib/artifactory/resources/repository.rb', line 186

def delete
  client.delete(api_path)
  true
rescue Error::HTTPError => e
  false
end

#descriptionObject

Return this object’s description

Returns:

  • (Object)


70
# File 'lib/artifactory/resources/repository.rb', line 70

attribute :description

#description=(value) ⇒ Object

Set this object’s description

Parameters:

  • value (Object)

    the value to set for description

  • default (Object)

    the default value for this attribute



70
# File 'lib/artifactory/resources/repository.rb', line 70

attribute :description

#description?Boolean

Determines if the description value exists and is truthy

Returns:

  • (Boolean)


70
# File 'lib/artifactory/resources/repository.rb', line 70

attribute :description

#excludes_patternObject

Return this object’s excludes_pattern

Returns:

  • (Object)


72
# File 'lib/artifactory/resources/repository.rb', line 72

attribute :excludes_pattern, ""

#excludes_pattern=(value) ⇒ Object

Set this object’s excludes_pattern

Parameters:

  • value (Object)

    the value to set for excludes_pattern

  • default (Object)

    the default value for this attribute



72
# File 'lib/artifactory/resources/repository.rb', line 72

attribute :excludes_pattern, ""

#excludes_pattern?Boolean

Determines if the excludes_pattern value exists and is truthy

Returns:

  • (Boolean)


72
# File 'lib/artifactory/resources/repository.rb', line 72

attribute :excludes_pattern, ""

#external_dependencies_enabledObject

Return this object’s external_dependencies_enabled

Returns:

  • (Object)


89
# File 'lib/artifactory/resources/repository.rb', line 89

attribute :external_dependencies_enabled, false

#external_dependencies_enabled=(value) ⇒ Object

Set this object’s external_dependencies_enabled

Parameters:

  • value (Object)

    the value to set for external_dependencies_enabled

  • default (Object)

    the default value for this attribute



89
# File 'lib/artifactory/resources/repository.rb', line 89

attribute :external_dependencies_enabled, false

#external_dependencies_enabled?Boolean

Determines if the external_dependencies_enabled value exists and is truthy

Returns:

  • (Boolean)


89
# File 'lib/artifactory/resources/repository.rb', line 89

attribute :external_dependencies_enabled, false

#filesObject



168
169
170
171
172
173
174
175
176
177
# File 'lib/artifactory/resources/repository.rb', line 168

def files
  response = client.get("/api/storage/#{url_safe(key)}", {
    deep:            0,
    listFolders:     0,
    mdTimestamps:    0,
    includeRootPath: 0,
  })

  response["children"]
end

#handle_releasesObject

Return this object’s handle_releases

Returns:

  • (Object)


73
# File 'lib/artifactory/resources/repository.rb', line 73

attribute :handle_releases, true

#handle_releases=(value) ⇒ Object

Set this object’s handle_releases

Parameters:

  • value (Object)

    the value to set for handle_releases

  • default (Object)

    the default value for this attribute



73
# File 'lib/artifactory/resources/repository.rb', line 73

attribute :handle_releases, true

#handle_releases?Boolean

Determines if the handle_releases value exists and is truthy

Returns:

  • (Boolean)


73
# File 'lib/artifactory/resources/repository.rb', line 73

attribute :handle_releases, true

#handle_snapshotsObject

Return this object’s handle_snapshots

Returns:

  • (Object)


74
# File 'lib/artifactory/resources/repository.rb', line 74

attribute :handle_snapshots, true

#handle_snapshots=(value) ⇒ Object

Set this object’s handle_snapshots

Parameters:

  • value (Object)

    the value to set for handle_snapshots

  • default (Object)

    the default value for this attribute



74
# File 'lib/artifactory/resources/repository.rb', line 74

attribute :handle_snapshots, true

#handle_snapshots?Boolean

Determines if the handle_snapshots value exists and is truthy

Returns:

  • (Boolean)


74
# File 'lib/artifactory/resources/repository.rb', line 74

attribute :handle_snapshots, true

#includes_patternObject

Return this object’s includes_pattern

Returns:

  • (Object)


75
# File 'lib/artifactory/resources/repository.rb', line 75

attribute :includes_pattern, "**/*"

#includes_pattern=(value) ⇒ Object

Set this object’s includes_pattern

Parameters:

  • value (Object)

    the value to set for includes_pattern

  • default (Object)

    the default value for this attribute



75
# File 'lib/artifactory/resources/repository.rb', line 75

attribute :includes_pattern, "**/*"

#includes_pattern?Boolean

Determines if the includes_pattern value exists and is truthy

Returns:

  • (Boolean)


75
# File 'lib/artifactory/resources/repository.rb', line 75

attribute :includes_pattern, "**/*"

#keyObject

Return this object’s key

Returns:

  • (Object)


76
# File 'lib/artifactory/resources/repository.rb', line 76

attribute :key, -> { raise "Key is missing!" }

#key=(value) ⇒ Object

Set this object’s key

Parameters:

  • value (Object)

    the value to set for key

  • default (Object)

    the default value for this attribute



76
# File 'lib/artifactory/resources/repository.rb', line 76

attribute :key, -> { raise "Key is missing!" }

#key?Boolean

Determines if the key value exists and is truthy

Returns:

  • (Boolean)


76
# File 'lib/artifactory/resources/repository.rb', line 76

attribute :key, -> { raise "Key is missing!" }

#max_unique_snapshotsObject

Return this object’s max_unique_snapshots

Returns:

  • (Object)


77
# File 'lib/artifactory/resources/repository.rb', line 77

attribute :max_unique_snapshots, 0

#max_unique_snapshots=(value) ⇒ Object

Set this object’s max_unique_snapshots

Parameters:

  • value (Object)

    the value to set for max_unique_snapshots

  • default (Object)

    the default value for this attribute



77
# File 'lib/artifactory/resources/repository.rb', line 77

attribute :max_unique_snapshots, 0

#max_unique_snapshots?Boolean

Determines if the max_unique_snapshots value exists and is truthy

Returns:

  • (Boolean)


77
# File 'lib/artifactory/resources/repository.rb', line 77

attribute :max_unique_snapshots, 0

#notesObject

Return this object’s notes

Returns:

  • (Object)


78
# File 'lib/artifactory/resources/repository.rb', line 78

attribute :notes

#notes=(value) ⇒ Object

Set this object’s notes

Parameters:

  • value (Object)

    the value to set for notes

  • default (Object)

    the default value for this attribute



78
# File 'lib/artifactory/resources/repository.rb', line 78

attribute :notes

#notes?Boolean

Determines if the notes value exists and is truthy

Returns:

  • (Boolean)


78
# File 'lib/artifactory/resources/repository.rb', line 78

attribute :notes

#package_typeObject

Return this object’s package_type

Returns:

  • (Object)


79
# File 'lib/artifactory/resources/repository.rb', line 79

attribute :package_type, "generic"

#package_type=(value) ⇒ Object

Set this object’s package_type

Parameters:

  • value (Object)

    the value to set for package_type

  • default (Object)

    the default value for this attribute



79
# File 'lib/artifactory/resources/repository.rb', line 79

attribute :package_type, "generic"

#package_type?Boolean

Determines if the package_type value exists and is truthy

Returns:

  • (Boolean)


79
# File 'lib/artifactory/resources/repository.rb', line 79

attribute :package_type, "generic"

#property_setsObject

Return this object’s property_sets

Returns:

  • (Object)


80
# File 'lib/artifactory/resources/repository.rb', line 80

attribute :property_sets, []

#property_sets=(value) ⇒ Object

Set this object’s property_sets

Parameters:

  • value (Object)

    the value to set for property_sets

  • default (Object)

    the default value for this attribute



80
# File 'lib/artifactory/resources/repository.rb', line 80

attribute :property_sets, []

#property_sets?Boolean

Determines if the property_sets value exists and is truthy

Returns:

  • (Boolean)


80
# File 'lib/artifactory/resources/repository.rb', line 80

attribute :property_sets, []

#rclassObject

Return this object’s rclass

Returns:

  • (Object)


82
# File 'lib/artifactory/resources/repository.rb', line 82

attribute :rclass, "local"

#rclass=(value) ⇒ Object

Set this object’s rclass

Parameters:

  • value (Object)

    the value to set for rclass

  • default (Object)

    the default value for this attribute



82
# File 'lib/artifactory/resources/repository.rb', line 82

attribute :rclass, "local"

#rclass?Boolean

Determines if the rclass value exists and is truthy

Returns:

  • (Boolean)


82
# File 'lib/artifactory/resources/repository.rb', line 82

attribute :rclass, "local"

#repo_layout_refObject

Return this object’s repo_layout_ref

Returns:

  • (Object)


81
# File 'lib/artifactory/resources/repository.rb', line 81

attribute :repo_layout_ref, "simple-default"

#repo_layout_ref=(value) ⇒ Object

Set this object’s repo_layout_ref

Parameters:

  • value (Object)

    the value to set for repo_layout_ref

  • default (Object)

    the default value for this attribute



81
# File 'lib/artifactory/resources/repository.rb', line 81

attribute :repo_layout_ref, "simple-default"

#repo_layout_ref?Boolean

Determines if the repo_layout_ref value exists and is truthy

Returns:

  • (Boolean)


81
# File 'lib/artifactory/resources/repository.rb', line 81

attribute :repo_layout_ref, "simple-default"

#repositoriesObject

Return this object’s repositories

Returns:

  • (Object)


88
# File 'lib/artifactory/resources/repository.rb', line 88

attribute :repositories, []

#repositories=(value) ⇒ Object

Set this object’s repositories

Parameters:

  • value (Object)

    the value to set for repositories

  • default (Object)

    the default value for this attribute



88
# File 'lib/artifactory/resources/repository.rb', line 88

attribute :repositories, []

#repositories?Boolean

Determines if the repositories value exists and is truthy

Returns:

  • (Boolean)


88
# File 'lib/artifactory/resources/repository.rb', line 88

attribute :repositories, []

#saveBoolean

Creates or updates a repository configuration depending on if the repository configuration previously existed. This method also works around Artifactory’s dangerous default behavior:

> An existing repository with the same key are removed from the
> configuration and its content is removed!

Returns:

  • (Boolean)


102
103
104
105
106
107
108
109
# File 'lib/artifactory/resources/repository.rb', line 102

def save
  if self.class.find(key, client: client)
    client.post(api_path, to_json, headers)
  else
    client.put(api_path, to_json, headers)
  end
  true
end

#snapshot_version_behaviorObject

Return this object’s snapshot_version_behavior

Returns:

  • (Object)


83
# File 'lib/artifactory/resources/repository.rb', line 83

attribute :snapshot_version_behavior, "non-unique"

#snapshot_version_behavior=(value) ⇒ Object

Set this object’s snapshot_version_behavior

Parameters:

  • value (Object)

    the value to set for snapshot_version_behavior

  • default (Object)

    the default value for this attribute



83
# File 'lib/artifactory/resources/repository.rb', line 83

attribute :snapshot_version_behavior, "non-unique"

#snapshot_version_behavior?Boolean

Determines if the snapshot_version_behavior value exists and is truthy

Returns:

  • (Boolean)


83
# File 'lib/artifactory/resources/repository.rb', line 83

attribute :snapshot_version_behavior, "non-unique"

#suppress_pom_consistency_checksObject

Return this object’s suppress_pom_consistency_checks

Returns:

  • (Object)


84
# File 'lib/artifactory/resources/repository.rb', line 84

attribute :suppress_pom_consistency_checks, false

#suppress_pom_consistency_checks=(value) ⇒ Object

Set this object’s suppress_pom_consistency_checks

Parameters:

  • value (Object)

    the value to set for suppress_pom_consistency_checks

  • default (Object)

    the default value for this attribute



84
# File 'lib/artifactory/resources/repository.rb', line 84

attribute :suppress_pom_consistency_checks, false

#suppress_pom_consistency_checks?Boolean

Determines if the suppress_pom_consistency_checks value exists and is truthy

Returns:

  • (Boolean)


84
# File 'lib/artifactory/resources/repository.rb', line 84

attribute :suppress_pom_consistency_checks, false

#upload(local_path, remote_path, properties = {}, headers = {}) ⇒ Resource::Artifact

Upload to a given repository



118
119
120
121
# File 'lib/artifactory/resources/repository.rb', line 118

def upload(local_path, remote_path, properties = {}, headers = {})
  artifact = Resource::Artifact.new(local_path: local_path)
  artifact.upload(key, remote_path, properties, headers)
end

#upload_from_archive(local_path, remote_path, properties = {}) ⇒ Object

Upload an artifact with the given archive. Consult the artifactory documentation for the format of the archive to upload.



141
142
143
144
# File 'lib/artifactory/resources/repository.rb', line 141

def upload_from_archive(local_path, remote_path, properties = {})
  artifact = Resource::Artifact.new(local_path: local_path)
  artifact.upload_from_archive(key, remote_path, properties)
end

#upload_with_checksum(local_path, remote_path, checksum, properties = {}) ⇒ Object

Upload an artifact with the given SHA checksum. Consult the artifactory documentation for the possible responses when the checksums fail to match.



130
131
132
133
# File 'lib/artifactory/resources/repository.rb', line 130

def upload_with_checksum(local_path, remote_path, checksum, properties = {})
  artifact = Resource::Artifact.new(local_path: local_path)
  artifact.upload_with_checksum(key, remote_path, checksum, properties)
end

#urlObject

Return this object’s url

Returns:

  • (Object)


85
# File 'lib/artifactory/resources/repository.rb', line 85

attribute :url, ""

#url=(value) ⇒ Object

Set this object’s url

Parameters:

  • value (Object)

    the value to set for url

  • default (Object)

    the default value for this attribute



85
# File 'lib/artifactory/resources/repository.rb', line 85

attribute :url, ""

#url?Boolean

Determines if the url value exists and is truthy

Returns:

  • (Boolean)


85
# File 'lib/artifactory/resources/repository.rb', line 85

attribute :url, ""

#yum_root_depthObject

Return this object’s yum_root_depth

Returns:

  • (Object)


86
# File 'lib/artifactory/resources/repository.rb', line 86

attribute :yum_root_depth, 0

#yum_root_depth=(value) ⇒ Object

Set this object’s yum_root_depth

Parameters:

  • value (Object)

    the value to set for yum_root_depth

  • default (Object)

    the default value for this attribute



86
# File 'lib/artifactory/resources/repository.rb', line 86

attribute :yum_root_depth, 0

#yum_root_depth?Boolean

Determines if the yum_root_depth value exists and is truthy

Returns:

  • (Boolean)


86
# File 'lib/artifactory/resources/repository.rb', line 86

attribute :yum_root_depth, 0