Skip to content

Commit 579f029

Browse files
fix(api): Fix update/read path parameter for zone subscription
1 parent 1e7a9c6 commit 579f029

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1769
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5e53659eea1b4f1fb11addaddb82880c177d8fa3e7a93f0d664a65e43ac526f4.yml
33
openapi_spec_hash: 3e0f59ac2722028954566a4c850e8849
4-
config_hash: fba73e92c75cff1909420025367fd0c0
4+
config_hash: 7d141842aab5959e694a41aa0025b663

internal/services/zone_subscription/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type ZoneSubscriptionResultEnvelope struct {
1313
}
1414

1515
type ZoneSubscriptionModel struct {
16-
ID types.String `tfsdk:"id" json:"id,computed"`
16+
ID types.String `tfsdk:"id" json:"-,computed"`
1717
ZoneID types.String `tfsdk:"zone_id" path:"zone_id,required"`
1818
Frequency types.String `tfsdk:"frequency" json:"frequency,optional"`
1919
RatePlan *ZoneSubscriptionRatePlanModel `tfsdk:"rate_plan" json:"rate_plan,optional"`

internal/services/zone_subscription/resource.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (r *ZoneSubscriptionResource) Create(ctx context.Context, req resource.Crea
9191
return
9292
}
9393
data = &env.Result
94+
data.ID = data.ZoneID
9495

9596
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
9697
}
@@ -122,7 +123,7 @@ func (r *ZoneSubscriptionResource) Update(ctx context.Context, req resource.Upda
122123
_, err = r.client.Zones.Subscriptions.Update(
123124
ctx,
124125
zones.SubscriptionUpdateParams{
125-
ZoneID: cloudflare.F(data.ID.ValueString()),
126+
ZoneID: cloudflare.F(data.ZoneID.ValueString()),
126127
},
127128
option.WithRequestBody("application/json", dataBytes),
128129
option.WithResponseBodyInto(&res),
@@ -139,6 +140,7 @@ func (r *ZoneSubscriptionResource) Update(ctx context.Context, req resource.Upda
139140
return
140141
}
141142
data = &env.Result
143+
data.ID = data.ZoneID
142144

143145
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
144146
}
@@ -157,7 +159,7 @@ func (r *ZoneSubscriptionResource) Read(ctx context.Context, req resource.ReadRe
157159
_, err := r.client.Zones.Subscriptions.Get(
158160
ctx,
159161
zones.SubscriptionGetParams{
160-
ZoneID: cloudflare.F(data.ID.ValueString()),
162+
ZoneID: cloudflare.F(data.ZoneID.ValueString()),
161163
},
162164
option.WithResponseBodyInto(&res),
163165
option.WithMiddleware(logging.Middleware(ctx)),
@@ -178,6 +180,7 @@ func (r *ZoneSubscriptionResource) Read(ctx context.Context, req resource.ReadRe
178180
return
179181
}
180182
data = &env.Result
183+
data.ID = data.ZoneID
181184

182185
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
183186
}
@@ -223,6 +226,7 @@ func (r *ZoneSubscriptionResource) ImportState(ctx context.Context, req resource
223226
return
224227
}
225228
data = &env.Result
229+
data.ID = data.ZoneID
226230

227231
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
228232
}

internal/services/zone_subscription/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ func ResourceSchema(ctx context.Context) schema.Schema {
2323
"id": schema.StringAttribute{
2424
Description: "Subscription identifier tag.",
2525
Computed: true,
26-
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
26+
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown(), stringplanmodifier.RequiresReplace()},
2727
},
2828
"zone_id": schema.StringAttribute{
2929
Description: "Subscription identifier tag.",
3030
Required: true,
31-
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
31+
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown(), stringplanmodifier.RequiresReplace()},
3232
},
3333
"frequency": schema.StringAttribute{
3434
Description: "How often the subscription is renewed automatically.\nAvailable values: \"weekly\", \"monthly\", \"quarterly\", \"yearly\".",

0 commit comments

Comments
 (0)