Class: Fog::Compute::Google::Real

Inherits:
Object
  • Object
show all
Includes:
Google::Shared
Defined in:
lib/fog/compute/google/real.rb,
lib/fog/compute/google/requests/get_disk.rb,
lib/fog/compute/google/requests/get_zone.rb,
lib/fog/compute/google/requests/get_image.rb,
lib/fog/compute/google/requests/get_route.rb,
lib/fog/compute/google/requests/get_region.rb,
lib/fog/compute/google/requests/get_server.rb,
lib/fog/compute/google/requests/list_disks.rb,
lib/fog/compute/google/requests/list_zones.rb,
lib/fog/compute/google/requests/attach_disk.rb,
lib/fog/compute/google/requests/delete_disk.rb,
lib/fog/compute/google/requests/detach_disk.rb,
lib/fog/compute/google/requests/get_address.rb,
lib/fog/compute/google/requests/get_network.rb,
lib/fog/compute/google/requests/get_project.rb,
lib/fog/compute/google/requests/get_url_map.rb,
lib/fog/compute/google/requests/insert_disk.rb,
lib/fog/compute/google/requests/list_images.rb,
lib/fog/compute/google/requests/list_routes.rb,
lib/fog/compute/google/requests/stop_server.rb,
lib/fog/compute/google/requests/delete_image.rb,
lib/fog/compute/google/requests/delete_route.rb,
lib/fog/compute/google/requests/get_firewall.rb,
lib/fog/compute/google/requests/get_snapshot.rb,
lib/fog/compute/google/requests/insert_image.rb,
lib/fog/compute/google/requests/insert_route.rb,
lib/fog/compute/google/requests/list_regions.rb,
lib/fog/compute/google/requests/list_servers.rb,
lib/fog/compute/google/requests/reset_server.rb,
lib/fog/compute/google/requests/start_server.rb,
lib/fog/compute/google/requests/delete_server.rb,
lib/fog/compute/google/requests/get_disk_type.rb,
lib/fog/compute/google/requests/insert_server.rb,
lib/fog/compute/google/requests/list_networks.rb,
lib/fog/compute/google/requests/list_url_maps.rb,
lib/fog/compute/google/requests/patch_url_map.rb,
lib/fog/compute/google/requests/delete_address.rb,
lib/fog/compute/google/requests/delete_network.rb,
lib/fog/compute/google/requests/delete_url_map.rb,
lib/fog/compute/google/requests/get_subnetwork.rb,
lib/fog/compute/google/requests/insert_address.rb,
lib/fog/compute/google/requests/insert_network.rb,
lib/fog/compute/google/requests/insert_url_map.rb,
lib/fog/compute/google/requests/list_addresses.rb,
lib/fog/compute/google/requests/list_firewalls.rb,
lib/fog/compute/google/requests/list_snapshots.rb,
lib/fog/compute/google/requests/patch_firewall.rb,
lib/fog/compute/google/requests/update_url_map.rb,
lib/fog/compute/google/requests/delete_firewall.rb,
lib/fog/compute/google/requests/delete_snapshot.rb,
lib/fog/compute/google/requests/deprecate_image.rb,
lib/fog/compute/google/requests/get_target_pool.rb,
lib/fog/compute/google/requests/insert_firewall.rb,
lib/fog/compute/google/requests/list_disk_types.rb,
lib/fog/compute/google/requests/set_server_tags.rb,
lib/fog/compute/google/requests/update_firewall.rb,
lib/fog/compute/google/requests/get_machine_type.rb,
lib/fog/compute/google/requests/list_subnetworks.rb,
lib/fog/compute/google/requests/validate_url_map.rb,
lib/fog/compute/google/requests/delete_subnetwork.rb,
lib/fog/compute/google/requests/insert_subnetwork.rb,
lib/fog/compute/google/requests/list_target_pools.rb,
lib/fog/compute/google/requests/delete_target_pool.rb,
lib/fog/compute/google/requests/get_global_address.rb,
lib/fog/compute/google/requests/get_instance_group.rb,
lib/fog/compute/google/requests/get_zone_operation.rb,
lib/fog/compute/google/requests/insert_target_pool.rb,
lib/fog/compute/google/requests/list_machine_types.rb,
lib/fog/compute/google/requests/get_backend_service.rb,
lib/fog/compute/google/requests/get_forwarding_rule.rb,
lib/fog/compute/google/requests/get_ssl_certificate.rb,
lib/fog/compute/google/requests/get_target_instance.rb,
lib/fog/compute/google/requests/set_server_metadata.rb,
lib/fog/compute/google/requests/set_snapshot_labels.rb,
lib/fog/compute/google/requests/create_disk_snapshot.rb,
lib/fog/compute/google/requests/get_global_operation.rb,
lib/fog/compute/google/requests/get_region_operation.rb,
lib/fog/compute/google/requests/list_instance_groups.rb,
lib/fog/compute/google/requests/list_zone_operations.rb,
lib/fog/compute/google/requests/delete_global_address.rb,
lib/fog/compute/google/requests/delete_instance_group.rb,
lib/fog/compute/google/requests/delete_zone_operation.rb,
lib/fog/compute/google/requests/get_http_health_check.rb,
lib/fog/compute/google/requests/get_image_from_family.rb,
lib/fog/compute/google/requests/get_target_http_proxy.rb,
lib/fog/compute/google/requests/insert_global_address.rb,
lib/fog/compute/google/requests/insert_instance_group.rb,
lib/fog/compute/google/requests/list_aggregated_disks.rb,
lib/fog/compute/google/requests/list_backend_services.rb,
lib/fog/compute/google/requests/list_forwarding_rules.rb,
lib/fog/compute/google/requests/list_global_addresses.rb,
lib/fog/compute/google/requests/list_ssl_certificates.rb,
lib/fog/compute/google/requests/list_target_instances.rb,
lib/fog/compute/google/requests/set_server_scheduling.rb,
lib/fog/compute/google/requests/delete_backend_service.rb,
lib/fog/compute/google/requests/delete_forwarding_rule.rb,
lib/fog/compute/google/requests/delete_ssl_certificate.rb,
lib/fog/compute/google/requests/delete_target_instance.rb,
lib/fog/compute/google/requests/get_target_https_proxy.rb,
lib/fog/compute/google/requests/get_target_pool_health.rb,
lib/fog/compute/google/requests/insert_backend_service.rb,
lib/fog/compute/google/requests/insert_forwarding_rule.rb,
lib/fog/compute/google/requests/insert_ssl_certificate.rb,
lib/fog/compute/google/requests/insert_target_instance.rb,
lib/fog/compute/google/requests/list_global_operations.rb,
lib/fog/compute/google/requests/list_region_operations.rb,
lib/fog/compute/google/requests/set_target_pool_backup.rb,
lib/fog/compute/google/requests/delete_global_operation.rb,
lib/fog/compute/google/requests/delete_region_operation.rb,
lib/fog/compute/google/requests/list_aggregated_servers.rb,
lib/fog/compute/google/requests/list_http_health_checks.rb,
lib/fog/compute/google/requests/add_server_access_config.rb,
lib/fog/compute/google/requests/delete_http_health_check.rb,
lib/fog/compute/google/requests/delete_target_http_proxy.rb,
lib/fog/compute/google/requests/insert_http_health_check.rb,
lib/fog/compute/google/requests/insert_target_http_proxy.rb,
lib/fog/compute/google/requests/invalidate_url_map_cache.rb,
lib/fog/compute/google/requests/list_target_http_proxies.rb,
lib/fog/compute/google/requests/update_http_health_check.rb,
lib/fog/compute/google/requests/add_target_pool_instances.rb,
lib/fog/compute/google/requests/delete_target_https_proxy.rb,
lib/fog/compute/google/requests/insert_target_https_proxy.rb,
lib/fog/compute/google/requests/list_aggregated_addresses.rb,
lib/fog/compute/google/requests/list_target_https_proxies.rb,
lib/fog/compute/google/requests/get_backend_service_health.rb,
lib/fog/compute/google/requests/get_global_forwarding_rule.rb,
lib/fog/compute/google/requests/list_aggregated_disk_types.rb,
lib/fog/compute/google/requests/set_forwarding_rule_target.rb,
lib/fog/compute/google/requests/delete_server_access_config.rb,
lib/fog/compute/google/requests/list_aggregated_subnetworks.rb,
lib/fog/compute/google/requests/remove_target_pool_instance.rb,
lib/fog/compute/google/requests/set_server_disk_auto_delete.rb,
lib/fog/compute/google/requests/add_backend_service_backends.rb,
lib/fog/compute/google/requests/add_instance_group_instances.rb,
lib/fog/compute/google/requests/list_aggregated_target_pools.rb,
lib/fog/compute/google/requests/list_global_forwarding_rules.rb,
lib/fog/compute/google/requests/remove_target_pool_instances.rb,
lib/fog/compute/google/requests/set_common_instance_metadata.rb,
lib/fog/compute/google/requests/add_target_pool_health_checks.rb,
lib/fog/compute/google/requests/delete_global_forwarding_rule.rb,
lib/fog/compute/google/requests/get_server_serial_port_output.rb,
lib/fog/compute/google/requests/insert_global_forwarding_rule.rb,
lib/fog/compute/google/requests/list_aggregated_machine_types.rb,
lib/fog/compute/google/requests/list_instance_group_instances.rb,
lib/fog/compute/google/requests/set_target_http_proxy_url_map.rb,
lib/fog/compute/google/requests/set_target_https_proxy_url_map.rb,
lib/fog/compute/google/requests/expand_subnetwork_ip_cidr_range.rb,
lib/fog/compute/google/requests/list_aggregated_instance_groups.rb,
lib/fog/compute/google/requests/remove_instance_group_instances.rb,
lib/fog/compute/google/requests/list_aggregated_forwarding_rules.rb,
lib/fog/compute/google/requests/list_aggregated_target_instances.rb,
lib/fog/compute/google/requests/remove_target_pool_health_checks.rb,
lib/fog/compute/google/requests/set_global_forwarding_rule_target.rb,
lib/fog/compute/google/requests/set_subnetwork_private_ip_google_access.rb,
lib/fog/compute/google/requests/set_target_https_proxy_ssl_certificates.rb

