ibm_cloud_resource_controller 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +148 -0
  4. data/Rakefile +10 -0
  5. data/docs/Credentials.md +25 -0
  6. data/docs/ErrorReport.md +23 -0
  7. data/docs/PlanHistoryItem.md +19 -0
  8. data/docs/Reclamation.md +45 -0
  9. data/docs/ReclamationActionsPost.md +19 -0
  10. data/docs/ReclamationsList.md +17 -0
  11. data/docs/ResourceAlias.md +57 -0
  12. data/docs/ResourceAliasPatch.md +17 -0
  13. data/docs/ResourceAliasPost.md +21 -0
  14. data/docs/ResourceAliasesApi.md +302 -0
  15. data/docs/ResourceAliasesList.md +21 -0
  16. data/docs/ResourceBinding.md +57 -0
  17. data/docs/ResourceBindingPatch.md +17 -0
  18. data/docs/ResourceBindingPost.md +25 -0
  19. data/docs/ResourceBindingPostParameters.md +17 -0
  20. data/docs/ResourceBindingsApi.md +300 -0
  21. data/docs/ResourceBindingsList.md +21 -0
  22. data/docs/ResourceInstance.md +81 -0
  23. data/docs/ResourceInstancePatch.md +23 -0
  24. data/docs/ResourceInstancePost.md +29 -0
  25. data/docs/ResourceInstancesApi.md +418 -0
  26. data/docs/ResourceInstancesList.md +21 -0
  27. data/docs/ResourceKey.md +53 -0
  28. data/docs/ResourceKeyPatch.md +17 -0
  29. data/docs/ResourceKeyPost.md +23 -0
  30. data/docs/ResourceKeysApi.md +298 -0
  31. data/docs/ResourceKeysList.md +21 -0
  32. data/docs/ResourceReclamationsApi.md +128 -0
  33. data/git_push.sh +58 -0
  34. data/ibm_cloud_resource_controller.gemspec +38 -0
  35. data/lib/ibm_cloud_resource_controller.rb +67 -0
  36. data/lib/ibm_cloud_resource_controller/api/resource_aliases_api.rb +363 -0
  37. data/lib/ibm_cloud_resource_controller/api/resource_bindings_api.rb +360 -0
  38. data/lib/ibm_cloud_resource_controller/api/resource_instances_api.rb +493 -0
  39. data/lib/ibm_cloud_resource_controller/api/resource_keys_api.rb +357 -0
  40. data/lib/ibm_cloud_resource_controller/api/resource_reclamations_api.rb +156 -0
  41. data/lib/ibm_cloud_resource_controller/api_client.rb +388 -0
  42. data/lib/ibm_cloud_resource_controller/api_error.rb +57 -0
  43. data/lib/ibm_cloud_resource_controller/configuration.rb +248 -0
  44. data/lib/ibm_cloud_resource_controller/models/credentials.rb +250 -0
  45. data/lib/ibm_cloud_resource_controller/models/error_report.rb +240 -0
  46. data/lib/ibm_cloud_resource_controller/models/plan_history_item.rb +230 -0
  47. data/lib/ibm_cloud_resource_controller/models/reclamation.rb +352 -0
  48. data/lib/ibm_cloud_resource_controller/models/reclamation_actions_post.rb +220 -0
  49. data/lib/ibm_cloud_resource_controller/models/reclamations_list.rb +212 -0
  50. data/lib/ibm_cloud_resource_controller/models/resource_alias.rb +410 -0
  51. data/lib/ibm_cloud_resource_controller/models/resource_alias_patch.rb +236 -0
  52. data/lib/ibm_cloud_resource_controller/models/resource_alias_post.rb +266 -0
  53. data/lib/ibm_cloud_resource_controller/models/resource_aliases_list.rb +247 -0
  54. data/lib/ibm_cloud_resource_controller/models/resource_binding.rb +410 -0
  55. data/lib/ibm_cloud_resource_controller/models/resource_binding_patch.rb +236 -0
  56. data/lib/ibm_cloud_resource_controller/models/resource_binding_post.rb +278 -0
  57. data/lib/ibm_cloud_resource_controller/models/resource_binding_post_parameters.rb +210 -0
  58. data/lib/ibm_cloud_resource_controller/models/resource_bindings_list.rb +247 -0
  59. data/lib/ibm_cloud_resource_controller/models/resource_instance.rb +536 -0
  60. data/lib/ibm_cloud_resource_controller/models/resource_instance_patch.rb +259 -0
  61. data/lib/ibm_cloud_resource_controller/models/resource_instance_post.rb +317 -0
  62. data/lib/ibm_cloud_resource_controller/models/resource_instances_list.rb +247 -0
  63. data/lib/ibm_cloud_resource_controller/models/resource_key.rb +390 -0
  64. data/lib/ibm_cloud_resource_controller/models/resource_key_patch.rb +236 -0
  65. data/lib/ibm_cloud_resource_controller/models/resource_key_post.rb +251 -0
  66. data/lib/ibm_cloud_resource_controller/models/resource_keys_list.rb +247 -0
  67. data/lib/ibm_cloud_resource_controller/version.rb +15 -0
  68. data/spec/api/resource_aliases_api_spec.rb +104 -0
  69. data/spec/api/resource_bindings_api_spec.rb +103 -0
  70. data/spec/api/resource_instances_api_spec.rb +130 -0
  71. data/spec/api/resource_keys_api_spec.rb +102 -0
  72. data/spec/api/resource_reclamations_api_spec.rb +62 -0
  73. data/spec/api_client_spec.rb +226 -0
  74. data/spec/configuration_spec.rb +42 -0
  75. data/spec/models/credentials_spec.rb +65 -0
  76. data/spec/models/error_report_spec.rb +59 -0
  77. data/spec/models/plan_history_item_spec.rb +47 -0
  78. data/spec/models/reclamation_actions_post_spec.rb +47 -0
  79. data/spec/models/reclamation_spec.rb +125 -0
  80. data/spec/models/reclamations_list_spec.rb +41 -0
  81. data/spec/models/resource_alias_patch_spec.rb +41 -0
  82. data/spec/models/resource_alias_post_spec.rb +53 -0
  83. data/spec/models/resource_alias_spec.rb +143 -0
  84. data/spec/models/resource_aliases_list_spec.rb +53 -0
  85. data/spec/models/resource_binding_patch_spec.rb +41 -0
  86. data/spec/models/resource_binding_post_parameters_spec.rb +41 -0
  87. data/spec/models/resource_binding_post_spec.rb +65 -0
  88. data/spec/models/resource_binding_spec.rb +137 -0
  89. data/spec/models/resource_bindings_list_spec.rb +53 -0
  90. data/spec/models/resource_instance_patch_spec.rb +59 -0
  91. data/spec/models/resource_instance_post_spec.rb +77 -0
  92. data/spec/models/resource_instance_spec.rb +191 -0
  93. data/spec/models/resource_instances_list_spec.rb +53 -0
  94. data/spec/models/resource_key_patch_spec.rb +41 -0
  95. data/spec/models/resource_key_post_spec.rb +59 -0
  96. data/spec/models/resource_key_spec.rb +125 -0
  97. data/spec/models/resource_keys_list_spec.rb +53 -0
  98. data/spec/spec_helper.rb +111 -0
  99. metadata +211 -0
