Client for Google Cloud OS Login API#
-
class
google.cloud.oslogin_v1.
OsLoginServiceClient
(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]# 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.
- Parameters
(Union[OsLoginServiceGrpcTransport, (transport) – Callable[[~.Credentials, type], ~.OsLoginServiceGrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.
channel (grpc.Channel) – DEPRECATED. A
Channel
instance through which to make calls. This argument is mutually exclusive withcredentials
; 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
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Deletes a POSIX account.
Example
>>> from google.cloud import oslogin_v1 >>> >>> client = oslogin_v1.OsLoginServiceClient() >>> >>> name = client.project_path('[USER]', '[PROJECT]') >>> >>> client.delete_posix_account(name)
- Parameters
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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
delete_ssh_public_key
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Deletes an SSH public key.
Example
>>> from google.cloud import oslogin_v1 >>> >>> client = oslogin_v1.OsLoginServiceClient() >>> >>> name = client.fingerprint_path('[USER]', '[FINGERPRINT]') >>> >>> client.delete_ssh_public_key(name)
- Parameters
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.
- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
classmethod
fingerprint_path
(user, fingerprint)[source]# Return a fully-qualified fingerprint string.
-
classmethod
from_service_account_file
(filename, *args, **kwargs)[source]# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
classmethod
from_service_account_json
(filename, *args, **kwargs)# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
get_login_profile
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine.
Example
>>> from google.cloud import oslogin_v1 >>> >>> client = oslogin_v1.OsLoginServiceClient() >>> >>> name = client.user_path('[USER]') >>> >>> response = client.get_login_profile(name)
- Parameters
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.
- Returns
A
LoginProfile
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
get_ssh_public_key
(name, retry=<object object>, timeout=<object object>, metadata=None)[source]# Retrieves an SSH public key.
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
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.
- Returns
A
SshPublicKey
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
import_ssh_public_key
(parent, ssh_public_key, project_id=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# 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.
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
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.
- Returns
A
ImportSshPublicKeyResponse
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
update_ssh_public_key
(name, ssh_public_key, update_mask=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Updates an SSH public key and returns the profile information. This method supports patch semantics.
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
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.
- Returns
A
SshPublicKey
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.