pulpcore_client 3.0.0rc2.dev.1558538021 → 3.0.0rc2.dev.1558637727
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pulpcore_client might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +9 -5
- data/docs/DatabaseConnection.md +17 -0
- data/docs/RedisConnection.md +17 -0
- data/docs/Status.md +25 -0
- data/docs/StatusApi.md +8 -7
- data/docs/Version.md +19 -0
- data/lib/pulpcore_client.rb +4 -0
- data/lib/pulpcore_client/api/status_api.rb +11 -9
- data/lib/pulpcore_client/models/database_connection.rb +203 -0
- data/lib/pulpcore_client/models/redis_connection.rb +203 -0
- data/lib/pulpcore_client/models/status.rb +266 -0
- data/lib/pulpcore_client/models/version.rb +256 -0
- data/lib/pulpcore_client/models/worker.rb +1 -0
- data/lib/pulpcore_client/version.rb +1 -1
- data/spec/api/status_api_spec.rb +3 -3
- data/spec/models/database_connection_spec.rb +41 -0
- data/spec/models/redis_connection_spec.rb +41 -0
- data/spec/models/status_spec.rb +65 -0
- data/spec/models/version_spec.rb +47 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15a4471d4e174303842cee258b491bf3d24bbd5ce3e288f50b82c3306296d486
|
4
|
+
data.tar.gz: 68862a2988695628a6ac2e1efbd4ea3d627d1a94d9bf65124193d264561235bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a14a0a4c2dd184967e3ee19bb4d6f826786575918a06e4018bee1f2afe478c4e1c0d70d03b3110cca74740ca782e39e1d9550d17a139b190592b985b2e741f02
|
7
|
+
data.tar.gz: 64fff6612f0a71f6cd68b00834cd331cfde932f0048b59affbe0faebec49b0f7056a114b4729e44128d821af3a6d1d5661866e7aaab6fab9fe1a9d6ed0abcc1f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ No description provided (generated by Openapi Generator https://github.com/opena
|
|
7
7
|
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
8
8
|
|
9
9
|
- API version: v3
|
10
|
-
- Package version: 3.0.0rc2.dev.
|
10
|
+
- Package version: 3.0.0rc2.dev.1558637727
|
11
11
|
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
|
12
12
|
|
13
13
|
## Installation
|
@@ -23,16 +23,16 @@ gem build pulpcore_client.gemspec
|
|
23
23
|
Then either install the gem locally:
|
24
24
|
|
25
25
|
```shell
|
26
|
-
gem install ./pulpcore_client-3.0.0rc2.dev.
|
26
|
+
gem install ./pulpcore_client-3.0.0rc2.dev.1558637727.gem
|
27
27
|
```
|
28
28
|
|
29
|
-
(for development, run `gem install --dev ./pulpcore_client-3.0.0rc2.dev.
|
29
|
+
(for development, run `gem install --dev ./pulpcore_client-3.0.0rc2.dev.1558637727.gem` to install the development dependencies)
|
30
30
|
|
31
31
|
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
32
32
|
|
33
33
|
Finally add this to the Gemfile:
|
34
34
|
|
35
|
-
gem 'pulpcore_client', '~> 3.0.0rc2.dev.
|
35
|
+
gem 'pulpcore_client', '~> 3.0.0rc2.dev.1558637727'
|
36
36
|
|
37
37
|
### Install from Git
|
38
38
|
|
@@ -107,7 +107,7 @@ Class | Method | HTTP request | Description
|
|
107
107
|
*PulpcoreClient::RepositoriesApi* | [**repositories_versions_delete**](docs/RepositoriesApi.md#repositories_versions_delete) | **DELETE** {repository_version_href} | Delete a repository version
|
108
108
|
*PulpcoreClient::RepositoriesApi* | [**repositories_versions_list**](docs/RepositoriesApi.md#repositories_versions_list) | **GET** {repository_href}versions/ | List repository versions
|
109
109
|
*PulpcoreClient::RepositoriesApi* | [**repositories_versions_read**](docs/RepositoriesApi.md#repositories_versions_read) | **GET** {repository_version_href} | Inspect a repository version
|
110
|
-
*PulpcoreClient::StatusApi* | [**
|
110
|
+
*PulpcoreClient::StatusApi* | [**status_read**](docs/StatusApi.md#status_read) | **GET** /pulp/api/v3/status/ | Inspect status of Pulp
|
111
111
|
*PulpcoreClient::TasksApi* | [**tasks_cancel**](docs/TasksApi.md#tasks_cancel) | **POST** {task_href}cancel/ | Cancel a task
|
112
112
|
*PulpcoreClient::TasksApi* | [**tasks_delete**](docs/TasksApi.md#tasks_delete) | **DELETE** {task_href} | Delete a task
|
113
113
|
*PulpcoreClient::TasksApi* | [**tasks_list**](docs/TasksApi.md#tasks_list) | **GET** /pulp/api/v3/tasks/ | List tasks
|
@@ -127,6 +127,7 @@ Class | Method | HTTP request | Description
|
|
127
127
|
|
128
128
|
- [PulpcoreClient::Artifact](docs/Artifact.md)
|
129
129
|
- [PulpcoreClient::AsyncOperationResponse](docs/AsyncOperationResponse.md)
|
130
|
+
- [PulpcoreClient::DatabaseConnection](docs/DatabaseConnection.md)
|
130
131
|
- [PulpcoreClient::InlineResponse200](docs/InlineResponse200.md)
|
131
132
|
- [PulpcoreClient::InlineResponse2001](docs/InlineResponse2001.md)
|
132
133
|
- [PulpcoreClient::InlineResponse2002](docs/InlineResponse2002.md)
|
@@ -134,11 +135,14 @@ Class | Method | HTTP request | Description
|
|
134
135
|
- [PulpcoreClient::InlineResponse2004](docs/InlineResponse2004.md)
|
135
136
|
- [PulpcoreClient::InlineResponse2005](docs/InlineResponse2005.md)
|
136
137
|
- [PulpcoreClient::ProgressReport](docs/ProgressReport.md)
|
138
|
+
- [PulpcoreClient::RedisConnection](docs/RedisConnection.md)
|
137
139
|
- [PulpcoreClient::Repository](docs/Repository.md)
|
138
140
|
- [PulpcoreClient::RepositoryVersion](docs/RepositoryVersion.md)
|
139
141
|
- [PulpcoreClient::RepositoryVersionCreate](docs/RepositoryVersionCreate.md)
|
142
|
+
- [PulpcoreClient::Status](docs/Status.md)
|
140
143
|
- [PulpcoreClient::Task](docs/Task.md)
|
141
144
|
- [PulpcoreClient::Upload](docs/Upload.md)
|
145
|
+
- [PulpcoreClient::Version](docs/Version.md)
|
142
146
|
- [PulpcoreClient::Worker](docs/Worker.md)
|
143
147
|
|
144
148
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# PulpcoreClient::DatabaseConnection
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
Name | Type | Description | Notes
|
6
|
+
------------ | ------------- | ------------- | -------------
|
7
|
+
**connected** | **Boolean** | Info about whether the app can connect to the database |
|
8
|
+
|
9
|
+
## Code Sample
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'PulpcoreClient'
|
13
|
+
|
14
|
+
instance = PulpcoreClient::DatabaseConnection.new(connected: null)
|
15
|
+
```
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# PulpcoreClient::RedisConnection
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
Name | Type | Description | Notes
|
6
|
+
------------ | ------------- | ------------- | -------------
|
7
|
+
**connected** | **Boolean** | Info about whether the app can connect to Redis |
|
8
|
+
|
9
|
+
## Code Sample
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'PulpcoreClient'
|
13
|
+
|
14
|
+
instance = PulpcoreClient::RedisConnection.new(connected: null)
|
15
|
+
```
|
16
|
+
|
17
|
+
|
data/docs/Status.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# PulpcoreClient::Status
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
Name | Type | Description | Notes
|
6
|
+
------------ | ------------- | ------------- | -------------
|
7
|
+
**versions** | [**Array<Version>**](Version.md) | Version information of Pulp components |
|
8
|
+
**online_workers** | [**Array<Worker>**](Worker.md) | List of online workers known to the application. An online worker is actively heartbeating and can respond to new work |
|
9
|
+
**missing_workers** | [**Array<Worker>**](Worker.md) | List of missing workers known to the application. A missing worker is a worker that was online, but has now stopped heartbeating and has potentially died |
|
10
|
+
**database_connection** | [**DatabaseConnection**](DatabaseConnection.md) | |
|
11
|
+
**redis_connection** | [**RedisConnection**](RedisConnection.md) | |
|
12
|
+
|
13
|
+
## Code Sample
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'PulpcoreClient'
|
17
|
+
|
18
|
+
instance = PulpcoreClient::Status.new(versions: null,
|
19
|
+
online_workers: null,
|
20
|
+
missing_workers: null,
|
21
|
+
database_connection: null,
|
22
|
+
redis_connection: null)
|
23
|
+
```
|
24
|
+
|
25
|
+
|
data/docs/StatusApi.md
CHANGED
@@ -4,13 +4,13 @@ All URIs are relative to *http://localhost:24817*
|
|
4
4
|
|
5
5
|
Method | HTTP request | Description
|
6
6
|
------------- | ------------- | -------------
|
7
|
-
[**
|
7
|
+
[**status_read**](StatusApi.md#status_read) | **GET** /pulp/api/v3/status/ | Inspect status of Pulp
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
##
|
11
|
+
## status_read
|
12
12
|
|
13
|
-
>
|
13
|
+
> Status status_read
|
14
14
|
|
15
15
|
Inspect status of Pulp
|
16
16
|
|
@@ -32,9 +32,10 @@ api_instance = PulpcoreClient::StatusApi.new
|
|
32
32
|
|
33
33
|
begin
|
34
34
|
#Inspect status of Pulp
|
35
|
-
api_instance.
|
35
|
+
result = api_instance.status_read
|
36
|
+
p result
|
36
37
|
rescue PulpcoreClient::ApiError => e
|
37
|
-
puts "Exception when calling StatusApi->
|
38
|
+
puts "Exception when calling StatusApi->status_read: #{e}"
|
38
39
|
end
|
39
40
|
```
|
40
41
|
|
@@ -44,7 +45,7 @@ This endpoint does not need any parameter.
|
|
44
45
|
|
45
46
|
### Return type
|
46
47
|
|
47
|
-
|
48
|
+
[**Status**](Status.md)
|
48
49
|
|
49
50
|
### Authorization
|
50
51
|
|
@@ -53,5 +54,5 @@ nil (empty response body)
|
|
53
54
|
### HTTP request headers
|
54
55
|
|
55
56
|
- **Content-Type**: Not defined
|
56
|
-
- **Accept**:
|
57
|
+
- **Accept**: application/json
|
57
58
|
|
data/docs/Version.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# PulpcoreClient::Version
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
|
5
|
+
Name | Type | Description | Notes
|
6
|
+
------------ | ------------- | ------------- | -------------
|
7
|
+
**component** | **String** | Name of a versioned component of Pulp |
|
8
|
+
**version** | **String** | Version of the component (e.g. 3.0.0) |
|
9
|
+
|
10
|
+
## Code Sample
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
require 'PulpcoreClient'
|
14
|
+
|
15
|
+
instance = PulpcoreClient::Version.new(component: null,
|
16
|
+
version: null)
|
17
|
+
```
|
18
|
+
|
19
|
+
|
data/lib/pulpcore_client.rb
CHANGED
@@ -19,6 +19,7 @@ require 'pulpcore_client/configuration'
|
|
19
19
|
# Models
|
20
20
|
require 'pulpcore_client/models/artifact'
|
21
21
|
require 'pulpcore_client/models/async_operation_response'
|
22
|
+
require 'pulpcore_client/models/database_connection'
|
22
23
|
require 'pulpcore_client/models/inline_response200'
|
23
24
|
require 'pulpcore_client/models/inline_response2001'
|
24
25
|
require 'pulpcore_client/models/inline_response2002'
|
@@ -26,11 +27,14 @@ require 'pulpcore_client/models/inline_response2003'
|
|
26
27
|
require 'pulpcore_client/models/inline_response2004'
|
27
28
|
require 'pulpcore_client/models/inline_response2005'
|
28
29
|
require 'pulpcore_client/models/progress_report'
|
30
|
+
require 'pulpcore_client/models/redis_connection'
|
29
31
|
require 'pulpcore_client/models/repository'
|
30
32
|
require 'pulpcore_client/models/repository_version'
|
31
33
|
require 'pulpcore_client/models/repository_version_create'
|
34
|
+
require 'pulpcore_client/models/status'
|
32
35
|
require 'pulpcore_client/models/task'
|
33
36
|
require 'pulpcore_client/models/upload'
|
37
|
+
require 'pulpcore_client/models/version'
|
34
38
|
require 'pulpcore_client/models/worker'
|
35
39
|
|
36
40
|
# APIs
|
@@ -22,19 +22,19 @@ module PulpcoreClient
|
|
22
22
|
# Inspect status of Pulp
|
23
23
|
# Returns app information including the version of pulpcore and loaded pulp plugins, known workers, database connection status, and messaging connection status
|
24
24
|
# @param [Hash] opts the optional parameters
|
25
|
-
# @return [
|
26
|
-
def
|
27
|
-
|
28
|
-
|
25
|
+
# @return [Status]
|
26
|
+
def status_read(opts = {})
|
27
|
+
data, _status_code, _headers = status_read_with_http_info(opts)
|
28
|
+
data
|
29
29
|
end
|
30
30
|
|
31
31
|
# Inspect status of Pulp
|
32
32
|
# Returns app information including the version of pulpcore and loaded pulp plugins, known workers, database connection status, and messaging connection status
|
33
33
|
# @param [Hash] opts the optional parameters
|
34
|
-
# @return [Array<(
|
35
|
-
def
|
34
|
+
# @return [Array<(Status, Integer, Hash)>] Status data, response status code and response headers
|
35
|
+
def status_read_with_http_info(opts = {})
|
36
36
|
if @api_client.config.debugging
|
37
|
-
@api_client.config.logger.debug 'Calling API: StatusApi.
|
37
|
+
@api_client.config.logger.debug 'Calling API: StatusApi.status_read ...'
|
38
38
|
end
|
39
39
|
# resource path
|
40
40
|
local_var_path = '/pulp/api/v3/status/'
|
@@ -44,6 +44,8 @@ module PulpcoreClient
|
|
44
44
|
|
45
45
|
# header parameters
|
46
46
|
header_params = opts[:header_params] || {}
|
47
|
+
# HTTP header 'Accept' (if needed)
|
48
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
47
49
|
|
48
50
|
# form parameters
|
49
51
|
form_params = opts[:form_params] || {}
|
@@ -52,7 +54,7 @@ module PulpcoreClient
|
|
52
54
|
post_body = opts[:body]
|
53
55
|
|
54
56
|
# return_type
|
55
|
-
return_type = opts[:return_type]
|
57
|
+
return_type = opts[:return_type] || 'Status'
|
56
58
|
|
57
59
|
# auth_names
|
58
60
|
auth_names = opts[:auth_names] || ['Basic']
|
@@ -68,7 +70,7 @@ module PulpcoreClient
|
|
68
70
|
|
69
71
|
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
70
72
|
if @api_client.config.debugging
|
71
|
-
@api_client.config.logger.debug "API called: StatusApi#
|
73
|
+
@api_client.config.logger.debug "API called: StatusApi#status_read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
72
74
|
end
|
73
75
|
return data, status_code, headers
|
74
76
|
end
|
@@ -0,0 +1,203 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.1-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpcoreClient
|
16
|
+
# Database connection information
|
17
|
+
class DatabaseConnection
|
18
|
+
# Info about whether the app can connect to the database
|
19
|
+
attr_accessor :connected
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'connected' => :'connected'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.openapi_types
|
30
|
+
{
|
31
|
+
:'connected' => :'Boolean'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
if (!attributes.is_a?(Hash))
|
39
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::DatabaseConnection` initialize method"
|
40
|
+
end
|
41
|
+
|
42
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
44
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
45
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::DatabaseConnection`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
46
|
+
end
|
47
|
+
h[k.to_sym] = v
|
48
|
+
}
|
49
|
+
|
50
|
+
if attributes.key?(:'connected')
|
51
|
+
self.connected = attributes[:'connected']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
56
|
+
# @return Array for valid properties with the reasons
|
57
|
+
def list_invalid_properties
|
58
|
+
invalid_properties = Array.new
|
59
|
+
if @connected.nil?
|
60
|
+
invalid_properties.push('invalid value for "connected", connected cannot be nil.')
|
61
|
+
end
|
62
|
+
|
63
|
+
invalid_properties
|
64
|
+
end
|
65
|
+
|
66
|
+
# Check to see if the all the properties in the model are valid
|
67
|
+
# @return true if the model is valid
|
68
|
+
def valid?
|
69
|
+
return false if @connected.nil?
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
# Checks equality by comparing each attribute.
|
74
|
+
# @param [Object] Object to be compared
|
75
|
+
def ==(o)
|
76
|
+
return true if self.equal?(o)
|
77
|
+
self.class == o.class &&
|
78
|
+
connected == o.connected
|
79
|
+
end
|
80
|
+
|
81
|
+
# @see the `==` method
|
82
|
+
# @param [Object] Object to be compared
|
83
|
+
def eql?(o)
|
84
|
+
self == o
|
85
|
+
end
|
86
|
+
|
87
|
+
# Calculates hash code according to all attributes.
|
88
|
+
# @return [Integer] Hash code
|
89
|
+
def hash
|
90
|
+
[connected].hash
|
91
|
+
end
|
92
|
+
|
93
|
+
# Builds the object from hash
|
94
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
95
|
+
# @return [Object] Returns the model itself
|
96
|
+
def self.build_from_hash(attributes)
|
97
|
+
new.build_from_hash(attributes)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Builds the object from hash
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
# @return [Object] Returns the model itself
|
103
|
+
def build_from_hash(attributes)
|
104
|
+
return nil unless attributes.is_a?(Hash)
|
105
|
+
self.class.openapi_types.each_pair do |key, type|
|
106
|
+
if type =~ /\AArray<(.*)>/i
|
107
|
+
# check to ensure the input is an array given that the attribute
|
108
|
+
# is documented as an array but the input is not
|
109
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
110
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
111
|
+
end
|
112
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
113
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
114
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
115
|
+
end
|
116
|
+
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
# Deserializes the data based on type
|
121
|
+
# @param string type Data type
|
122
|
+
# @param string value Value to be deserialized
|
123
|
+
# @return [Object] Deserialized data
|
124
|
+
def _deserialize(type, value)
|
125
|
+
case type.to_sym
|
126
|
+
when :DateTime
|
127
|
+
DateTime.parse(value)
|
128
|
+
when :Date
|
129
|
+
Date.parse(value)
|
130
|
+
when :String
|
131
|
+
value.to_s
|
132
|
+
when :Integer
|
133
|
+
value.to_i
|
134
|
+
when :Float
|
135
|
+
value.to_f
|
136
|
+
when :Boolean
|
137
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
138
|
+
true
|
139
|
+
else
|
140
|
+
false
|
141
|
+
end
|
142
|
+
when :Object
|
143
|
+
# generic object (usually a Hash), return directly
|
144
|
+
value
|
145
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
146
|
+
inner_type = Regexp.last_match[:inner_type]
|
147
|
+
value.map { |v| _deserialize(inner_type, v) }
|
148
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
149
|
+
k_type = Regexp.last_match[:k_type]
|
150
|
+
v_type = Regexp.last_match[:v_type]
|
151
|
+
{}.tap do |hash|
|
152
|
+
value.each do |k, v|
|
153
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
else # model
|
157
|
+
PulpcoreClient.const_get(type).build_from_hash(value)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns the string representation of the object
|
162
|
+
# @return [String] String presentation of the object
|
163
|
+
def to_s
|
164
|
+
to_hash.to_s
|
165
|
+
end
|
166
|
+
|
167
|
+
# to_body is an alias to to_hash (backward compatibility)
|
168
|
+
# @return [Hash] Returns the object in the form of hash
|
169
|
+
def to_body
|
170
|
+
to_hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# Returns the object in the form of hash
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
175
|
+
def to_hash
|
176
|
+
hash = {}
|
177
|
+
self.class.attribute_map.each_pair do |attr, param|
|
178
|
+
value = self.send(attr)
|
179
|
+
next if value.nil?
|
180
|
+
hash[param] = _to_hash(value)
|
181
|
+
end
|
182
|
+
hash
|
183
|
+
end
|
184
|
+
|
185
|
+
# Outputs non-array value in the form of hash
|
186
|
+
# For object, use to_hash. Otherwise, just return the value
|
187
|
+
# @param [Object] value Any valid value
|
188
|
+
# @return [Hash] Returns the value in the form of hash
|
189
|
+
def _to_hash(value)
|
190
|
+
if value.is_a?(Array)
|
191
|
+
value.compact.map { |v| _to_hash(v) }
|
192
|
+
elsif value.is_a?(Hash)
|
193
|
+
{}.tap do |hash|
|
194
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
195
|
+
end
|
196
|
+
elsif value.respond_to? :to_hash
|
197
|
+
value.to_hash
|
198
|
+
else
|
199
|
+
value
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|