cloudpathlib.GSClient¶
Bases: Client
Client class for Google Cloud Storage which handles authentication with GCP for
GSPath
instances. See documentation for the
__init__
method for detailed authentication
options.
Source code in cloudpathlib/gs/gsclient.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
Attributes¶
blob_kwargs: dict[str, Any] = {}
instance-attribute
¶
client = StorageClient()
instance-attribute
¶
content_type_method = content_type_method
instance-attribute
¶
download_chunks_concurrently_kwargs = download_chunks_concurrently_kwargs
instance-attribute
¶
file_cache_mode = file_cache_mode
instance-attribute
¶
retry: Retry = retry
instance-attribute
¶
timeout: float = timeout
instance-attribute
¶
Functions¶
CloudPath(cloud_path: Union[str, BoundedCloudPath]) -> BoundedCloudPath
¶
Source code in cloudpathlib/client.py
112 113 |
|
__init__(application_credentials: Optional[Union[str, os.PathLike]] = None, credentials: Optional[Credentials] = None, project: Optional[str] = None, storage_client: Optional[StorageClient] = None, file_cache_mode: Optional[Union[str, FileCacheMode]] = None, local_cache_dir: Optional[Union[str, os.PathLike]] = None, content_type_method: Optional[Callable] = mimetypes.guess_type, download_chunks_concurrently_kwargs: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None, retry: Optional[Retry] = None)
¶
Class constructor. Sets up a Storage
Client
.
Supports the following authentication methods of Storage Client
.
- Environment variable
"GOOGLE_APPLICATION_CREDENTIALS"
containing a path to a JSON credentials file for a Google service account. See Authenticating as a Service Account. - File path to a JSON credentials file for a Google service account.
- OAuth2 Credentials object and a project name.
- Instantiated and already authenticated
Storage Client
.
If multiple methods are used, priority order is reverse of list above (later in list takes priority). If no authentication methods are used, then the client will be instantiated as anonymous, which will only have access to public buckets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
application_credentials
|
Optional[Union[str, PathLike]]
|
Path to Google service account credentials file. |
None
|
credentials
|
Optional[Credentials]
|
The OAuth2 Credentials to use for this client.
See documentation for |
None
|
project
|
Optional[str]
|
The project which the client acts on behalf of. See
documentation for |
None
|
storage_client
|
Optional[Client]
|
Instantiated |
None
|
file_cache_mode
|
Optional[Union[str, FileCacheMode]]
|
How often to clear the file cache; see the caching docs for more information about the options in cloudpathlib.eums.FileCacheMode. |
None
|
local_cache_dir
|
Optional[Union[str, PathLike]]
|
Path to directory to use as cache
for downloaded files. If None, will use a temporary directory. Default can be set with
the |
None
|
content_type_method
|
Optional[Callable]
|
Function to call to guess media type (mimetype) when
writing a file to the cloud. Defaults to |
guess_type
|
download_chunks_concurrently_kwargs
|
Optional[Dict[str, Any]]
|
Keyword arguments to pass to
|
None
|
timeout
|
Optional[float]
|
Cloud Storage timeout value |
None
|
retry
|
Optional[Retry]
|
Cloud Storage retry configuration |
None
|
Source code in cloudpathlib/gs/gsclient.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
clear_cache()
¶
Clears the contents of the cache folder. Does not remove folder so it can keep being written to.
Source code in cloudpathlib/client.py
115 116 117 118 119 120 121 122 123 124 |
|
get_default_client() -> Client
classmethod
¶
Get the default client, which the one that is used when instantiating a cloud path instance for this cloud without a client specified.
Source code in cloudpathlib/client.py
98 99 100 101 102 103 104 105 |
|
set_as_default_client() -> None
¶
Set this client instance as the default one used when instantiating cloud path instances for this cloud without a client specified.
Source code in cloudpathlib/client.py
107 108 109 110 |
|