Paths and File Access
s2gos_utils.io.paths.PathRef
pydantic-model
Bases: BaseModel
Path configuration that preserves credential reference through serialization.
This model allows paths to reference credentials by ID rather than embedding
actual credentials. When serialized to JSON it is structurally an OGC Link:
{"href": <path/URI>, "x-cid": <credential id>} (only the path and the
credential reference are stored, never actual credentials). When deserialized,
credentials are resolved from the credential provider (environment variables or
.secrets.yaml).
Attributes:
| Name | Type | Description |
|---|---|---|
href |
str
|
The actual path/URI (the OGC Link |
type |
str | None
|
Optional Link media (MIME) type. |
options |
dict[str, Any] | None
|
Optional extra client options (serialized as |
cid |
str | None
|
Optional reference to a Credential ID in the credential provider.
Serialized as the |
Example
With credentials
path = PathRef( "https://data.earthdatahub.destine.eu/data.zarr", cid="earthdatahub" )
Without credentials (public or local path)
path = PathRef("/local/path/data.zarr")
Access the authenticated UPath
upath = path.upath
Config:
frozen:Truepopulate_by_name:Trueserialize_by_alias:True
Fields:
Validators:
-
_coerce
Attributes
options
pydantic-field
Extra client options for accessing href in its storage
upath
property
Get the authenticated UPath by resolving credentials.
If cid is set, retrieves the credential from the credential
provider and constructs an authenticated UPath. Otherwise returns a
simple UPath without authentication.
Returns:
| Type | Description |
|---|---|
UPath
|
UPath object with authentication if |
Raises:
| Type | Description |
|---|---|
CredentialNotFoundError
|
If |