Class: Morpheus::SecurityGroupsInterface

Inherits:
APIClient
  • Object
show all
Defined in:
lib/morpheus/api/security_groups_interface.rb

Instance Method Summary collapse

Methods inherited from APIClient

#account_groups, #accounts, #apps, #archive_buckets, #archive_files, #auth, #blueprints, #cloud_datastores, #cloud_folders, #cloud_policies, #cloud_resource_pools, #clouds, #containers, #custom_instance_types, #cypher, #dashboard, #default_content_type, #deploy, #deployments, #dry, #dry_run, #environments, #execute, #execute_schedules, #execution_request, #file_copy_request, #group_policies, #groups, #image_builder, #instance_types, #instances, #key_pairs, #library_container_scripts, #library_container_templates, #library_container_types, #library_container_upgrades, #library_instance_types, #library_layouts, #license, #load_balancers, #logs, #monitoring, #network_domains, #network_groups, #network_pool_servers, #network_pools, #network_proxies, #network_services, #network_types, #networks, #old_cypher, #option_type_lists, #option_types, #options, #packages, #policies, #power_schedules, #processes, #provision_types, #reports, #roles, #security_group_rules, #security_groups, #server_types, #servers, #set_ssl_verification_enabled, #setopts, #setup, #ssl_verification_enabled?, #storage_providers, #task_sets, #tasks, #user_groups, #user_settings, #user_sources, #users, #virtual_images, #whoami, #wiki, #withopts

Constructor Details

#initialize(access_token, refresh_token, expires_at = nil, base_url = nil) ⇒ SecurityGroupsInterface

Returns a new instance of SecurityGroupsInterface.



4
5
6
7
8
9
# File 'lib/morpheus/api/security_groups_interface.rb', line 4

def initialize(access_token, refresh_token,expires_at = nil, base_url=nil) 
  @access_token = access_token
  @refresh_token = refresh_token
  @base_url = base_url
  @expires_at = expires_at
end

Instance Method Details

#create(payload) ⇒ Object



23
24
25
26
27
# File 'lib/morpheus/api/security_groups_interface.rb', line 23

def create(payload)
  url = "#{@base_url}/api/security-groups"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#create_location(id, payload) ⇒ Object



41
42
43
44
45
# File 'lib/morpheus/api/security_groups_interface.rb', line 41

def create_location(id, payload)
  url = "#{@base_url}/api/security-groups/#{id}/locations"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :post, url: url, headers: headers, payload: payload.to_json)
end

#delete(id) ⇒ Object



35
36
37
38
39
# File 'lib/morpheus/api/security_groups_interface.rb', line 35

def delete(id)
  url = "#{@base_url}/api/security-groups/#{id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers)
end

#delete_location(id, location_id, params = {}) ⇒ Object



47
48
49
50
51
# File 'lib/morpheus/api/security_groups_interface.rb', line 47

def delete_location(id, location_id, params={})
  url = "#{@base_url}/api/security-groups/#{id}/locations/#{location_id}"
  headers = { :params => params, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :delete, url: url, headers: headers)
end

#get(id, params = {}) ⇒ Object



17
18
19
20
21
# File 'lib/morpheus/api/security_groups_interface.rb', line 17

def get(id, params={})
  url = "#{@base_url}/api/security-groups/#{id}"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#list(params = {}) ⇒ Object



11
12
13
14
15
# File 'lib/morpheus/api/security_groups_interface.rb', line 11

def list(params={})
  url = "#{@base_url}/api/security-groups"
  headers = { params: params, authorization: "Bearer #{@access_token}" }
  execute(method: :get, url: url, headers: headers)
end

#update(id, payload) ⇒ Object



29
30
31
32
33
# File 'lib/morpheus/api/security_groups_interface.rb', line 29

def update(id, payload)
  url = "#{@base_url}/api/security-groups/#{id}"
  headers = { :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
  execute(method: :put, url: url, headers: headers, payload: payload.to_json)
end