Class: Morpheus::APIClient
- Inherits:
-
Object
- Object
- Morpheus::APIClient
show all
- Defined in:
- lib/morpheus/api/api_client.rb
Direct Known Subclasses
AccountGroupsInterface, AccountsInterface, ActivityInterface, ApplianceSettingsInterface, ApprovalsInterface, AppsInterface, ArchiveBucketsInterface, ArchiveFilesInterface, AuthInterface, BackupSettingsInterface, BillingInterface, BlueprintsInterface, BudgetsInterface, CloudDatastoresInterface, CloudFoldersInterface, CloudPoliciesInterface, CloudResourcePoolsInterface, CloudsInterface, ClustersInterface, ContainersInterface, CustomInstanceTypesInterface, CypherInterface, DashboardInterface, DatastoresInterface, DeployInterface, DocInterface, EnvironmentsInterface, ExecuteSchedulesInterface, ExecutionRequestInterface, FileCopyRequestInterface, ForgotPasswordInterface, GroupPoliciesInterface, GroupsInterface, GuidanceInterface, HealthInterface, ImageBuilderBootScriptsInterface, ImageBuilderImageBuildsInterface, ImageBuilderInterface, ImageBuilderPreseedScriptsInterface, InstanceTypesInterface, InstancesInterface, InvoiceLineItemsInterface, InvoicesInterface, JobsInterface, KeyPairsInterface, LibraryClusterLayoutsInterface, LibraryContainerScriptsInterface, LibraryContainerTemplatesInterface, LibraryContainerTypesInterface, LibraryContainerUpgradesInterface, LibraryInstanceTypesInterface, LibraryLayoutsInterface, LibrarySpecTemplateTypesInterface, LibrarySpecTemplatesInterface, LicenseInterface, LoadBalancersInterface, LogSettingsInterface, LogsInterface, MonitoringAlertsInterface, MonitoringAppsInterface, MonitoringChecksInterface, MonitoringContactsInterface, MonitoringGroupsInterface, MonitoringIncidentsInterface, MonitoringInterface, NetworkDomainRecordsInterface, NetworkDomainsInterface, NetworkGroupsInterface, NetworkPoolIpsInterface, NetworkPoolServersInterface, NetworkPoolsInterface, NetworkProxiesInterface, NetworkRoutersInterface, NetworkSecurityServersInterface, NetworkServicesInterface, NetworkSubnetsInterface, NetworkTypesInterface, NetworksInterface, OptionTypeListsInterface, OptionTypesInterface, OptionsInterface, PackagesInterface, PingInterface, PoliciesInterface, PowerSchedulesInterface, PriceSetsInterface, PricesInterface, ProcessesInterface, ProjectsInterface, ProvisionTypesInterface, ProvisioningLicenseTypesInterface, ProvisioningLicensesInterface, ProvisioningSettingsInterface, ReadInterface, ReportsInterface, RestInterface, RolesInterface, SearchInterface, SecurityGroupRulesInterface, SecurityGroupsInterface, ServerTypesInterface, ServersInterface, ServiceCatalogInterface, ServicePlansInterface, SetupInterface, StorageProvidersInterface, SubnetTypesInterface, SubnetsInterface, TaskSetsInterface, TasksInterface, UsageInterface, UserGroupsInterface, UserSettingsInterface, UserSourcesInterface, UsersInterface, VdiInterface, VirtualImagesInterface, WhitelabelSettingsInterface, WhoamiInterface, WikiInterface
Constant Summary
collapse
- CLIENT_ID =
'morph-cli'
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#account_groups ⇒ Object
-
#accounts ⇒ Object
-
#activity ⇒ Object
-
#appliance_settings ⇒ Object
-
#approvals ⇒ Object
-
#apps ⇒ Object
-
#archive_buckets ⇒ Object
-
#archive_files ⇒ Object
-
#auth ⇒ Object
-
#authorization_required? ⇒ Boolean
Authorization is required, except for a couple commands like Ping and Setup.
-
#backup_jobs ⇒ Object
-
#backup_settings ⇒ Object
-
#backups ⇒ Object
-
#billing ⇒ Object
-
#blueprints ⇒ Object
-
#budgets ⇒ Object
-
#catalog ⇒ Object
-
#catalog_item_types ⇒ Object
-
#certificate_types ⇒ Object
-
#certificates ⇒ Object
-
#cloud_datastores ⇒ Object
-
#cloud_folders ⇒ Object
-
#cloud_policies ⇒ Object
-
#cloud_resource_pools ⇒ Object
-
#clouds ⇒ Object
-
#clusters ⇒ Object
-
#common_interface_options ⇒ Object
-
#containers ⇒ Object
-
#cypher ⇒ Object
-
#dashboard ⇒ Object
-
#datastores ⇒ Object
-
#default_content_type ⇒ Object
set this in your interface, eg.
-
#default_timeout ⇒ Object
set default seconds for interface to timeout after or let it use system default? none, it should not timeout by default..
-
#deploy ⇒ Object
-
#deployments ⇒ Object
-
#doc ⇒ Object
-
#dry ⇒ Object
-
#dry_run(val = true) ⇒ Object
-
#environments ⇒ Object
-
#execute(opts, options = {}) ⇒ Object
Execute an HTTP request with this client.
-
#execute_schedules ⇒ Object
-
#execution_request ⇒ Object
-
#file_copy_request ⇒ Object
-
#forgot ⇒ Object
-
#group_policies ⇒ Object
-
#groups ⇒ Object
-
#guidance ⇒ Object
-
#health ⇒ Object
-
#image_builder ⇒ Object
-
#initialize(access_token, refresh_token = nil, expires_in = nil, base_url = nil, verify_ssl = true, options = {}) ⇒ APIClient
constructor
Initialize a new APIClient client = APIClient.new(url:"https://morpheus.yourcompany.com", verify_ssl:false) This old method signature is being deprecated: client = APIClient.new(access_token, refresh_token, expires_in, base_url, verify_ssl, options={}).
-
#inspect ⇒ Object
-
#instance_types ⇒ Object
-
#instances ⇒ Object
-
#integration_types ⇒ Object
-
#integrations ⇒ Object
-
#invoice_line_items ⇒ Object
-
#invoices ⇒ Object
-
#jobs ⇒ Object
-
#key_pairs ⇒ Object
-
#library_cluster_layouts ⇒ Object
-
#library_container_scripts ⇒ Object
-
#library_container_templates ⇒ Object
-
#library_container_types ⇒ Object
-
#library_container_upgrades ⇒ Object
-
#library_instance_types ⇒ Object
-
#library_layouts ⇒ Object
-
#library_spec_template_types ⇒ Object
-
#library_spec_templates ⇒ Object
-
#license ⇒ Object
-
#load_balancers ⇒ Object
-
#log_settings ⇒ Object
-
#logged_in? ⇒ Boolean
-
#login(username, password, use_client_id = nil) ⇒ Object
-
#logout ⇒ Object
-
#logs ⇒ Object
-
#monitoring ⇒ Object
-
#network_domain_records ⇒ Object
-
#network_domains ⇒ Object
-
#network_groups ⇒ Object
-
#network_pool_ips ⇒ Object
-
#network_pool_servers ⇒ Object
-
#network_pools ⇒ Object
-
#network_proxies ⇒ Object
-
#network_routers ⇒ Object
-
#network_security_servers ⇒ Object
-
#network_services ⇒ Object
-
#network_types ⇒ Object
-
#networks ⇒ Object
-
#old_cypher ⇒ Object
-
#option_type_lists ⇒ Object
-
#option_types ⇒ Object
-
#options ⇒ Object
-
#packages ⇒ Object
-
#ping ⇒ Object
-
#policies ⇒ Object
def incidents # Morpheus::MonitoringIncidentsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options) monitoring.incidents end.
-
#power_schedules ⇒ Object
-
#price_sets ⇒ Object
-
#prices ⇒ Object
-
#processes ⇒ Object
-
#projects ⇒ Object
-
#provision_types ⇒ Object
-
#provisioning_license_types ⇒ Object
-
#provisioning_licenses ⇒ Object
-
#provisioning_settings ⇒ Object
-
#reports ⇒ Object
-
#roles ⇒ Object
-
#search ⇒ Object
-
#security_group_rules ⇒ Object
-
#security_groups ⇒ Object
-
#server_types ⇒ Object
-
#servers ⇒ Object
-
#service_plans ⇒ Object
-
#set_ssl_verification_enabled(val) ⇒ Object
-
#setopts(new_options) ⇒ Object
(also: #set_options)
set common global @options for use with all requests meant for inline use just like dry(), set_options(dry_run:true) can be used in place of dry() Example: Prints curl -XGET .../whoami -H "Bearer" instead of actually request APIClient.new(token).whoami.setopts(curl:true).get({}).
-
#setup ⇒ Object
-
#ssl_verification_enabled? ⇒ Boolean
-
#storage_providers ⇒ Object
-
#subnet_types ⇒ Object
-
#subnets ⇒ Object
-
#task_sets ⇒ Object
-
#tasks ⇒ Object
-
#to_s ⇒ Object
-
#url ⇒ Object
-
#usage ⇒ Object
-
#use_refresh_token(t = nil) ⇒ Object
-
#user_groups ⇒ Object
-
#user_settings ⇒ Object
-
#user_sources ⇒ Object
-
#users ⇒ Object
-
#vdi ⇒ Object
-
#vdi_allocations ⇒ Object
-
#vdi_apps ⇒ Object
-
#vdi_gateways ⇒ Object
-
#vdi_pools ⇒ Object
-
#virtual_images ⇒ Object
-
#whitelabel_settings ⇒ Object
-
#whoami ⇒ Object
-
#wiki ⇒ Object
-
#withopts(tmp_options, &block) ⇒ Object
(also: #with_options)
with_options sets common global @options for the duration of the block only then returns the options to their prior values.
Constructor Details
#initialize(access_token, refresh_token = nil, expires_in = nil, base_url = nil, verify_ssl = true, options = {}) ⇒ APIClient
Initialize a new APIClient
client = APIClient.new(url:"https://morpheus.yourcompany.com", verify_ssl:false)
This old method signature is being deprecated:
client = APIClient.new(access_token, refresh_token, expires_in, base_url, verify_ssl, options={})
def initialize(attrs={}, options={})
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/morpheus/api/api_client.rb', line 16
def initialize(access_token, refresh_token=nil,expires_in = nil, base_url=nil, verify_ssl=true, options={})
self.client_id = CLIENT_ID
attrs = {}
if access_token.is_a?(Hash)
attrs = access_token.clone()
access_token = attrs[:access_token]
refresh_token = attrs[:refresh_token]
base_url = attrs[:url] || attrs[:base_url]
expires_in = attrs[:expires_in]
verify_ssl = attrs.key?(:verify_ssl) ? attrs[:verify_ssl] : true
self.client_id = attrs[:client_id] ? attrs[:client_id] : CLIENT_ID
if attrs[:client_id]
self.client_id = attrs[:client_id]
end
options = refresh_token.is_a?(Hash) ? refresh_token.clone() : {}
end
@access_token = access_token
@refresh_token = refresh_token
@base_url = base_url
if @base_url.to_s.empty?
raise "#{self.class} initialized without a required option :url"
end
@base_url = @base_url.chomp("/")
if expires_in != nil
@expires_at = Time.now + expires_in
end
set_ssl_verification_enabled(verify_ssl)
setopts(options)
end
|
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
9
10
11
|
# File 'lib/morpheus/api/api_client.rb', line 9
def client_id
@client_id
end
|
Instance Method Details
#accounts ⇒ Object
515
516
517
|
# File 'lib/morpheus/api/api_client.rb', line 515
def accounts
Morpheus::AccountsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#appliance_settings ⇒ Object
#approvals ⇒ Object
519
520
521
|
# File 'lib/morpheus/api/api_client.rb', line 519
def approvals
Morpheus::ApprovalsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#apps ⇒ Object
487
488
489
|
# File 'lib/morpheus/api/api_client.rb', line 487
def apps
Morpheus::AppsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#archive_buckets ⇒ Object
#auth ⇒ Object
346
347
348
349
|
# File 'lib/morpheus/api/api_client.rb', line 346
def auth
Morpheus::AuthInterface.new({url: @base_url, client_id: @client_id}).setopts(@options)
end
|
#authorization_required? ⇒ Boolean
Authorization is required, except for a couple commands like Ping and Setup
91
92
93
|
# File 'lib/morpheus/api/api_client.rb', line 91
def authorization_required?
true
end
|
#backup_settings ⇒ Object
#blueprints ⇒ Object
491
492
493
|
# File 'lib/morpheus/api/api_client.rb', line 491
def blueprints
Morpheus::BlueprintsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#budgets ⇒ Object
757
758
759
|
# File 'lib/morpheus/api/api_client.rb', line 757
def budgets
Morpheus::BudgetsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#catalog_item_types ⇒ Object
#certificate_types ⇒ Object
#cloud_datastores ⇒ Object
#cloud_resource_pools ⇒ Object
#clouds ⇒ Object
387
388
389
|
# File 'lib/morpheus/api/api_client.rb', line 387
def clouds
Morpheus::CloudsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#clusters ⇒ Object
511
512
513
|
# File 'lib/morpheus/api/api_client.rb', line 511
def clusters
Morpheus::ClustersInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#common_interface_options ⇒ Object
324
325
326
327
328
329
330
331
332
|
# File 'lib/morpheus/api/api_client.rb', line 324
def common_interface_options
{
url: @base_url,
access_token: @access_token,
refresh_token: @refresh_token,
expires_at: @expires_at,
client_id: @client_id
}
end
|
#containers ⇒ Object
431
432
433
|
# File 'lib/morpheus/api/api_client.rb', line 431
def containers
Morpheus::ContainersInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#cypher ⇒ Object
713
714
715
|
# File 'lib/morpheus/api/api_client.rb', line 713
def cypher
Morpheus::CypherInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#datastores ⇒ Object
403
404
405
|
# File 'lib/morpheus/api/api_client.rb', line 403
def datastores
Morpheus::DatastoresInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#default_content_type ⇒ Object
set this in your interface, eg. to 'application/json'
or let it it default to json when payload is present.
78
79
80
|
# File 'lib/morpheus/api/api_client.rb', line 78
def default_content_type
nil
end
|
#default_timeout ⇒ Object
set default seconds for interface to timeout after
or let it use system default? none, it should not timeout by default..
I think execute() may use 30 seconds for get by default.
and it should remove timeout when method is post, put, or delete
86
87
88
|
# File 'lib/morpheus/api/api_client.rb', line 86
def default_timeout
nil
end
|
#deploy ⇒ Object
495
496
497
|
# File 'lib/morpheus/api/api_client.rb', line 495
def deploy
Morpheus::DeployInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#dry ⇒ Object
64
65
66
|
# File 'lib/morpheus/api/api_client.rb', line 64
def dry()
dry_run(true)
end
|
#dry_run(val = true) ⇒ Object
59
60
61
62
|
# File 'lib/morpheus/api/api_client.rb', line 59
def dry_run(val=true)
@dry_run = !!val
self
end
|
#execute(opts, options = {}) ⇒ Object
Execute an HTTP request with this client.
opts - Hash of options for HTTP Request.
:url - The full url
:method - The default method is :get (GET)
:headers - Hash of headers to include in the request.
eg. => 'application/json'. :params is a special key for query parameters.
:params - query parameters
:payload - The body of the request.
:timeout - A custom timeout in seconds for api requests. The default is 30. todo: separate timeout options
options - Hash of common global options that commands parse. eg. :headers, :timeout, :dry_run, :curl, etc
:headers - Extra headers to add. This expects a Hash like => 'application/json'.
:timeout - A custom timeout in seconds for api requests. The default is 30. todo: separate timeout options
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
|
# File 'lib/morpheus/api/api_client.rb', line 148
def execute(opts, options={})
if opts[:url]
if !opts[:url].include?(@base_url)
opts[:url] = "#{@base_url}#{opts[:url]}"
end
end
if @options
options = options.merge(@options)
else
options = options.clone
end
if opts[:method].nil?
opts[:method] = :get
else
opts[:method] = opts[:method].to_s.downcase.to_sym
end
opts[:headers] ||= {}
is_multipart = (opts[:payload].is_a?(Hash) && opts[:payload][:multipart] == true)
if authorization_required?
if @access_token
if opts[:headers][:authorization].nil? && opts[:headers]['Authorization'].nil?
opts[:headers][:authorization] = "Bearer #{@access_token}"
else
end
end
end
if opts[:method] == :post || opts[:method] == :put
if opts[:headers]['Content-Type'].nil? && opts[:payload] && is_multipart != true && opts[:form_data] != true
opts[:headers]['Content-Type'] = (default_content_type || 'application/json')
end
if opts[:headers]['Content-Type'] == 'application/json' && !opts[:payload].is_a?(String)
opts[:payload] = opts[:payload].to_json
end
end
if opts[:timeout].nil?
if options[:timeout]
opts[:timeout] = options[:timeout].to_f
elsif default_timeout && opts[:method] == :get
opts[:timeout] = default_timeout.to_f
end
end
if options[:headers]
opts[:headers] = opts[:headers].merge(options[:headers])
end
if @verify_ssl == false
opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
end
if @dry_run
opts[:command_options] = options return opts
end
response = Morpheus::RestClient.execute(opts)
if opts[:parse_json] != false && options[:parse_json] != false
return JSON.parse(response.to_s)
else
return response
end
end
|
#execute_schedules ⇒ Object
#execution_request ⇒ Object
#file_copy_request ⇒ Object
#groups ⇒ Object
379
380
381
|
# File 'lib/morpheus/api/api_client.rb', line 379
def groups
Morpheus::GroupsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#guidance ⇒ Object
773
774
775
|
# File 'lib/morpheus/api/api_client.rb', line 773
def guidance
Morpheus::GuidanceInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#health ⇒ Object
761
762
763
|
# File 'lib/morpheus/api/api_client.rb', line 761
def health
Morpheus::HealthInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#inspect ⇒ Object
55
56
57
|
# File 'lib/morpheus/api/api_client.rb', line 55
def inspect
to_s
end
|
#instances ⇒ Object
411
412
413
|
# File 'lib/morpheus/api/api_client.rb', line 411
def instances
Morpheus::InstancesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#integration_types ⇒ Object
#invoice_line_items ⇒ Object
#jobs ⇒ Object
447
448
449
|
# File 'lib/morpheus/api/api_client.rb', line 447
def jobs
Morpheus::JobsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#key_pairs ⇒ Object
543
544
545
|
# File 'lib/morpheus/api/api_client.rb', line 543
def key_pairs
Morpheus::KeyPairsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#library_cluster_layouts ⇒ Object
#library_container_scripts ⇒ Object
#library_container_templates ⇒ Object
#library_container_types ⇒ Object
#library_container_upgrades ⇒ Object
#library_instance_types ⇒ Object
#library_layouts ⇒ Object
#library_spec_template_types ⇒ Object
#library_spec_templates ⇒ Object
#license ⇒ Object
555
556
557
|
# File 'lib/morpheus/api/api_client.rb', line 555
def license
Morpheus::LicenseInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#log_settings ⇒ Object
745
746
747
|
# File 'lib/morpheus/api/api_client.rb', line 745
def log_settings
Morpheus::LogSettingsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#logged_in? ⇒ Boolean
272
273
274
|
# File 'lib/morpheus/api/api_client.rb', line 272
def logged_in?
!!@access_token
end
|
#login(username, password, use_client_id = nil) ⇒ Object
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/morpheus/api/api_client.rb', line 284
def login(username, password, use_client_id=nil)
if use_client_id
self.client_id = use_client_id
end
@access_token, @refresh_token, @expires_at = nil, nil, nil
response = auth.login(username, password, self.client_id)
@access_token = response['access_token']
@refresh_token = response['refresh_token']
if response['expires_in'] != nil
@expires_at = Time.now + response['expires_in']
end
return self
end
|
#logout ⇒ Object
317
318
319
320
321
322
|
# File 'lib/morpheus/api/api_client.rb', line 317
def logout
@access_token = nil
@refresh_token = nil
@expires_at = nil
return self
end
|
#logs ⇒ Object
535
536
537
|
# File 'lib/morpheus/api/api_client.rb', line 535
def logs
Morpheus::LogsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#monitoring ⇒ Object
575
576
577
|
# File 'lib/morpheus/api/api_client.rb', line 575
def monitoring
Morpheus::MonitoringInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#network_domain_records ⇒ Object
#network_domains ⇒ Object
#network_pool_ips ⇒ Object
#network_pool_servers ⇒ Object
#network_proxies ⇒ Object
#network_routers ⇒ Object
#network_security_servers ⇒ Object
#network_services ⇒ Object
#networks ⇒ Object
601
602
603
|
# File 'lib/morpheus/api/api_client.rb', line 601
def networks
Morpheus::NetworksInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#old_cypher ⇒ Object
717
718
719
|
# File 'lib/morpheus/api/api_client.rb', line 717
def old_cypher
Morpheus::OldCypherInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#option_type_lists ⇒ Object
#option_types ⇒ Object
559
560
561
|
# File 'lib/morpheus/api/api_client.rb', line 559
def option_types
Morpheus::OptionTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#options ⇒ Object
375
376
377
|
# File 'lib/morpheus/api/api_client.rb', line 375
def options
Morpheus::OptionsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#packages ⇒ Object
709
710
711
|
# File 'lib/morpheus/api/api_client.rb', line 709
def packages
Morpheus::PackagesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#policies ⇒ Object
def incidents
Morpheus::MonitoringIncidentsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
monitoring.incidents
end
589
590
591
|
# File 'lib/morpheus/api/api_client.rb', line 589
def policies
Morpheus::PoliciesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#power_schedules ⇒ Object
#price_sets ⇒ Object
463
464
465
|
# File 'lib/morpheus/api/api_client.rb', line 463
def price_sets
Morpheus::PriceSetsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#prices ⇒ Object
467
468
469
|
# File 'lib/morpheus/api/api_client.rb', line 467
def prices
Morpheus::PricesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#processes ⇒ Object
729
730
731
|
# File 'lib/morpheus/api/api_client.rb', line 729
def processes
Morpheus::ProcessesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#provision_types ⇒ Object
#provisioning_license_types ⇒ Object
#provisioning_licenses ⇒ Object
#provisioning_settings ⇒ Object
#reports ⇒ Object
733
734
735
|
# File 'lib/morpheus/api/api_client.rb', line 733
def reports
Morpheus::ReportsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#roles ⇒ Object
539
540
541
|
# File 'lib/morpheus/api/api_client.rb', line 539
def roles
Morpheus::RolesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#security_group_rules ⇒ Object
#security_groups ⇒ Object
#server_types ⇒ Object
451
452
453
|
# File 'lib/morpheus/api/api_client.rb', line 451
def server_types
Morpheus::ServerTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#servers ⇒ Object
407
408
409
|
# File 'lib/morpheus/api/api_client.rb', line 407
def servers
Morpheus::ServersInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#set_ssl_verification_enabled(val) ⇒ Object
72
73
74
|
# File 'lib/morpheus/api/api_client.rb', line 72
def set_ssl_verification_enabled(val)
@verify_ssl = !!val
end
|
#setopts(new_options) ⇒ Object
Also known as:
set_options
set common global @options for use with all requests
meant for inline use just like dry(), set_options(dry_run:true) can be used in place of dry()
Example:
Prints curl -XGET .../whoami -H "Bearer" instead of actually request
APIClient.new(token).whoami.setopts(curl:true).get({})
111
112
113
114
115
116
117
|
# File 'lib/morpheus/api/api_client.rb', line 111
def setopts(new_options)
@options = new_options
if @options[:dry_run]
dry_run(true)
end
self
end
|
#ssl_verification_enabled? ⇒ Boolean
68
69
70
|
# File 'lib/morpheus/api/api_client.rb', line 68
def ssl_verification_enabled?
@verify_ssl
end
|
#storage_providers ⇒ Object
#subnet_types ⇒ Object
613
614
615
|
# File 'lib/morpheus/api/api_client.rb', line 613
def subnet_types
Morpheus::SubnetTypesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#subnets ⇒ Object
609
610
611
|
# File 'lib/morpheus/api/api_client.rb', line 609
def subnets
Morpheus::SubnetsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#task_sets ⇒ Object
479
480
481
|
# File 'lib/morpheus/api/api_client.rb', line 479
def task_sets
Morpheus::TaskSetsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#tasks ⇒ Object
475
476
477
|
# File 'lib/morpheus/api/api_client.rb', line 475
def tasks
Morpheus::TasksInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#to_s ⇒ Object
51
52
53
|
# File 'lib/morpheus/api/api_client.rb', line 51
def to_s
"<##{self.class}:#{self.object_id.to_s(8)} @url=#{@base_url} @verify_ssl=#{@verify_ssl} @access_token=#{@access_token ? '************' : nil} @refresh_token=#{@access_token ? '************' : nil} @expires_at=#{@expires_at} @client_id=#{@client_id} @options=#{@options}>"
end
|
#url ⇒ Object
47
48
49
|
# File 'lib/morpheus/api/api_client.rb', line 47
def url
@base_url
end
|
#use_refresh_token(t = nil) ⇒ Object
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
# File 'lib/morpheus/api/api_client.rb', line 299
def use_refresh_token(t=nil)
if t.nil?
t = @refresh_token
end
if t.nil?
raise "#{self.class} does not currently have a refresh_token"
end
response = auth.use_refresh_token(t, self.client_id)
@access_token = response['access_token']
@refresh_token = response['refresh_token']
if response['expires_in'] != nil
@expires_at = Time.now + response['expires_in']
end
@access_token = response['access_token']
return self
end
|
#user_groups ⇒ Object
527
528
529
|
# File 'lib/morpheus/api/api_client.rb', line 527
def user_groups
Morpheus::UserGroupsInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#user_sources ⇒ Object
531
532
533
|
# File 'lib/morpheus/api/api_client.rb', line 531
def user_sources
Morpheus::UserSourcesInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#users ⇒ Object
523
524
525
|
# File 'lib/morpheus/api/api_client.rb', line 523
def users
Morpheus::UsersInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#vdi_allocations ⇒ Object
#whitelabel_settings ⇒ Object
#wiki ⇒ Object
753
754
755
|
# File 'lib/morpheus/api/api_client.rb', line 753
def wiki
Morpheus::WikiInterface.new(@access_token, @refresh_token, @expires_at, @base_url).setopts(@options)
end
|
#withopts(tmp_options, &block) ⇒ Object
Also known as:
with_options
with_options sets common global @options for the duration of the block only
then returns the options to their prior values
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/morpheus/api/api_client.rb', line 123
def withopts(tmp_options, &block)
@_old_options = @options
begin
@options = tmp_options
result = block.call()
ensure
@options = @_old_options
end
return result
end
|