Skip to content

Commit 11ba7e0

Browse files
committed
feat(tem): add data source for offer subscription
1 parent 82371b2 commit 11ba7e0

File tree

4 files changed

+296
-4
lines changed

4 files changed

+296
-4
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
subcategory: "Transactional Email"
3+
page_title: "Scaleway: scaleway_tem_offer_subscription"
4+
---
5+
6+
# scaleway_tem_offer_subscription
7+
8+
Gets information about a transactional email offer subscription.
9+
10+
## Example Usage
11+
12+
```hcl
13+
// Retrieve offer subscription information
14+
data "scaleway_tem_offer_subscription" "test" {}
15+
```
16+
17+
## Argument Reference
18+
19+
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions) where the offer subscription exists.
20+
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the offer subscription is associated with.
21+
22+
## Attributes Reference
23+
24+
The following attributes are exported:
25+
26+
- `offer_name` - The name of the offer associated with the subscription (e.g., `scale`).
27+
- `subscribed_at` - The date and time of the subscription.
28+
- `cancellation_available_at` - The date and time when cancellation becomes available for the subscription.
29+
- `sla` - The Service Level Agreement (SLA) percentage of the offer subscription.
30+
- `max_domains` - The maximum number of domains that can be associated with the offer subscription.
31+
- `max_dedicated_ips` - The maximum number of dedicated IPs that can be associated with the offer subscription.
32+
- `max_webhooks_per_domain` - The maximum number of webhooks that can be associated with the offer subscription per domain.
33+
- `max_custom_blocklists_per_domain` - The maximum number of custom blocklists that can be associated with the offer subscription per domain.
34+
- `included_monthly_emails` - The number of emails included in the offer subscription per month.
35+
36+
## Import
37+
38+
This data source is read-only and cannot be imported.
39+

