pnap_location_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,245 @@
1
+ =begin
2
+ #Locations API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module LocationApi
17
+ # Location resource
18
+ class Location
19
+ attr_accessor :location
20
+
21
+ attr_accessor :location_description
22
+
23
+ attr_accessor :product_categories
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'location' => :'location',
29
+ :'location_description' => :'locationDescription',
30
+ :'product_categories' => :'productCategories'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'location' => :'LocationEnum',
43
+ :'location_description' => :'String',
44
+ :'product_categories' => :'Array<ProductCategory>'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `LocationApi::Location` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `LocationApi::Location`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'location')
70
+ self.location = attributes[:'location']
71
+ end
72
+
73
+ if attributes.key?(:'location_description')
74
+ self.location_description = attributes[:'location_description']
75
+ end
76
+
77
+ if attributes.key?(:'product_categories')
78
+ if (value = attributes[:'product_categories']).is_a?(Array)
79
+ self.product_categories = value
80
+ end
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ if @location.nil?
89
+ invalid_properties.push('invalid value for "location", location cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ return false if @location.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ location == o.location &&
108
+ location_description == o.location_description &&
109
+ product_categories == o.product_categories
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Integer] Hash code
120
+ def hash
121
+ [location, location_description, product_categories].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def self.build_from_hash(attributes)
128
+ new.build_from_hash(attributes)
129
+ end
130
+
131
+ # Builds the object from hash
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ # @return [Object] Returns the model itself
134
+ def build_from_hash(attributes)
135
+ return nil unless attributes.is_a?(Hash)
136
+ attributes = attributes.transform_keys(&:to_sym)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
139
+ self.send("#{key}=", nil)
140
+ elsif type =~ /\AArray<(.*)>/i
141
+ # check to ensure the input is an array given that the attribute
142
+ # is documented as an array but the input is not
143
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
144
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
145
+ end
146
+ elsif !attributes[self.class.attribute_map[key]].nil?
147
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
148
+ end
149
+ end
150
+
151
+ self
152
+ end
153
+
154
+ # Deserializes the data based on type
155
+ # @param string type Data type
156
+ # @param string value Value to be deserialized
157
+ # @return [Object] Deserialized data
158
+ def _deserialize(type, value)
159
+ case type.to_sym
160
+ when :Time
161
+ Time.parse(value)
162
+ when :Date
163
+ Date.parse(value)
164
+ when :String
165
+ value.to_s
166
+ when :Integer
167
+ value.to_i
168
+ when :Float
169
+ value.to_f
170
+ when :Boolean
171
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
172
+ true
173
+ else
174
+ false
175
+ end
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ else # model
191
+ # models (e.g. Pet) or oneOf
192
+ klass = LocationApi.const_get(type)
193
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
194
+ end
195
+ end
196
+
197
+ # Returns the string representation of the object
198
+ # @return [String] String presentation of the object
199
+ def to_s
200
+ to_hash.to_s
201
+ end
202
+
203
+ # to_body is an alias to to_hash (backward compatibility)
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_body
206
+ to_hash
207
+ end
208
+
209
+ # Returns the object in the form of hash
210
+ # @return [Hash] Returns the object in the form of hash
211
+ def to_hash
212
+ hash = {}
213
+ self.class.attribute_map.each_pair do |attr, param|
214
+ value = self.send(attr)
215
+ if value.nil?
216
+ is_nullable = self.class.openapi_nullable.include?(attr)
217
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
218
+ end
219
+
220
+ hash[param] = _to_hash(value)
221
+ end
222
+ hash
223
+ end
224
+
225
+ # Outputs non-array value in the form of hash
226
+ # For object, use to_hash. Otherwise, just return the value
227
+ # @param [Object] value Any valid value
228
+ # @return [Hash] Returns the value in the form of hash
229
+ def _to_hash(value)
230
+ if value.is_a?(Array)
231
+ value.compact.map { |v| _to_hash(v) }
232
+ elsif value.is_a?(Hash)
233
+ {}.tap do |hash|
234
+ value.each { |k, v| hash[k] = _to_hash(v) }
235
+ end
236
+ elsif value.respond_to? :to_hash
237
+ value.to_hash
238
+ else
239
+ value
240
+ end
241
+ end
242
+
243
+ end
244
+
245
+ end
@@ -0,0 +1,42 @@
1
+ =begin
2
+ #Locations API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module LocationApi
17
+ class LocationEnum
18
+ PHX = "PHX".freeze
19
+ ASH = "ASH".freeze
20
+ NLD = "NLD".freeze
21
+ SGP = "SGP".freeze
22
+ CHI = "CHI".freeze
23
+ SEA = "SEA".freeze
24
+ AUS = "AUS".freeze
25
+
26
+ # Builds the enum from string
27
+ # @param [String] The enum value in the form of the string
28
+ # @return [String] The enum value
29
+ def self.build_from_hash(value)
30
+ new.build_from_hash(value)
31
+ end
32
+
33
+ # Builds the enum from string
34
+ # @param [String] The enum value in the form of the string
35
+ # @return [String] The enum value
36
+ def build_from_hash(value)
37
+ constantValues = LocationEnum.constants.select { |c| LocationEnum::const_get(c) == value }
38
+ raise "Invalid ENUM value #{value} for class #LocationEnum" if constantValues.empty?
39
+ value
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,233 @@
1
+ =begin
2
+ #Locations API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module LocationApi
17
+ class ProductCategory
18
+ attr_accessor :product_category
19
+
20
+ attr_accessor :product_category_description
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'product_category' => :'productCategory',
26
+ :'product_category_description' => :'productCategoryDescription'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'product_category' => :'ProductCategoryEnum',
39
+ :'product_category_description' => :'String'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ fail ArgumentError, "The input argument (attributes) must be a hash in `LocationApi::ProductCategory` initialize method"
54
+ end
55
+
56
+ # check to see if the attribute exists and convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h|
58
+ if (!self.class.attribute_map.key?(k.to_sym))
59
+ fail ArgumentError, "`#{k}` is not a valid attribute in `LocationApi::ProductCategory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
+ end
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:'product_category')
65
+ self.product_category = attributes[:'product_category']
66
+ end
67
+
68
+ if attributes.key?(:'product_category_description')
69
+ self.product_category_description = attributes[:'product_category_description']
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ invalid_properties = Array.new
77
+ if @product_category.nil?
78
+ invalid_properties.push('invalid value for "product_category", product_category cannot be nil.')
79
+ end
80
+
81
+ invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ return false if @product_category.nil?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ product_category == o.product_category &&
97
+ product_category_description == o.product_category_description
98
+ end
99
+
100
+ # @see the `==` method
101
+ # @param [Object] Object to be compared
102
+ def eql?(o)
103
+ self == o
104
+ end
105
+
106
+ # Calculates hash code according to all attributes.
107
+ # @return [Integer] Hash code
108
+ def hash
109
+ [product_category, product_category_description].hash
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def self.build_from_hash(attributes)
116
+ new.build_from_hash(attributes)
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ attributes = attributes.transform_keys(&:to_sym)
125
+ self.class.openapi_types.each_pair do |key, type|
126
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
127
+ self.send("#{key}=", nil)
128
+ elsif type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :Time
149
+ Time.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :Boolean
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ # models (e.g. Pet) or oneOf
180
+ klass = LocationApi.const_get(type)
181
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ if value.nil?
204
+ is_nullable = self.class.openapi_nullable.include?(attr)
205
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
+ end
207
+
208
+ hash[param] = _to_hash(value)
209
+ end
210
+ hash
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ end
232
+
233
+ end
@@ -0,0 +1,40 @@
1
+ =begin
2
+ #Locations API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module LocationApi
17
+ class ProductCategoryEnum
18
+ SERVER = "SERVER".freeze
19
+ BANDWIDTH = "BANDWIDTH".freeze
20
+ OPERATING_SYSTEM = "OPERATING_SYSTEM".freeze
21
+ PUBLIC_IP = "PUBLIC_IP".freeze
22
+ STORAGE = "STORAGE".freeze
23
+
24
+ # Builds the enum from string
25
+ # @param [String] The enum value in the form of the string
26
+ # @return [String] The enum value
27
+ def self.build_from_hash(value)
28
+ new.build_from_hash(value)
29
+ end
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def build_from_hash(value)
35
+ constantValues = ProductCategoryEnum.constants.select { |c| ProductCategoryEnum::const_get(c) == value }
36
+ raise "Invalid ENUM value #{value} for class #ProductCategoryEnum" if constantValues.empty?
37
+ value
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ =begin
2
+ #Locations API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ def get_version()
14
+ return File.read(File.expand_path('../../../VERSION', __FILE__)).strip
15
+ end
16
+
17
+ module LocationApi
18
+ VERSION = get_version()
19
+ end
@@ -0,0 +1,45 @@
1
+ =begin
2
+ #Locations API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.1.0
10
+
11
+ =end
12
+
13
+ # Common files
14
+ require 'pnap_location_api/api_client'
15
+ require 'pnap_location_api/api_error'
16
+ require 'pnap_location_api/version'
17
+ require 'pnap_location_api/configuration'
18
+
19
+ # Models
20
+ require 'pnap_location_api/models/error'
21
+ require 'pnap_location_api/models/location'
22
+ require 'pnap_location_api/models/location_enum'
23
+ require 'pnap_location_api/models/product_category'
24
+ require 'pnap_location_api/models/product_category_enum'
25
+
26
+ # APIs
27
+ require 'pnap_location_api/api/locations_api'
28
+
29
+ module LocationApi
30
+ class << self
31
+ # Customize default settings for the SDK using block.
32
+ # LocationApi.configure do |config|
33
+ # config.username = "xxx"
34
+ # config.password = "xxx"
35
+ # end
36
+ # If no block given, return the default Configuration object.
37
+ def configure
38
+ if block_given?
39
+ yield(Configuration.default)
40
+ else
41
+ Configuration.default
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ =begin
4
+ #Locations API
5
+
6
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 1.0
9
+ Contact: support@phoenixnap.com
10
+ Generated by: https://openapi-generator.tech
11
+ OpenAPI Generator version: 6.1.0
12
+
13
+ =end
14
+
15
+ $:.push File.expand_path("../lib", __FILE__)
16
+ require "pnap_location_api/version"
17
+
18
+ Gem::Specification.new do |s|
19
+ s.name = "pnap_location_api"
20
+ s.version = LocationApi::VERSION
21
+ s.platform = Gem::Platform::RUBY
22
+ s.authors = ["PhoenixNAP"]
23
+ s.email = ["support@phoenixnap.com"]
24
+ s.homepage = "https://phoenixnap.com/bare-metal-cloud"
25
+ s.summary = "Locations API Ruby Gem"
26
+ s.description = "Locations API Ruby Gem"
27
+ s.license = "MPL-2.0"
28
+ s.required_ruby_version = ">= 2.4"
29
+ s.metadata = { "source_code_uri" => "https://github.com/phoenixnap/ruby-sdk-bmc" }
30
+
31
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
32
+
33
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
34
+
35
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
36
+ s.test_files = `find spec/*`.split("\n")
37
+ s.executables = []
38
+ s.require_paths = ["lib"]
39
+ end