Class: SwaggerClient::ServiceBody

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet_x/swagger_client/models/service_body.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ ServiceBody

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 121

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.address_version = if attributes.key?(:'address-version')
                           attributes[:'address-version']
                         else
                           'IPv4'
                         end

  self.status = if attributes.key?(:status)
                  attributes[:status]
                else
                  'On'
                end

  self.name = attributes[:name] if attributes.key?(:name)

  self.port = attributes[:port] if attributes.key?(:port)

  self.comments = if attributes.key?(:comments)
                    attributes[:comments]
                  else
                    ''
                  end

  self.enable_access_logs = if attributes.key?(:'enable-access-logs')
                              attributes[:'enable-access-logs']
                            else
                              'Yes'
                            end

  if attributes.key?(:'session-timeout')
    self.session_timeout = attributes[:'session-timeout']
  end

  self.app_id = attributes[:'app-id'] if attributes.key?(:'app-id')

  self.group = attributes[:group] if attributes.key?(:group)

  self.vsite = attributes[:vsite] if attributes.key?(:vsite)

  self.type = if attributes.key?(:type)
                attributes[:type]
              else
                'HTTP'
              end

  self.dps_enabled = if attributes.key?(:'dps-enabled')
                       attributes[:'dps-enabled']
                     else
                       'No'
                     end

  if attributes.key?(:'ip-address')
    self.ip_address = attributes[:'ip-address']
  end

  self.mask = attributes[:mask] if attributes.key?(:mask)
end

Instance Attribute Details

#address_versionObject

Version



16
17
18
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 16

def address_version
  @address_version
end

#app_idObject

Service App Id



37
38
39
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 37

def app_id
  @app_id
end

#commentsObject

Comments



28
29
30
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 28

def comments
  @comments
end

#dps_enabledObject

Enable DDoS Prevention Service



49
50
51
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 49

def dps_enabled
  @dps_enabled
end

#enable_access_logsObject

Enable Access Logs



31
32
33
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 31

def enable_access_logs
  @enable_access_logs
end

#groupObject

Service Group



40
41
42
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 40

def group
  @group
end

#ip_addressObject

VIP



52
53
54
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 52

def ip_address
  @ip_address
end

#maskObject

Mask



55
56
57
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 55

def mask
  @mask
end

#nameObject

Web Application Name



22
23
24
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 22

def name
  @name
end

#portObject

Port



25
26
27
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 25

def port
  @port
end

#session_timeoutObject

Session Timeout



34
35
36
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 34

def session_timeout
  @session_timeout
end

#statusObject

Status



19
20
21
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 19

def status
  @status
end

#typeObject

Type



46
47
48
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 46

def type
  @type
end

#vsiteObject

Vsite



43
44
45
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 43

def vsite
  @vsite
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 80

def self.attribute_map
  {
    address_version: :'address-version',
    status: :status,
    name: :name,
    port: :port,
    comments: :comments,
    enable_access_logs: :'enable-access-logs',
    session_timeout: :'session-timeout',
    app_id: :'app-id',
    group: :group,
    vsite: :vsite,
    type: :type,
    dps_enabled: :'dps-enabled',
    ip_address: :'ip-address',
    mask: :mask
  }
end

.swagger_typesObject

Attribute type mapping.



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 100

def self.swagger_types
  {
    address_version: :String,
    status: :String,
    name: :String,
    port: :Integer,
    comments: :String,
    enable_access_logs: :String,
    session_timeout: :Integer,
    app_id: :String,
    group: :String,
    vsite: :String,
    type: :String,
    dps_enabled: :String,
    ip_address: :String,
    mask: :String
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 299

def ==(o)
  return true if equal?(o)
  self.class == o.class &&
    address_version == o.address_version &&
    status == o.status &&
    name == o.name &&
    port == o.port &&
    comments == o.comments &&
    enable_access_logs == o.enable_access_logs &&
    session_timeout == o.session_timeout &&
    app_id == o.app_id &&
    group == o.group &&
    vsite == o.vsite &&
    type == o.type &&
    dps_enabled == o.dps_enabled &&
    ip_address == o.ip_address &&
    mask == o.mask
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 354

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = SwaggerClient.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 420

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 333

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(Regexp.last_match(1), v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


320
321
322
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 320

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



326
327
328
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 326

def hash
  [address_version, status, name, port, comments, enable_access_logs, session_timeout, app_id, group, vsite, type, dps_enabled, ip_address, mask].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properies with the reasons



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 186

def list_invalid_properties
  invalid_properties = []
  if @name.nil?
    invalid_properties.push("invalid value for 'name', name cannot be nil.")
  end

  if !@port.nil? && @port < 1
    invalid_properties.push("invalid value for 'port', must be greater than or equal to 1.")
  end

  if !@session_timeout.nil? && @session_timeout < 0
    invalid_properties.push("invalid value for 'session_timeout', must be greater than or equal to 0.")
  end

  if @ip_address.nil?
    invalid_properties.push("invalid value for 'ip_address', ip_address cannot be nil.")
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



400
401
402
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 400

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



406
407
408
409
410
411
412
413
414
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 406

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



394
395
396
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 394

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/puppet_x/swagger_client/models/service_body.rb', line 209

def valid?
  address_version_validator = EnumAttributeValidator.new('String', %w[IPv4 IPv6])
  return false unless address_version_validator.valid?(@address_version)
  status_validator = EnumAttributeValidator.new('String', %w[On Off])
  return false unless status_validator.valid?(@status)
  return false if @name.nil?
  return false if !@port.nil? && @port < 1
  enable_access_logs_validator = EnumAttributeValidator.new('String', %w[Yes No])
  return false unless enable_access_logs_validator.valid?(@enable_access_logs)
  return false if !@session_timeout.nil? && @session_timeout < 0
  type_validator = EnumAttributeValidator.new('String', ['HTTP', 'HTTPS', 'Instant SSL', 'Redirect Service', 'Custom', 'Custom SSL', 'FTP', 'FTP SSL'])
  return false unless type_validator.valid?(@type)
  dps_enabled_validator = EnumAttributeValidator.new('String', %w[Yes No])
  return false unless dps_enabled_validator.valid?(@dps_enabled)
  return false if @ip_address.nil?
  true
end