Class: TemplateFox::S3ConfigRequest

Inherits:
ApiModelBase show all
Defined in:
lib/templatefox/models/s3_config_request.rb

Overview

Request model for S3 configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ S3ConfigRequest

Initializes the object

Parameters:

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

    Model attributes in the form of hash



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/templatefox/models/s3_config_request.rb', line 74

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TemplateFox::S3ConfigRequest` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TemplateFox::S3ConfigRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

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

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

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

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

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

Instance Attribute Details

#access_key_idObject

Access key ID for S3 authentication



23
24
25
# File 'lib/templatefox/models/s3_config_request.rb', line 23

def access_key_id
  @access_key_id
end

#bucket_nameObject

S3 bucket name. Must follow S3 naming conventions (lowercase, no underscores)



28
29
30
# File 'lib/templatefox/models/s3_config_request.rb', line 28

def bucket_name
  @bucket_name
end

#default_prefixObject

Default path prefix for uploaded files. Can include slashes for folder structure



31
32
33
# File 'lib/templatefox/models/s3_config_request.rb', line 31

def default_prefix
  @default_prefix
end

#endpoint_urlObject

S3-compatible endpoint URL. Must start with https://



20
21
22
# File 'lib/templatefox/models/s3_config_request.rb', line 20

def endpoint_url
  @endpoint_url
end

#secret_access_keyObject

Returns the value of attribute secret_access_key.



25
26
27
# File 'lib/templatefox/models/s3_config_request.rb', line 25

def secret_access_key
  @secret_access_key
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



45
46
47
# File 'lib/templatefox/models/s3_config_request.rb', line 45

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



50
51
52
# File 'lib/templatefox/models/s3_config_request.rb', line 50

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



34
35
36
37
38
39
40
41
42
# File 'lib/templatefox/models/s3_config_request.rb', line 34

def self.attribute_map
  {
    :'endpoint_url' => :'endpoint_url',
    :'access_key_id' => :'access_key_id',
    :'secret_access_key' => :'secret_access_key',
    :'bucket_name' => :'bucket_name',
    :'default_prefix' => :'default_prefix'
  }
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



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/templatefox/models/s3_config_request.rb', line 334

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



66
67
68
69
70
# File 'lib/templatefox/models/s3_config_request.rb', line 66

def self.openapi_nullable
  Set.new([
    :'secret_access_key',
  ])
end

.openapi_typesObject

Attribute type mapping.



55
56
57
58
59
60
61
62
63
# File 'lib/templatefox/models/s3_config_request.rb', line 55

def self.openapi_types
  {
    :'endpoint_url' => :'String',
    :'access_key_id' => :'String',
    :'secret_access_key' => :'String',
    :'bucket_name' => :'String',
    :'default_prefix' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



309
310
311
312
313
314
315
316
317
# File 'lib/templatefox/models/s3_config_request.rb', line 309

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      endpoint_url == o.endpoint_url &&
      access_key_id == o.access_key_id &&
      secret_access_key == o.secret_access_key &&
      bucket_name == o.bucket_name &&
      default_prefix == o.default_prefix
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


321
322
323
# File 'lib/templatefox/models/s3_config_request.rb', line 321

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



327
328
329
# File 'lib/templatefox/models/s3_config_request.rb', line 327

def hash
  [endpoint_url, access_key_id, secret_access_key, bucket_name, default_prefix].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/templatefox/models/s3_config_request.rb', line 119

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @endpoint_url.nil?
    invalid_properties.push('invalid value for "endpoint_url", endpoint_url cannot be nil.')
  end

  if @endpoint_url.to_s.length > 200
    invalid_properties.push('invalid value for "endpoint_url", the character length must be smaller than or equal to 200.')
  end

  if @endpoint_url.to_s.length < 10
    invalid_properties.push('invalid value for "endpoint_url", the character length must be greater than or equal to 10.')
  end

  pattern = Regexp.new(/^https:\/\//)
  if @endpoint_url !~ pattern
    invalid_properties.push("invalid value for \"endpoint_url\", must conform to the pattern #{pattern}.")
  end

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

  if @access_key_id.to_s.length > 128
    invalid_properties.push('invalid value for "access_key_id", the character length must be smaller than or equal to 128.')
  end

  if @access_key_id.to_s.length < 16
    invalid_properties.push('invalid value for "access_key_id", the character length must be greater than or equal to 16.')
  end

  if !@secret_access_key.nil? && @secret_access_key.to_s.length > 128
    invalid_properties.push('invalid value for "secret_access_key", the character length must be smaller than or equal to 128.')
  end

  if !@secret_access_key.nil? && @secret_access_key.to_s.length < 16
    invalid_properties.push('invalid value for "secret_access_key", the character length must be greater than or equal to 16.')
  end

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

  if @bucket_name.to_s.length > 63
    invalid_properties.push('invalid value for "bucket_name", the character length must be smaller than or equal to 63.')
  end

  if @bucket_name.to_s.length < 3
    invalid_properties.push('invalid value for "bucket_name", the character length must be greater than or equal to 3.')
  end

  pattern = Regexp.new(/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/)
  if @bucket_name !~ pattern
    invalid_properties.push("invalid value for \"bucket_name\", must conform to the pattern #{pattern}.")
  end

  if !@default_prefix.nil? && @default_prefix.to_s.length > 500
    invalid_properties.push('invalid value for "default_prefix", the character length must be smaller than or equal to 500.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_\-\.\/]*$/)
  if !@default_prefix.nil? && @default_prefix !~ pattern
    invalid_properties.push("invalid value for \"default_prefix\", must conform to the pattern #{pattern}.")
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/templatefox/models/s3_config_request.rb', line 356

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/templatefox/models/s3_config_request.rb', line 190

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @endpoint_url.nil?
  return false if @endpoint_url.to_s.length > 200
  return false if @endpoint_url.to_s.length < 10
  return false if @endpoint_url !~ Regexp.new(/^https:\/\//)
  return false if @access_key_id.nil?
  return false if @access_key_id.to_s.length > 128
  return false if @access_key_id.to_s.length < 16
  return false if !@secret_access_key.nil? && @secret_access_key.to_s.length > 128
  return false if !@secret_access_key.nil? && @secret_access_key.to_s.length < 16
  return false if @bucket_name.nil?
  return false if @bucket_name.to_s.length > 63
  return false if @bucket_name.to_s.length < 3
  return false if @bucket_name !~ Regexp.new(/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/)
  return false if !@default_prefix.nil? && @default_prefix.to_s.length > 500
  return false if !@default_prefix.nil? && @default_prefix !~ Regexp.new(/^[a-zA-Z0-9_\-\.\/]*$/)
  true
end