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. The options accepted by the constructor are described in detail in this document. The common options are:

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.

apiEndpoint string <optional>

The domain name of the API remote host.

clientConfig gax.ClientConfig <optional>

Client configuration override. Follows the structure of gapicConfig.

fallback boolean <optional>

Use HTTP fallback mode. In fallback mode, a special browser-compatible transport implementation is used instead of gRPC transport. In browser context (if the window object is defined) the fallback mode is enabled automatically; set options.fallback to false if you need to override this behavior.

Members

apiEndpoint

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

port

The port for this API service.

scopes

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

servicePath

The DNS address for this API service.

Methods

close() → {Promise}

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns:
Type Description
Promise

A promise that resolves when the client is closed.

deletePosixAccount(request, optionsopt) → {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

Required. 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>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.deletePosixAccount(request);

deleteSshPublicKey(request, optionsopt) → {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

Required. 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>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.
Example
const [response] = await client.deleteSshPublicKey(request);

getLoginProfile(request, optionsopt) → {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

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

projectId string

The project ID of the Google Cloud Platform project.

systemId string

A system ID for filtering the results of the request.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing LoginProfile. Please see the documentation for more details and examples.
Example
const [response] = await client.getLoginProfile(request);

getProjectId() → {Promise}

Return the project ID used by this class.

Returns:
Type Description
Promise

A promise that resolves to string containing the project ID.

getSshPublicKey(request, optionsopt) → {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

Required. 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>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing SshPublicKey. Please see the documentation for more details and examples.
Example
const [response] = await client.getSshPublicKey(request);

importSshPublicKey(request, optionsopt) → {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 Description
parent string

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

sshPublicKey google.cloud.oslogin.common.SshPublicKey

Required. The SSH public key and expiration time.

projectId string

The project ID of the Google Cloud Platform project.

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
Example
const [response] = await client.importSshPublicKey(request);

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns:
Type Description
Promise

A promise that resolves to an authenticated service stub.

matchFingerprintFromSshPublicKeyName(sshPublicKeyName) → {string}

Parse the fingerprint from SshPublicKey resource.

Parameters:
Name Type Description
sshPublicKeyName string

A fully-qualified path representing SshPublicKey resource.

Returns:
Type Description
string

A string representing the fingerprint.

matchProjectFromPosixAccountName(posixAccountName) → {string}

Parse the project from PosixAccount resource.

Parameters:
Name Type Description
posixAccountName string

A fully-qualified path representing PosixAccount resource.

Returns:
Type Description
string

A string representing the project.

matchUserFromPosixAccountName(posixAccountName) → {string}

Parse the user from PosixAccount resource.

Parameters:
Name Type Description
posixAccountName string

A fully-qualified path representing PosixAccount resource.

Returns:
Type Description
string

A string representing the user.

matchUserFromSshPublicKeyName(sshPublicKeyName) → {string}

Parse the user from SshPublicKey resource.

Parameters:
Name Type Description
sshPublicKeyName string

A fully-qualified path representing SshPublicKey resource.

Returns:
Type Description
string

A string representing the user.

matchUserFromUserName(userName) → {string}

Parse the user from User resource.

Parameters:
Name Type Description
userName string

A fully-qualified path representing User resource.

Returns:
Type Description
string

A string representing the user.

posixAccountPath(user, project) → {string}

Return a fully-qualified posixAccount resource name string.

Parameters:
Name Type Description
user string
project string
Returns:
Type Description
string

Resource name string.

sshPublicKeyPath(user, fingerprint) → {string}

Return a fully-qualified sshPublicKey resource name string.

Parameters:
Name Type Description
user string
fingerprint string
Returns:
Type Description
string

Resource name string.

updateSshPublicKey(request, optionsopt) → {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 Description
name string

Required. 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 google.cloud.oslogin.common.SshPublicKey

Required. The SSH public key and expiration time.

updateMask google.protobuf.FieldMask

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

options object <optional>

Call options. See CallOptions for more details.

Returns:
Type Description
Promise
  • The promise which resolves to an array. The first element of the array is an object representing SshPublicKey. Please see the documentation for more details and examples.
Example
const [response] = await client.updateSshPublicKey(request);

userPath(user) → {string}

Return a fully-qualified user resource name string.

Parameters:
Name Type Description
user string
Returns:
Type Description
string

Resource name string.