class Artifactory::Resource::PermissionTarget

def all(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :client (Artifactory::Client) --

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

def api_path

Returns:
  • (String) -
def api_path
  @api_path ||= "/api/security/permissions/#{url_safe(name)}"
end

def client_principal

def client_principal
  @client_principal ||= Principal.new(principals['users'], principals['groups'])
end

def delete

Returns:
  • (Boolean) -
def delete
  client.delete(api_path)
    true
  rescue Error::HTTPError
    false
end

def find(name, options = {})

Returns:
  • (Resource::PermissionTarget, nil) -

Options Hash: (**options)
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --
  • name (String) --

Other tags:
    Example: Find a permission target by its name -
def find(name, options = {})
  client = extract_client!(options)
  response = client.get("/api/security/permissions/#{url_safe(name)}")
  from_hash(response, client: client)
rescue Error::HTTPError => e
  raise unless e.code == 404
  nil
end

def from_hash(hash, options = {})

Other tags:
    See: Resource::Base.from_hash -
def from_hash(hash, options = {})
  super.tap do |instance|
    %w(users groups).each do |key|
      if instance.principals[key] && !instance.principals[key].nil?
        instance.principals[key] = Hash[instance.principals[key].map { |k, v| [k, verbose(v)] } ]
      end
    end
  end
end

def groups


Getter for groups
def groups
  client_principal.groups
end

def groups=(groups_hash)


Setter for groups (groups_hash expected to be friendly)
def groups=(groups_hash)
  client_principal.groups = Hash[groups_hash.map { |k, v| [k, v.sort] } ]
end

def headers

Returns:
  • (Hash) -
def headers
  @headers ||= {
    'Content-Type' => 'application/vnd.org.jfrog.artifactory.security.PermissionTarget+json'
  }
end

def save

Returns:
  • (Boolean) -
def save
  send("#{:principals}=", client_principal.to_abbreviated)
  client.put(api_path, to_json, headers)
  true
end

def users


Getter for users
def users
  client_principal.users
end

def users=(users_hash)


Setter for users (expecting users_hash to be friendly)
def users=(users_hash)
  client_principal.users = Hash[users_hash.map { |k, v| [k, v.sort] } ]
end

def verbose(array)


Replace an array of permissions with one using verbose permission names
def verbose(array)
  array.map { |elt| VERBOSE_PERMS[elt] }.sort
end