internal/services/tem/offer_subscription_data_source.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ func DataSourceOfferSubscription() *schema.Resource {
1919
Schema: map[string]*schema.Schema{
2020
"region": regional.Schema(),
2121
"project_id": account.ProjectIDSchema(),
22+
"offer_name": {
23+
Type: schema.TypeString,
24+
Computed: true,
25+
Description: "Name of the offer",
26+
},
2227
"subscribed_at": {
2328
Type: schema.TypeString,
2429
Computed: true,
@@ -64,11 +69,11 @@ func DataSourceOfferSubscription() *schema.Resource {
6469
}
6570

6671
func DataSourceOfferSubscriptionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
67-
api, region, projectID, err := NewAPIWithRegionAndID(m, d.Get("project_id").(string))
72+
api, region, err := temAPIWithRegion(d, m)
6873
if err != nil {
6974
return diag.FromErr(err)
7075
}
71-
76+
projectID := d.Get("project_id").(string)
7277
offer, err := api.ListOfferSubscriptions(&tem.ListOfferSubscriptionsRequest{
7378
Region: region,
7479
ProjectID: projectID,
@@ -93,6 +98,7 @@ func DataSourceOfferSubscriptionRead(ctx context.Context, d *schema.ResourceData
9398
d.SetId(regional.NewIDString(region, offerSubscription.ProjectID))
9499
_ = d.Set("project_id", offerSubscription.ProjectID)
95100
_ = d.Set("region", region)
101+
_ = d.Set("offer_name", offerSubscription.OfferName)
96102
_ = d.Set("subscribed_at", offerSubscription.SubscribedAt.Format(time.RFC3339))
97103
_ = d.Set("cancellation_available_at", offerSubscription.CancellationAvailableAt.Format(time.RFC3339))
98104
_ = d.Set("sla", offerSubscription.SLA)

internal/services/tem/offer_subscription_data_source_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ func TestAccDataSourceOfferSubscription_Basic(t *testing.T) {
1818
{
1919
Config: `
2020
data "scaleway_tem_offer_subscription" "test" {
21-
project_id = "your_project_id"
2221
}
2322
`,
2423
Check: resource.ComposeTestCheckFunc(
2524
resource.TestCheckResourceAttrSet("data.scaleway_tem_offer_subscription.test", "project_id"),
26-
resource.TestCheckResourceAttr("data.scaleway_tem_offer_subscription.test", "name", "scale"),
25+
resource.TestCheckResourceAttr("data.scaleway_tem_offer_subscription.test", "offer_name", "scale"),
2726
),
2827
},
2928
},
Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
---
2+
version: 2
3+
interactions:
4+
- id: 0
5+
request:
6+
proto: HTTP/1.1
7+
proto_major: 1
8+
proto_minor: 1
9+
content_length: 0
10+
transfer_encoding: []
11+
trailer: {}
12+
host: api.scaleway.com
13+
remote_addr: ""
14+
request_uri: ""
15+
body: ""
16+
form: {}
17+
headers:
18+
User-Agent:
19+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
20+
url: https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/offer-subscriptions?project_id=105bdce1-64c0-48ab-899d-868455867ecf
21+
method: GET
22+
response:
23+
proto: HTTP/2.0
24+
proto_major: 2
25+
proto_minor: 0
26+
transfer_encoding: []
27+
trailer: {}
28+
content_length: 427
29+
uncompressed: false
30+
body: '{"offer_subscriptions":[{"cancellation_available_at":"2025-03-14T16:16:43.798008Z","included_monthly_emails":100000,"max_custom_blocklists_per_domain":-1,"max_dedicated_ips":1,"max_domains":-1,"max_webhooks_per_domain":-1,"offer_name":"scale","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","sla":99.9,"subscribed_at":"2025-03-14T15:56:47.106678Z"}],"total_count":1}'
31+
headers:
32+
Content-Length:
33+
- "427"
34+
Content-Security-Policy:
35+
- default-src 'none'; frame-ancestors 'none'
36+
Content-Type:
37+
- application/json
38+
Date:
39+
- Wed, 19 Mar 2025 13:40:06 GMT
40+
Server:
41+
- Scaleway API Gateway (fr-par-1;edge03)
42+
Strict-Transport-Security:
43+
- max-age=63072000
44+
X-Content-Type-Options:
45+
- nosniff
46+
X-Frame-Options:
47+
- DENY
48+
X-Request-Id:
49+
- b0c7918e-02a5-4f9f-905a-a01c5b92f624
50+
status: 200 OK
51+
code: 200
52+
duration: 234.755583ms
53+
- id: 1
54+
request:
55+
proto: HTTP/1.1
56+
proto_major: 1
57+
proto_minor: 1
58+
content_length: 0
59+
transfer_encoding: []
60+
trailer: {}
61+
host: api.scaleway.com
62+
remote_addr: ""
63+
request_uri: ""
64+
body: ""
65+
form: {}
66+
headers:
67+
User-Agent:
68+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
69+
url: https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/offer-subscriptions?project_id=105bdce1-64c0-48ab-899d-868455867ecf
70+
method: GET
71+
response:
72+
proto: HTTP/2.0
73+
proto_major: 2
74+
proto_minor: 0
75+
transfer_encoding: []
76+
trailer: {}
77+
content_length: 427
78+
uncompressed: false
79+
body: '{"offer_subscriptions":[{"cancellation_available_at":"2025-03-14T16:16:43.798008Z","included_monthly_emails":100000,"max_custom_blocklists_per_domain":-1,"max_dedicated_ips":1,"max_domains":-1,"max_webhooks_per_domain":-1,"offer_name":"scale","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","sla":99.9,"subscribed_at":"2025-03-14T15:56:47.106678Z"}],"total_count":1}'
80+
headers:
81+
Content-Length:
82+
- "427"
83+
Content-Security-Policy:
84+
- default-src 'none'; frame-ancestors 'none'
85+
Content-Type:
86+
- application/json
87+
Date:
88+
- Wed, 19 Mar 2025 13:40:06 GMT
89+
Server:
90+
- Scaleway API Gateway (fr-par-1;edge03)
91+
Strict-Transport-Security:
92+
- max-age=63072000
93+
X-Content-Type-Options:
94+
- nosniff
95+
X-Frame-Options:
96+
- DENY
97+
X-Request-Id:
98+
- 0f2c6a0a-b815-4972-b365-5154f7d2ba43
99+
status: 200 OK
100+
code: 200
101+
duration: 99.037667ms
102+
- id: 2
103+
request:
104+
proto: HTTP/1.1
105+
proto_major: 1
106+
proto_minor: 1
107+
content_length: 0
108+
transfer_encoding: []
109+
trailer: {}
110+
host: api.scaleway.com
111+
remote_addr: ""
112+
request_uri: ""
113+
body: ""
114+
form: {}
115+
headers:
116+
User-Agent:
117+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
118+
url: https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/offer-subscriptions?project_id=105bdce1-64c0-48ab-899d-868455867ecf
119+
method: GET
120+
response:
121+
proto: HTTP/2.0
122+
proto_major: 2
123+
proto_minor: 0
124+
transfer_encoding: []
125+
trailer: {}
126+
content_length: 427
127+
uncompressed: false
128+
body: '{"offer_subscriptions":[{"cancellation_available_at":"2025-03-14T16:16:43.798008Z","included_monthly_emails":100000,"max_custom_blocklists_per_domain":-1,"max_dedicated_ips":1,"max_domains":-1,"max_webhooks_per_domain":-1,"offer_name":"scale","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","sla":99.9,"subscribed_at":"2025-03-14T15:56:47.106678Z"}],"total_count":1}'
129+
headers:
130+
Content-Length:
131+
- "427"
132+
Content-Security-Policy:
133+
- default-src 'none'; frame-ancestors 'none'
134+
Content-Type:
135+
- application/json
136+
Date:
137+
- Wed, 19 Mar 2025 13:40:07 GMT
138+
Server:
139+
- Scaleway API Gateway (fr-par-1;edge03)
140+
Strict-Transport-Security:
141+
- max-age=63072000
142+
X-Content-Type-Options:
143+
- nosniff
144+
X-Frame-Options:
145+
- DENY
146+
X-Request-Id:
147+
- 6843e933-61e4-4fdd-9f08-5120a097b50b
148+
status: 200 OK
149+
code: 200
150+
duration: 27.722709ms
151+
- id: 3
152+
request:
153+
proto: HTTP/1.1
154+
proto_major: 1
155+
proto_minor: 1
156+
content_length: 0
157+
transfer_encoding: []
158+
trailer: {}
159+
host: api.scaleway.com
160+
remote_addr: ""
161+
request_uri: ""
162+
body: ""
163+
form: {}
164+
headers:
165+
User-Agent:
166+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
167+
url: https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/offer-subscriptions?project_id=105bdce1-64c0-48ab-899d-868455867ecf
168+
method: GET
169+
response:
170+
proto: HTTP/2.0
171+
proto_major: 2
172+
proto_minor: 0
173+
transfer_encoding: []
174+
trailer: {}
175+
content_length: 427
176+
uncompressed: false
177+
body: '{"offer_subscriptions":[{"cancellation_available_at":"2025-03-14T16:16:43.798008Z","included_monthly_emails":100000,"max_custom_blocklists_per_domain":-1,"max_dedicated_ips":1,"max_domains":-1,"max_webhooks_per_domain":-1,"offer_name":"scale","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","sla":99.9,"subscribed_at":"2025-03-14T15:56:47.106678Z"}],"total_count":1}'
178+
headers:
179+
Content-Length:
180+
- "427"
181+
Content-Security-Policy:
182+
- default-src 'none'; frame-ancestors 'none'
183+
Content-Type:
184+
- application/json
185+
Date:
186+
- Wed, 19 Mar 2025 13:40:08 GMT
187+
Server:
188+
- Scaleway API Gateway (fr-par-1;edge03)
189+
Strict-Transport-Security:
190+
- max-age=63072000
191+
X-Content-Type-Options:
192+
- nosniff
193+
X-Frame-Options:
194+
- DENY
195+
X-Request-Id:
196+
- 78842bd8-b003-486a-8655-34c29120ba90
197+
status: 200 OK
198+
code: 200
199+
duration: 87.182625ms
200+
- id: 4
201+
request:
202+
proto: HTTP/1.1
203+
proto_major: 1
204+
proto_minor: 1
205+
content_length: 0
206+
transfer_encoding: []
207+
trailer: {}
208+
host: api.scaleway.com
209+
remote_addr: ""
210+
request_uri: ""
211+
body: ""
212+
form: {}
213+
headers:
214+
User-Agent:
215+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.24.0; darwin; arm64) terraform-provider/develop terraform/terraform-tests
216+
url: https://api.scaleway.com/transactional-email/v1alpha1/regions/fr-par/offer-subscriptions?project_id=105bdce1-64c0-48ab-899d-868455867ecf
217+
method: GET
218+
response:
219+
proto: HTTP/2.0
220+
proto_major: 2
221+
proto_minor: 0
222+
transfer_encoding: []
223+
trailer: {}
224+
content_length: 427
225+
uncompressed: false
226+
body: '{"offer_subscriptions":[{"cancellation_available_at":"2025-03-14T16:16:43.798008Z","included_monthly_emails":100000,"max_custom_blocklists_per_domain":-1,"max_dedicated_ips":1,"max_domains":-1,"max_webhooks_per_domain":-1,"offer_name":"scale","organization_id":"105bdce1-64c0-48ab-899d-868455867ecf","project_id":"105bdce1-64c0-48ab-899d-868455867ecf","sla":99.9,"subscribed_at":"2025-03-14T15:56:47.106678Z"}],"total_count":1}'
227+
headers:
228+
Content-Length:
229+
- "427"
230+
Content-Security-Policy:
231+
- default-src 'none'; frame-ancestors 'none'
232+
Content-Type:
233+
- application/json
234+
Date:
235+
- Wed, 19 Mar 2025 13:40:08 GMT
236+
Server:
237+
- Scaleway API Gateway (fr-par-1;edge03)
238+
Strict-Transport-Security:
239+
- max-age=63072000
240+
X-Content-Type-Options:
241+
- nosniff
242+
X-Frame-Options:
243+
- DENY
244+
X-Request-Id:
245+
- 8adadd68-6981-453a-94b2-7a30b04bfa46
246+
status: 200 OK
247+
code: 200
248+
duration: 72.693208ms

0 commit comments

Comments
 (0)