Constant Summary collapse

INSERTABLE_NETWORK_FIELDS =
%i{
  auto_create_subnetworks
  description
  gateway_i_pv4
  i_pv4_range
  name
  routing_config
}.freeze
INSERTABLE_FIREWALL_FIELDS =
%i{
  allowed
  denied
  description
  destination_ranges
  direction
  name
  network
  priority
  source_ranges
  source_service_accounts
  source_tags
  target_service_accounts
  target_tags
}.freeze
UPDATABLE_FIREWALL_FIELDS =
%i{
  allowed
  description
  source_ranges
  source_service_accounts
  source_tags
  target_service_accounts
  target_tags
}.freeze
INSERTABLE_ADDRESS_FIELDS =
%i{description ip_version}.freeze

Instance Attribute Summary collapse

Attributes included from Google::Shared

#api_url, #api_version, #project

Instance Method Summary collapse

Methods included from Google::Shared

#build_excon_response, #initialize_google_client, #request, #shared_initialize

Constructor Details

#initialize(options) ⇒ Real

Returns a new instance of Real.


10
11
12
13
14
15
16
17
# File 'lib/fog/compute/google/real.rb', line 10

def initialize(options)
  shared_initialize(options[:google_project], GOOGLE_COMPUTE_API_VERSION, GOOGLE_COMPUTE_BASE_URL)
  options[:google_api_scope_url] = GOOGLE_COMPUTE_API_SCOPE_URLS.join(" ")

  initialize_google_client(options)
  @compute = ::Google::Apis::ComputeV1::ComputeService.new
  @extra_global_projects = options[:google_extra_global_projects] || []
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


7
8
9
# File 'lib/fog/compute/google/real.rb', line 7

def client
  @client
end

#computeObject (readonly)

Returns the value of attribute compute


8
9
10
# File 'lib/fog/compute/google/real.rb', line 8

def compute
  @compute
end

#extra_global_projectsObject (readonly)

Returns the value of attribute extra_global_projects


8
9
10
# File 'lib/fog/compute/google/real.rb', line 8

def extra_global_projects
  @extra_global_projects
end

Instance Method Details

#add_backend_service_backends(backend_service, _new_backends) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/add_backend_service_backends.rb', line 11

def add_backend_service_backends(backend_service, _new_backends)
  @compute.patch_backend_service(@project, backend_service.name, backend_service)
end

#add_instance_group_instances(group_name, zone, instances) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/google/requests/add_instance_group_instances.rb', line 11

def add_instance_group_instances(group_name, zone, instances)
  instances.map! do |instance|
    if instance.start_with?("https:")
      ::Google::Apis::ComputeV1::InstanceReference.new(:instance => instance)
    else
      ::Google::Apis::ComputeV1::InstanceReference.new(
        :instance => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone}/instances/#{instance}\n"
      )
    end
  end

  request = ::Google::Apis::ComputeV1::InstanceGroupsAddInstancesRequest.new(
    :instances => instances
  )
  @compute.add_instance_group_instances(
    @project,
    zone,
    group_name,
    request
  )
end

#add_server_access_config(identity, zone, network_interface, access_config_name = "External NAT", nat_ip: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/compute/google/requests/add_server_access_config.rb', line 11

def add_server_access_config(identity, zone,
                             network_interface,
                             access_config_name = "External NAT",
                             nat_ip: nil)
  @compute.add_instance_access_config(
    @project,
    zone.split("/")[-1],
    identity,
    network_interface,
    ::Google::Apis::ComputeV1::AccessConfig.new(
      :name => access_config_name,
      :nat_ip => nat_ip,
      :type => "ONE_TO_ONE_NAT"
    )
  )
end

#add_target_pool_health_checks(target_pool, region, health_checks) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/compute/google/requests/add_target_pool_health_checks.rb', line 11

def add_target_pool_health_checks(target_pool, region, health_checks)
  check_list = health_checks.map do |health_check|
    ::Google::Apis::ComputeV1::HealthCheckReference.new(
      :health_check => health_check
    )
  end

  @compute.add_target_pool_health_check(
    @project,
    region.split("/")[-1],
    target_pool,
    ::Google::Apis::ComputeV1::AddTargetPoolsHealthCheckRequest.new(
      :health_checks => check_list
    )
  )
end

#add_target_pool_instances(target_pool, region, instances) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/compute/google/requests/add_target_pool_instances.rb', line 11

def add_target_pool_instances(target_pool, region, instances)
  instances_lst = instances.map do |instance|
    ::Google::Apis::ComputeV1::InstanceReference.new(:instance => instance)
  end

  @compute.add_target_pool_instance(
    @project,
    region.split("/")[-1],
    target_pool,
    ::Google::Apis::ComputeV1::AddTargetPoolsInstanceRequest.new(
      :instances => instances_lst
    )
  )
end

#attach_disk(instance, zone, disk = {}) ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/compute/google/requests/attach_disk.rb', line 11

def attach_disk(instance, zone, disk = {})
  @compute.attach_disk(
    @project, zone.split("/")[-1], instance,
    ::Google::Apis::ComputeV1::AttachedDisk.new(disk)
  )
end

#create_disk_snapshot(snapshot_name, disk, zone, snapshot = {}) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/create_disk_snapshot.rb', line 11

def create_disk_snapshot(snapshot_name, disk, zone, snapshot = {})
  @compute.create_disk_snapshot(
    @project, zone, disk,
    ::Google::Apis::ComputeV1::Snapshot.new(
      snapshot.merge(:name => snapshot_name)
    )
  )
end

#default_network_interfaceObject


11
12
13
# File 'lib/fog/compute/google/requests/insert_server.rb', line 11

def default_network_interface
  { :network => "global/networks/#{GOOGLE_COMPUTE_DEFAULT_NETWORK}" }
end

#delete_address(address_name, region_name) ⇒ Object

Delete an address resource in the specified project cloud.google.com/compute/docs/reference/latest/addresses/delete

Parameters:

  • address_name (String)

    Project ID for this address

  • region_name (String)

    Region for address


16
17
18
# File 'lib/fog/compute/google/requests/delete_address.rb', line 16

def delete_address(address_name, region_name)
  @compute.delete_address(@project, region_name, address_name)
end

#delete_backend_service(backend_service_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_backend_service.rb', line 11

def delete_backend_service(backend_service_name)
  @compute.delete_backend_service(@project, backend_service_name)
end

#delete_disk(disk_name, zone_name) ⇒ Object

Parameters:

  • disk_name (String)

    Name of the disk to delete

  • zone_name (String)

    Zone the disk reside in


16
17
18
19
# File 'lib/fog/compute/google/requests/delete_disk.rb', line 16

def delete_disk(disk_name, zone_name)
  zone_name = zone_name.split("/")[-1] if zone_name.start_with? "http"
  @compute.delete_disk(@project, zone_name, disk_name)
end

#delete_firewall(firewall_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_firewall.rb', line 11

def delete_firewall(firewall_name)
  @compute.delete_firewall(@project, firewall_name)
end

#delete_forwarding_rule(rule, region) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/delete_forwarding_rule.rb', line 11

def delete_forwarding_rule(rule, region)
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.delete_forwarding_rule(@project, region, rule)
end

#delete_global_address(address_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_global_address.rb', line 11

def delete_global_address(address_name)
  @compute.delete_global_address(@project, address_name)
end

#delete_global_forwarding_rule(rule) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_global_forwarding_rule.rb', line 11

def delete_global_forwarding_rule(rule)
  @compute.delete_global_forwarding_rule(@project, rule)
end

#delete_global_operation(operation) ⇒ Object


12
13
14
# File 'lib/fog/compute/google/requests/delete_global_operation.rb', line 12

def delete_global_operation(operation)
  @compute.delete_global_operation(@project, operation)
end

#delete_http_health_check(check_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_http_health_check.rb', line 11

def delete_http_health_check(check_name)
  @compute.delete_http_health_check(@project, check_name)
end

#delete_image(image_name, project = @project) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_image.rb', line 11

def delete_image(image_name, project = @project)
  @compute.delete_image(project, image_name)
end

#delete_instance_group(group_name, zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_instance_group.rb', line 11

def delete_instance_group(group_name, zone)
  @compute.delete_instance_group(@project, zone, group_name)
