Class: SharedCredential

Inherits:
Object
  • Object
show all
Defined in:
lib/domain/shared_credential/model.rb

Overview

Shared Credential can be used in multiple sites NOTE: There is no dimension, so the API is the source of truth

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, account:, site_assignment:, sites:, description:, host_restriction:, port_restriction:) ⇒ SharedCredential

Returns a new instance of SharedCredential.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/domain/shared_credential/model.rb', line 8

def initialize(id:,
               name:,
               account:,
               site_assignment:,
               sites:,
               description:,
               host_restriction:,
               port_restriction:)
  @account = 
  @description = description
  @host_restriction = host_restriction
  @id = id
  @name = name
  @port_restriction = port_restriction
  @site_assignment  = site_assignment
  @sites = sites
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def 
  @account
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def description
  @description
end

#host_restrictionObject

Returns the value of attribute host_restriction.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def host_restriction
  @host_restriction
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def id
  @id
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def name
  @name
end

#port_restrictionObject

Returns the value of attribute port_restriction.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def port_restriction
  @port_restriction
end

#site_assignmentObject

Returns the value of attribute site_assignment.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def site_assignment
  @site_assignment
end

#sitesObject

Returns the value of attribute sites.



6
7
8
# File 'lib/domain/shared_credential/model.rb', line 6

def sites
  @sites
end

Class Method Details

.from_json(data) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/domain/shared_credential/model.rb', line 50

def self.from_json(data)
  SharedCredential.new(
    account: data['account'],
    description: data['description'],
    host_restriction: data['hostRestriction'],
    id: data['id'],
    name: data['name'],
    port_restriction: data['portRestriction'],
    site_assignment: data['siteAssignment'],
    sites: data['sites']
  )
end

Instance Method Details

#cyberark?(country) ⇒ Boolean

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

Returns:

  • (Boolean)


90
91
92
# File 'lib/domain/shared_credential/model.rb', line 90

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

#domainObject



26
27
28
# File 'lib/domain/shared_credential/model.rb', line 26

def domain
  @account['domain']
end

#from_csvObject



80
# File 'lib/domain/shared_credential/model.rb', line 80

def from_csv; end

#permission_elevationObject



42
43
44
# File 'lib/domain/shared_credential/model.rb', line 42

def permission_elevation
  @account['permissionElevation']
end

#permission_elevation_user_nameObject



46
47
48
# File 'lib/domain/shared_credential/model.rb', line 46

def permission_elevation_user_name
  @account['permissionElevationUsername']
end

#serviceObject



30
31
32
# File 'lib/domain/shared_credential/model.rb', line 30

def service
  @account['service']
end

#service_nameObject



34
35
36
# File 'lib/domain/shared_credential/model.rb', line 34

def service_name
  @account['serviceName']
end

#to_csvObject



82
83
84
85
# File 'lib/domain/shared_credential/model.rb', line 82

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

#to_json(*_options) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/domain/shared_credential/model.rb', line 63

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



76
77
78
# File 'lib/domain/shared_credential/model.rb', line 76

def to_s
  [id, name, service, domain, user_name].join ','
end

#user_nameObject



38
39
40
# File 'lib/domain/shared_credential/model.rb', line 38

def user_name
  @account['userName']
end