Introduce API Token Ephemeral Resource #996
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces our first Ephemeral Resource:
apstra_api_token
Broad changes
github.com/hashicorp/terraform-plugin-docs
dependency also needed to be upgraded to generate docs for Ephemeral Resources.go
needed to be updated ingo.mod
, I think because of tfplugindocs.The new Ephemeral Resource:
apstra_api_token
implements the following framework interfaces:ephemeral.EphemeralResource
ephemeral.EphemeralResourceWithClose
ephemeral.EphemeralResourceWithConfigure
ephemeral.EphemeralResourceWithRenew
In
Configure()
, we extract theapstra.Client
from provider data (no surprises here).In
Open()
, we create a client based on the one passed in by the provider, log it in, extract the required token info, and set theRenew()
time for shortly before the token expires.In
Renew()
, we can't actually freshen the token.Renew()
is a feature designed for "leased" credentials where the lease can be renewed without replacing the value. All we can do is raise warnings or errors. If the credential is not yet expired, we raise a warning and update the renew time. If it's expired, we raise an error.In
Close()
, we call the logout API unless the user asked us not to or the token is already expired.Odds and Ends
Bugfixes in
github.com/hashicorp/terraform-plugin-docs
cause several documentation pages to render differently even though the source data didn't change.