Class: Artifactory::Resource::User
- Defined in:
- lib/artifactory/resources/user.rb
Class Method Summary collapse
-
.all(options = {}) ⇒ Array<Resource::User>
Get a list of all users in the system.
-
.find(name, options = {}) ⇒ Resource::User?
Find (fetch) a user by its name.
-
.from_hash(hash, options = {}) ⇒ Resource::User
Create a instance from the given Hash.
-
.from_url(url, options = {}) ⇒ Resource::User
Construct a user from the given URL.
Instance Method Summary collapse
-
#admin ⇒ Object
Return this object’s
admin
. -
#admin=(value) ⇒ Object
Set this object’s
admin
. -
#admin? ⇒ Boolean
Determines if the
admin
value exists and is truthy. -
#delete ⇒ Boolean
Delete this user from artifactory, suppressing any
ResourceNotFound
exceptions might occur. -
#email ⇒ Object
Return this object’s
email
. -
#email=(value) ⇒ Object
Set this object’s
email
. -
#email? ⇒ Boolean
Determines if the
email
value exists and is truthy. -
#groups ⇒ Object
Return this object’s
groups
. -
#groups=(value) ⇒ Object
Set this object’s
groups
. -
#groups? ⇒ Boolean
Determines if the
groups
value exists and is truthy. -
#internal_password_disabled ⇒ Object
Return this object’s
internal_password_disabled
. -
#internal_password_disabled=(value) ⇒ Object
Set this object’s
internal_password_disabled
. -
#internal_password_disabled? ⇒ Boolean
Determines if the
internal_password_disabled
value exists and is truthy. -
#last_logged_in ⇒ Object
Return this object’s
last_logged_in
. -
#last_logged_in=(value) ⇒ Object
Set this object’s
last_logged_in
. -
#last_logged_in? ⇒ Boolean
Determines if the
last_logged_in
value exists and is truthy. -
#name ⇒ Object
Return this object’s
name
. -
#name=(value) ⇒ Object
Set this object’s
name
. -
#name? ⇒ Boolean
Determines if the
name
value exists and is truthy. -
#password ⇒ Object
Return this object’s
password
. -
#password=(value) ⇒ Object
Set this object’s
password
. -
#password? ⇒ Boolean
Determines if the
password
value exists and is truthy. -
#profile_updatable ⇒ Object
Return this object’s
profile_updatable
. -
#profile_updatable=(value) ⇒ Object
Set this object’s
profile_updatable
. -
#profile_updatable? ⇒ Boolean
Determines if the
profile_updatable
value exists and is truthy. -
#realm ⇒ Object
Return this object’s
realm
. -
#realm=(value) ⇒ Object
Set this object’s
realm
. -
#realm? ⇒ Boolean
Determines if the
realm
value exists and is truthy. -
#save ⇒ Boolean
Save the user to the artifactory server.
-
#to_hash ⇒ Hash
The hash format for this user.
-
#to_json ⇒ String
The JSON representation of this resource.
Methods inherited from Base
attribute, #attributes, attributes, #client, #client=, #client?, extract_client!, #extract_client!, format_repos!, #format_repos!, #initialize, #inspect, #set, #to_s, #url_safe, url_safe
Constructor Details
This class inherits a constructor from Artifactory::Resource::Base
Class Method Details
.all(options = {}) ⇒ Array<Resource::User>
Get a list of all users in the system.
16 17 18 19 20 21 |
# File 'lib/artifactory/resources/user.rb', line 16 def all( = {}) client = extract_client!() client.get('/api/security/users').map do |hash| from_url(hash['uri'], client: client) end end |
.find(name, options = {}) ⇒ Resource::User?
Find (fetch) a user by its name.
41 42 43 44 45 46 47 48 |
# File 'lib/artifactory/resources/user.rb', line 41 def find(name, = {}) client = extract_client!() response = client.get("/api/security/users/#{url_safe(name)}") from_hash(response, client: client) rescue Error::NotFound nil end |
.from_hash(hash, options = {}) ⇒ Resource::User
Create a instance from the given Hash. This method extracts the “safe” information from the hash and adds them to the instance.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/artifactory/resources/user.rb', line 82 def from_hash(hash, = {}) client = extract_client!() new.tap do |instance| instance.admin = !!hash['admin'] instance.email = hash['email'] instance.groups = Array(hash['groups']) instance.internal_password_disabled = hash['internalPasswordDisabled'] instance.last_logged_in = hash['lastLoggedIn'] instance.name = hash['name'] instance.password = hash['password'] instance.profile_updatable = !!hash['profileUpdatable'] instance.realm = hash['realm'] end end |
.from_url(url, options = {}) ⇒ Resource::User
Construct a user from the given URL.
63 64 65 66 |
# File 'lib/artifactory/resources/user.rb', line 63 def from_url(url, = {}) client = extract_client!() from_hash(client.get(url), client: client) end |
Instance Method Details
#admin ⇒ Object
Return this object’s admin
99 |
# File 'lib/artifactory/resources/user.rb', line 99 attribute :admin, false |
#admin=(value) ⇒ Object
Set this object’s admin
99 |
# File 'lib/artifactory/resources/user.rb', line 99 attribute :admin, false |
#admin? ⇒ Boolean
Determines if the admin
value exists and is truthy
99 |
# File 'lib/artifactory/resources/user.rb', line 99 attribute :admin, false |
#delete ⇒ Boolean
Delete this user from artifactory, suppressing any ResourceNotFound
exceptions might occur.
116 117 118 119 120 |
# File 'lib/artifactory/resources/user.rb', line 116 def delete !!client.delete(api_path) rescue Error::NotFound false end |
#email ⇒ Object
Return this object’s email
100 |
# File 'lib/artifactory/resources/user.rb', line 100 attribute :email |
#email=(value) ⇒ Object
Set this object’s email
100 |
# File 'lib/artifactory/resources/user.rb', line 100 attribute :email |
#email? ⇒ Boolean
Determines if the email
value exists and is truthy
100 |
# File 'lib/artifactory/resources/user.rb', line 100 attribute :email |
#groups ⇒ Object
Return this object’s groups
101 |
# File 'lib/artifactory/resources/user.rb', line 101 attribute :groups, [] |
#groups=(value) ⇒ Object
Set this object’s groups
101 |
# File 'lib/artifactory/resources/user.rb', line 101 attribute :groups, [] |
#groups? ⇒ Boolean
Determines if the groups
value exists and is truthy
101 |
# File 'lib/artifactory/resources/user.rb', line 101 attribute :groups, [] |
#internal_password_disabled ⇒ Object
Return this object’s internal_password_disabled
102 |
# File 'lib/artifactory/resources/user.rb', line 102 attribute :internal_password_disabled, false |
#internal_password_disabled=(value) ⇒ Object
Set this object’s internal_password_disabled
102 |
# File 'lib/artifactory/resources/user.rb', line 102 attribute :internal_password_disabled, false |
#internal_password_disabled? ⇒ Boolean
Determines if the internal_password_disabled
value exists and is truthy
102 |
# File 'lib/artifactory/resources/user.rb', line 102 attribute :internal_password_disabled, false |
#last_logged_in ⇒ Object
Return this object’s last_logged_in
103 |
# File 'lib/artifactory/resources/user.rb', line 103 attribute :last_logged_in |
#last_logged_in=(value) ⇒ Object
Set this object’s last_logged_in
103 |
# File 'lib/artifactory/resources/user.rb', line 103 attribute :last_logged_in |
#last_logged_in? ⇒ Boolean
Determines if the last_logged_in
value exists and is truthy
103 |
# File 'lib/artifactory/resources/user.rb', line 103 attribute :last_logged_in |
#name ⇒ Object
Return this object’s name
104 |
# File 'lib/artifactory/resources/user.rb', line 104 attribute :name, -> { raise 'Name missing' } |
#name=(value) ⇒ Object
Set this object’s name
104 |
# File 'lib/artifactory/resources/user.rb', line 104 attribute :name, -> { raise 'Name missing' } |
#name? ⇒ Boolean
Determines if the name
value exists and is truthy
104 |
# File 'lib/artifactory/resources/user.rb', line 104 attribute :name, -> { raise 'Name missing' } |
#password ⇒ Object
Return this object’s password
105 |
# File 'lib/artifactory/resources/user.rb', line 105 attribute :password |
#password=(value) ⇒ Object
Set this object’s password
105 |
# File 'lib/artifactory/resources/user.rb', line 105 attribute :password |
#password? ⇒ Boolean
Determines if the password
value exists and is truthy
105 |
# File 'lib/artifactory/resources/user.rb', line 105 attribute :password |
#profile_updatable ⇒ Object
Return this object’s profile_updatable
106 |
# File 'lib/artifactory/resources/user.rb', line 106 attribute :profile_updatable, true |
#profile_updatable=(value) ⇒ Object
Set this object’s profile_updatable
106 |
# File 'lib/artifactory/resources/user.rb', line 106 attribute :profile_updatable, true |
#profile_updatable? ⇒ Boolean
Determines if the profile_updatable
value exists and is truthy
106 |
# File 'lib/artifactory/resources/user.rb', line 106 attribute :profile_updatable, true |
#realm ⇒ Object
Return this object’s realm
107 |
# File 'lib/artifactory/resources/user.rb', line 107 attribute :realm |
#realm=(value) ⇒ Object
Set this object’s realm
107 |
# File 'lib/artifactory/resources/user.rb', line 107 attribute :realm |
#realm? ⇒ Boolean
Determines if the realm
value exists and is truthy
107 |
# File 'lib/artifactory/resources/user.rb', line 107 attribute :realm |
#save ⇒ Boolean
Save the user to the artifactory server.
127 128 129 130 |
# File 'lib/artifactory/resources/user.rb', line 127 def save client.put(api_path, to_json, headers) true end |
#to_hash ⇒ Hash
The hash format for this user.
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/artifactory/resources/user.rb', line 137 def to_hash { 'admin' => admin, 'email' => email, 'groups' => groups, 'internalPasswordDisabled' => internal_password_disabled, 'lastLoggedIn' => last_logged_in, 'name' => name, 'password' => password, 'profileUpdatable' => profile_updatable, 'realm' => realm, } end |
#to_json ⇒ String
The JSON representation of this resource.
156 157 158 |
# File 'lib/artifactory/resources/user.rb', line 156 def to_json JSON.fast_generate(to_hash) end |