Context(project_id, credentials, config=None)¶
Maintains contextual state for connecting to Cloud APIs.
Initializes an instance of a Context object.
- project_id – the current cloud project.
- credentials – the credentials to use to authorize requests.
- config – key/value configurations for cloud operations
Retrieves the value of the config property.
Returns: The current config object used in cloud operations
Retrieves the value of the credentials property.
Returns: The current credentials used in authorizing API requests.
Retrieves a default Context object, creating it if necessary.
The default Context is a global shared instance used every time the default context is retrieved.
Attempting to use a Context with no project_id will raise an exception, so on first use set_project_id must be called.
Returns: An initialized and shared instance of a Context object.
Retrieves the value of the project_id property.
Returns: The current project id to associate with API requests.
Set the config property for the context.
Set the credentials for the context.
Set the project_id for the context.
A manager object for async operations.
A Job can have a Future in which case it will be able to monitor its own completion state and result, or it may have no Future in which case it must be a derived class that manages this some other way. We do this instead of having an abstract base class in order to make wait_one/wait_all more efficient; instead of just sleeping and polling we can use more reactive ways of monitoring groups of Jobs.
Initializes an instance of a Job.
- job_id – a unique ID for the job. If None, a UUID will be generated.
- future – the Future associated with the Job, if any.
The UTC end time of the job (or None if incomplete) as a Python datetime.
Get the non-fatal errors in the job.
Returns: None if the job is still running, else the list of errors that occurred.
Get the success state of the job.
Returns: True if the job failed; False if it is still running or succeeded (possibly with partial failure).
Get the job error.
Returns: None if the job succeeded or is still running, else the error tuple for the failure.
Get the Job ID.
Returns: The ID of the job.
Get the completion state of the job.
Returns: True if the job is complete; False if it is still running.
Get the result for a job. This will block if the job is incomplete.
Returns: The result for the Job. Raises: An exception if the Job resulted in an exception.
The UTC start time of the job as a Python datetime.
Describe the state of a Job.
Returns: A string describing the job’s state.
The total time in fractional seconds that the job took, or None if not complete.
Wait for the job to complete, or a timeout to happen.
Parameters: timeout – how long to wait before giving up (in seconds); default None which means no timeout. Returns: The Job