Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(datasource/cloudsigma_subscription): migrate subscription data source to framework #85

Merged
merged 2 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 0 additions & 105 deletions cloudsigma/data_source_cloudsigma_common_schema.go

This file was deleted.

114 changes: 0 additions & 114 deletions cloudsigma/data_source_cloudsigma_subscription.go

This file was deleted.

4 changes: 1 addition & 3 deletions cloudsigma/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ func Provider() *schema.Provider {
},
},

DataSourcesMap: map[string]*schema.Resource{
"cloudsigma_subscription": dataSourceCloudSigmaSubscription(),
},
DataSourcesMap: map[string]*schema.Resource{},

ResourcesMap: map[string]*schema.Resource{
"cloudsigma_drive": resourceCloudSigmaDrive(),
Expand Down
50 changes: 36 additions & 14 deletions docs/data-sources/subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,61 @@
page_title: "cloudsigma_subscription Data Source - terraform-provider-cloudsigma"
subcategory: ""
description: |-
The subscription data source provides information about an existing CloudSigma subscriptions.
The subscription data source provides information about an existing CloudSigma subscription.
---

# cloudsigma_subscription (Data Source)

The subscription data source provides information about an existing CloudSigma subscriptions.
The subscription data source provides information about an existing CloudSigma subscription.


## Example Usage

### Default

```terraform
data "cloudsigma_subscription" "static_ip" {
uuid = "35a1d3bb-2fed-4e92-918a-eaf1f6bf3a41"
}
```

### Using deprecated filter block

```terraform
data "cloudsigma_subscription" "static_ip" {
filter {
name = "uuid"
values = ["35a1d3bb-2fed-4e92-918a-eaf1f6bf3a41"]
}
}
```


<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `filter` (Block Set) One or more name/value pairs to filter off of. (see [below for nested schema](#nestedblock--filter))
- `filter` (Block Set, Deprecated) One or more name/value pairs to filter off of. (see [below for nested schema](#nestedblock--filter))
- `uuid` (String) The unique universal identifier of the current subscription.

### Read-Only

- `amount` (String)
- `auto_renew` (Boolean)
- `free_tier` (Boolean)
- `id` (String) The ID of this resource.
- `period` (String)
- `price` (String)
- `remaining` (String)
- `resource` (String)
- `resource_uri` (String)
- `status` (String)
- `amount` (String) The amount of the subscription.
- `auto_renew` (Boolean) `true`, if the subscription will auto renew on expire, otherwise `false`.
- `free_tier` (Boolean) `true`, if the subscription is in free tier, otherwise `false`.
- `id` (String) The ID of the subscription.
- `period` (String) The duration of the subscription.
- `price` (String) The price of the subscription.
- `remaining` (String) The amount remaining.
- `resource` (String) The name of resource associated with the subscription.
- `resource_uri` (String) The unique resource identifier of the subscription.
- `status` (String) The status of the subscription.

<a id="nestedblock--filter"></a>
### Nested Schema for `filter`

Required:
Optional:

- `name` (String) The name of the attribute to filter.
- `values` (List of String) The value of the attribute to filter.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "cloudsigma_subscription" "static_ip" {
uuid = "35a1d3bb-2fed-4e92-918a-eaf1f6bf3a41"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
data "cloudsigma_subscription" "static_ip" {
filter {
name = "uuid"
values = ["35a1d3bb-2fed-4e92-918a-eaf1f6bf3a41"]
}
}
6 changes: 3 additions & 3 deletions internal/provider/data_source_cloudsigma_license.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (d *licenseDataSource) Read(ctx context.Context, request datasource.ReadReq
}
tflog.Trace(ctx, "Got licenses", map[string]interface{}{"data": licenses})

licensesFound := false
licenseFound := false
for _, license := range licenses {
if licenseName == license.Name {
data.Burstable = types.BoolValue(license.Burstable)
Expand All @@ -207,12 +207,12 @@ func (d *licenseDataSource) Read(ctx context.Context, request datasource.ReadReq
data.UserMetric = types.StringValue(license.UserMetric)
data.UUID = types.StringValue(license.Name)

licensesFound = true
licenseFound = true
break
}
}

if !licensesFound {
if !licenseFound {
response.Diagnostics.AddError("No search results", "Please refine your search.")
return
}
Expand Down
Loading