Skip to content

Commit b47cd8f

Browse files
authored
Merge pull request #889 from ovh/dev/aamstutz/add-pcc-datasource
feat: Add datasource ovh_dedicated_cloud
2 parents 9c34945 + b66dfcf commit b47cd8f

File tree

8 files changed

+1059
-5
lines changed

8 files changed

+1059
-5
lines changed

docs/data-sources/dedicated_cloud.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
subcategory: "Hosted Private Cloud (Managed VMWare)"
3+
---
4+
5+
# ovh_dedicated_cloud (Data Source)
6+
7+
Get information about a Managed VMware service.
8+
9+
## Example Usage
10+
11+
```terraform
12+
data "ovh_dedicated_cloud" "pcc" {
13+
service_name = "<Dedicated Cloud service name>"
14+
}
15+
```
16+
17+
<!-- schema generated by tfplugindocs -->
18+
## Schema
19+
20+
### Required
21+
22+
- `service_name` (String) Domain of the service
23+
24+
### Read-Only
25+
26+
- `advanced_security` (Boolean) Advanced security state
27+
- `bandwidth` (String) The current bandwidth of your VMware on OVHcloud
28+
- `billing_type` (String) Billing type of your VMware on OVHcloud
29+
- `can_migrate_to_vcd` (Boolean) Can the PCC be migrated to VCD
30+
- `certified_interface_url` (String) Url to the VMware on OVHcloud certified interface
31+
- `commercial_range` (String) The current version of your VMware on OVHcloud
32+
- `description` (String) Description of your VMware on OVHcloud
33+
- `generation` (String) Generation of your VMware on OVHcloud
34+
- `iam` (Attributes) IAM resource metadata (see [below for nested schema](#nestedatt--iam))
35+
- `location` (String) Datacenter where your VMware on OVHcloud is physically located
36+
- `management_interface` (String) The management interface name
37+
- `product_reference` (String) The reference universe information for your VMware on OVHcloud
38+
- `service_pack_name` (String) Name of the current service pack
39+
- `spla` (Boolean) SPLA licensing state
40+
- `ssl_v3` (Boolean) Enable SSL v3 support. Warning : this option is not recommended as it was recognized as a security breach. If this is enabled, we advise you to enable the filtered User access policy
41+
- `state` (String) Current state of your VMware on OVHcloud
42+
- `user_access_policy` (String) Access policy of your VMware on OVHcloud : opened to every IPs or filtered
43+
- `user_limit_concurrent_session` (Number) The maximum amount of connected users allowed on the VMware on OVHcloud management interface
44+
- `user_logout_policy` (String) Which user will be disconnected first in case of quota of maximum connection is reached
45+
- `user_session_timeout` (Number) The timeout (in seconds) for the user sessions on the VMware on OVHcloud management interface. 0 value disable the timeout
46+
- `v_scope_url` (String) Url to the VMware on OVHcloud vScope interface
47+
- `version` (Attributes) Version of the management interface (see [below for nested schema](#nestedatt--version))
48+
- `web_interface_url` (String) Url to the VMware on OVHcloud web interface
49+
50+
<a id="nestedatt--iam"></a>
51+
### Nested Schema for `iam`
52+
53+
Read-Only:
54+
55+
- `display_name` (String) Resource display name
56+
- `id` (String) Unique identifier of the resource
57+
- `tags` (Map of String) Resource tags. Tags that were internally computed are prefixed with ovh:
58+
- `urn` (String) Unique resource name used in policies
59+
60+
61+
<a id="nestedatt--version"></a>
62+
### Nested Schema for `version`
63+
64+
Read-Only:
65+
66+
- `build` (String)
67+
- `major` (String)
68+
- `minor` (String)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data "ovh_dedicated_cloud" "pcc" {
2+
service_name = "<Dedicated Cloud service name>"
3+
}

ovh/data_dedicated_cloud.go

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package ovh
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/url"
7+
8+
"github.com/hashicorp/terraform-plugin-framework/datasource"
9+
)
10+
11+
var _ datasource.DataSourceWithConfigure = (*dedicatedCloudDataSource)(nil)
12+
13+
func NewDedicatedCloudDataSource() datasource.DataSource {
14+
return &dedicatedCloudDataSource{}
15+
}
16+
17+
type dedicatedCloudDataSource struct {
18+
config *Config
19+
}
20+
21+
func (d *dedicatedCloudDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
22+
resp.TypeName = req.ProviderTypeName + "_dedicated_cloud"
23+
}
24+
25+
func (d *dedicatedCloudDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
26+
if req.ProviderData == nil {
27+
return
28+
}
29+
30+
config, ok := req.ProviderData.(*Config)
31+
if !ok {
32+
resp.Diagnostics.AddError(
33+
"Unexpected Data Source Configure Type",
34+
fmt.Sprintf("Expected *Config, got: %T. Please report this issue to the provider developers.", req.ProviderData),
35+
)
36+
return
37+
}
38+
39+
d.config = config
40+
}
41+
42+
func (d *dedicatedCloudDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
43+
resp.Schema = DedicatedCloudDataSourceSchema(ctx)
44+
}
45+
46+
func (d *dedicatedCloudDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
47+
var data DedicatedCloudModel
48+
49+
// Read Terraform configuration data into the model
50+
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
51+
52+
if resp.Diagnostics.HasError() {
53+
return
54+
}
55+
56+
// Read API call logic
57+
endpoint := "/dedicatedCloud/" + url.PathEscape(data.ServiceName.ValueString())
58+
59+
if err := d.config.OVHClient.Get(endpoint, &data); err != nil {
60+
resp.Diagnostics.AddError(
61+
fmt.Sprintf("Error calling Get %s", endpoint),
62+
err.Error(),
63+
)
64+
return
65+
}
66+
67+
// Save data into Terraform state
68+
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
69+
}

0 commit comments

Comments
 (0)