end

#delete_network(network_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_network.rb', line 11

def delete_network(network_name)
  @compute.delete_network(@project, network_name)
end

#delete_region_operation(region, operation) ⇒ Object

Deletes the specified region-specific Operations resource.


13
14
15
16
# File 'lib/fog/compute/google/requests/delete_region_operation.rb', line 13

def delete_region_operation(region, operation)
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.delete_region_operation(@project, region, operation)
end

#delete_route(identity) ⇒ Object

Deletes the specified Route resource.

Parameters:

  • identity (String)

    Name of the route to delete

See Also:


15
16
17
# File 'lib/fog/compute/google/requests/delete_route.rb', line 15

def delete_route(identity)
  @compute.delete_route(@project, identity)
end

#delete_server(server, zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_server.rb', line 11

def delete_server(server, zone)
  @compute.delete_instance(@project, zone.split("/")[-1], server)
end

#delete_server_access_config(identity, zone, nic, access_config = "External NAT") ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/compute/google/requests/delete_server_access_config.rb', line 11

def delete_server_access_config(identity, zone, nic,
                                access_config = "External NAT")
  @compute.delete_instance_access_config(
    @project, zone.split("/")[-1], identity, access_config, nic
  )
end

#delete_snapshot(snapshot_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_snapshot.rb', line 11

def delete_snapshot(snapshot_name)
  @compute.delete_snapshot(@project, snapshot_name)
end

#delete_ssl_certificate(certificate_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_ssl_certificate.rb', line 11

def delete_ssl_certificate(certificate_name)
  @compute.delete_ssl_certificate(project, certificate_name)
end

#delete_subnetwork(subnetwork_name, region_name) ⇒ Google::Apis::ComputeV1::Operation

Delete a subnetwork.

Parameters:

  • subnetwork_name (String)

    the name of the subnetwork to delete

  • region_name (String)

    the name of the subnetwork's region

Returns:

  • (Google::Apis::ComputeV1::Operation)

    delete operation

See Also:


20
21
22
23
24
25
# File 'lib/fog/compute/google/requests/delete_subnetwork.rb', line 20

def delete_subnetwork(subnetwork_name, region_name)
  if region_name.start_with? "http"
    region_name = region_name.split("/")[-1]
  end
  @compute.delete_subnetwork(@project, region_name, subnetwork_name)
end

#delete_target_http_proxy(proxy_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_target_http_proxy.rb', line 11

def delete_target_http_proxy(proxy_name)
  @compute.delete_target_http_proxy(@project, proxy_name)
end

#delete_target_https_proxy(proxy_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_target_https_proxy.rb', line 11

def delete_target_https_proxy(proxy_name)
  @compute.delete_target_https_proxy(@project, proxy_name)
end

#delete_target_instance(target_name, zone) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/delete_target_instance.rb', line 11

def delete_target_instance(target_name, zone)
  zone = zone.split("/")[-1] if zone.start_with? "http"
  @compute.delete_target_instance(@project, zone, target_name)
end

#delete_target_pool(target_pool, region) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/delete_target_pool.rb', line 11

def delete_target_pool(target_pool, region)
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.delete_target_pool(@project, region, target_pool)
end

#delete_url_map(url_map_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/delete_url_map.rb', line 11

def delete_url_map(url_map_name)
  @compute.delete_url_map(@project, url_map_name)
end

#delete_zone_operation(zone_name, operation) ⇒ Object


13
14
15
16
# File 'lib/fog/compute/google/requests/delete_zone_operation.rb', line 13

def delete_zone_operation(zone_name, operation)
  zone_name = zone_name.split("/")[-1] if zone_name.start_with? "http"
  @compute.delete_zone_operation(@project, zone_name, operation)
end

#deprecate_image(image_name, deprecation_status = {}, project = @project) ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/compute/google/requests/deprecate_image.rb', line 11

def deprecate_image(image_name, deprecation_status = {}, project = @project)
  @compute.deprecate_image(
    project, image_name,
    ::Google::Apis::ComputeV1::DeprecationStatus.new(deprecation_status)
  )
end

#detach_disk(instance, zone, device_name) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/detach_disk.rb', line 11

def detach_disk(instance, zone, device_name)
  zone = zone.split("/")[-1]
  @compute.detach_disk(@project, zone, instance, device_name)
end

#expand_subnetwork_ip_cidr_range(subnetwork, region, ip_cidr_range) ⇒ Google::Apis::ComputeV1::SubnetworkList

Expands the IP CIDR range of the subnetwork to a specified value.

Parameters:

  • subnetwork (String)

    the name of the subnetwork

  • region (String)

    the name of the subnetwork's region

  • ip_cidr_range (String)

    The IP of internal addresses that are legal on this subnetwork

Returns:

  • (Google::Apis::ComputeV1::SubnetworkList)

    list result

See Also:


22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/compute/google/requests/expand_subnetwork_ip_cidr_range.rb', line 22

def expand_subnetwork_ip_cidr_range(subnetwork, region, ip_cidr_range)
  if region.start_with? "http"
    region = region.split("/")[-1]
  end
  @compute.expand_subnetwork_ip_cidr_range(
    @project, region, subnetwork,
    ::Google::Apis::ComputeV1::SubnetworksExpandIpCidrRangeRequest.new(
      :ip_cidr_range => ip_cidr_range
    )
  )
end

#get_address(address_name, region_name) ⇒ Object

Get an address resource in the specified project cloud.google.com/compute/docs/reference/latest/addresses/get

Parameters:

  • address_name (String)

    Project ID for this address

  • region_name (String)

    Region for address


16
17
18
# File 'lib/fog/compute/google/requests/get_address.rb', line 16

def get_address(address_name, region_name)
  @compute.get_address(@project, region_name, address_name)
end

#get_backend_service(service_name) ⇒ Object


13
14
15
# File 'lib/fog/compute/google/requests/get_backend_service.rb', line 13

def get_backend_service(service_name)
  @compute.get_backend_service(@project, service_name)
end

#get_backend_service_health(backend_service) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/get_backend_service_health.rb', line 11

def get_backend_service_health(backend_service)
  health_results = backend_service.backends.map do |backend|
    group = ::Google::Apis::ComputeV1::ResourceGroupReference.new(:group => backend[:group])
    resp = @compute.get_backend_service_health(@project, backend_service.name, group)
    [backend[:group], resp.health_status]
  end
  Hash[health_results]
end

#get_disk(disk_name, zone_name) ⇒ Object

Get a disk resource by name from the specified zone cloud.google.com/compute/docs/reference/latest/disks/get

Parameters:

  • zone_name (String)

    Zone the disk resides in


15
16
17
18
# File 'lib/fog/compute/google/requests/get_disk.rb', line 15

def get_disk(disk_name, zone_name)
  zone_name = zone_name.split("/")[-1] if zone_name.start_with? "http"
  @compute.get_disk(@project, zone_name, disk_name)
end

#get_disk_type(disk, zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_disk_type.rb', line 11

def get_disk_type(disk, zone)
  @compute.get_disk_type(@project, zone.split("/")[-1], disk)
end

#get_firewall(firewall_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_firewall.rb', line 11

def get_firewall(firewall_name)
  @compute.get_firewall(@project, firewall_name)
end

#get_forwarding_rule(rule, region) ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/compute/google/requests/get_forwarding_rule.rb', line 11

def get_forwarding_rule(rule, region)
  if region.start_with? "http"
    region = region.split("/")[-1]
  end
  @compute.get_forwarding_rule(@project, region, rule)
end

#get_global_address(address_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_global_address.rb', line 11

def get_global_address(address_name)
  @compute.get_global_address(@project, address_name)
end

#get_global_forwarding_rule(rule) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_global_forwarding_rule.rb', line 11

def get_global_forwarding_rule(rule)
  @compute.get_global_forwarding_rule(@project, rule)
end

#get_global_operation(operation) ⇒ Object

Get the updated status of a global operation

Parameters:

  • operation (Google::Apis::ComputeV1::Operation)

    Return value from asynchronous act

See Also:


15
16
17
# File 'lib/fog/compute/google/requests/get_global_operation.rb', line 15

def get_global_operation(operation)
  @compute.get_global_operation(@project, operation)
end

#get_http_health_check(check_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_http_health_check.rb', line 11

def get_http_health_check(check_name)
  @compute.get_http_health_check(@project, check_name)
end

#get_image(image_name, project = @project) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/get_image.rb', line 11

def get_image(image_name, project = @project)
  project = @project if project.nil?
  @compute.get_image(project, image_name)
end

#get_image_from_family(family, project = @project) ⇒ Object

Returns the latest non-deprecated image that is part of an image family.

Parameters:

  • family (String)

    Name of the image family

  • project (String) (defaults to: @project)

    Project the image belongs to.

Returns:

  • Google::Apis::ComputeV1::Image

See Also:


18
19
20
# File 'lib/fog/compute/google/requests/get_image_from_family.rb', line 18

def get_image_from_family(family, project = @project)
  @compute.get_image_from_family(project, family)
end

#get_instance_group(group_name, zone, project = @project) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_instance_group.rb', line 11

def get_instance_group(group_name, zone, project = @project)
  @compute.get_instance_group(project, zone, group_name)
end

