general library
General Google Cloud Platform integration features.
Enums
Properties
- gceMetadataHost → String
-
Returns the host for the GCE metadata server.
no setter
Functions
-
computeProjectId(
{Client? client, bool refresh = false}) → Future< String> - A convenience wrapper that tries multiple strategies to find the project ID, prioritizing local development strategies over cloud discovery.
-
fetchMetadataValue(
String path, {Client? client, Duration timeout = const Duration(seconds: 3)}) → Future< String> - Retrieves a value from the GCE metadata server without caching the result.
-
gceMetadataUrl(
String path) → Uri -
Returns a Uri for the given
pathon the GCE metadata server. -
getMetadataValue(
String path, {Client? client, Duration timeout = const Duration(seconds: 3), bool refresh = false}) → Future< String> - Retrieves a value from the GCE metadata server.
-
projectIdFromCredentialsFile(
) → String? -
Returns the
Project ID
for the current Google Cloud Project by reading the
project_idfield from the credentials JSON file specified by theGOOGLE_APPLICATION_CREDENTIALSenvironment variable. -
projectIdFromEnvironmentVariables(
) → String? - Returns the Project ID for the current Google Cloud Project by checking the environment variables in projectIdEnvironmentVariableOptions.
-
projectIdFromGcloudConfig(
) → Future< String?> - Returns a Future that completes with the Project ID for the current Google Cloud Project by querying the gcloud CLI configuration.
-
projectIdFromMetadataServer(
{Client? client, bool refresh = false}) → Future< String> - Returns a Future that completes with the Project ID for the current Google Cloud Project by checking project metadata.
-
serviceAccountEmailFromMetadataServer(
{Client? client, bool refresh = false}) → Future< String> - A convenience wrapper that tries to retrieve the default service account email from the Metadata Server.
-
structuredLogEntry(
Object message, LogSeverity severity, {String? traceId, StackTrace? stackTrace}) → String - Creates a JSON-encoded log entry that conforms with structured logs.
Exceptions / Errors
- MetadataServerException
- Exception thrown when accessing the GCE metadata server fails.