Class: Comet::ServerConfigOptions

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

Overview

ServerConfigOptions is a typed class wrapper around the underlying Comet Server API data structure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServerConfigOptions

Returns a new instance of ServerConfigOptions.



72
73
74
# File 'lib/comet/models/server_config_options.rb', line 72

def initialize
  clear
end

Instance Attribute Details

#admin_usersObject

Returns the value of attribute admin_users.



28
29
30
# File 'lib/comet/models/server_config_options.rb', line 28

def admin_users
  @admin_users
end

#authentication_roleObject

Returns the value of attribute authentication_role.



49
50
51
# File 'lib/comet/models/server_config_options.rb', line 49

def authentication_role
  @authentication_role
end

#brandingObject

Returns the value of attribute branding.



25
26
27
# File 'lib/comet/models/server_config_options.rb', line 25

def branding
  @branding
end

#constellation_roleObject

Returns the value of attribute constellation_role.



58
59
60
# File 'lib/comet/models/server_config_options.rb', line 58

def constellation_role
  @constellation_role
end

#constellation_role__legacyObject

Returns the value of attribute constellation_role__legacy.



61
62
63
# File 'lib/comet/models/server_config_options.rb', line 61

def constellation_role__legacy
  @constellation_role__legacy
end

#emailObject

Returns the value of attribute email.



46
47
48
# File 'lib/comet/models/server_config_options.rb', line 46

def email
  @email
end

#experimental_optionsObject

Returns the value of attribute experimental_options.



16
17
18
# File 'lib/comet/models/server_config_options.rb', line 16

def experimental_options
  @experimental_options
end

#external_admin_user_sourcesObject

Returns the value of attribute external_admin_user_sources.



34
35
36
# File 'lib/comet/models/server_config_options.rb', line 34

def external_admin_user_sources
  @external_admin_user_sources
end

#iprate_limitObject

Returns the value of attribute iprate_limit.



43
44
45
# File 'lib/comet/models/server_config_options.rb', line 43

def iprate_limit
  @iprate_limit
end

#licenseObject

Returns the value of attribute license.



22
23
24
# File 'lib/comet/models/server_config_options.rb', line 22

def license
  @license
end

#listen_addressesObject

Returns the value of attribute listen_addresses.



37
38
39
# File 'lib/comet/models/server_config_options.rb', line 37

def listen_addresses
  @listen_addresses
end

#organizationsObject

Returns the value of attribute organizations.



31
32
33
# File 'lib/comet/models/server_config_options.rb', line 31

def organizations
  @organizations
end

#self_backupObject

Returns the value of attribute self_backup.



64
65
66
# File 'lib/comet/models/server_config_options.rb', line 64

def self_backup
  @self_backup
end

#session_settingsObject

Returns the value of attribute session_settings.



67
68
69
# File 'lib/comet/models/server_config_options.rb', line 67

def session_settings
  @session_settings
end

#software_build_roleObject

Returns the value of attribute software_build_role.



55
56
57
# File 'lib/comet/models/server_config_options.rb', line 55

def software_build_role
  @software_build_role
end

#storage_roleObject

Returns the value of attribute storage_role.



52
53
54
# File 'lib/comet/models/server_config_options.rb', line 52

def storage_role
  @storage_role
end

#trust_xforwarded_forObject

Returns the value of attribute trust_xforwarded_for.



40
41
42
# File 'lib/comet/models/server_config_options.rb', line 40

def trust_xforwarded_for
  @trust_xforwarded_for
end

#unknown_json_fieldsObject

Returns the value of attribute unknown_json_fields.



70
71
72
# File 'lib/comet/models/server_config_options.rb', line 70

def unknown_json_fields
  @unknown_json_fields
end

#webhook_optionsObject

Returns the value of attribute webhook_options.



19
20
21
# File 'lib/comet/models/server_config_options.rb', line 19

def webhook_options
  @webhook_options
end

Instance Method Details

#clearObject



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/comet/models/server_config_options.rb', line 76

def clear
  @experimental_options = []
  @webhook_options = {}
  @license = Comet::LicenseOptions.new
  @branding = Comet::BrandingOptions.new
  @admin_users = []
  @organizations = {}
  @external_admin_user_sources = {}
  @listen_addresses = []
  @iprate_limit = Comet::RatelimitOptions.new
  @email = Comet::EmailOptions.new
  @authentication_role = Comet::AuthenticationRoleOptions.new
  @storage_role = Comet::StorageRoleOptions.new
  @software_build_role = Comet::SoftwareBuildRoleOptions.new
  @constellation_role = Comet::ConstellationRoleOptions.new
  @constellation_role__legacy = Comet::ConstellationRoleOptions.new
  @self_backup = Comet::SelfBackupOptions.new
  @session_settings = Comet::SessionOptions.new
  @unknown_json_fields = {}
end

#from_hash(obj) ⇒ Object

Parameters:

  • obj (Hash)

    The complete object as a Ruby hash

Raises:

  • (TypeError)


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/comet/models/server_config_options.rb', line 105