#get_machine_type(machine_type, zone) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/get_machine_type.rb', line 11

def get_machine_type(machine_type, zone)
  zone = zone.split("/")[-1] if zone.start_with? "http"
  @compute.get_machine_type(@project, zone, machine_type)
end

#get_network(network_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_network.rb', line 11

def get_network(network_name)
  @compute.get_network(@project, network_name)
end

#get_project(identity) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_project.rb', line 11

def get_project(identity)
  @compute.get_project(identity)
end

#get_region(identity) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_region.rb', line 11

def get_region(identity)
  @compute.get_region(@project, identity.split("/")[-1])
end

#get_region_operation(region, operation) ⇒ Object

Retrieves the specified region-specific Operations resource


13
14
15
16
# File 'lib/fog/compute/google/requests/get_region_operation.rb', line 13

def get_region_operation(region, operation)
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.get_region_operation(@project, region, operation)
end

#get_route(identity) ⇒ Object

List address resources in the specified project


14
15
16
# File 'lib/fog/compute/google/requests/get_route.rb', line 14

def get_route(identity)
  @compute.get_route(@project, identity)
end

#get_server(instance, zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_server.rb', line 11

def get_server(instance, zone)
  @compute.get_instance(@project, zone.split("/")[-1], instance)
end

#get_server_serial_port_output(identity, zone, port: nil, start: nil) ⇒ Object

Returns the specified instance's serial port output.

Parameters:

  • zone (String)

    Zone for the given instance

  • instance (String)

    Instance scoping this request.

  • port (Fixnum) (defaults to: nil)

    Specifies which COM or serial port to retrieve data from. Acceptable values are 1 to 4, inclusive. (Default: 1)

  • start (Fixnum) (defaults to: nil)

    Returns output starting from a specific byte position. Use this to page through output when the output is too large to return in a single request. For the initial request, leave this field unspecified. For subsequent calls, this field should be set to the next value returned in the previous call.

See Also:


24
25
26
27
28
29
30
31
32
# File 'lib/fog/compute/google/requests/get_server_serial_port_output.rb', line 24

def get_server_serial_port_output(identity, zone, port: nil, start: nil)
  @compute.get_instance_serial_port_output(
    @project,
    zone.split("/")[-1],
    identity,
    :port => port,
    :start => start
  )
end

#get_snapshot(snap_name, project = @project) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/get_snapshot.rb', line 11

def get_snapshot(snap_name, project = @project)
  raise ArgumentError.new "snap_name must not be nil." if snap_name.nil?
  @compute.get_snapshot(project, snap_name)
end

#get_ssl_certificate(certificate_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_ssl_certificate.rb', line 11

def get_ssl_certificate(certificate_name)
  @compute.get_ssl_certificate(@project, certificate_name)
end

#get_subnetwork(subnetwork_name, region_name) ⇒ Google::Apis::ComputeV1::Operation

Returns the specified subnetwork.

Parameters:

  • subnetwork_name (String)

    the name of the subnetwork

  • region_name (String)

    the name of the subnetwork's region

Returns:

  • (Google::Apis::ComputeV1::Operation)

    an operation response

See Also:


19
20
21
22
23
# File 'lib/fog/compute/google/requests/get_subnetwork.rb', line 19

def get_subnetwork(subnetwork_name, region_name)
  subnetwork_name = subnetwork_name.split("/")[-1] if subnetwork_name.start_with? "http"
  region_name = region_name.split("/")[-1] if region_name.start_with? "http"
  @compute.get_subnetwork(@project, region_name, subnetwork_name)
end

#get_target_http_proxy(proxy_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_target_http_proxy.rb', line 11

def get_target_http_proxy(proxy_name)
  @compute.get_target_http_proxy(@project, proxy_name)
end

#get_target_https_proxy(proxy_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_target_https_proxy.rb', line 11

def get_target_https_proxy(proxy_name)
  @compute.get_target_https_proxy(@project, proxy_name)
end

#get_target_instance(target_name, zone) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/get_target_instance.rb', line 11

def get_target_instance(target_name, zone)
  zone = zone.split("/")[-1] if zone.start_with? "http"
  @compute.get_target_instance(@project, zone, target_name)
end

#get_target_pool(target_pool, region) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/get_target_pool.rb', line 11

def get_target_pool(target_pool, region)
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.get_target_pool(@project, region, target_pool)
end

#get_target_pool_health(target_pool, region, instance) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/get_target_pool_health.rb', line 11

def get_target_pool_health(target_pool, region, instance)
  @compute.get_target_pool_health(
    @project, region.split("/")[-1], target_pool,
    ::Google::Apis::ComputeV1::InstanceReference.new(
      :instance => instance
    )
  )
end

#get_url_map(url_map_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_url_map.rb', line 11

def get_url_map(url_map_name)
  @compute.get_url_map(@project, url_map_name)
end

#get_zone(zone_name) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/get_zone.rb', line 11

def get_zone(zone_name)
  @compute.get_zone(@project, zone_name)
end

#get_zone_operation(zone_name, operation) ⇒ Object

Get the updated status of a zone operation

Parameters:

  • zone_name (String)

    Zone the operation was peformed in

  • operation (Google::Apis::ComputeV1::Operation)

    Return value from asynchronous actions

See Also:


16
17
18
19
# File 'lib/fog/compute/google/requests/get_zone_operation.rb', line 16

def get_zone_operation(zone_name, operation)
  zone_name = zone_name.split("/")[-1] if zone_name.start_with? "http"
  @compute.get_zone_operation(@project, zone_name, operation)
end

#insert_address(address_name, region_name, options = {}) ⇒ Object

Create an address resource in the specified project cloud.google.com/compute/docs/reference/latest/addresses/insert

Parameters:

  • address_name (String)

    Project ID for this address

  • region_name (String)

    Region for address

  • options (Hash) (defaults to: {})

    Optional hash of options

Options Hash (options):

  • :description (String)

    Description of resource


18
19
20
21
22
23
24
# File 'lib/fog/compute/google/requests/insert_address.rb', line 18

def insert_address(address_name, region_name, options = {})
  address = ::Google::Apis::ComputeV1::Address.new(
    :name => address_name,
    :description => options[:description]
  )
  @compute.insert_address(@project, region_name, address)
end

#insert_backend_service(backend_service_name, opts = {}) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/fog/compute/google/requests/insert_backend_service.rb', line 11

def insert_backend_service(backend_service_name, opts = {})
  options = opts.reject { |_k, v| v.nil? }
                .merge(:name => backend_service_name)

  be_service = ::Google::Apis::ComputeV1::BackendService.new(options)
  @compute.insert_backend_service(@project, be_service)
end

#insert_disk(disk_name, zone, image_name = nil, description: nil, type: nil, size_gb: nil, source_snapshot: nil, **_opts) ⇒ Object

Create a disk resource in a specific zone cloud.google.com/compute/docs/reference/latest/disks/insert

Parameters:

  • disk_name (String)

    Name of the disk to create

  • zone_name (String)

    Zone the disk reside in

  • image_name (String) (defaults to: nil)

    Optional image name to create the disk from

  • opts (Hash)

    Optional hash of options

  • options (Hash)

    a customizable set of options


22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/compute/google/requests/insert_disk.rb', line 22

def insert_disk(disk_name, zone, image_name = nil,
                description: nil, type: nil, size_gb: nil,
                source_snapshot: nil, **_opts)
  disk = ::Google::Apis::ComputeV1::Disk.new(
    :name => disk_name,
    :description => description,
    :type => type,
    :size_gb => size_gb,
    :source_snapshot => source_snapshot
  )
  @compute.insert_disk(@project, zone.split("/")[-1], disk,
                       :source_image => image_name)
end

#insert_firewall(firewall_name, opts = {}) ⇒ Object

Create a Firewall resource

Parameters:

  • opts (Hash) (defaults to: {})

    The firewall object to create

Options Hash (opts):

  • allowed (Array<Hash>)
  • denied (Array<Hash>)
  • description (String)
  • destination_ranges (Array<String>)
  • direction (String)
  • name (String)
  • network (String)
  • priority (Fixnum)
  • source_ranges (Array<String>)
  • source_service_accounts (Array<String>)
  • source_tags (Array<String>)
  • target_service_accounts (Array<String>)
  • target_tags (Array<String>)

See Also:


46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/compute/google/requests/insert_firewall.rb', line 46

def insert_firewall(firewall_name, opts = {})
  if opts.key?(:network) && !opts[:network].empty?
    unless opts[:network].start_with?("http://", "https://", "projects/", "global/")
      opts[:network] = "projects/#{@project}/global/networks/#{opts[:network]}"
    end
  end

  opts = opts.select { |k, _| INSERTABLE_FIREWALL_FIELDS.include? k }
             .merge(:name => firewall_name)

  @compute.insert_firewall(
    @project, ::Google::Apis::ComputeV1::Firewall.new(opts)
  )
end

#insert_forwarding_rule(rule_name, region, opts = {}) ⇒ Object

Create a forwarding rule.


15
16
17
18
19
20
21
22
23
# File 'lib/fog/compute/google/requests/insert_forwarding_rule.rb', line 15

