-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathdata_source.go
More file actions
executable file
·66 lines (57 loc) · 1.97 KB
/
Copy pathdata_source.go
File metadata and controls
executable file
·66 lines (57 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Code generated by terraform-provider-mongodbatlas using `make generate-resource`. DO NOT EDIT.
package mcpconfigsecret
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/autogen"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
)
var _ datasource.DataSource = &ds{}
var _ datasource.DataSourceWithConfigure = &ds{}
func DataSource() datasource.DataSource {
return &ds{
DSCommon: config.DSCommon{
DataSourceName: "mcp_config_secret",
},
}
}
type ds struct {
config.DSCommon
}
func (d *ds) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = DataSourceSchema(ctx)
if schemaHook, ok := any(d).(autogen.DataSourceSchemaHook); ok {
resp.Schema = schemaHook.DataSourceSchema(ctx, resp.Schema)
}
conversion.UpdateSchemaDescription(&resp.Schema)
}
func (d *ds) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var tfConfig TFDSModel
resp.Diagnostics.Append(req.Config.Get(ctx, &tfConfig)...)
if resp.Diagnostics.HasError() {
return
}
reqHandle := autogen.HandleReadReq{
Hooks: d,
RespDiags: &resp.Diagnostics,
RespState: &resp.State,
Client: d.Client,
State: &tfConfig,
CallParams: dataSourceReadAPICallParams(&tfConfig),
}
autogen.HandleDataSourceRead(ctx, reqHandle)
}
func dataSourceReadAPICallParams(model *TFDSModel) *config.APICallParams {
pathParams := map[string]string{
"orgId": model.OrgId.ValueString(),
"mcpConfigId": model.McpConfigId.ValueString(),
"secretId": model.SecretId.ValueString(),
}
return &config.APICallParams{
VersionHeader: "application/vnd.atlas.2025-03-12+json",
RelativePath: "/api/atlas/v2/orgs/{orgId}/mcpConfigs/{mcpConfigId}/secrets/{secretId}",
PathParams: pathParams,
Method: "GET",
}
}