def from_hash(obj)
  raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash

  obj.each do |k, v|
    case k
    when 'ExperimentalOptions'
      if v.nil?
        @experimental_options = []
      else
        @experimental_options = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @experimental_options[i1] = v1
        end
      end
    when 'WebhookOptions'
      @webhook_options = {}
      if v.nil?
        @webhook_options = {}
      else
        v.each do |k1, v1|
          @webhook_options[k1] = Comet::WebhookOption.new
          @webhook_options[k1].from_hash(v1)
        end
      end
    when 'License'
      @license = Comet::LicenseOptions.new
      @license.from_hash(v)
    when 'Branding'
      @branding = Comet::BrandingOptions.new
      @branding.from_hash(v)
    when 'AdminUsers'
      if v.nil?
        @admin_users = []
      else
        @admin_users = Array.new(v.length)
        v.each_with_index do |v1, i1|
          @admin_users[i1] = Comet::AllowedAdminUser.new
          @admin_users[i1].from_hash(v1)
        end
      end
    when 'Organizations'
      @organizations = {}
      if v.nil?
        @organizations = {}
      else
        v.each do |k1, v1|
          @organizations[k1] = Comet::Organization.new
          @organizations[k1].from_hash(v1)
        end
      end
    when 'ExternalAdminUserSources'
      @external_admin_user_sources = {}
      if v.nil?
        @external_admin_user_sources = {}
      else
        v.each do |k1, v1|
          @external_admin_user_sources[k1] = Comet::ExternalAuthenticationSource.new
          @external_admin_user_sources[k1].from_hash(v1)
        end
      end
    when 'ListenAddresses'
      if v.nil?
        @listen_addresses = []
      else
        @listen_addresses = Array.new(v.length)
        v.each_with_index do |v1, i1|
          @listen_addresses[i1] = Comet::HTTPConnectorOptions.new
          @listen_addresses[i1].from_hash(v1)
        end
      end
    when 'TrustXForwardedFor'
      @trust_xforwarded_for = v
    when 'IPRateLimit'
      @iprate_limit = Comet::RatelimitOptions.new
      @iprate_limit.from_hash(v)
    when 'Email'
      @email = Comet::EmailOptions.new
      @email.from_hash(v)
    when 'AuthenticationRole'
      @authentication_role = Comet::AuthenticationRoleOptions.new
      @authentication_role.from_hash(v)
    when 'StorageRole'
      @storage_role = Comet::StorageRoleOptions.new
      @storage_role.from_hash(v)
    when 'SoftwareBuildRole'
      @software_build_role = Comet::SoftwareBuildRoleOptions.new
      @software_build_role.from_hash(v)
    when 'ConstellationRole'
      @constellation_role = Comet::ConstellationRoleOptions.new
      @constellation_role.from_hash(v)
    when 'OverseerRole'
      @constellation_role__legacy = Comet::ConstellationRoleOptions.new
      @constellation_role__legacy.from_hash(v)
    when 'SelfBackup'
      @self_backup = Comet::SelfBackupOptions.new
      @self_backup.from_hash(v)
    when 'SessionSettings'
      @session_settings = Comet::SessionOptions.new
      @session_settings.from_hash(v)
    else
      @unknown_json_fields[k] = v
    end
  end
end

#from_json(json_string) ⇒ Object

Parameters:

  • json_string (String)

    The complete object in JSON format

Raises:

  • (TypeError)


98
99
100
101
102
# File 'lib/comet/models/server_config_options.rb', line 98

def from_json(json_string)
  raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String

  from_hash(JSON.parse(json_string))
end

#to_hHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



244
245
246
# File 'lib/comet/models/server_config_options.rb', line 244

def to_h
  to_hash
end

#to_hashHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/comet/models/server_config_options.rb', line 213

def to_hash
  ret = {}
  unless @experimental_options.nil?
    ret['ExperimentalOptions'] = @experimental_options
  end
  ret['WebhookOptions'] = @webhook_options
  ret['License'] = @license
  ret['Branding'] = @branding
  ret['AdminUsers'] = @admin_users
  ret['Organizations'] = @organizations
  ret['ExternalAdminUserSources'] = @external_admin_user_sources
  ret['ListenAddresses'] = @listen_addresses
  ret['TrustXForwardedFor'] = @trust_xforwarded_for
  ret['IPRateLimit'] = @iprate_limit
  ret['Email'] = @email
  ret['AuthenticationRole'] = @authentication_role
  ret['StorageRole'] = @storage_role
  ret['SoftwareBuildRole'] = @software_build_role
  ret['ConstellationRole'] = @constellation_role
  unless @constellation_role__legacy.nil?
    ret['OverseerRole'] = @constellation_role__legacy
  end
  ret['SelfBackup'] = @self_backup
  ret['SessionSettings'] = @session_settings
  @unknown_json_fields.each do |k, v|
    ret[k] = v
  end
  ret
end

#to_json(options = {}) ⇒ String

Returns The complete object as a JSON string.

Returns:

  • (String)

    The complete object as a JSON string



249
250
251
# File 'lib/comet/models/server_config_options.rb', line 249

def to_json(options = {})
  to_hash.to_json(options)
end