flayer.providers.contracts¶
flayer.providers.contracts ¶
Provider-neutral contracts for bounded, read-only infrastructure discovery.
IDENTIFIER_PATTERN
module-attribute
¶
IDENTIFIER_PATTERN = re.compile('[A-Za-z0-9][A-Za-z0-9_.-]{0,127}\\Z')
ResourceKind ¶
Bases: StrEnum
Infrastructure resource kinds supported by the discovery contract.
ProviderCapability ¶
Bases: StrEnum
Implemented operations advertised by a provider, independent of permissions.
ProviderErrorCode ¶
Bases: StrEnum
Stable failure categories that never include vendor output or credentials.
INCOMPLETE_INVENTORY
class-attribute
instance-attribute
¶
INCOMPLETE_INVENTORY = 'incomplete_inventory'
ProviderError ¶
ProviderError(code: ProviderErrorCode, operation: str)
Bases: RuntimeError
A sanitized provider failure with a stable code and retry recommendation.
Build an error without retaining external command output or exceptions.
源代码位于: installed/flayer/providers/contracts.py
53 54 55 56 57 58 59 60 61 62 | |
retryable
instance-attribute
¶
retryable = code in {ProviderErrorCode.TIMEOUT, ProviderErrorCode.THROTTLED}
ProviderIdentity
dataclass
¶
ProviderIdentity(provider_id: str, scope_id: str, authentication_source: str)
ResourceReference
dataclass
¶
ResourceReference(provider_id: str, scope_id: str, kind: ResourceKind, resource_id: str)
A resource key bound to one provider, one scope and one resource kind.
ProviderResource
dataclass
¶
ProviderResource(reference: ResourceReference, name: str, status: str = 'UNKNOWN', zone_id: str | None = None, labels: tuple[tuple[str, str], ...] = (), public_addresses: tuple[str, ...] = ())
A normalized observation, excluding raw vendor payloads and instance metadata.
HasLabels ¶
HasLabels(expected: tuple[tuple[str, str], ...]) -> bool
Check all required labels without treating a resource name as ownership.
源代码位于: installed/flayer/providers/contracts.py
150 151 152 153 154 155 | |
ProviderStatus
dataclass
¶
ProviderStatus(identity: ProviderIdentity, available: bool, authenticated: bool | None = None, error_code: ProviderErrorCode | None = None)
A sanitized probe result; unknown authentication differs from a failed probe.
CloudProvider ¶
Bases: Protocol
Read-only provider boundary consumed by diagnostics and future orchestration.
Identity
property
¶
Identity: ProviderIdentity
Return the provider identity and explicit discovery scope.
Capabilities
property
¶
Capabilities: frozenset[ProviderCapability]
Advertise implemented operations without promising account authorization.
CheckAvailability ¶
CheckAvailability() -> ProviderStatus
Probe the local provider adapter without accessing infrastructure.
源代码位于: installed/flayer/providers/contracts.py
184 185 186 187 | |
CheckAuthentication ¶
CheckAuthentication() -> ProviderStatus
Probe read permission to the selected scope without exposing credentials.
源代码位于: installed/flayer/providers/contracts.py
189 190 191 192 | |
ListResources ¶
ListResources(kind: ResourceKind) -> tuple[ProviderResource, ...]
List a complete resource kind within the provider's explicit scope.
源代码位于: installed/flayer/providers/contracts.py
194 195 196 197 | |
GetResource ¶
GetResource(reference: ResourceReference) -> ProviderResource
Read one resource and reject any reference or response outside the scope.
源代码位于: installed/flayer/providers/contracts.py
199 200 201 202 | |
DiscoverInventory ¶
DiscoverInventory() -> tuple[ProviderResource, ...]
Return all supported kinds or fail without returning partial inventory.
源代码位于: installed/flayer/providers/contracts.py
204 205 206 207 | |
ValidateIdentifier ¶
ValidateIdentifier(value: str) -> None
Reject unsafe identifiers without including the rejected value in errors.
源代码位于: installed/flayer/providers/contracts.py
65 66 67 68 69 70 71 | |