pcf.particle.gcp.storage package¶
Submodules¶
pcf.particle.gcp.storage.storage module¶
-
class
pcf.particle.gcp.storage.bucket.
Bucket
(particle_definition)¶ Bases:
pcf.core.gcp_resource.GCPResource
This is the implementation of Google’s storage service.
-
UNIQUE_KEYS
= ['gcp_resource.name']¶
-
_set_unique_keys
()¶ Logic that sets keys from state definition that are used to uniquely identify the storage bucket
-
_start
()¶ Creates the storage bucket
Returns: response of create_bucket
-
_stop
()¶ Storage bucket does not have a stopped state so it calls terminate.
-
_terminate
()¶ Deletes the storage bucket
Returns: response of gcp delete
-
_update
()¶ Not Implemented
-
delete_object
(blob_name)¶ Deletes an object in the storage bucket.
Parameters: blob_name (str) – Object Key name (Required)
-
download_object
(blob_name, file_obj, **kwargs)¶ Downloads a file from the Storage bucket.
Parameters: - blob_name (str) – Object name (Required)
- file_obj (str) – file name for the download (Required)
- **kwargs – Options for gcp get_object (optional)
-
equivalent_states
= {<State.running: 1>: 1, <State.stopped: 2>: 0, <State.terminated: 3>: 0}¶
-
flavor
= 'storage'¶
-
get_status
()¶ Determines if the bucket exists
Returns: status (dict)
-
is_state_equivalent
(state1, state2)¶ Determines if states are equivalent. Uses equivalent_states defined in the Storage class.
Parameters: - state1 (State) –
- state1 –
Returns: bool
-
list_objects
(**kwargs)¶ Lists all objects in the storage bucket.
Parameters: **kwargs – Options for gcp list_objects (optional)
-
put_file
(blob_name, file, **kwargs)¶ Puts a file in the Storage bucket.
Parameters: - blob_name (str) – Object Key name (Required)
- file (file) – the file to put into the bucket (Required)
- **kwargs – Options for gcp upload_file (optional)
-
put_object
(blob_name, file_obj, **kwargs)¶ Puts an object in the Storage bucket.
Parameters: - blob_name (str) – Object Key name (Required)
- file_obj (object) – the object to put into the bucket (Required)
- **kwargs – Options for gcp put_object (optional)
-
sync_state
()¶ Calls get status and then sets the current state.
-