Class: SDM::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

A Token is an account providing tokenized access for automation or integration use. Tokens include admin tokens, API keys, and SCIM tokens.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_type: nil, created_at: nil, deadline: nil, duration: nil, id: nil, name: nil, permissions: nil, rekeyed: nil, suspended: nil, tags: nil) ⇒ Token

Returns a new instance of Token.



18134
18135
18136
18137
18138
18139
18140
18141
18142
18143
18144
18145
18146
18147
18148
18149
18150
18151
18152
18153
18154
18155
18156
# File 'lib/models/porcelain.rb', line 18134

def initialize(
  account_type: nil,
  created_at: nil,
  deadline: nil,
  duration: nil,
  id: nil,
  name: nil,
  permissions: nil,
  rekeyed: nil,
  suspended: nil,
  tags: nil
)
  @account_type =  == nil ? "" : 
  @created_at = created_at == nil ? nil : created_at
  @deadline = deadline == nil ? nil : deadline
  @duration = duration == nil ? nil : duration
  @id = id == nil ? "" : id
  @name = name == nil ? "" : name
  @permissions = permissions == nil ? [] : permissions
  @rekeyed = rekeyed == nil ? nil : rekeyed
  @suspended = suspended == nil ? false : suspended
  @tags = tags == nil ? SDM::_porcelain_zero_value_tags() : tags
end

Instance Attribute Details

#account_typeObject

Corresponds to the type of token, e.g. api or admin-token.



18114
18115
18116
# File 'lib/models/porcelain.rb', line 18114

def 
  @account_type
end

#created_atObject

CreatedAt is the timestamp when the token was created



18116
18117
18118
# File 'lib/models/porcelain.rb', line 18116

def created_at
  @created_at
end

#deadlineObject

The timestamp when the Token will expire.



18118
18119
18120
# File 'lib/models/porcelain.rb', line 18118

def deadline
  @deadline
end

#durationObject

Duration from token creation to expiration.



18120
18121
18122
# File 'lib/models/porcelain.rb', line 18120

def duration
  @duration
end

#idObject

Unique identifier of the Token.



18122
18123
18124
# File 'lib/models/porcelain.rb', line 18122

def id
  @id
end

#nameObject

Unique human-readable name of the Token.



18124
18125
18126
# File 'lib/models/porcelain.rb', line 18124

def name
  @name
end

#permissionsObject

Permissions assigned to the token, e.g. role:create.



18126
18127
18128
# File 'lib/models/porcelain.rb', line 18126

def permissions
  @permissions
end

#rekeyedObject

The timestamp when the Token was last rekeyed.



18128
18129
18130
# File 'lib/models/porcelain.rb', line 18128

def rekeyed
  @rekeyed
end

#suspendedObject

Reserved for future use. Always false for tokens.



18130
18131
18132
# File 'lib/models/porcelain.rb', line 18130

def suspended
  @suspended
end

#tagsObject

Tags is a map of key, value pairs.



18132
18133
18134
# File 'lib/models/porcelain.rb', line 18132

def tags
  @tags
end

Instance Method Details

#to_json(options = {}) ⇒ Object



18158
18159
18160
18161
18162
18163
18164
# File 'lib/models/porcelain.rb', line 18158

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end