Class: IKE::Artifactory::Client
- Inherits:
-
Object
- Object
- IKE::Artifactory::Client
- Defined in:
- lib/ike_artifactory/client.rb
Constant Summary collapse
- IMAGE_MANIFEST =
'manifest.json'
Instance Attribute Summary collapse
-
#folder_path ⇒ Object
Returns the value of attribute folder_path.
-
#password ⇒ Object
Returns the value of attribute password.
-
#repo_key ⇒ Object
Returns the value of attribute repo_key.
-
#server ⇒ Object
Returns the value of attribute server.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #delete_object(path) ⇒ Object
- #get_images(path) ⇒ Object
- #get_object_age(path) ⇒ Object
- #get_object_info(path) ⇒ Object
- #get_subdirectories(path) ⇒ Object
- #get_subdirectory_ages(path) ⇒ Object
-
#initialize(**args) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(**args) ⇒ Client
Returns a new instance of Client.
19 20 21 22 23 24 25 26 |
# File 'lib/ike_artifactory/client.rb', line 19 def initialize(**args) @server = args[:server] @repo_key = args[:repo_key] @user = args[:user] @password = args[:password] raise IKEArtifactoryClientNotReady.new(msg = 'Required attributes are missing. IKEArtifactoryGem not ready.') unless self.ready? end |
Instance Attribute Details
#folder_path ⇒ Object
Returns the value of attribute folder_path.
15 16 17 |
# File 'lib/ike_artifactory/client.rb', line 15 def folder_path @folder_path end |
#password ⇒ Object
Returns the value of attribute password.
17 18 19 |
# File 'lib/ike_artifactory/client.rb', line 17 def password @password end |
#repo_key ⇒ Object
Returns the value of attribute repo_key.
14 15 16 |
# File 'lib/ike_artifactory/client.rb', line 14 def repo_key @repo_key end |
#server ⇒ Object
Returns the value of attribute server.
13 14 15 |
# File 'lib/ike_artifactory/client.rb', line 13 def server @server end |
#user ⇒ Object
Returns the value of attribute user.
16 17 18 |
# File 'lib/ike_artifactory/client.rb', line 16 def user @user end |
Instance Method Details
#delete_object(path) ⇒ Object
28 29 30 31 32 |
# File 'lib/ike_artifactory/client.rb', line 28 def delete_object(path) fetch(path, method: :delete) do |response, request, result| response.code == 204 end end |
#get_images(path) ⇒ Object
64 65 66 67 68 |
# File 'lib/ike_artifactory/client.rb', line 64 def get_images(path) get_subdirectory_ages(path).select do |(folder, _age)| get_object_info([path, folder, IMAGE_MANIFEST].join('/')) end end |
#get_object_age(path) ⇒ Object
44 45 46 47 48 |
# File 'lib/ike_artifactory/client.rb', line 44 def get_object_age(path) get(path) do |response| ( ( Time.now - Time.iso8601(response['lastModified']) ) / (24*60*60) ).to_int end end |
#get_object_info(path) ⇒ Object
50 51 52 |
# File 'lib/ike_artifactory/client.rb', line 50 def get_object_info(path) get(path) end |
#get_subdirectories(path) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/ike_artifactory/client.rb', line 34 def get_subdirectories(path) get(path) do |response| (response['children'] || []).select do |c| c['folder'] end.map do |f| f['uri'][1..] end end end |
#get_subdirectory_ages(path) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/ike_artifactory/client.rb', line 54 def get_subdirectory_ages(path) get(path, prefix: "#{server}:443/ui/api/v1/ui/nativeBrowser/#{repo_key}") do |response| (response['children'] || []).each_with_object({}) do |child, memo| days_old = ( ( Time.now.to_i - (child['lastModified']/1000) ) / (24*60*60) ).to_int memo[child['name']] = days_old memo end end end |