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_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::Group>

Get a list of all groups in the system.

Parameters:

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

    the list of options

Options Hash (options):

Returns:



32
33
34
35
36
37
# File 'lib/artifactory/resources/group.rb', line 32

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



57
58
59
60
61
62
63
64
65
# File 'lib/artifactory/resources/group.rb', line 57

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)


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

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



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

attribute :auto_join

#auto_join?Boolean

Determines if the auto_join value exists and is truthy

Returns:

  • (Boolean)


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

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



81
82
83
84
85
86
# File 'lib/artifactory/resources/group.rb', line 81

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

#descriptionObject

Return this object’s description

Returns:

  • (Object)


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

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



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

attribute :description

#description?Boolean

Determines if the description value exists and is truthy

Returns:

  • (Boolean)


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

attribute :description

#nameObject

Return this object’s name

Returns:

  • (Object)


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

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



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

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

#name?Boolean

Determines if the name value exists and is truthy

Returns:

  • (Boolean)


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

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

#realmObject

Return this object’s realm

Returns:

  • (Object)


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

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



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

attribute :realm

#realm?Boolean

Determines if the realm value exists and is truthy

Returns:

  • (Boolean)


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

attribute :realm

#realm_attributesObject

Return this object’s realm_attributes

Returns:

  • (Object)


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

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



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

attribute :realm_attributes

#realm_attributes?Boolean

Determines if the realm_attributes value exists and is truthy

Returns:

  • (Boolean)


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

attribute :realm_attributes

#saveBoolean

Creates or updates a group configuration depending on if the group configuration previously existed.

Returns:

  • (Boolean)


94
95
96
97
98
99
100
101
# File 'lib/artifactory/resources/group.rb', line 94

def save
  if self.class.find(name, client: client)
    client.post(api_path, to_json, headers)
  else
    client.put(api_path, to_json, headers)
  end
  true
end