cloudmesh.google.storage.Provider

Module Contents

Classes

Provider

class cloudmesh.google.storage.Provider.Provider(service=None, json=None, **kwargs)

Bases: cloudmesh.abstract.StorageABC.StorageABC

sample = cloudmesh:   storage:     {name}:       cm:         name: google         active: 'true'         heading: GCP         host: https://console.cloud.google.com/storage         kind: google         version: TBD         service: storage       default:         directory: {bucket}         Location_type: Region         Location: us - east1         Default_storage_class: Standard         Access_control: Uniform         Encryption: Google-managed         Link_URL: https://console.cloud.google.com/storage/browser/{bucket}         Link_for_gsutil: gs://{bucket}       credentials:         type: service_account         project_id: imposing-coast-123456         private_key_id: a1b2c3d4*********         private_key: TBD         client_email: TBD         client_id: TBD         auth_uri: https://accounts.google.com/o/oauth2/auth         token_uri: https://oauth2.googleapis.com/token         auth_provider_x509_cert_url: https://www.googleapis.com/oauth2/v1/certs         client_x509_cert_url: TBD
static get_filename(filename)
static get_kind()
static json_to_yaml(name, filename='~/.cloudmesh/google.json')

given a json file downloaded from google, copies the content into the cloudmesh yaml file, while overwriting or creating a new storage provider :param filename: :return:

static yaml_to_json(name, filename='~/.cloudmesh/google.json')

given the name in the yaml file, takes the information form that object and creates the json file that cna be conveniently used by google :param name: :param filename: :return:

abstract static delete_json(filename='~/.cloudmesh/google.json')

deletes the json file. Make sure you have it saved in the yaml :param filename: :return:

get(self, source=None, destination=None, recursive=False)

Downloads(get) the source(bucket blob) to local storage :param source: the source which either can be a directory or file :param destination: the destination which either can be a directory or file :return: dict

put(self, source=None, destination=None, recursive=None)

Uploads(puts) the source(local) to the destination service bucket :param source: the source which either can be a directory or file :param destination: the destination which either can be a directory or file :return: dict

list(self, source=None, dir_only=False, recursive=False)

Lists the source: google bucket blob(s) with and without prefix :param source: the source which either can be a directory or file (either provide fill path or a prefix) :return: dict

delete(self, source=None)

Deletes a blob from the bucket. :param source: Enter the blob name at google bucket you like to delete :return: dict

create_dir(self, directory=None)

Creates a directory or folder at google bucket. :param directory: Enter the directory structure you like to create at google bucket :return: dict

blob_metadata(self, blob_name=None)

Prints out a blob’s metadata. :param blob_name: Enter the blob name with full path at google bucket you like to get metadata :return: dict

rename_blob(self, blob_name=None, new_name=None)

Renames a blob at google bucket :param blob_name: Enter the existing blob name with full path at google bucket :param new_name: Enter the new blob name with full path at google bucket you like to rename :return: dict

create_bucket(self, new_bucket_name=None)

Creates a new bucket, only used for creating new bucket :param new_bucket_name: Enter the name of new bucket yoy like to create at google cloud :return: dict

list_bucket(self)

Lists google cloud bucket, only used for listing bucket :return: dict

copy_blob_btw_buckets(self, blob_name, bucket_name_dest, blob_name_dest)

Copies a blob from one bucket to another with a new name. :param blob_name: Enter the blob name with full path at google bucket you like to copy :param bucket_name_dest: Enter the destination google cloud bucket name you like to copy blob :param blob_name_dest: Enter the new destination blob name with full path at destination google bucket :return: dict

abstract search(self, directory=None, filename=None, recursive=False)

gets the destination and copies it in source

Parameters
  • service – the name of the service in the yaml file

  • directory – the directory which either can be a directory or file

  • filename – filename

  • recursive – in case of directory the recursive refers to all subdirectories in the specified source

Returns

dict

abstract sync(self, source=None, destination=None, recursive=None)

sync the destination and local

Parameters
  • source – local computer location

  • destination – cloud service

  • recursive – in case of directory the recursive refers to all subdirectories in the specified source

Returns

dict

massage_path(self, file_name_path)