OsLoginServiceClient

OsLoginServiceClient

Cloud OS Login API

The Cloud OS Login API allows you to manage users and their associated SSH public keys for logging into virtual machines on Google Cloud Platform.

Constructor

new OsLoginServiceClient(optionsopt)

Construct an instance of OsLoginServiceClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

promise function <optional>

Custom promise module to use instead of native Promises.

apiEndpoint string <optional>

The domain name of the API remote host.

Source:

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

Source:

(static) port

The port for this API service.

Source:

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

Source:

(static) servicePath

The DNS address for this API service.

Source:

Methods

deletePosixAccount(request, optionsopt, callbackopt) → {Promise}

Deletes a POSIX account.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

A reference to the POSIX account to update. POSIX accounts are identified by the project ID they are associated with. A reference to the POSIX account is in format users/{user}/projects/{project}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Source:
Example
const osLogin = require('@google-cloud/os-login');

const client = new osLogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

const formattedName = client.projectPath('[USER]', '[PROJECT]');
client.deletePosixAccount({name: formattedName}).catch(err => {
  console.error(err);
});

deleteSshPublicKey(request, optionsopt, callbackopt) → {Promise}

Deletes an SSH public key.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format users/{user}/sshPublicKeys/{fingerprint}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Source:
Example
const osLogin = require('@google-cloud/os-login');

const client = new osLogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

const formattedName = client.fingerprintPath('[USER]', '[FINGERPRINT]');
client.deleteSshPublicKey({name: formattedName}).catch(err => {
  console.error(err);
});

fingerprintPath(user, fingerprint) → {String}

Return a fully-qualified fingerprint resource name string.

Parameters:
Name Type Description
user String
fingerprint String
Source:

getLoginProfile(request, optionsopt, callbackopt) → {Promise}

Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The unique ID for the user in format users/{user}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing LoginProfile.

Source:
Example
const osLogin = require('@google-cloud/os-login');

const client = new osLogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

const formattedName = client.userPath('[USER]');
client.getLoginProfile({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

Source:

getSshPublicKey(request, optionsopt, callbackopt) → {Promise}

Retrieves an SSH public key.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

The fingerprint of the public key to retrieve. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format users/{user}/sshPublicKeys/{fingerprint}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing SshPublicKey.

Source:
Example
const osLogin = require('@google-cloud/os-login');

const client = new osLogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

const formattedName = client.fingerprintPath('[USER]', '[FINGERPRINT]');
client.getSshPublicKey({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

importSshPublicKey(request, optionsopt, callbackopt) → {Promise}

Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the login profile.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

The unique ID for the user in format users/{user}.

sshPublicKey Object

The SSH public key and expiration time.

This object should have the same structure as SshPublicKey

projectId string <optional>

The project ID of the Google Cloud Platform project.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ImportSshPublicKeyResponse.

Source:
Example
const osLogin = require('@google-cloud/os-login');

const client = new osLogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

const formattedParent = client.userPath('[USER]');
const sshPublicKey = {};
const request = {
  parent: formattedParent,
  sshPublicKey: sshPublicKey,
};
client.importSshPublicKey(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

matchFingerprintFromFingerprintName(fingerprintName) → {String}

Parse the fingerprintName from a fingerprint resource.

Parameters:
Name Type Description
fingerprintName String

A fully-qualified path representing a fingerprint resources.

Source:

matchProjectFromProjectName(projectName) → {String}

Parse the projectName from a project resource.

Parameters:
Name Type Description
projectName String

A fully-qualified path representing a project resources.

Source:

matchUserFromFingerprintName(fingerprintName) → {String}

Parse the fingerprintName from a fingerprint resource.

Parameters:
Name Type Description
fingerprintName String

A fully-qualified path representing a fingerprint resources.

Source:

matchUserFromProjectName(projectName) → {String}

Parse the projectName from a project resource.

Parameters:
Name Type Description
projectName String

A fully-qualified path representing a project resources.

Source:

matchUserFromUserName(userName) → {String}

Parse the userName from a user resource.

Parameters:
Name Type Description
userName String

A fully-qualified path representing a user resources.

Source:

projectPath(user, project) → {String}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
user String
project String
Source:

updateSshPublicKey(request, optionsopt, callbackopt) → {Promise}

Updates an SSH public key and returns the profile information. This method supports patch semantics.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

The fingerprint of the public key to update. Public keys are identified by their SHA-256 fingerprint. The fingerprint of the public key is in format users/{user}/sshPublicKeys/{fingerprint}.

sshPublicKey Object

The SSH public key and expiration time.

This object should have the same structure as SshPublicKey

updateMask Object <optional>

Mask to control which fields get updated. Updates all if not present.

This object should have the same structure as FieldMask

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing SshPublicKey.

Source:
Example
const osLogin = require('@google-cloud/os-login');

const client = new osLogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

const formattedName = client.fingerprintPath('[USER]', '[FINGERPRINT]');
const sshPublicKey = {};
const request = {
  name: formattedName,
  sshPublicKey: sshPublicKey,
};
client.updateSshPublicKey(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

userPath(user) → {String}

Return a fully-qualified user resource name string.

Parameters:
Name Type Description
user String
Source: