Class: SharedCredential

Inherits:
Domain::Model show all
Defined in:
lib/domain/shared_credential/model.rb

Overview

SharedCredential represents a credential that can be used across multiple sites in the system.

This class serves as a representation of shared credentials, which are primarily managed through the API, as there is no corresponding dimension in the database.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Domain::Model

columns, from_csv, from_json, headers, #initialize, primary_key, table_name, #to_hash, view

Constructor Details

This class inherits a constructor from Domain::Model

Instance Attribute Details

#accountObject

Returns the value of attribute account.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def 
  @account
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def description
  @description
end

#host_restrictionObject

Returns the value of attribute host_restriction.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def host_restriction
  @host_restriction
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def id
  @id
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def name
  @name
end

#port_restrictionObject

Returns the value of attribute port_restriction.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def port_restriction
  @port_restriction
end

#site_assignmentObject

Returns the value of attribute site_assignment.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def site_assignment
  @site_assignment
end

#sitesObject

Returns the value of attribute sites.



11
12
13
# File 'lib/domain/shared_credential/model.rb', line 11

def sites
  @sites
end

Instance Method Details

#assigned_to_all_sites?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/domain/shared_credential/model.rb', line 73

def assigned_to_all_sites?
  site_assignment == 'all-sites'
end

#cyberark?(country) ⇒ Boolean

returns true if the name starts with CyberArk and the name contains the country name

Returns:

  • (Boolean)


69
70
71
# File 'lib/domain/shared_credential/model.rb', line 69

def cyberark?(country)
  name.downcase.include?('cyberark') && name.downcase.include?(country.downcase)
end

#domainObject



20
21
22
# File 'lib/domain/shared_credential/model.rb', line 20

def domain
  @account['domain']
end

#permission_elevationObject



36
37
38
# File 'lib/domain/shared_credential/model.rb', line 36

def permission_elevation
  @account['permissionElevation']
end

#permission_elevation_user_nameObject



40
41
42
# File 'lib/domain/shared_credential/model.rb', line 40

def permission_elevation_user_name
  @account['permissionElevationUsername']
end

#serviceObject



24
25
26
# File 'lib/domain/shared_credential/model.rb', line 24

def service
  @account['service']
end

#service_nameObject



28
29
30
# File 'lib/domain/shared_credential/model.rb', line 28

def service_name
  @account['serviceName']
end

#to_csvObject



61
62
63
64
# File 'lib/domain/shared_credential/model.rb', line 61

def to_csv
  site_ids = sites&.join('|') || ''
  [id, name, , site_assignment, site_ids].join ','
end

#to_json(*_options) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/domain/shared_credential/model.rb', line 44

def to_json(*_options)
  {
    account: @account,
    description: @description,
    hostRestriction: @host_restriction,
    id: @id,
    name: @name,
    portRestriction: @port_restriction,
    siteAssignment: @site_assignment,
    sites: @sites
  }.to_json
end

#to_sObject



57
58
59
# File 'lib/domain/shared_credential/model.rb', line 57

def to_s
  "#{name} #{}"
end

#user_nameObject



32
33
34
# File 'lib/domain/shared_credential/model.rb', line 32

def user_name
  @account['userName']
end