Class OsLoginServiceClient (0.2.0)

OsLoginServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

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.

Inheritance

builtins.object > google.cloud.oslogin_v1.gapic.os_login_service_client.OsLoginServiceClient > OsLoginServiceClient

Methods

OsLoginServiceClient

OsLoginServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

credentials google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

client_config dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

delete_posix_account

delete_posix_account(name, retry=<object object>, timeout=<object object>, metadata=None)

Deletes a POSIX account.

.. rubric:: Example

from google.cloud import oslogin_v1

client = oslogin_v1.OsLoginServiceClient()

name = client.project_path('[USER]', '[PROJECT]')

client.delete_posix_account(name)

Parameters
NameDescription
name str

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

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

delete_ssh_public_key

delete_ssh_public_key(name, retry=<object object>, timeout=<object object>, metadata=None)

Deletes an SSH public key.

.. rubric:: Example

from google.cloud import oslogin_v1

client = oslogin_v1.OsLoginServiceClient()

name = client.fingerprint_path('[USER]', '[FINGERPRINT]')

client.delete_ssh_public_key(name)

Parameters
NameDescription
name str

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

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

fingerprint_path

fingerprint_path(user, fingerprint)

Return a fully-qualified fingerprint string.

from_service_account_file

from_service_account_file(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
OsLoginServiceClientThe constructed client.

from_service_account_json

from_service_account_json(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
OsLoginServiceClientThe constructed client.

get_login_profile

get_login_profile(name, retry=<object object>, timeout=<object object>, metadata=None)

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

.. rubric:: Example

from google.cloud import oslogin_v1

client = oslogin_v1.OsLoginServiceClient()

name = client.user_path('[USER]')

response = client.get_login_profile(name)

Parameters
NameDescription
name str

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

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

get_ssh_public_key

get_ssh_public_key(name, retry=<object object>, timeout=<object object>, metadata=None)

Retrieves an SSH public key.

.. rubric:: Example

from google.cloud import oslogin_v1

client = oslogin_v1.OsLoginServiceClient()

name = client.fingerprint_path('[USER]', '[FINGERPRINT]')

response = client.get_ssh_public_key(name)

Parameters
NameDescription
name str

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

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

import_ssh_public_key

import_ssh_public_key(parent, ssh_public_key, project_id=None, retry=<object object>, timeout=<object object>, metadata=None)

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.

.. rubric:: Example

from google.cloud import oslogin_v1

client = oslogin_v1.OsLoginServiceClient()

parent = client.user_path('[USER]')

TODO: Initialize ssh_public_key:

ssh_public_key = {}

response = client.import_ssh_public_key(parent, ssh_public_key)

Parameters
NameDescription
parent str

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

ssh_public_key Union[dict, SshPublicKey]

The SSH public key and expiration time. If a dict is provided, it must be of the same form as the protobuf message SshPublicKey

project_id str

The project ID of the Google Cloud Platform project.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

project_path

project_path(user, project)

Return a fully-qualified project string.

update_ssh_public_key

update_ssh_public_key(name, ssh_public_key, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)

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

.. rubric:: Example

from google.cloud import oslogin_v1

client = oslogin_v1.OsLoginServiceClient()

name = client.fingerprint_path('[USER]', '[FINGERPRINT]')

TODO: Initialize ssh_public_key:

ssh_public_key = {}

response = client.update_ssh_public_key(name, ssh_public_key)

Parameters
NameDescription
name str

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

ssh_public_key Union[dict, SshPublicKey]

The SSH public key and expiration time. If a dict is provided, it must be of the same form as the protobuf message SshPublicKey

update_mask Union[dict, FieldMask]

Mask to control which fields get updated. Updates all if not present. If a dict is provided, it must be of the same form as the protobuf message FieldMask

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will not be retried.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

user_path

user_path(user)

Return a fully-qualified user string.