Skip to content

Commit 8a030f5

Browse files
feat(api): api update
1 parent 6326bb6 commit 8a030f5

File tree

16 files changed

+122
-73
lines changed

16 files changed

+122
-73
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1781
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3ec774bdf5de1d462e90eef2ae707df91819ae8426bbd28e1968eae25f86b0a4.yml
3-
openapi_spec_hash: 494018bf95f397e1cdd863dd5c5a33a9
4-
config_hash: 11218d4e895d6852fa70acc77ad5da3d
1+
configured_endpoints: 1790
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-405704dec8d5041847ab820752a75813fe0e8ceabb72f42ba840ced58c0f8643.yml
3+
openapi_spec_hash: 56d7b6b4cd0ca89589c3e6fa53b28225
4+
config_hash: 320699f1f989d92845c2558a970acd18

internal/services/argo_smart_routing/data_source_model.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/cloudflare/cloudflare-go/v5"
99
"github.com/cloudflare/cloudflare-go/v5/argo"
10+
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
1011
"github.com/hashicorp/terraform-plugin-framework/diag"
1112
"github.com/hashicorp/terraform-plugin-framework/types"
1213
)
@@ -16,7 +17,11 @@ type ArgoSmartRoutingResultDataSourceEnvelope struct {
1617
}
1718

1819
type ArgoSmartRoutingDataSourceModel struct {
19-
ZoneID types.String `tfsdk:"zone_id" path:"zone_id,required"`
20+
ZoneID types.String `tfsdk:"zone_id" path:"zone_id,required"`
21+
Editable types.Bool `tfsdk:"editable" json:"editable,computed"`
22+
ID types.String `tfsdk:"id" json:"id,computed"`
23+
ModifiedOn timetypes.RFC3339 `tfsdk:"modified_on" json:"modified_on,computed" format:"date-time"`
24+
Value types.String `tfsdk:"value" json:"value,computed"`
2025
}
2126

2227
func (m *ArgoSmartRoutingDataSourceModel) toReadParams(_ context.Context) (params argo.SmartRoutingGetParams, diags diag.Diagnostics) {

internal/services/argo_smart_routing/data_source_schema.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ package argo_smart_routing
55
import (
66
"context"
77

8+
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
9+
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
810
"github.com/hashicorp/terraform-plugin-framework/datasource"
911
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
12+
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
1013
)
1114

1215
var _ datasource.DataSourceWithConfigValidators = (*ArgoSmartRoutingDataSource)(nil)
@@ -18,6 +21,26 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
1821
Description: "Specifies the zone associated with the API call.",
1922
Required: true,
2023
},
24+
"editable": schema.BoolAttribute{
25+
Description: "Specifies if the setting is editable.",
26+
Computed: true,
27+
},
28+
"id": schema.StringAttribute{
29+
Description: "Specifies the identifier of the Argo Smart Routing setting.",
30+
Computed: true,
31+
},
32+
"modified_on": schema.StringAttribute{
33+
Description: "Specifies the time when the setting was last modified.",
34+
Computed: true,
35+
CustomType: timetypes.RFC3339Type{},
36+
},
37+
"value": schema.StringAttribute{
38+
Description: "Specifies the enablement value of Argo Smart Routing.\nAvailable values: \"on\", \"off\".",
39+
Computed: true,
40+
Validators: []validator.String{
41+
stringvalidator.OneOfCaseInsensitive("on", "off"),
42+
},
43+
},
2144
},
2245
}
2346
}

internal/services/argo_smart_routing/model.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package argo_smart_routing
44

55
import (
66
"github.com/cloudflare/terraform-provider-cloudflare/internal/apijson"
7+
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
78
"github.com/hashicorp/terraform-plugin-framework/types"
89
)
910

@@ -12,9 +13,11 @@ type ArgoSmartRoutingResultEnvelope struct {
1213
}
1314

1415
type ArgoSmartRoutingModel struct {
15-
ID types.String `tfsdk:"id" json:"-,computed"`
16-
ZoneID types.String `tfsdk:"zone_id" path:"zone_id,required"`
17-
Value types.String `tfsdk:"value" json:"value,required,no_refresh"`
16+
ID types.String `tfsdk:"id" json:"-,computed"`
17+
ZoneID types.String `tfsdk:"zone_id" path:"zone_id,required"`
18+
Value types.String `tfsdk:"value" json:"value,required"`
19+
Editable types.Bool `tfsdk:"editable" json:"editable,computed"`
20+
ModifiedOn timetypes.RFC3339 `tfsdk:"modified_on" json:"modified_on,computed" format:"date-time"`
1821
}
1922

2023
func (m ArgoSmartRoutingModel) MarshalJSON() (data []byte, err error) {

internal/services/argo_smart_routing/resource.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ func (r *ArgoSmartRoutingResource) Read(ctx context.Context, req resource.ReadRe
155155
}
156156

157157
res := new(http.Response)
158+
env := ArgoSmartRoutingResultEnvelope{*data}
158159
_, err := r.client.Argo.SmartRouting.Get(
159160
ctx,
160161
argo.SmartRoutingGetParams{
@@ -172,6 +173,13 @@ func (r *ArgoSmartRoutingResource) Read(ctx context.Context, req resource.ReadRe
172173
resp.Diagnostics.AddError("failed to make http request", err.Error())
173174
return
174175
}
176+
bytes, _ := io.ReadAll(res.Body)
177+
err = apijson.Unmarshal(bytes, &env)
178+
if err != nil {
179+
resp.Diagnostics.AddError("failed to deserialize http request", err.Error())
180+
return
181+
}
182+
data = &env.Result
175183
data.ID = data.ZoneID
176184

177185
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)

internal/services/argo_smart_routing/schema.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package argo_smart_routing
55
import (
66
"context"
77

8+
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
89
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
910
"github.com/hashicorp/terraform-plugin-framework/resource"
1011
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
@@ -29,12 +30,21 @@ func ResourceSchema(ctx context.Context) schema.Schema {
2930
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown(), stringplanmodifier.RequiresReplace()},
3031
},
3132
"value": schema.StringAttribute{
32-
Description: "Enables Argo Smart Routing.\nAvailable values: \"on\", \"off\".",
33+
Description: "Specifies the enablement value of Argo Smart Routing.\nAvailable values: \"on\", \"off\".",
3334
Required: true,
3435
Validators: []validator.String{
3536
stringvalidator.OneOfCaseInsensitive("on", "off"),
3637
},
3738
},
39+
"editable": schema.BoolAttribute{
40+
Description: "Specifies if the setting is editable.",
41+
Computed: true,
42+
},
43+
"modified_on": schema.StringAttribute{
44+
Description: "Specifies the time when the setting was last modified.",
45+
Computed: true,
46+
CustomType: timetypes.RFC3339Type{},
47+
},
3848
},
3949
}
4050
}

0 commit comments

Comments
 (0)