Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
fix: use compute.googleapis.com as base URI (#168)
Browse files Browse the repository at this point in the history
This change updates the root URL used for requests from `www.googleapis.com` to `compute.googleapis.com`.
  • Loading branch information
JustinBeckwith authored Sep 6, 2019
1 parent 56ccd07 commit 98c45e5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ images.getAll((err, images) => {
[
{
kind: 'compute#image',
selfLink: 'https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20150710',
selfLink: 'https://compute.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20150710',
id: '2223645373384728207',
creationTimestamp: '2015-07-13T13:32:32.483-07:00',
name: 'centos-6-v20150710',
Expand Down Expand Up @@ -60,7 +60,7 @@ images.getLatest('ubuntu', (err, image) => {
/*
image = {
kind: 'compute#image',
selfLink: 'https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1504-vivid-v20150616a',
selfLink: 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1504-vivid-v20150616a',
id: '6610082300127119636',
creationTimestamp: '2015-06-17T02:03:55.825-07:00',
name: 'ubuntu-1504-vivid-v20150616a',
Expand All @@ -71,7 +71,7 @@ images.getLatest('ubuntu', (err, image) => {
archiveSizeBytes: '806558757',
diskSizeGb: '10',
licenses: [
'https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1504-vivid'
'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1504-vivid'
]
}
*/
Expand All @@ -85,7 +85,7 @@ images.getLatest('your-project-id-or-name/ubuntu', (err, image) => {
/*
image = {
kind: 'compute#image',
selfLink: 'https://www.googleapis.com/compute/v1/projects/your-project-id-or-name/global/images/ubuntu-1504-vivid-v20150616a',
selfLink: 'https://compute.googleapis.com/compute/v1/projects/your-project-id-or-name/global/images/ubuntu-1504-vivid-v20150616a',
id: '6610082300127119636',
creationTimestamp: '2015-06-17T02:03:55.825-07:00',
name: 'ubuntu-1504-vivid-v20150616a',
Expand All @@ -96,7 +96,7 @@ images.getLatest('your-project-id-or-name/ubuntu', (err, image) => {
archiveSizeBytes: '806558757',
diskSizeGb: '10',
licenses: [
'https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1504-vivid'
'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1504-vivid'
]
}
*/
Expand All @@ -110,7 +110,7 @@ images.getLatest('ubuntu-1404', (err, image) => {
/*
image = {
kind: 'compute#image',
selfLink: 'https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1410-utopic-v20150625',
selfLink: 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1410-utopic-v20150625',
id: '7075003915689987469',
creationTimestamp: '2015-07-09T10:46:10.424-07:00',
name: 'ubuntu-1410-utopic-v20150625',
Expand All @@ -121,7 +121,7 @@ images.getLatest('ubuntu-1404', (err, image) => {
archiveSizeBytes: '752874399',
diskSizeGb: '10',
licenses: [
'https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1410-utopic'
'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-1410-utopic'
]
}
*/
Expand All @@ -134,15 +134,15 @@ images.getLatest('ubuntu-1404', (err, image) => {
images.OS_URLS; // also available on require('gce-images').OS_URLS;
/*
{
centos: 'https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images',
'container-vm': 'https://www.googleapis.com/compute/v1/projects/cos-cloud/global/images',
coreos: 'https://www.googleapis.com/compute/v1/projects/coreos-cloud/global/images',
debian: 'https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images',
redhat: 'https://www.googleapis.com/compute/v1/projects/rhel-cloud/global/images',
opensuse: 'https://www.googleapis.com/compute/v1/projects/opensuse-cloud/global/images',
suse: 'https://www.googleapis.com/compute/v1/projects/suse-cloud/global/images',
ubuntu: 'https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images',
windows: 'https://www.googleapis.com/compute/v1/projects/windows-cloud/global/images'
centos: 'https://compute.googleapis.com/compute/v1/projects/centos-cloud/global/images',
'container-vm': 'https://compute.googleapis.com/compute/v1/projects/cos-cloud/global/images',
coreos: 'https://compute.googleapis.com/compute/v1/projects/coreos-cloud/global/images',
debian: 'https://compute.googleapis.com/compute/v1/projects/debian-cloud/global/images',
redhat: 'https://compute.googleapis.com/compute/v1/projects/rhel-cloud/global/images',
opensuse: 'https://compute.googleapis.com/compute/v1/projects/opensuse-cloud/global/images',
suse: 'https://compute.googleapis.com/compute/v1/projects/suse-cloud/global/images',
ubuntu: 'https://compute.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images',
windows: 'https://compute.googleapis.com/compute/v1/projects/windows-cloud/global/images'
}
*/
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"google-auth-library": "^5.0.0"
},
"devDependencies": {
"@compodoc/compodoc": "^1.1.9",
"@compodoc/compodoc": "^1.1.10",
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.5",
"@types/node": "^10.5.6",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface GCEImagesConfig extends GoogleAuthOptions {
authClient?: GoogleAuth;
/**
* The host name used to access the compute API.
* Defaults to `www.googleapis.com`.
* Defaults to `compute.googleapis.com`.
*/
apiEndpoint?: string;
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export class GCEImages {
OS_URLS: OSUrls;
OS_TO_URL: {[index: string]: string};
constructor(config: GCEImagesConfig = {}) {
this.apiEndpoint = config.apiEndpoint || 'www.googleapis.com';
this.apiEndpoint = config.apiEndpoint || 'compute.googleapis.com';
config.scopes = ['https://www.googleapis.com/auth/compute'];
this._auth = config.authClient || new GoogleAuth(config);
const projectsPath = `https://${this.apiEndpoint}/compute/v1/projects`;
Expand Down Expand Up @@ -320,7 +320,7 @@ export class GCEImages {
}

if (hasProject) {
osParts.url = `https://www.googleapis.com/compute/v1/projects/${project!}/global/images`;
osParts.url = `https://compute.googleapis.com/compute/v1/projects/${project!}/global/images`;
} else {
osParts.url = this.OS_TO_URL[osParts.name];
}
Expand Down

0 comments on commit 98c45e5

Please sign in to comment.