-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce
apstra_blueprint_anomalies
, deprecate apstra_anomalies
…
…data sources
- Loading branch information
1 parent
a3fa950
commit b0fb79b
Showing
5 changed files
with
881 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package tfapstra | ||
|
||
import ( | ||
"context" | ||
"github.com/Juniper/apstra-go-sdk/apstra" | ||
"github.com/Juniper/terraform-provider-apstra/apstra/blueprint" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
_ "github.com/hashicorp/terraform-plugin-framework/provider" | ||
) | ||
|
||
var _ datasource.DataSourceWithConfigure = &dataSourceAnomalies{} | ||
var _ datasourceWithSetClient = &dataSourceAnomalies{} | ||
|
||
type dataSourceBlueprintAnomalies struct { | ||
client *apstra.Client | ||
} | ||
|
||
func (o *dataSourceBlueprintAnomalies) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { | ||
resp.TypeName = req.ProviderTypeName + "_blueprint_anomalies" | ||
} | ||
|
||
func (o *dataSourceBlueprintAnomalies) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { | ||
configureDataSource(ctx, o, req, resp) | ||
} | ||
|
||
func (o *dataSourceBlueprintAnomalies) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { | ||
resp.Schema = schema.Schema{ | ||
MarkdownDescription: docCategoryRefDesignAny + "This data source provides per-node summary, " + | ||
"per-service summary and full details of anomalies in the specified Blueprint.", | ||
Attributes: blueprint.Anomalies{}.DataSourceAttributes(), | ||
} | ||
} | ||
|
||
func (o *dataSourceBlueprintAnomalies) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { | ||
var config blueprint.Anomalies | ||
resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
config.ReadFromApi(ctx, o.client, &resp.Diagnostics) | ||
|
||
// set state | ||
resp.Diagnostics.Append(resp.State.Set(ctx, &config)...) | ||
} | ||
|
||
func (o *dataSourceBlueprintAnomalies) setClient(client *apstra.Client) { | ||
o.client = client | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.