def insert_forwarding_rule(rule_name, region, opts = {})
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.insert_forwarding_rule(
    @project, region,
    ::Google::Apis::ComputeV1::ForwardingRule.new(
      opts.merge(:name => rule_name)
    )
  )
end

#insert_global_address(address_name, options = {}) ⇒ Object


13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/insert_global_address.rb', line 13

def insert_global_address(address_name, options = {})
  opts = options.select { |k, _| INSERTABLE_ADDRESS_FIELDS.include? k }
                .merge(:name => address_name)
  @compute.insert_global_address(
    @project, ::Google::Apis::ComputeV1::Address.new(opts)
  )
end

#insert_global_forwarding_rule(rule_name, opts = {}) ⇒ Object

Create a global forwarding rule.


15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/insert_global_forwarding_rule.rb', line 15

def insert_global_forwarding_rule(rule_name, opts = {})
  opts = opts.merge(:name => rule_name)
  @compute.insert_global_forwarding_rule(
    @project, ::Google::Apis::ComputeV1::ForwardingRule.new(opts)
  )
end

#insert_http_health_check(check_name, opts = {}) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/insert_http_health_check.rb', line 11

def insert_http_health_check(check_name, opts = {})
  @compute.insert_http_health_check(
    @project,
    ::Google::Apis::ComputeV1::HttpHealthCheck.new(
      opts.merge(:name => check_name)
    )
  )
end

#insert_image(image_name, image = {}, project = @project) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/fog/compute/google/requests/insert_image.rb', line 11

def insert_image(image_name, image = {}, project = @project)
  image = image.merge(:name => image_name)
  @compute.insert_image(
    project,
    ::Google::Apis::ComputeV1::Image.new(image)
  )
end

#insert_instance_group(group_name, zone, options = {}) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/compute/google/requests/insert_instance_group.rb', line 11

def insert_instance_group(group_name, zone, options = {})
  if options["network"]
    network_name = last_url_segment(options["network"])
  else
    network_name = GOOGLE_COMPUTE_DEFAULT_NETWORK
  end

  instance_group = ::Google::Apis::ComputeV1::InstanceGroup.new(
    :description => options["description"],
    :name => group_name,
    :network => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/global/networks/#{network_name}"
  )

  @compute.insert_instance_group(@project,
                                 last_url_segment(zone),
                                 instance_group)
end

#insert_network(network_name, opts = {}) ⇒ Object


20
21
22
23
24
25
26
27
28
# File 'lib/fog/compute/google/requests/insert_network.rb', line 20

def insert_network(network_name, opts = {})
  opts = opts.select { |k, _| INSERTABLE_NETWORK_FIELDS.include? k }
             .merge(:name => network_name)

  @compute.insert_network(
    @project,
    ::Google::Apis::ComputeV1::Network.new(opts)
  )
end

#insert_route(route_name, network, dest_range, priority, options = {}) ⇒ Object

Creates a Route resource.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/compute/google/requests/insert_route.rb', line 14

def insert_route(route_name, network, dest_range, priority, options = {})
  route = ::Google::Apis::ComputeV1::Route.new(
    :name => route_name,
    :network => network,
    :dest_range => dest_range,
    :priority => priority,
    :tags => options[:tags] || [],
    :next_hop_instance => options[:next_hop_instance],
    :next_hop_gateway => options[:next_hop_gateway],
    :next_hop_ip => options[:next_hop_ip],
    :next_hop_vpn_tunnel => options[:next_hop_vpn_tunnel],
    :description => options[:description]
  )

  @compute.insert_route(@project, route)
end

#insert_server(instance_name, zone, options = {}) ⇒ ::Google::Apis::ComputeV1::Operation

Create a new instance (virtual machine).

This method allows you to use low-level request options and thus expects instance options similar to API requests. If you don't need to modify low-level request options, consider using the Fog::Compute::Google::Servers collection object instead.

Examples:

minimal server creation

my_operation = client.insert_server(
  "my-server",
  "us-central1-a",
  :machine_type => "f1-micro",
  :disks => [
    {
      :initialize_params => {
        :source_image => "projects/debian-cloud/global/images/family/debian-8"
      }
    }
  ]
)

Parameters:

  • instance_name (String)

    Name to assign to the created server. Must be unique within the specified zone.

  • zone (String)

    Name or URL of zone containing the created server.

  • options (Hash) (defaults to: {})

    Server attributes. You can use any of the options documented at cloud.google.com/compute/docs/reference/latest/instances/insert.

Returns:

  • (::Google::Apis::ComputeV1::Operation)

    response object that represents the insertion operation.

See Also:


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/fog/compute/google/requests/insert_server.rb', line 69

def insert_server(instance_name, zone, options = {})
  zone = zone.split("/")[-1]

  data = options.merge(:name => instance_name)
  data[:disks] = process_disks(options[:disks])
  data[:network_interfaces] = process_network_interfaces(options[:network_interfaces])

  machine_type = options[:machine_type]
  unless machine_type
    raise ArgumentError.new("machine type is required")
  end

  unless machine_type.include?("zones/")
    machine_type = "zones/#{zone}/machineTypes/#{data[:machine_type]}"
  end
  data[:machine_type] = machine_type

  # Optional subclassed attributes
  if data[:guest_accelerators]
    data[:guest_accelerators] = data[:guest_accelerators].map do |acc_config|
      ::Google::Apis::ComputeV1::AcceleratorConfig.new(acc_config)
    end
  end

  if data[:metadata]
    data[:metadata] = ::Google::Apis::ComputeV1::Metadata.new(options[:metadata])
  end

  if data[:scheduling]
    data[:scheduling] = ::Google::Apis::ComputeV1::Scheduling.new(options[:scheduling])
  end

  if data[:tags]
    data[:tags] = ::Google::Apis::ComputeV1::Tags.new(options[:tags])
  end

  instance = ::Google::Apis::ComputeV1::Instance.new(data)
  @compute.insert_instance(@project, zone, instance)
end

#insert_ssl_certificate(certificate_name, certificate, private_key, description: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/compute/google/requests/insert_ssl_certificate.rb', line 11

def insert_ssl_certificate(certificate_name, certificate, private_key, description: nil)
  @compute.insert_ssl_certificate(
    @project,
    ::Google::Apis::ComputeV1::SslCertificate.new(
      :certificate => certificate,
      :name => certificate_name,
      :private_key => private_key,
      :description => description
    )
  )
end

#insert_subnetwork(subnetwork_name, region_name, network, ip_range, options = {}) ⇒ Google::Apis::ComputeV1::Operation

Create a subnetwork.

Parameters:

  • subnetwork_name (String)

    the name of the subnetwork

  • region_name (String)

    the name of the subnetwork's region

  • network (String)

    URL of the network this subnetwork belongs to

  • ip_range (String)

    The range of internal addresses that are owned by this subnetwork.

  • options (Hash) (defaults to: {})

    Other optional attributes to set on the subnetwork

  • secondary_ip_ranges (Hash)

    a customizable set of options

Options Hash (options):

  • private_ip_google_access (Boolean)

    Whether the VMs in this subnet can access Google services without assigned external IP addresses.

  • description (String)

    An optional description of this resource.

  • secondary_ip_ranges (Array<Hash>)

    An array of configurations for secondary IP ranges

Returns:

  • (Google::Apis::ComputeV1::Operation)

    an operation response

See Also:


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/compute/google/requests/insert_subnetwork.rb', line 34

def insert_subnetwork(subnetwork_name, region_name, network, ip_range, options = {})
  region_name = region_name.split("/")[-1] if region_name.start_with? "http"
  unless network.start_with? "http"
    network = "#{@api_url}#{@project}/global/networks/#{network}"
  end

  params = {
    :name => subnetwork_name,
    :ip_cidr_range => ip_range,
    :region => region_name,
    :network => network
  }

  optional_fields = %i{private_ip_google_access description secondary_ip_ranges}
  params = optional_fields.inject(params) do |data, field|
    data[field] = options[field] unless options[field].nil?
    data
  end

  subnetwork = ::Google::Apis::ComputeV1::Subnetwork.new(params)
  @compute.insert_subnetwork(@project, region_name, subnetwork)
end

#insert_target_http_proxy(proxy_name, description: nil, url_map: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/insert_target_http_proxy.rb', line 11

def insert_target_http_proxy(proxy_name, description: nil, url_map: nil)
  @compute.insert_target_http_proxy(
    @project,
    ::Google::Apis::ComputeV1::TargetHttpProxy.new(
      :name => proxy_name,
      :description => description,
      :url_map => url_map
    )
  )
end

#insert_target_https_proxy(proxy_name, description: nil, url_map: nil, ssl_certificates: nil) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/compute/google/requests/insert_target_https_proxy.rb', line 12

def insert_target_https_proxy(proxy_name, description: nil,
                              url_map: nil, ssl_certificates: nil)
  @compute.insert_target_https_proxy(
    @project,
    ::Google::Apis::ComputeV1::TargetHttpsProxy.new(
      :name => proxy_name,
      :description => description,
      :url_map => url_map,
      :ssl_certificates => ssl_certificates
    )
  )
end

#insert_target_instance(target_name, zone, target_instance = {}) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/insert_target_instance.rb', line 11

def insert_target_instance(target_name, zone, target_instance = {})
  zone = zone.split("/")[-1] if zone.start_with? "http"
  @compute.insert_target_instance(
    @project, zone,
    ::Google::Apis::ComputeV1::TargetInstance.new(
      target_instance.merge(:name => target_name)
    )
  )
end

#insert_target_pool(target_pool_name, region, target_pool = {}) ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/compute/google/requests/insert_target_pool.rb', line 11

def insert_target_pool(target_pool_name, region, target_pool = {})
  pool_obj = ::Google::Apis::ComputeV1::TargetPool.new(
    target_pool.merge(:name => target_pool_name)
  )
  @compute.insert_target_pool(@project, region.split("/")[-1], pool_obj)
end

#insert_url_map(url_map_name, url_map = {}) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/insert_url_map.rb', line 11

def insert_url_map(url_map_name, url_map = {})
  url_map[:host_rules] = url_map[:host_rules] || []
  url_map[:path_matchers] = url_map[:path_matchers] || []
  url_map[:tests] = url_map[:tests] || []

  url_map_obj = ::Google::Apis::ComputeV1::UrlMap.new(
    url_map.merge(:name => url_map_name)
  )
  @compute.insert_url_map(@project, url_map_obj)
end

#invalidate_url_map_cache(url_map_name, path, host = nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/invalidate_url_map_cache.rb', line 11

def invalidate_url_map_cache(url_map_name, path, host = nil)
  @compute.invalidate_url_map_cache(
    @project, url_map_name,
    ::Google::Apis::ComputeV1::CacheInvalidationRule.new(
      :path => path, :host => host
    )
  )
end

#last_url_segment(network) ⇒ Object


29
30
31
# File 'lib/fog/compute/google/requests/insert_instance_group.rb', line 29

def last_url_segment(network)
  network.split("/")[-1]
end

#list_addresses(region_name, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object

List address resources in the specified project


13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/compute/google/requests/list_addresses.rb', line 13

