Class: Artifactory::Resource::Certificate
- Defined in:
- lib/artifactory/resources/certificate.rb
Class Method Summary collapse
-
.all(options = {}) ⇒ Array<Resource::Certificate>
Get a list of all certificates in the system.
- .from_hash(hash, options = {}) ⇒ Object
Instance Method Summary collapse
-
#certificate_alias ⇒ Object
Return this object’s
certificate_alias
. -
#certificate_alias=(value) ⇒ Object
Set this object’s
certificate_alias
. -
#certificate_alias? ⇒ Boolean
Determines if the
certificate_alias
value exists and is truthy. -
#delete ⇒ Boolean
Delete this certificate from artifactory, suppressing any
ResourceNotFound
exceptions might occur. -
#fingerprint ⇒ Object
Return this object’s
fingerprint
. -
#fingerprint=(value) ⇒ Object
Set this object’s
fingerprint
. -
#fingerprint? ⇒ Boolean
Determines if the
fingerprint
value exists and is truthy. -
#issued_by ⇒ Object
Return this object’s
issued_by
. -
#issued_by=(value) ⇒ Object
Set this object’s
issued_by
. -
#issued_by? ⇒ Boolean
Determines if the
issued_by
value exists and is truthy. -
#issued_on ⇒ Object
Return this object’s
issued_on
. -
#issued_on=(value) ⇒ Object
Set this object’s
issued_on
. -
#issued_on? ⇒ Boolean
Determines if the
issued_on
value exists and is truthy. -
#issued_to ⇒ Object
Return this object’s
issued_to
. -
#issued_to=(value) ⇒ Object
Set this object’s
issued_to
. -
#issued_to? ⇒ Boolean
Determines if the
issued_to
value exists and is truthy. -
#local_path ⇒ Object
Return this object’s
local_path
. -
#local_path=(value) ⇒ Object
Set this object’s
local_path
. -
#local_path? ⇒ Boolean
Determines if the
local_path
value exists and is truthy. -
#upload ⇒ Resource::Certificate
Upload a certificate.
-
#valid_until ⇒ Object
Return this object’s
valid_until
. -
#valid_until=(value) ⇒ Object
Set this object’s
valid_until
. -
#valid_until? ⇒ Boolean
Determines if the
valid_until
value exists and is truthy.
Methods inherited from Base
attribute, attributes, #attributes, #client, #client=, #client?, #extract_client!, extract_client!, find_from_config, format_repos!, #format_repos!, from_url, has_attribute?, #initialize, #inspect, list_from_config, #set, #to_hash, #to_json, #to_matrix_properties, #to_query_string_parameters, #to_s, url_safe, #url_safe
Constructor Details
This class inherits a constructor from Artifactory::Resource::Base
Class Method Details
.all(options = {}) ⇒ Array<Resource::Certificate>
Get a list of all certificates in the system.
16 17 18 19 20 21 |
# File 'lib/artifactory/resources/certificate.rb', line 16 def all( = {}) client = extract_client!() client.get("/api/system/security/certificates").map do |cert| from_hash(cert, client: client) end.compact end |
.from_hash(hash, options = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/artifactory/resources/certificate.rb', line 26 def from_hash(hash, = {}) super.tap do |instance| instance.issued_on = Time.parse(instance.issued_on) rescue nil instance.valid_until = Time.parse(instance.valid_until) rescue nil end end |
Instance Method Details
#certificate_alias ⇒ Object
Return this object’s certificate_alias
34 |
# File 'lib/artifactory/resources/certificate.rb', line 34 attribute :certificate_alias, -> { raise "Certificate alias missing!" } |
#certificate_alias=(value) ⇒ Object
Set this object’s certificate_alias
34 |
# File 'lib/artifactory/resources/certificate.rb', line 34 attribute :certificate_alias, -> { raise "Certificate alias missing!" } |
#certificate_alias? ⇒ Boolean
Determines if the certificate_alias
value exists and is truthy
34 |
# File 'lib/artifactory/resources/certificate.rb', line 34 attribute :certificate_alias, -> { raise "Certificate alias missing!" } |
#delete ⇒ Boolean
Delete this certificate from artifactory, suppressing any ResourceNotFound
exceptions might occur.
49 50 51 52 53 54 |
# File 'lib/artifactory/resources/certificate.rb', line 49 def delete client.delete(api_path) true rescue Error::HTTPError false end |
#fingerprint ⇒ Object
Return this object’s fingerprint
35 |
# File 'lib/artifactory/resources/certificate.rb', line 35 attribute :fingerprint |
#fingerprint=(value) ⇒ Object
Set this object’s fingerprint
35 |
# File 'lib/artifactory/resources/certificate.rb', line 35 attribute :fingerprint |
#fingerprint? ⇒ Boolean
Determines if the fingerprint
value exists and is truthy
35 |
# File 'lib/artifactory/resources/certificate.rb', line 35 attribute :fingerprint |
#issued_by ⇒ Object
Return this object’s issued_by
36 |
# File 'lib/artifactory/resources/certificate.rb', line 36 attribute :issued_by |
#issued_by=(value) ⇒ Object
Set this object’s issued_by
36 |
# File 'lib/artifactory/resources/certificate.rb', line 36 attribute :issued_by |
#issued_by? ⇒ Boolean
Determines if the issued_by
value exists and is truthy
36 |
# File 'lib/artifactory/resources/certificate.rb', line 36 attribute :issued_by |
#issued_on ⇒ Object
Return this object’s issued_on
37 |
# File 'lib/artifactory/resources/certificate.rb', line 37 attribute :issued_on |
#issued_on=(value) ⇒ Object
Set this object’s issued_on
37 |
# File 'lib/artifactory/resources/certificate.rb', line 37 attribute :issued_on |
#issued_on? ⇒ Boolean
Determines if the issued_on
value exists and is truthy
37 |
# File 'lib/artifactory/resources/certificate.rb', line 37 attribute :issued_on |
#issued_to ⇒ Object
Return this object’s issued_to
38 |
# File 'lib/artifactory/resources/certificate.rb', line 38 attribute :issued_to |
#issued_to=(value) ⇒ Object
Set this object’s issued_to
38 |
# File 'lib/artifactory/resources/certificate.rb', line 38 attribute :issued_to |
#issued_to? ⇒ Boolean
Determines if the issued_to
value exists and is truthy
38 |
# File 'lib/artifactory/resources/certificate.rb', line 38 attribute :issued_to |
#local_path ⇒ Object
Return this object’s local_path
39 |
# File 'lib/artifactory/resources/certificate.rb', line 39 attribute :local_path, -> { raise "Local destination missing!" } |
#local_path=(value) ⇒ Object
Set this object’s local_path
39 |
# File 'lib/artifactory/resources/certificate.rb', line 39 attribute :local_path, -> { raise "Local destination missing!" } |
#local_path? ⇒ Boolean
Determines if the local_path
value exists and is truthy
39 |
# File 'lib/artifactory/resources/certificate.rb', line 39 attribute :local_path, -> { raise "Local destination missing!" } |
#upload ⇒ Resource::Certificate
Upload a certificate. If the first parameter is a File object, that file descriptor is passed to the uploader. If the first parameter is a string, it is assumed to be a path to a local file on disk. This method will automatically construct the File object from the given path.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/artifactory/resources/certificate.rb', line 68 def upload file = File.new(File.(local_path)) headers = { "Content-Type" => "application/text" } response = client.post(api_path, file, headers) return unless response.is_a?(Hash) self.class.all.select { |x| x.certificate_alias.eql?(certificate_alias) }.first end |
#valid_until ⇒ Object
Return this object’s valid_until
40 |
# File 'lib/artifactory/resources/certificate.rb', line 40 attribute :valid_until |
#valid_until=(value) ⇒ Object
Set this object’s valid_until
40 |
# File 'lib/artifactory/resources/certificate.rb', line 40 attribute :valid_until |
#valid_until? ⇒ Boolean
Determines if the valid_until
value exists and is truthy
40 |
# File 'lib/artifactory/resources/certificate.rb', line 40 attribute :valid_until |