Session
class
The smokestack.Session
class is the entrypoint for using Startifact via Python.
- class startifact.Session(bucket_names: Optional[startifact.bucket_names.BucketNames] = None, configuration_loader: Optional[startifact.configuration_loader.ConfigurationLoader] = None, out: Optional[IO[str]] = None, read_only: bool = False, regions: Optional[List[str]] = None)
A Startifact session.
- Parameters
bucket_names –
BucketNames
cache to use during this session. Defaults to a new cache.configuration_loader –
ConfigurationLoader
to use during this session. Defaults to a new loader.out – Output writer. Defaults to
stdout
.read_only – Prevents the session writing to Amazon Web Services. Defaults to allowing writes.
regions – Regions to operate in. Defaults to reading your
STARTIFACT_REGIONS
environment variable.
- property bucket_names: startifact.bucket_names.BucketNames
Gets the cache of bucket names.
- Raises
NoConfiguration – if the organisation configuration is empty.
- property configuration: startifact.configuration_loader.ConfigurationLoader
Gets the configuration loader.
- get(project: str, version: Optional[semver.VersionInfo] = None) startifact.artifact.Artifact
Gets an artifact.
- Parameters
project – Project.
version – Version. Omit to infer the latest version.
- Returns
Artifact.
- property read_only: bool
Returns
True
if this session is read-only.
- property regions: List[str]
Gets the regions that this session operates in.
- stage(project: str, version: semver.VersionInfo, path: pathlib.Path, metadata: Optional[Dict[str, str]] = None, save_filename: bool = False) None
Stages an artifact to as many regions as possible.
For example, to stage “dist.tar.gz” as version 1.0.9000 of the SugarWater project with “lang” metadata set to “dotnet”:
from pathlib import Path from semver import VersionInfo from startifact import Session session = Session() session.stage( "SugarWater", VersionInfo(1, 0, 9000), Path("dist.tar.gz"), metadata={ "lang": "dotnet", } )
- Parameters
project – Project.
version – Version.
path – Path to file to upload.
metadata – Optional metadata.
save_filename – Save the filename as metadata.
- Raises
ProjectNameError – if the project name is not acceptable.
CannotStageArtifact – if the artifact could not be staged at all.
- static validate_project_name(name: str) None
Validates a proposed project name.
- Raises
ProjectNameError – if the project name is not acceptable.