@@ -0,0 +1,130 @@
1
+ =begin
2
+ #IBM Cloud Resource Controller API
3
+
4
+ #Manage lifecycle of your Cloud resources using Resource Controller APIs. Resources are provisioned globally in an account scope. Supports asynchronous provisioning of resources. Enables consumption of a global resource through a Cloud Foundry space in any region.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for IbmCloudResourceController::ResourceInstancesApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'ResourceInstancesApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = IbmCloudResourceController::ResourceInstancesApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ResourceInstancesApi' do
30
+ it 'should create an instance of ResourceInstancesApi' do
31
+ expect(@api_instance).to be_instance_of(IbmCloudResourceController::ResourceInstancesApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for create_resource_instance
36
+ # Create (provision) a new resource instance
37
+ # Provision a new resource in the specified location for the selected plan.
38
+ # @param resource_instance_post
39
+ # @param [Hash] opts the optional parameters
40
+ # @option opts [String] :entity_lock Indicates if the resource instance is locked for further update or delete operations. It does not affect actions performed on child resources like aliases, bindings or keys. False by default.
41
+ # @return [ResourceInstance]
42
+ describe 'create_resource_instance test' do
43
+ it 'should work' do
44
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
45
+ end
46
+ end
47
+
48
+ # unit tests for delete_resource_instance
49
+ # Delete a resource instance
50
+ # Delete a resource instance by ID.
51
+ # @param id The short or long ID of the instance.
52
+ # @param [Hash] opts the optional parameters
53
+ # @return [nil]
54
+ describe 'delete_resource_instance test' do
55
+ it 'should work' do
56
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
57
+ end
58
+ end
59
+
60
+ # unit tests for get_resource_instance
61
+ # Get a resource instance
62
+ # Retrieve a resource instance by ID.
63
+ # @param id The short or long ID of the instance.
64
+ # @param [Hash] opts the optional parameters
65
+ # @return [ResourceInstance]
66
+ describe 'get_resource_instance test' do
67
+ it 'should work' do
68
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
69
+ end
70
+ end
71
+
72
+ # unit tests for list_resource_instances
73
+ # Get a list of all resource instances
74
+ # Get a list of all resource instances.
75
+ # @param [Hash] opts the optional parameters
76
+ # @option opts [String] :guid When you provision a new resource in the specified location for the selected plan, a GUID (globally unique identifier) is created. This is a unique internal GUID managed by Resource controller that corresponds to the instance.
77
+ # @option opts [String] :name The human-readable name of the instance.
78
+ # @option opts [String] :resource_group_id Short ID of a resource group.
79
+ # @option opts [String] :resource_id The unique ID of the offering. This value is provided by and stored in the global catalog.
80
+ # @option opts [String] :resource_plan_id The unique ID of the plan associated with the offering. This value is provided by and stored in the global catalog.
81
+ # @option opts [String] :type The type of the instance. For example, `service_instance`.
82
+ # @option opts [String] :sub_type The sub-type of instance, e.g. `cfaas`.
83
+ # @option opts [String] :limit Limit on how many items should be returned.
84
+ # @option opts [String] :updated_from Start date inclusive filter.
85
+ # @option opts [String] :updated_to End date inclusive filter.
86
+ # @return [ResourceInstancesList]
87
+ describe 'list_resource_instances test' do
88
+ it 'should work' do
89
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
90
+ end
91
+ end
92
+
93
+ # unit tests for lock_resource_instance
94
+ # Lock a resource instance
95
+ # Locks a resource instance by ID. A locked instance can not be updated or deleted. It does not affect actions performed on child resources like aliases, bindings or keys.
96
+ # @param id The short or long ID of the instance.
97
+ # @param [Hash] opts the optional parameters
98
+ # @return [ResourceInstance]
99
+ describe 'lock_resource_instance test' do
100
+ it 'should work' do
101
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
102
+ end
103
+ end
104
+
105
+ # unit tests for unlock_resource_instance
106
+ # Unlock a resource instance
107
+ # Unlocks a resource instance by ID.
108
+ # @param id The short or long ID of the instance.
109
+ # @param [Hash] opts the optional parameters
110
+ # @return [ResourceInstance]
111
+ describe 'unlock_resource_instance test' do
112
+ it 'should work' do
113
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
114
+ end
115
+ end
116
+
117
+ # unit tests for update_resource_instance
118
+ # Update a resource instance
119
+ # Update a resource instance by ID.
120
+ # @param id The short or long ID of the instance.
121
+ # @param resource_instance_patch
122
+ # @param [Hash] opts the optional parameters
123
+ # @return [ResourceInstance]
124
+ describe 'update_resource_instance test' do
125
+ it 'should work' do
126
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
127
+ end
128
+ end
129
+
130
+ end
@@ -0,0 +1,102 @@
1
+ =begin
2
+ #IBM Cloud Resource Controller API
3
+
4
+ #Manage lifecycle of your Cloud resources using Resource Controller APIs. Resources are provisioned globally in an account scope. Supports asynchronous provisioning of resources. Enables consumption of a global resource through a Cloud Foundry space in any region.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for IbmCloudResourceController::ResourceKeysApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'ResourceKeysApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = IbmCloudResourceController::ResourceKeysApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ResourceKeysApi' do
30
+ it 'should create an instance of ResourceKeysApi' do
31
+ expect(@api_instance).to be_instance_of(IbmCloudResourceController::ResourceKeysApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for create_resource_key
36
+ # Create a new resource key
37
+ # Create a new resource key.
38
+ # @param resource_key_post
39
+ # @param [Hash] opts the optional parameters
40
+ # @return [ResourceKey]
41
+ describe 'create_resource_key test' do
42
+ it 'should work' do
43
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
44
+ end
45
+ end
46
+
47
+ # unit tests for delete_resource_key
48
+ # Delete a resource key by ID
49
+ # Delete a resource key by ID.
50
+ # @param id The short or long ID of the key.
51
+ # @param [Hash] opts the optional parameters
52
+ # @return [nil]
53
+ describe 'delete_resource_key test' do
54
+ it 'should work' do
55
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
+ end
57
+ end
58
+
59
+ # unit tests for get_resource_key
60
+ # Get resource key by ID
61
+ # Get resource key by ID.
62
+ # @param id The short or long ID of the key.
63
+ # @param [Hash] opts the optional parameters
64
+ # @return [ResourceKey]
65
+ describe 'get_resource_key test' do
66
+ it 'should work' do
67
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
+ end
69
+ end
70
+
71
+ # unit tests for list_resource_keys
72
+ # Get a list of all of the resource keys.
73
+ # List all resource keys.
74
+ # @param [Hash] opts the optional parameters
75
+ # @option opts [String] :guid When you create a new key, a GUID (globally unique identifier) is assigned. This is a unique internal GUID managed by Resource controller that corresponds to the key.
76
+ # @option opts [String] :name The human-readable name of the key.
77
+ # @option opts [String] :resource_group_id The short ID of the resource group.
78
+ # @option opts [String] :resource_id The unique ID of the offering. This value is provided by and stored in the global catalog.
79
+ # @option opts [String] :limit Limit on how many items should be returned.
80
+ # @option opts [String] :updated_from Start date inclusive filter.
81
+ # @option opts [String] :updated_to End date inclusive filter.
82
+ # @return [ResourceKeysList]
83
+ describe 'list_resource_keys test' do
84
+ it 'should work' do
85
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
86
+ end
87
+ end
88
+
89
+ # unit tests for update_resource_key
90
+ # Update a resource key
91
+ # Update a resource key by ID.
92
+ # @param id The short or long ID of the key.
93
+ # @param resource_key_patch
94
+ # @param [Hash] opts the optional parameters
95
+ # @return [ResourceKey]
96
+ describe 'update_resource_key test' do
97
+ it 'should work' do
98
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
99
+ end
100
+ end
101
+
102
+ end
@@ -0,0 +1,62 @@
1
+ =begin
2
+ #IBM Cloud Resource Controller API
3
+
4
+ #Manage lifecycle of your Cloud resources using Resource Controller APIs. Resources are provisioned globally in an account scope. Supports asynchronous provisioning of resources. Enables consumption of a global resource through a Cloud Foundry space in any region.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for IbmCloudResourceController::ResourceReclamationsApi
17
+ # Automatically generated by openapi-generator (https://openapi-generator.tech)
18
+ # Please update as you see appropriate
19
+ describe 'ResourceReclamationsApi' do
20
+ before do
21
+ # run before each test
22
+ @api_instance = IbmCloudResourceController::ResourceReclamationsApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of ResourceReclamationsApi' do
30
+ it 'should create an instance of ResourceReclamationsApi' do
31
+ expect(@api_instance).to be_instance_of(IbmCloudResourceController::ResourceReclamationsApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for list_reclamations
36
+ # Get a list of all reclamations
37
+ # Get a list of all reclamations.
38
+ # @param [Hash] opts the optional parameters
39
+ # @option opts [String] :account_id An alpha-numeric value identifying the account ID.
40
+ # @option opts [String] :resource_instance_id The short ID of the resource instance.
41
+ # @return [ReclamationsList]
42
+ describe 'list_reclamations test' do
43
+ it 'should work' do
44
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
45
+ end
46
+ end
47
+
48
+ # unit tests for run_reclamation_action
49
+ # Perform a reclamation action
50
+ # Reclaim (provisionally delete) a resource so that it can no longer be used, or restore a resource so that it's usable again.
51
+ # @param id The ID associated with the reclamation.
52
+ # @param action_name The reclamation action name. Specify `reclaim` to delete a resource, or `restore` to restore a resource.
53
+ # @param [Hash] opts the optional parameters
54
+ # @option opts [ReclamationActionsPost] :reclamation_actions_post
55
+ # @return [Reclamation]
56
+ describe 'run_reclamation_action test' do
57
+ it 'should work' do
58
+ # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #IBM Cloud Resource Controller API
3
+
4
+ #Manage lifecycle of your Cloud resources using Resource Controller APIs. Resources are provisioned globally in an account scope. Supports asynchronous provisioning of resources. Enables consumption of a global resource through a Cloud Foundry space in any region.
5
+
6
+ The version of the OpenAPI document: 2.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0-beta2
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe IbmCloudResourceController::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ IbmCloudResourceController.configure { |c| c.host = 'http://example.com' }
21
+ expect(IbmCloudResourceController::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ IbmCloudResourceController.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(IbmCloudResourceController::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ IbmCloudResourceController.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(IbmCloudResourceController::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ IbmCloudResourceController.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(IbmCloudResourceController::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ IbmCloudResourceController.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(IbmCloudResourceController::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ IbmCloudResourceController.configure { |c| c.base_path = nil }
48
+ expect(IbmCloudResourceController::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'params_encoding in #build_request' do
55
+ let(:config) { IbmCloudResourceController::Configuration.new }
56
+ let(:api_client) { IbmCloudResourceController::ApiClient.new(config) }
57
+
58
+ it 'defaults to nil' do
59
+ expect(IbmCloudResourceController::Configuration.default.params_encoding).to eq(nil)
60
+ expect(config.params_encoding).to eq(nil)
61
+
62
+ request = api_client.build_request(:get, '/test')
63
+ expect(request.options[:params_encoding]).to eq(nil)
64
+ end
65
+
66
+ it 'can be customized' do
67
+ config.params_encoding = :multi
68
+ request = api_client.build_request(:get, '/test')
69
+ expect(request.options[:params_encoding]).to eq(:multi)
70
+ end
71
+ end
72
+
73
+ describe 'timeout in #build_request' do
74
+ let(:config) { IbmCloudResourceController::Configuration.new }
75
+ let(:api_client) { IbmCloudResourceController::ApiClient.new(config) }
76
+
77
+ it 'defaults to 0' do
78
+ expect(IbmCloudResourceController::Configuration.default.timeout).to eq(0)
79
+ expect(config.timeout).to eq(0)
80
+
81
+ request = api_client.build_request(:get, '/test')
82
+ expect(request.options[:timeout]).to eq(0)
83
+ end
84
+
85
+ it 'can be customized' do
86
+ config.timeout = 100
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(100)
89
+ end
90
+ end
91
+
92
+ describe '#deserialize' do
93
+ it "handles Array<Integer>" do
94
+ api_client = IbmCloudResourceController::ApiClient.new
95
+ headers = { 'Content-Type' => 'application/json' }
96
+ response = double('response', headers: headers, body: '[12, 34]')
97
+ data = api_client.deserialize(response, 'Array<Integer>')
98
+ expect(data).to be_instance_of(Array)
99
+ expect(data).to eq([12, 34])
100
+ end
101
+
102
+ it 'handles Array<Array<Integer>>' do
103
+ api_client = IbmCloudResourceController::ApiClient.new
104
+ headers = { 'Content-Type' => 'application/json' }
105
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
106
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
107
+ expect(data).to be_instance_of(Array)
108
+ expect(data).to eq([[12, 34], [56]])
109
+ end
110
+
111
+ it 'handles Hash<String, String>' do
112
+ api_client = IbmCloudResourceController::ApiClient.new
113
+ headers = { 'Content-Type' => 'application/json' }
114
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
115
+ data = api_client.deserialize(response, 'Hash<String, String>')
116
+ expect(data).to be_instance_of(Hash)
117
+ expect(data).to eq(:message => 'Hello')
118
+ end
119
+ end
120
+
121
+ describe "#object_to_hash" do
122
+ it 'ignores nils and includes empty arrays' do
123
+ # uncomment below to test object_to_hash for model
124
+ # api_client = IbmCloudResourceController::ApiClient.new
125
+ # _model = IbmCloudResourceController::ModelName.new
126
+ # update the model attribute below
127
+ # _model.id = 1
128
+ # update the expected value (hash) below
129
+ # expected = {id: 1, name: '', tags: []}
130
+ # expect(api_client.object_to_hash(_model)).to eq(expected)
131
+ end
132
+ end
133
+
134
+ describe '#build_collection_param' do
135
+ let(:param) { ['aa', 'bb', 'cc'] }
136
+ let(:api_client) { IbmCloudResourceController::ApiClient.new }
137
+
138
+ it 'works for csv' do
139
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
140
+ end
141
+
142
+ it 'works for ssv' do
143
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
144
+ end
145
+
146
+ it 'works for tsv' do
147
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
148
+ end
149
+
150
+ it 'works for pipes' do
151
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
152
+ end
153
+
154
+ it 'works for multi' do
155
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
156
+ end
157
+
158
+ it 'fails for invalid collection format' do
159
+ expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
160
+ end
161
+ end
162
+
163
+ describe '#json_mime?' do
164
+ let(:api_client) { IbmCloudResourceController::ApiClient.new }
165
+
166
+ it 'works' do
167
+ expect(api_client.json_mime?(nil)).to eq false
168
+ expect(api_client.json_mime?('')).to eq false
169
+
170
+ expect(api_client.json_mime?('application/json')).to eq true
171
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
172
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
173
+
174
+ expect(api_client.json_mime?('application/xml')).to eq false
175
+ expect(api_client.json_mime?('text/plain')).to eq false
176
+ expect(api_client.json_mime?('application/jsonp')).to eq false
177
+ end
178
+ end
179
+
180
+ describe '#select_header_accept' do
181
+ let(:api_client) { IbmCloudResourceController::ApiClient.new }
182
+
183
+ it 'works' do
184
+ expect(api_client.select_header_accept(nil)).to be_nil
185
+ expect(api_client.select_header_accept([])).to be_nil
186
+
187
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
188
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
189
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
190
+
191
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
192
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
193
+ end
194
+ end
195
+
196
+ describe '#select_header_content_type' do
197
+ let(:api_client) { IbmCloudResourceController::ApiClient.new }
198
+
199
+ it 'works' do
200
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
201
+ expect(api_client.select_header_content_type([])).to eq('application/json')
202
+
203
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
204
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
205
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
206
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
207
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
208
+ end
209
+ end
210
+
211
+ describe '#sanitize_filename' do
212
+ let(:api_client) { IbmCloudResourceController::ApiClient.new }
213
+
214
+ it 'works' do
215
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
216
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
217
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
218
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
220
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
221
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
222
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
223
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
224
+ end
225
+ end
226
+ end