Constructor

OsLoginServiceClient

new OsLoginServiceClient(options)

Construct an instance of OsLoginServiceClient.

Parameter

options

Optional

object

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

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

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

keyFilename

Optional

string

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 above is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

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

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

Properties

port

static

The port for this API service.

scopes

static

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

servicePath

static

The DNS address for this API service.

Methods

deletePosixAccount

deletePosixAccount(request, options, callback) returns Promise

Deletes a POSIX account.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

Object

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

callback

Optional

function(nullable Error)

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

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const oslogin = require('@google-cloud/oslogin');

var client = new oslogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

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

deleteSshPublicKey

deleteSshPublicKey(request, options, callback) returns Promise

Deletes an SSH public key.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

Object

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

callback

Optional

function(nullable Error)

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

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const oslogin = require('@google-cloud/oslogin');

var client = new oslogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

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

fingerprintPath

fingerprintPath(user, fingerprint) returns String

Return a fully-qualified fingerprint resource name string.

Parameter

user

String

fingerprint

String

Returns

String 

getLoginProfile

getLoginProfile(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing LoginProfile. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const oslogin = require('@google-cloud/oslogin');

var client = new oslogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

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

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

getSshPublicKey

getSshPublicKey(request, options, callback) returns Promise

Retrieves an SSH public key.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing SshPublicKey. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const oslogin = require('@google-cloud/oslogin');

var client = new oslogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

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

importSshPublicKey

importSshPublicKey(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

string

The project ID of the Google Cloud Platform project.

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ImportSshPublicKeyResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const oslogin = require('@google-cloud/oslogin');

var client = new oslogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

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

matchFingerprintFromFingerprintName

matchFingerprintFromFingerprintName(fingerprintName) returns String

Parse the fingerprintName from a fingerprint resource.

Parameter

fingerprintName

String

A fully-qualified path representing a fingerprint resources.

Returns

String 

  • A string representing the fingerprint.

matchProjectFromProjectName

matchProjectFromProjectName(projectName) returns String

Parse the projectName from a project resource.

Parameter

projectName

String

A fully-qualified path representing a project resources.

Returns

String 

  • A string representing the project.

matchUserFromFingerprintName

matchUserFromFingerprintName(fingerprintName) returns String

Parse the fingerprintName from a fingerprint resource.

Parameter

fingerprintName

String

A fully-qualified path representing a fingerprint resources.

Returns

String 

  • A string representing the user.

matchUserFromProjectName

matchUserFromProjectName(projectName) returns String

Parse the projectName from a project resource.

Parameter

projectName

String

A fully-qualified path representing a project resources.

Returns

String 

  • A string representing the user.

matchUserFromUserName

matchUserFromUserName(userName) returns String

Parse the userName from a user resource.

Parameter

userName

String

A fully-qualified path representing a user resources.

Returns

String 

  • A string representing the user.

projectPath

projectPath(user, project) returns String

Return a fully-qualified project resource name string.

Parameter

user

String

project

String

Returns

String 

updateSshPublicKey

updateSshPublicKey(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

Object

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

This object should have the same structure as FieldMask

options

Optional

Object

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

callback

Optional

function(nullable Error, nullable Object)

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

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

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing SshPublicKey. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const oslogin = require('@google-cloud/oslogin');

var client = new oslogin.v1beta.OsLoginServiceClient({
  // optional auth parameters.
});

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

userPath

userPath(user) returns String

Return a fully-qualified user resource name string.

Parameter

user

String

Returns

String