Skip to content

Modification in default network url #170

Description

@herambgadgil

The current gce_vm() function fetches and appends the project and network parameters as follows

gce_get_network <- function(network,
project = gce_get_global_project()) {
url <- sprintf("https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s",
project, network)
# compute.networks.get
f <- gar_api_generator(url, "GET", data_parse_function = function(x) x)
f()
}

But having global/networks/ is not necessarily true in all GCP setups. My organization has it setup as this - https://www.googleapis.com/compute/v1/projects/**project-name**/regions/us-central1/subnetworks/local-us-central1-net01

Because of this, I am never able to setup a VM instance through the function. Below is the error snippet that I get

2020-12-14 23:47:06> Creating template VM
i 2020-12-14 23:47:07 > Request Status Code: 404
Error: API returned: The resource 'projects/**project-name**/global/networks/regions/us-central1/subnetworks/local-us-central1-net01' was not found

Solution
Modification in the source code to remove /global/networks/ as default keywords. Users can put them as and when required.

gce_get_network <- function(network,
project = gce_get_global_project()) {
url <- sprintf("https://www.googleapis.com/compute/v1/projects/%s/%s", project, network)
# compute.networks.get
f <- gar_api_generator(url, "GET", data_parse_function = function(x) x)
f()
}

https://github.com/cloudyr/googleComputeEngineR/blob/master/R/networks.R

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions