-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Adjusts search_deployment schema definitions with structure…
… of new schema scaffolding command (#1830) * refactor: Adjusts search_deployment schema definitions with structure of new schema scaffolding command * adding final new line in generator_config.yml Co-authored-by: Andrea Angiolillo <[email protected]> --------- Co-authored-by: Andrea Angiolillo <[email protected]>
- Loading branch information
1 parent
d1fba18
commit d8eee33
Showing
5 changed files
with
183 additions
and
113 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
62 changes: 62 additions & 0 deletions
62
internal/service/searchdeployment/data_source_search_deployment_schema.go
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,62 @@ | ||
package searchdeployment | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
func DataSourceSchema(ctx context.Context) schema.Schema { | ||
return schema.Schema{ | ||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Computed: true, | ||
Description: "Unique 24-hexadecimal digit string that identifies the search deployment.", | ||
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the search deployment.", | ||
}, | ||
"cluster_name": schema.StringAttribute{ | ||
Required: true, | ||
Description: "Label that identifies the cluster to return the search nodes for.", | ||
MarkdownDescription: "Label that identifies the cluster to return the search nodes for.", | ||
}, | ||
"project_id": schema.StringAttribute{ | ||
Required: true, | ||
Description: "Unique 24-hexadecimal digit string that identifies your project.", | ||
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project.", | ||
}, | ||
"specs": schema.ListNestedAttribute{ | ||
Computed: true, | ||
NestedObject: schema.NestedAttributeObject{ | ||
Attributes: map[string]schema.Attribute{ | ||
"instance_size": schema.StringAttribute{ | ||
Computed: true, | ||
Description: "Hardware specification for the search node instance sizes.", | ||
MarkdownDescription: "Hardware specification for the search node instance sizes.", | ||
}, | ||
"node_count": schema.Int64Attribute{ | ||
Computed: true, | ||
Description: "Number of search nodes in the cluster.", | ||
MarkdownDescription: "Number of search nodes in the cluster.", | ||
}, | ||
}, | ||
}, | ||
Description: "List of settings that configure the search nodes for your cluster.", | ||
MarkdownDescription: "List of settings that configure the search nodes for your cluster.", | ||
}, | ||
"state_name": schema.StringAttribute{ | ||
Computed: true, | ||
Description: "Human-readable label that indicates the current operating condition of this search deployment.", | ||
MarkdownDescription: "Human-readable label that indicates the current operating condition of this search deployment.", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
type TFSearchDeploymentDSModel struct { | ||
ID types.String `tfsdk:"id"` | ||
ClusterName types.String `tfsdk:"cluster_name"` | ||
ProjectID types.String `tfsdk:"project_id"` | ||
Specs types.List `tfsdk:"specs"` | ||
StateName types.String `tfsdk:"state_name"` | ||
} |
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
94 changes: 94 additions & 0 deletions
94
internal/service/searchdeployment/resource_search_deployment_schema.go
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,94 @@ | ||
package searchdeployment | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" | ||
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator" | ||
"github.com/hashicorp/terraform-plugin-framework/attr" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" | ||
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" | ||
"github.com/hashicorp/terraform-plugin-framework/schema/validator" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
func ResourceSchema(ctx context.Context) schema.Schema { | ||
return schema.Schema{ | ||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.StringAttribute{ | ||
Computed: true, | ||
Description: "Unique 24-hexadecimal digit string that identifies the search deployment.", | ||
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the search deployment.", | ||
}, | ||
"cluster_name": schema.StringAttribute{ | ||
Required: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), | ||
}, | ||
Description: "Label that identifies the cluster to return the search nodes for.", | ||
MarkdownDescription: "Label that identifies the cluster to return the search nodes for.", | ||
}, | ||
"project_id": schema.StringAttribute{ | ||
Required: true, | ||
PlanModifiers: []planmodifier.String{ | ||
stringplanmodifier.RequiresReplace(), | ||
}, | ||
Description: "Unique 24-hexadecimal character string that identifies the project.", | ||
MarkdownDescription: "Unique 24-hexadecimal character string that identifies the project.", | ||
}, | ||
"specs": schema.ListNestedAttribute{ | ||
Validators: []validator.List{ | ||
listvalidator.SizeAtMost(1), | ||
listvalidator.SizeAtLeast(1), | ||
}, | ||
Required: true, | ||
NestedObject: schema.NestedAttributeObject{ | ||
Attributes: map[string]schema.Attribute{ | ||
"instance_size": schema.StringAttribute{ | ||
Required: true, | ||
Description: "Hardware specification for the search node instance sizes.", | ||
MarkdownDescription: "Hardware specification for the search node instance sizes.", | ||
}, | ||
"node_count": schema.Int64Attribute{ | ||
Required: true, | ||
Description: "Number of search nodes in the cluster.", | ||
MarkdownDescription: "Number of search nodes in the cluster.", | ||
}, | ||
}, | ||
}, | ||
Description: "List of settings that configure the search nodes for your cluster.", | ||
MarkdownDescription: "List of settings that configure the search nodes for your cluster.", | ||
}, | ||
"state_name": schema.StringAttribute{ | ||
Computed: true, | ||
Description: "Human-readable label that indicates the current operating condition of this search deployment.", | ||
MarkdownDescription: "Human-readable label that indicates the current operating condition of this search deployment.", | ||
}, | ||
"timeouts": timeouts.Attributes(ctx, timeouts.Opts{ | ||
Create: true, | ||
Update: true, | ||
Delete: true, | ||
}), | ||
}, | ||
} | ||
} | ||
|
||
type TFSearchDeploymentRSModel struct { | ||
ID types.String `tfsdk:"id"` | ||
ClusterName types.String `tfsdk:"cluster_name"` | ||
ProjectID types.String `tfsdk:"project_id"` | ||
Specs types.List `tfsdk:"specs"` | ||
StateName types.String `tfsdk:"state_name"` | ||
Timeouts timeouts.Value `tfsdk:"timeouts"` | ||
} | ||
|
||
type TFSearchNodeSpecModel struct { | ||
InstanceSize types.String `tfsdk:"instance_size"` | ||
NodeCount types.Int64 `tfsdk:"node_count"` | ||
} | ||
|
||
var SpecObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{ | ||
"instance_size": types.StringType, | ||
"node_count": types.Int64Type, | ||
}} |
22 changes: 22 additions & 0 deletions
22
internal/service/searchdeployment/tfplugingen/generator_config.yml
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,22 @@ | ||
provider: | ||
name: mongodbatlas | ||
|
||
resources: | ||
search_deployment: | ||
read: | ||
path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment | ||
method: GET | ||
create: | ||
path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment | ||
method: POST | ||
schema: | ||
ignores: [] | ||
|
||
|
||
data_sources: | ||
search_deployment: | ||
read: | ||
path: /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/search/deployment | ||
method: GET | ||
schema: | ||
ignores: [] |