def list_addresses(region_name, filter: nil, max_results: nil,
                   order_by: nil, page_token: nil)
  @compute.list_addresses(
    @project, region_name,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_aggregated_addresses(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    Optional hash of options

Options Hash (options):

  • :filter (String)

    Filter expression for filtering listed resources


15
16
17
# File 'lib/fog/compute/google/requests/list_aggregated_addresses.rb', line 15

def list_aggregated_addresses(options = {})
  @compute.list_aggregated_addresses(@project, options)
end

#list_aggregated_disk_types(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_aggregated_disk_types.rb', line 11

def list_aggregated_disk_types(filter: nil, max_results: nil,
                               order_by: nil, page_token: nil)
  @compute.list_aggregated_disk_types(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_aggregated_disks(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object

Parameters:

  • options (Hash)

    Optional hash of options


19
20
21
22
23
24
25
26
# File 'lib/fog/compute/google/requests/list_aggregated_disks.rb', line 19

def list_aggregated_disks(filter: nil, max_results: nil,
                          order_by: nil, page_token: nil)
  @compute.list_aggregated_disk(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_aggregated_forwarding_rules(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_aggregated_forwarding_rules.rb', line 11

def list_aggregated_forwarding_rules(filter: nil, max_results: nil,
                                     order_by: nil, page_token: nil)
  @compute.list_aggregated_forwarding_rules(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_aggregated_instance_groups(options = {}) ⇒ Object


11
12
13
14
# File 'lib/fog/compute/google/requests/list_aggregated_instance_groups.rb', line 11

def list_aggregated_instance_groups(options = {})
  @compute.list_aggregated_instance_groups(@project,
                                           :filter => options[:filter])
end

#list_aggregated_machine_types(filter: nil, max_results: nil, page_token: nil, order_by: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_aggregated_machine_types.rb', line 11

def list_aggregated_machine_types(filter: nil, max_results: nil,
                                  page_token: nil, order_by: nil)
  @compute.list_aggregated_machine_types(
    @project,
    :filter => filter, :max_results => max_results,
    :page_token => page_token, :order_by => order_by
  )
end

#list_aggregated_servers(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_aggregated_servers.rb', line 11

def list_aggregated_servers(filter: nil, max_results: nil,
                            order_by: nil, page_token: nil)
  @compute.list_aggregated_instances(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_aggregated_subnetworks(filter: nil, max_results: nil, page_token: nil, order_by: nil) ⇒ Google::Apis::ComputeV1::SubnetworkAggregatedList

Retrieves an aggregated list of subnetworks across a project.

Parameters:

  • filter (String) (defaults to: nil)

    A filter expression for filtering listed resources.

  • max_results (Fixnum) (defaults to: nil)

    Max number of results to return

  • order_by (String) (defaults to: nil)

    Sorts list results by a certain order

  • page_token (String) (defaults to: nil)

    specifies a page token to use

Returns:

  • (Google::Apis::ComputeV1::SubnetworkAggregatedList)

    list result

See Also:


21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/compute/google/requests/list_aggregated_subnetworks.rb', line 21

def list_aggregated_subnetworks(filter: nil, max_results: nil,
                                page_token: nil, order_by: nil)
  @compute.aggregated_subnetwork_list(
    @project,
    :filter => filter,
    :max_results => max_results,
    :page_token => page_token,
    :order_by => order_by
  )
end

#list_aggregated_target_instances(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/list_aggregated_target_instances.rb', line 11

def list_aggregated_target_instances(filter: nil, max_results: nil,
                                     order_by: nil, page_token: nil)
  @compute.list_aggregated_target_instance(
    @project,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_aggregated_target_pools(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/list_aggregated_target_pools.rb', line 11

def list_aggregated_target_pools(filter: nil, max_results: nil,
                                 order_by: nil, page_token: nil)
  @compute.list_aggregated_target_pools(
    @project,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_backend_servicesObject


16
17
18
# File 'lib/fog/compute/google/requests/list_backend_services.rb', line 16

def list_backend_services
  @compute.list_backend_services(@project)
end

#list_disk_types(zone, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_disk_types.rb', line 11

def list_disk_types(zone, filter: nil, max_results: nil,
                    order_by: nil, page_token: nil)
  @compute.list_disk_types(
    @project, zone.split("/")[-1],
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_disks(zone_name, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object

List disk resources in the specified zone cloud.google.com/compute/docs/reference/latest/disks/list

Parameters:

  • zone_name (String)

    Zone to list disks from


15
16
17
18
19
20
21
22
# File 'lib/fog/compute/google/requests/list_disks.rb', line 15

def list_disks(zone_name, filter: nil, max_results: nil,
               order_by: nil, page_token: nil)
  @compute.list_disks(
    @project, zone_name,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_firewalls(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_firewalls.rb', line 11

def list_firewalls(filter: nil, max_results: nil,
                   order_by: nil, page_token: nil)
  @compute.list_firewalls(@project,
                          :filter => filter,
                          :max_results => max_results,
                          :order_by => order_by,
                          :page_token => page_token)
end

#list_forwarding_rules(region, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/list_forwarding_rules.rb', line 11

def list_forwarding_rules(region,
                          filter: nil, max_results: nil,
                          order_by: nil, page_token: nil)
  @compute.list_forwarding_rules(
    @project, region,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_global_addresses(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object

List address resources in the specified project


13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/list_global_addresses.rb', line 13

def list_global_addresses(filter: nil, max_results: nil, order_by: nil,
                          page_token: nil)
  @compute.list_global_addresses(@project,
                                 :filter => filter,
                                 :max_results => max_results,
                                 :order_by => order_by,
                                 :page_token => page_token)
end

#list_global_forwarding_rules(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_global_forwarding_rules.rb', line 11

def list_global_forwarding_rules(filter: nil, max_results: nil,
                                 order_by: nil, page_token: nil)
  @compute.list_global_forwarding_rules(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_global_operations(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/compute/google/requests/list_global_operations.rb', line 12

def list_global_operations(filter: nil, max_results: nil,
                           order_by: nil, page_token: nil)
  @compute.list_global_operations(
    @project,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_http_health_checks(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_http_health_checks.rb', line 11

def list_http_health_checks(filter: nil, max_results: nil,
                            order_by: nil, page_token: nil)
  @compute.list_http_health_checks(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_images(project = @project, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/list_images.rb', line 11

def list_images(project = @project,
                filter: nil, max_results: nil,
                order_by: nil, page_token: nil)
  @compute.list_images(
    project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_instance_group_instances(group_name, zone) ⇒ Object


11
12
13
14
15
# File 'lib/fog/compute/google/requests/list_instance_group_instances.rb', line 11

def list_instance_group_instances(group_name, zone)
  @compute.list_instance_group_instances(@project,
                                         zone,
                                         group_name)
end

#list_instance_groups(zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/list_instance_groups.rb', line 11

def list_instance_groups(zone)
  @compute.list_instance_groups(@project, zone)
end

#list_machine_types(zone, filter: nil, max_results: nil, page_token: nil, order_by: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/list_machine_types.rb', line 11

def list_machine_types(zone, filter: nil, max_results: nil,
                       page_token: nil, order_by: nil)
  zone = zone.split("/")[-1] if zone.start_with? "http"
  @compute.list_machine_types(@project, zone,
                              :filter => filter,
                              :max_results => max_results,
                              :page_token => page_token,
                              :order_by => order_by)
end

#list_networks(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_networks.rb', line 11

def list_networks(filter: nil, max_results: nil,
                  order_by: nil, page_token: nil)
  @compute.list_networks(@project,
                         :filter => filter,
                         :max_results => max_results,
                         :order_by => order_by,
                         :page_token => page_token)
end

#list_region_operations(region, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object

Retrieves a list of Operation resources contained within the specified region


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/compute/google/requests/list_region_operations.rb', line 13

def list_region_operations(region, filter: nil, max_results: nil,
                           order_by: nil, page_token: nil)
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.list_region_operations(
    @project, region,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_regions(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/fog/compute/google/requests/list_regions.rb', line 11

def list_regions(filter: nil, max_results: nil,
                 order_by: nil, page_token: nil)
  @compute.list_regions(
    @project, :filter => filter, :max_results => max_results,
              :order_by => order_by, :page_token => page_token
  )
end

#list_routes(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object

Retrieves the list of Route resources available to the specified project.


14
15
16
17
18
19
20
21
22
# File 'lib/fog/compute/google/requests/list_routes.rb', line 14

def list_routes(filter: nil, max_results: nil, order_by: nil, page_token: nil)
  @compute.list_routes(
    @project,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_servers(zone, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_servers.rb', line 11

def list_servers(zone, filter: nil, max_results: nil,
                 order_by: nil, page_token: nil)
  @compute.list_instances(
    @project, zone.split("/")[-1],
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_snapshots(project = @project, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/compute/google/requests/list_snapshots.rb', line 11

def list_snapshots(project = @project, filter: nil, max_results: nil,
                   order_by: nil, page_token: nil)
  @compute.list_snapshots(project,
                          :filter => filter, :max_results => max_results,
                          :order_by => order_by, :page_token => page_token)
end

#list_ssl_certificates(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/list_ssl_certificates.rb', line 11

def list_ssl_certificates(filter: nil, max_results: nil,
                          order_by: nil, page_token: nil)
  @compute.list_ssl_certificates(
    @project,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_subnetworks(region_name, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Google::Apis::ComputeV1::SubnetworkList

Retrieves a list of subnetworks specific to a region and project.

Parameters:

  • region_name (String)

    the name of the subnetwork's region

  • filter (String) (defaults to: nil)

    A filter expression for filtering listed resources.

  • max_results (Fixnum) (defaults to: nil)

    Max number of results to return

  • order_by (String) (defaults to: nil)

    Sorts list results by a certain order

  • page_token (String) (defaults to: nil)

    specifies a page token to use

Returns:

  • (Google::Apis::ComputeV1::SubnetworkList)

    list result

See Also:


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/compute/google/requests/list_subnetworks.rb', line 23

def list_subnetworks(region_name, filter: nil, max_results: nil,
                     order_by: nil, page_token: nil)
  if region_name.start_with? "http"
    region_name = region_name.split("/")[-1]
  end
  @compute.list_subnetworks(@project, region_name,
                            :filter => filter,
                            :max_results => max_results,
                            :order_by => order_by,
                            :page_token => page_token)
end

#list_target_http_proxies(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/list_target_http_proxies.rb', line 12

def list_target_http_proxies(filter: nil, max_results: nil,
                             order_by: nil, page_token: nil)
  @compute.list_target_http_proxies(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_target_https_proxies(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/list_target_https_proxies.rb', line 11

def list_target_https_proxies(filter: nil, max_results: nil,
                              order_by: nil, page_token: nil)
  @compute.list_target_https_proxies(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_target_instances(zone, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/compute/google/requests/list_target_instances.rb', line 11

def list_target_instances(zone, filter: nil, max_results: nil,
                          order_by: nil, page_token: nil)
  zone = zone.split("/")[-1] if zone.start_with? "http"
  @compute.list_target_instances(
    @project, zone,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_target_pools(region, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/list_target_pools.rb', line 11

def list_target_pools(region, filter: nil, max_results: nil,
                      order_by: nil, page_token: nil)
  @compute.list_target_pools(
    @project, region.split("/")[-1],
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_url_maps(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/list_url_maps.rb', line 12

def list_url_maps(filter: nil, max_results: nil,
                  order_by: nil, page_token: nil)
  @compute.list_url_maps(
    @project,
    :filter => filter, :max_results => max_results,
    :order_by => order_by, :page_token => page_token
  )
end

#list_zone_operations(zone, filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/compute/google/requests/list_zone_operations.rb', line 12

def list_zone_operations(zone, filter: nil, max_results: nil,
                         order_by: nil, page_token: nil)
  zone = zone.split("/")[-1] if zone.start_with? "http"
  @compute.list_zone_operations(
    @project, zone,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#list_zones(filter: nil, max_results: nil, order_by: nil, page_token: nil) ⇒ Object


11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/list_zones.rb', line 11

def list_zones(filter: nil, max_results: nil,
               order_by: nil, page_token: nil)
  @compute.list_zones(
    @project,
    :filter => filter,
    :max_results => max_results,
    :order_by => order_by,
    :page_token => page_token
  )
end

#patch_firewall(firewall_name, opts = {}) ⇒ Object

Patch a Firewall resource. Supports PATCH semantics.


15
16
17
18
19
20
21
# File 'lib/fog/compute/google/requests/patch_firewall.rb', line 15

def patch_firewall(firewall_name, opts = {})
  opts = opts.select { |k, _| UPDATABLE_FIREWALL_FIELDS.include? k }
  @compute.patch_firewall(
    @project, firewall_name,
    ::Google::Apis::ComputeV1::Firewall.new(opts)
  )
end

#patch_url_map(url_map_name, options = {}) ⇒ Object


11
12
13
14
15
# File 'lib/fog/compute/google/requests/patch_url_map.rb', line 11

def patch_url_map(url_map_name, options = {})
  @compute.patch_url_map(
    @project, url_map_name, ::Google::Apis::ComputeV1::UrlMap.new(options)
  )
end

#process_disks(disks) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/compute/google/requests/insert_server.rb', line 15

def process_disks(disks)
  unless disks && !disks.empty?
    raise ArgumentError.new("at least one value for disks is required")
  end

  disk_lst = disks.map do |d|
    d = d.attached_disk_obj if d.is_a? Disk
    ::Google::Apis::ComputeV1::AttachedDisk.new(d)
  end
  disk_lst.first.boot = true
  disk_lst
end

#process_network_interfaces(network_interfaces) ⇒ Object


28
29
30
31
32
33
34
35
# File 'lib/fog/compute/google/requests/insert_server.rb', line 28

def process_network_interfaces(network_interfaces)
  unless network_interfaces && !network_interfaces.empty?
    network_interfaces = [default_network_interface]
  end
  network_interfaces.map do |network|
    ::Google::Apis::ComputeV1::NetworkInterface.new(network)
  end
end

#remove_instance_group_instances(group_name, zone, instances) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/google/requests/remove_instance_group_instances.rb', line 11

def remove_instance_group_instances(group_name, zone, instances)
  instances.map! do |instance|
    if instance.start_with?("https:")
      ::Google::Apis::ComputeV1::InstanceReference.new(:instance => instance)
    else
      ::Google::Apis::ComputeV1::InstanceReference.new(
        :instance => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone}/instances/#{instance}\n"
      )
    end
  end

  request = ::Google::Apis::ComputeV1::InstanceGroupsRemoveInstancesRequest.new(
    :instances => instances
  )
  @compute.remove_instance_group_instances(
    @project,
    zone,
    group_name,
    request
  )
end

#remove_target_pool_health_checks(target_pool, region, health_checks) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/compute/google/requests/remove_target_pool_health_checks.rb', line 11

def remove_target_pool_health_checks(target_pool, region, health_checks)
  health_check_lst = health_checks.map do |hc|
    ::Google::Apis::ComputeV1::HealthCheckReference.new(:health_check => hc)
  end

  @compute.remove_target_pool_health_check(
    @project,
    region.split("/")[-1],
    target_pool,
    ::Google::Apis::ComputeV1::RemoveTargetPoolsHealthCheckRequest.new(
      :health_checks => health_check_lst
    )
  )
end

#remove_target_pool_instances(target_pool, region, instances) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/compute/google/requests/remove_target_pool_instance.rb', line 11

def remove_target_pool_instances(target_pool, region, instances)
  instance_lst = instances.map do |instance|
    ::Google::Apis::ComputeV1::InstanceReference.new(:instance => instance)
  end

  @compute.remove_target_pool_instance(
    @project,
    region.split("/")[-1],
    target_pool,
    ::Google::Apis::ComputeV1::RemoveTargetPoolsInstanceRequest.new(
      :instances => instance_lst
    )
  )
end

#reset_server(identity, zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/reset_server.rb', line 11

def reset_server(identity, zone)
  @compute.reset_instance(@project, zone.split("/")[-1], identity)
end

#set_common_instance_metadata(project, current_fingerprint, metadata = {}) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/fog/compute/google/requests/set_common_instance_metadata.rb', line 11

def (project, current_fingerprint,  = {})
   = ::Google::Apis::ComputeV1::Metadata.new(
    :fingerprint => current_fingerprint,
    :items => .map { |k, v| { :key => k, :value => v } }
  )
  @compute.(project, )
end

#set_forwarding_rule_target(rule_name, region, target_opts) ⇒ Object


11
12
13
14
15
16
17
# File 'lib/fog/compute/google/requests/set_forwarding_rule_target.rb', line 11

def set_forwarding_rule_target(rule_name, region, target_opts)
  region = region.split("/")[-1] if region.start_with? "http"
  @compute.set_forwarding_rule_target(
    @project, region, rule_name,
    ::Google::Apis::ComputeV1::TargetReference.new(target_opts)
  )
end

#set_global_forwarding_rule_target(rule_name, target_opts) ⇒ Object


11
12
13
14
15
16
# File 'lib/fog/compute/google/requests/set_global_forwarding_rule_target.rb', line 11

def set_global_forwarding_rule_target(rule_name, target_opts)
  @compute.set_global_forwarding_rule_target(
    @project, rule_name,
    ::Google::Apis::ComputeV1::TargetReference.new(target_opts)
  )
end

#set_server_disk_auto_delete(identity, zone, auto_delete, device_name) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/fog/compute/google/requests/set_server_disk_auto_delete.rb', line 12

def set_server_disk_auto_delete(identity, zone, auto_delete, device_name)
  @compute.set_disk_auto_delete(
    @project,
    zone.split("/")[-1],
    identity,
    auto_delete,
    device_name
  )
end

#set_server_metadata(instance, zone, fingerprint, metadata_items = []) ⇒ Object

Set an instance metadata

Parameters:

  • instance (String)

    Instance name (identity)

  • zone (String)

    Name of zone

  • fingerprint (String)

    The fingerprint of the last metadata. Can be retrieved by reloading the compute object, and checking the metadata fingerprint field.

    instance.reload
    fingerprint = instance.['fingerprint']
    
  • metadata (Hash)

    A new metadata object


23
24
25
26
27
28
29
30
31
# File 'lib/fog/compute/google/requests/set_server_metadata.rb', line 23

def (instance, zone, fingerprint,  = [])
  items = .map { |item| ::Google::Apis::ComputeV1::Metadata::Item.new(item) }
  @compute.(
    @project, zone.split("/")[-1], instance,
    ::Google::Apis::ComputeV1::Metadata.new(
      :fingerprint => fingerprint, :items => items
    )
  )
end

#set_server_scheduling(identity, zone, on_host_maintenance: nil, automatic_restart: nil, preemptible: nil) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/set_server_scheduling.rb', line 11

def set_server_scheduling(identity, zone, on_host_maintenance: nil, automatic_restart: nil, preemptible: nil)
  scheduling = ::Google::Apis::ComputeV1::Scheduling.new
  scheduling.on_host_maintenance = on_host_maintenance unless on_host_maintenance.nil?
  scheduling.automatic_restart = automatic_restart unless automatic_restart.nil?
  scheduling.preemptible = preemptible unless preemptible.nil?
  zone = zone.split("/")[-1]
  @compute.set_instance_scheduling(@project, zone, identity, scheduling)
end

#set_server_tags(instance, zone, fingerprint, tags = []) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/set_server_tags.rb', line 11

def set_server_tags(instance, zone, fingerprint, tags = [])
  @compute.set_instance_tags(
    @project, zone.split("/")[-1], instance,
    ::Google::Apis::ComputeV1::Tags.new(
      :fingerprint => fingerprint,
      :items => tags
    )
  )
end

#set_snapshot_labels(snap_name, label_fingerprint, labels) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/set_snapshot_labels.rb', line 11

def set_snapshot_labels(snap_name, label_fingerprint, labels)
  @compute.set_snapshot_labels(
    project, snap_name,
    ::Google::Apis::ComputeV1::GlobalSetLabelsRequest.new(
      :label_fingerprint => label_fingerprint,
      :labels => labels
    )
  )
end

#set_subnetwork_private_ip_google_access(subnetwork_name, region_name, private_ip_google_access) ⇒ Google::Apis::ComputeV1::Operation

Set whether VMs in this subnet can access Google services without assigning external IP addresses through Private Google Access.

Parameters:

  • subnetwork_name (String)

    the name of the subnetwork

  • region_name (String)

    the name of the subnetwork's region

  • private_ip_google_access (Boolean)

    whether private ip google access should be enforced

Returns:

  • (Google::Apis::ComputeV1::Operation)

    an operation response

See Also:


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/compute/google/requests/set_subnetwork_private_ip_google_access.rb', line 24

def set_subnetwork_private_ip_google_access(subnetwork_name,
                                            region_name,
                                            private_ip_google_access)
  if region_name.start_with? "http"
    region_name = region_name.split("/")[-1]
  end
  @compute.set_subnetwork_private_ip_google_access(
    @project, region_name, subnetwork_name,
    ::Google::Apis::ComputeV1::SubnetworksSetPrivateIpGoogleAccessRequest.new(
      :private_ip_google_access => private_ip_google_access
    )
  )
end

#set_target_http_proxy_url_map(proxy_name, url_map) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/set_target_http_proxy_url_map.rb', line 11

def set_target_http_proxy_url_map(proxy_name, url_map)
  @compute.set_target_http_proxy_url_map(
    @project, proxy_name,
    ::Google::Apis::ComputeV1::UrlMapReference.new(
      :url_map => url_map.class == String ? url_map : url_map.self_link
    )
  )
end

#set_target_https_proxy_ssl_certificates(proxy_name, certs) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/set_target_https_proxy_ssl_certificates.rb', line 11

def set_target_https_proxy_ssl_certificates(proxy_name, certs)
  @compute.set_target_https_proxy_ssl_certificates(
    @project, proxy_name,
    ::Google::Apis::ComputeV1::TargetHttpsProxiesSetSslCertificatesRequest.new(
      :ssl_certificates => certs
    )
  )
end

#set_target_https_proxy_url_map(proxy_name, url_map) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/set_target_https_proxy_url_map.rb', line 11

def set_target_https_proxy_url_map(proxy_name, url_map)
  @compute.set_target_https_proxy_url_map(
    @project, proxy_name,
    ::Google::Apis::ComputeV1::UrlMapReference.new(
      :url_map => url_map.class == String ? url_map : url_map.self_link
    )
  )
end

#set_target_pool_backup(target_pool, region, backup_target, failover_ratio: nil) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/compute/google/requests/set_target_pool_backup.rb', line 12

def set_target_pool_backup(target_pool, region, backup_target,
                           failover_ratio: nil)
  target_ref = ::Google::Apis::ComputeV1::TargetReference.new(
    :target => backup_target
  )

  @compute.set_target_pool_backup(
    project,
    region.split("/")[-1],
    target_pool,
    target_ref,
    :failover_ratio => failover_ratio
  )
end

#start_server(identity, zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/start_server.rb', line 11

def start_server(identity, zone)
  @compute.start_instance(@project, zone.split("/")[-1], identity)
end

#stop_server(identity, zone) ⇒ Object


11
12
13
# File 'lib/fog/compute/google/requests/stop_server.rb', line 11

def stop_server(identity, zone)
  @compute.stop_instance(@project, zone.split("/")[-1], identity)
end

#update_firewall(firewall_name, opts = {}) ⇒ Object

Update a Firewall resource.

Only the following fields can/will be changed.

Parameters:

  • opts (Hash) (defaults to: {})

    The firewall object to create

Options Hash (opts):

  • allowed (Array<Hash>)
  • description (String)
  • destination_ranges (Array<String>)
  • source_ranges (Array<String>)
  • source_service_accounts (Array<String>)
  • source_tags (Array<String>)
  • target_service_accounts (Array<String>)
  • target_tags (Array<String>)

See Also:


37
38
39
40
41
42
43
# File 'lib/fog/compute/google/requests/update_firewall.rb', line 37

def update_firewall(firewall_name, opts = {})
  opts = opts.select { |k, _| UPDATABLE_FIREWALL_FIELDS.include? k }
  @compute.update_firewall(
    @project, firewall_name,
    ::Google::Apis::ComputeV1::Firewall.new(opts)
  )
end

#update_http_health_check(check_name, opts = {}) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/fog/compute/google/requests/update_http_health_check.rb', line 11

def update_http_health_check(check_name, opts = {})
  @compute.update_http_health_check(
    @project,
    check_name,
    ::Google::Apis::ComputeV1::HttpHealthCheck.new(
      opts.merge(:name => check_name)
    )
  )
end

#update_url_map(url_map_name, url_map = {}) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/compute/google/requests/update_url_map.rb', line 11

def update_url_map(url_map_name, url_map = {})
  url_map[:host_rules] = url_map[:host_rules] || []
  url_map[:path_matchers] = url_map[:path_matchers] || []
  url_map[:tests] = url_map[:tests] || []

  @compute.update_url_map(
    @project, url_map_name,
    ::Google::Apis::ComputeV1::UrlMap.new(
      url_map.merge(:name => url_map_name)
    )
  )
end

#validate_url_map(url_map_name, url_map = {}) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/fog/compute/google/requests/validate_url_map.rb', line 11

def validate_url_map(url_map_name, url_map = {})
  @compute.validate_url_map(
    @project, url_map_name,
    ::Google::Apis::ComputeV1::ValidateUrlMapsRequest.new(
      :url_map => ::Google::Apis::ComputeV1::UrlMap.new(url_map)
    )
  )
end