Class: Artifactory::Resource::Group

Inherits:
Base
  • Object
show all
Defined in:
lib/artifactory/resources/group.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_s, url_safe, #url_safe

Constructor Details

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

Class Method Details

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

Get a list of all groups in the system.

Parameters:

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

    the list of options

Options Hash (options):

Returns:



16
17
18
19
20
21
# File 'lib/artifactory/resources/group.rb', line 16

def all(options = {})
  client = extract_client!(options)
  client.get('/api/security/groups').map do |hash|
    from_url(hash['uri'], client: client)
  end
end

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

Find (fetch) a group by its name.

Examples:

Find a group by its name

Group.find('readers') #=> #<Group name: 'readers' ...>

Parameters:

  • name (String)

    the name of the group to find

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

    the list of options

Options Hash (options):

Returns:

  • (Resource::Group, nil)

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



41
42
43
44
45
46
47
48
49
# File 'lib/artifactory/resources/group.rb', line 41

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

  response = client.get("/api/security/groups/#{url_safe(name)}")
  from_hash(response, client: client)
rescue Error::HTTPError => e
  raise unless e.code == 404
  nil
end

Instance Method Details

#auto_joinObject

Return this object’s auto_join

Returns:

  • (Object)


52
# File 'lib/artifactory/resources/group.rb', line 52

attribute :auto_join

#auto_join=(value) ⇒ Object

Set this object’s auto_join

Parameters:

  • value (Object)

    the value to set for auto_join

  • default (Object)

    the default value for this attribute



52
# File 'lib/artifactory/resources/group.rb', line 52

attribute :auto_join

#auto_join?Boolean

Determines if the auto_join value exists and is truthy

Returns:

  • (Boolean)


52
# File 'lib/artifactory/resources/group.rb', line 52

attribute :auto_join

#deleteBoolean

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

Returns:

  • (Boolean)

    true if the object was deleted successfully, false otherwise



65
66
67
68
69
70
# File 'lib/artifactory/resources/group.rb', line 65

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

#descriptionObject

Return this object’s description

Returns:

  • (Object)


53
# File 'lib/artifactory/resources/group.rb', line 53

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



53
# File 'lib/artifactory/resources/group.rb', line 53

attribute :description

#description?Boolean

Determines if the description value exists and is truthy

Returns:

  • (Boolean)


53
# File 'lib/artifactory/resources/group.rb', line 53

attribute :description

#nameObject

Return this object’s name

Returns:

  • (Object)


54
# File 'lib/artifactory/resources/group.rb', line 54

attribute :name, ->{ raise 'Name missing!' }

#name=(value) ⇒ Object

Set this object’s name

Parameters:

  • value (Object)

    the value to set for name

  • default (Object)

    the default value for this attribute



54
# File 'lib/artifactory/resources/group.rb', line 54

attribute :name, ->{ raise 'Name missing!' }

#name?Boolean

Determines if the name value exists and is truthy

Returns:

  • (Boolean)


54
# File 'lib/artifactory/resources/group.rb', line 54

attribute :name, ->{ raise 'Name missing!' }

#realmObject

Return this object’s realm

Returns:

  • (Object)


55
# File 'lib/artifactory/resources/group.rb', line 55

attribute :realm

#realm=(value) ⇒ Object

Set this object’s realm

Parameters:

  • value (Object)

    the value to set for realm

  • default (Object)

    the default value for this attribute



55
# File 'lib/artifactory/resources/group.rb', line 55

attribute :realm

#realm?Boolean

Determines if the realm value exists and is truthy

Returns:

  • (Boolean)


55
# File 'lib/artifactory/resources/group.rb', line 55

attribute :realm

#realm_attributesObject

Return this object’s realm_attributes

Returns:

  • (Object)


56
# File 'lib/artifactory/resources/group.rb', line 56

attribute :realm_attributes

#realm_attributes=(value) ⇒ Object

Set this object’s realm_attributes

Parameters:

  • value (Object)

    the value to set for realm_attributes

  • default (Object)

    the default value for this attribute



56
# File 'lib/artifactory/resources/group.rb', line 56

attribute :realm_attributes

#realm_attributes?Boolean

Determines if the realm_attributes value exists and is truthy

Returns:

  • (Boolean)


56
# File 'lib/artifactory/resources/group.rb', line 56

attribute :realm_attributes

#saveBoolean

Save the group to the artifactory server.

Returns:

  • (Boolean)


77
78
79
80
# File 'lib/artifactory/resources/group.rb', line 77

def save
  client.put(api_path, to_json, headers)
  true
end