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.

Options Hash (options):



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>

Options Hash (options):

  • :name (String)

    the name of the repository to find

  • :client (Artifactory::Client)

    the client object to make the request with



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>, ...]

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



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

attribute :blacked_out, false

#blacked_out=(value) ⇒ Object

Set this object’s blacked_out



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



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

attribute :blacked_out, false

#calculate_yum_metadataObject

Return this object’s calculate_yum_metadata



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



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



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

attribute :calculate_yum_metadata, false

#checksum_policy_typeObject

Return this object’s checksum_policy_type



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



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



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



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



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



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.



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



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

attribute :description

#description=(value) ⇒ Object

Set this object’s description



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

attribute :description

#description?Boolean

Determines if the description value exists and is truthy



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

attribute :description

#excludes_patternObject

Return this object’s excludes_pattern



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

attribute :excludes_pattern, ""

#excludes_pattern=(value) ⇒ Object

Set this object’s excludes_pattern



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



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

attribute :excludes_pattern, ""

#external_dependencies_enabledObject

Return this object’s external_dependencies_enabled



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



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



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



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

attribute :handle_releases, true

#handle_releases=(value) ⇒ Object

Set this object’s handle_releases



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



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

attribute :handle_releases, true

#handle_snapshotsObject

Return this object’s handle_snapshots



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

attribute :handle_snapshots, true

#handle_snapshots=(value) ⇒ Object

Set this object’s handle_snapshots



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



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

attribute :handle_snapshots, true

#includes_patternObject

Return this object’s includes_pattern



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

attribute :includes_pattern, "**/*"

#includes_pattern=(value) ⇒ Object

Set this object’s includes_pattern



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



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

attribute :includes_pattern, "**/*"

#keyObject

Return this object’s key



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

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

#key=(value) ⇒ Object

Set this object’s key



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



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



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



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



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

attribute :max_unique_snapshots, 0

#notesObject

Return this object’s notes



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

attribute :notes

#notes=(value) ⇒ Object

Set this object’s notes



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

attribute :notes

#notes?Boolean

Determines if the notes value exists and is truthy



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

attribute :notes

#package_typeObject

Return this object’s package_type



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

attribute :package_type, "generic"

#package_type=(value) ⇒ Object

Set this object’s package_type



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



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

attribute :package_type, "generic"

#property_setsObject

Return this object’s property_sets



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

attribute :property_sets, []

#property_sets=(value) ⇒ Object

Set this object’s property_sets



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



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

attribute :property_sets, []

#rclassObject

Return this object’s rclass



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

attribute :rclass, "local"

#rclass=(value) ⇒ Object

Set this object’s rclass



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

attribute :rclass, "local"

#rclass?Boolean

Determines if the rclass value exists and is truthy



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

attribute :rclass, "local"

#repo_layout_refObject

Return this object’s repo_layout_ref



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



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



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

attribute :repo_layout_ref, "simple-default"

#repositoriesObject

Return this object’s repositories



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

attribute :repositories, []

#repositories=(value) ⇒ Object

Set this object’s repositories



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

attribute :repositories, []

#repositories?Boolean

Determines if the repositories value exists and is truthy



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!


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



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



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



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



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



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



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



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

attribute :url, ""

#url=(value) ⇒ Object

Set this object’s url



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

attribute :url, ""

#url?Boolean

Determines if the url value exists and is truthy



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

attribute :url, ""

#yum_root_depthObject

Return this object’s yum_root_depth



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



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



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

attribute :yum_root_depth, 0