pub struct ProviderConn { /* private fields */ }Expand description
A connected provider — the protocol-matched client over a dialed channel.
Implementations§
Source§impl ProviderConn
impl ProviderConn
Sourcepub fn new(channel: H2Channel, protocol: PluginProtocol) -> Self
pub fn new(channel: H2Channel, protocol: PluginProtocol) -> Self
Wrap a dialed channel, selecting the client by the handshake’s
negotiated protocol (Plugin::handshake().app_protocol).
Sourcepub async fn get_schema(&mut self) -> Result<ProviderSchema, ProviderError>
pub async fn get_schema(&mut self) -> Result<ProviderSchema, ProviderError>
GetProviderSchema (v6) / GetSchema (v5) → provider-config +
per-resource implied types.
Sourcepub async fn configure(
&mut self,
config: &DynamicValue,
terraform_version: &str,
) -> Result<(), ProviderError>
pub async fn configure( &mut self, config: &DynamicValue, terraform_version: &str, ) -> Result<(), ProviderError>
ConfigureProvider (v6) / Configure (v5) — provider creds/settings.
Sourcepub async fn plan_resource_change(
&mut self,
type_name: &str,
prior_state: &DynamicValue,
proposed_new_state: &DynamicValue,
config: &DynamicValue,
) -> Result<PlannedChange, ProviderError>
pub async fn plan_resource_change( &mut self, type_name: &str, prior_state: &DynamicValue, proposed_new_state: &DynamicValue, config: &DynamicValue, ) -> Result<PlannedChange, ProviderError>
PlanResourceChange — the provider’s proposed new state PLUS
which attribute paths (if any) force a destroy+create instead of
an in-place update. See PlannedChange’s doc for why the
latter matters: it is the ONLY authoritative source for that
decision, and was silently discarded here before PlannedChange
existed.
Sourcepub async fn apply_resource_change(
&mut self,
type_name: &str,
prior_state: &DynamicValue,
planned_state: &DynamicValue,
config: &DynamicValue,
) -> Result<DynamicValue, ProviderError>
pub async fn apply_resource_change( &mut self, type_name: &str, prior_state: &DynamicValue, planned_state: &DynamicValue, config: &DynamicValue, ) -> Result<DynamicValue, ProviderError>
ApplyResourceChange — execute the change. Returns the new state.
Sourcepub async fn read_resource(
&mut self,
type_name: &str,
current_state: &DynamicValue,
) -> Result<Option<DynamicValue>, ProviderError>
pub async fn read_resource( &mut self, type_name: &str, current_state: &DynamicValue, ) -> Result<Option<DynamicValue>, ProviderError>
ReadResource — read the resource’s ACTUAL current state from the
provider (the refresh primitive). Returns Ok(None) when the provider
reports the resource no longer exists (new_state is cty-null), so
callers drop stale / phantom entries from state; Ok(Some(dv)) with
the refreshed wire state when it still exists.
Sourcepub async fn read_data_source(
&mut self,
type_name: &str,
config: &DynamicValue,
) -> Result<Option<DynamicValue>, ProviderError>
pub async fn read_data_source( &mut self, type_name: &str, config: &DynamicValue, ) -> Result<Option<DynamicValue>, ProviderError>
ReadDataSource — evaluate a data block by querying the provider,
returning its result state. The apply engine reads data sources up front
so ${data.<type>.<name>.<attr>} references resolve; without it those
strings leaked verbatim to managed-resource RPCs (the rio-drive
Cloudflare 400). Ok(None) if the provider returned cty-null.
Sourcepub async fn import_resource_state(
&mut self,
type_name: &str,
id: &str,
) -> Result<Option<DynamicValue>, ProviderError>
pub async fn import_resource_state( &mut self, type_name: &str, id: &str, ) -> Result<Option<DynamicValue>, ProviderError>
ImportResourceState — adopt a resource that EXISTS in the cloud but
is absent from magma’s state, by its provider-native import id (e.g.
the repo name for github_repository). Returns the imported wire state
(Ok(Some(dv))) or Ok(None) if the provider imported nothing /
returned cty-null. This is the read/import half of the protocol that
powers import-on-create-conflict (422 already-exists → observe → adopt)
magma import. Mirrors apply/read’s V5/V6 dispatch + msgpack decode.
Sourcepub async fn upgrade_resource_state(
&mut self,
type_name: &str,
stored_version: i64,
raw_json: &[u8],
) -> Result<DynamicValue, ProviderError>
pub async fn upgrade_resource_state( &mut self, type_name: &str, stored_version: i64, raw_json: &[u8], ) -> Result<DynamicValue, ProviderError>
UpgradeResourceState — migrate a StateInstance’s raw attribute
JSON (persisted under an older stored_version of the provider’s
schema for type_name) forward to the CURRENT schema. The
terraform plugin protocol requires this to run before a stored
instance is fed into ReadResource/PlanResourceChange/
ApplyResourceChange whenever stored_version is older than the
provider’s live ProviderSchema::resource_version — decoding
old-schema JSON straight against the new implied type (skipping
this call) risks a marshal mismatch or provider-side crash/misparse
on any resource type whose schema evolved. raw_json is the
instance’s raw attribute bytes as stored (magma persists state
attributes as JSON, never the legacy flatmap format, so only
RawState.json is populated). Returns the upgraded value, decodable
via DynamicValue::to_json against the CURRENT implied type.
Auto Trait Implementations§
impl !Freeze for ProviderConn
impl !RefUnwindSafe for ProviderConn
impl !UnwindSafe for ProviderConn
impl Send for ProviderConn
impl Sync for ProviderConn
impl Unpin for ProviderConn
impl UnsafeUnpin for ProviderConn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request