Skip to content

Commit 33e7b03

Browse files
chore(api): upload stainless config from cloudflare-config
1 parent 21d06f1 commit 33e7b03

File tree

5 files changed

+192
-9
lines changed

5 files changed

+192
-9
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1793
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-5b8e1dbaaf6d219cc93cf890a1c5eee22464d53994c0135af2bd575ec04f4633.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2f61590aa8911086b5c879a035656860c8ea7919bc350836130d9ed1d94cb7a8.yml
33
openapi_spec_hash: 7f912d56bd17a6197f37cad70250bef6
4-
config_hash: 04c3e87def66bed3001640fca84ff9c5
4+
config_hash: 79f17109e02e2ed32ead147f166f5879

internal/services/list_item/data_source_model.go

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

55
import (
6+
"context"
7+
8+
"github.com/cloudflare/cloudflare-go/v5"
9+
"github.com/cloudflare/cloudflare-go/v5/rules"
610
"github.com/cloudflare/terraform-provider-cloudflare/internal/customfield"
11+
"github.com/hashicorp/terraform-plugin-framework/diag"
712
"github.com/hashicorp/terraform-plugin-framework/types"
813
)
914

@@ -25,16 +30,17 @@ type ListItemDataSourceModel struct {
2530
Redirect customfield.NestedObject[ListItemRedirectDataSourceModel] `tfsdk:"redirect" json:"redirect,computed"`
2631
}
2732

28-
// func (m *ListItemDataSourceModel) toReadParams(_ context.Context) (params rules.ListItemGetParams, diags diag.Diagnostics) {
29-
// params = rules.ListItemGetParams{
30-
// AccountID: cloudflare.F(m.AccountID.ValueString()),
31-
// }
33+
func (m *ListItemDataSourceModel) toReadParams(_ context.Context) (params rules.ListItemGetParams, diags diag.Diagnostics) {
34+
params = rules.ListItemGetParams{
35+
AccountID: cloudflare.F(m.AccountID.ValueString()),
36+
}
3237

33-
// return
34-
// }
38+
return
39+
}
3540

3641
type ListItemHostnameDataSourceModel struct {
3742
URLHostname types.String `tfsdk:"url_hostname" json:"url_hostname,computed"`
43+
ExcludeExactHostname types.Bool `tfsdk:"exclude_exact_hostname" json:"exclude_exact_hostname,computed"`
3844
}
3945

4046
type ListItemRedirectDataSourceModel struct {

internal/services/list_item/data_source_schema.go

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

8+
"github.com/cloudflare/terraform-provider-cloudflare/internal/customfield"
9+
"github.com/hashicorp/terraform-plugin-framework-validators/int64validator"
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 = (*ListItemDataSource)(nil)
@@ -26,6 +29,81 @@ func DataSourceSchema(ctx context.Context) schema.Schema {
2629
Description: "The unique ID of the list.",
2730
Required: true,
2831
},
32+
"asn": schema.Int64Attribute{
33+
Description: "Defines a non-negative 32 bit integer.",
34+
Computed: true,
35+
},
36+
"comment": schema.StringAttribute{
37+
Description: "Defines an informative summary of the list item.",
38+
Computed: true,
39+
},
40+
"created_on": schema.StringAttribute{
41+
Description: "The RFC 3339 timestamp of when the list was created.",
42+
Computed: true,
43+
},
44+
"id": schema.StringAttribute{
45+
Description: "The unique ID of the list.",
46+
Computed: true,
47+
},
48+
"ip": schema.StringAttribute{
49+
Description: "An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR.",
50+
Computed: true,
51+
},
52+
"modified_on": schema.StringAttribute{
53+
Description: "The RFC 3339 timestamp of when the list was last modified.",
54+
Computed: true,
55+
},
56+
"hostname": schema.SingleNestedAttribute{
57+
Description: "Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-).",
58+
Computed: true,
59+
CustomType: customfield.NewNestedObjectType[ListItemHostnameDataSourceModel](ctx),
60+
Attributes: map[string]schema.Attribute{
61+
"url_hostname": schema.StringAttribute{
62+
Computed: true,
63+
},
64+
"exclude_exact_hostname": schema.BoolAttribute{
65+
Description: "Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked.",
66+
Computed: true,
67+
},
68+
},
69+
},
70+
"redirect": schema.SingleNestedAttribute{
71+
Description: "The definition of the redirect.",
72+
Computed: true,
73+
CustomType: customfield.NewNestedObjectType[ListItemRedirectDataSourceModel](ctx),
74+
Attributes: map[string]schema.Attribute{
75+
"source_url": schema.StringAttribute{
76+
Computed: true,
77+
},
78+
"target_url": schema.StringAttribute{
79+
Computed: true,
80+
},
81+
"include_subdomains": schema.BoolAttribute{
82+
Computed: true,
83+
},
84+
"preserve_path_suffix": schema.BoolAttribute{
85+
Computed: true,
86+
},
87+
"preserve_query_string": schema.BoolAttribute{
88+
Computed: true,
89+
},
90+
"status_code": schema.Int64Attribute{
91+
Description: "Available values: 301, 302, 307, 308.",
92+
Computed: true,
93+
Validators: []validator.Int64{
94+
int64validator.OneOf(
95+
301,
96+
302,
97+
307,
98+
308,
99+
),
100+
},
101+
},
102+
"subpath_matching": schema.BoolAttribute{
103+
Computed: true,
104+
},
105+
},
106+
},
29107
},
30108
}
31109
}

internal/services/list_item/list_data_source_model.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,27 @@ func (m *ListItemsDataSourceModel) toListParams(_ context.Context) (params rules
3737
}
3838

3939
type ListItemsResultDataSourceModel struct {
40+
ID types.String `tfsdk:"id" json:"id,computed"`
41+
CreatedOn types.String `tfsdk:"created_on" json:"created_on,computed"`
42+
IP types.String `tfsdk:"ip" json:"ip,computed"`
43+
ModifiedOn types.String `tfsdk:"modified_on" json:"modified_on,computed"`
44+
Comment types.String `tfsdk:"comment" json:"comment,computed"`
45+
Hostname customfield.NestedObject[ListItemsHostnameDataSourceModel] `tfsdk:"hostname" json:"hostname,computed"`
46+
Redirect customfield.NestedObject[ListItemsRedirectDataSourceModel] `tfsdk:"redirect" json:"redirect,computed"`
47+
ASN types.Int64 `tfsdk:"asn" json:"asn,computed"`
48+
}
49+
50+
type ListItemsHostnameDataSourceModel struct {
51+
URLHostname types.String `tfsdk:"url_hostname" json:"url_hostname,computed"`
52+
ExcludeExactHostname types.Bool `tfsdk:"exclude_exact_hostname" json:"exclude_exact_hostname,computed"`
53+
}
54+
55+
type ListItemsRedirectDataSourceModel struct {
56+
SourceURL types.String `tfsdk:"source_url" json:"source_url,computed"`
57+
TargetURL types.String `tfsdk:"target_url" json:"target_url,computed"`
58+
IncludeSubdomains types.Bool `tfsdk:"include_subdomains" json:"include_subdomains,computed"`
59+
PreservePathSuffix types.Bool `tfsdk:"preserve_path_suffix" json:"preserve_path_suffix,computed"`
60+
PreserveQueryString types.Bool `tfsdk:"preserve_query_string" json:"preserve_query_string,computed"`
61+
StatusCode types.Int64 `tfsdk:"status_code" json:"status_code,computed"`
62+
SubpathMatching types.Bool `tfsdk:"subpath_matching" json:"subpath_matching,computed"`
4063
}

internal/services/list_item/list_data_source_schema.go

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,83 @@ func ListDataSourceSchema(ctx context.Context) schema.Schema {
4141
Computed: true,
4242
CustomType: customfield.NewNestedObjectListType[ListItemsResultDataSourceModel](ctx),
4343
NestedObject: schema.NestedAttributeObject{
44-
Attributes: map[string]schema.Attribute{},
44+
Attributes: map[string]schema.Attribute{
45+
"id": schema.StringAttribute{
46+
Description: "The unique ID of the list.",
47+
Computed: true,
48+
},
49+
"created_on": schema.StringAttribute{
50+
Description: "The RFC 3339 timestamp of when the list was created.",
51+
Computed: true,
52+
},
53+
"ip": schema.StringAttribute{
54+
Description: "An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR.",
55+
Computed: true,
56+
},
57+
"modified_on": schema.StringAttribute{
58+
Description: "The RFC 3339 timestamp of when the list was last modified.",
59+
Computed: true,
60+
},
61+
"comment": schema.StringAttribute{
62+
Description: "Defines an informative summary of the list item.",
63+
Computed: true,
64+
},
65+
"hostname": schema.SingleNestedAttribute{
66+
Description: "Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-).",
67+
Computed: true,
68+
CustomType: customfield.NewNestedObjectType[ListItemsHostnameDataSourceModel](ctx),
69+
Attributes: map[string]schema.Attribute{
70+
"url_hostname": schema.StringAttribute{
71+
Computed: true,
72+
},
73+
"exclude_exact_hostname": schema.BoolAttribute{
74+
Description: "Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked.",
75+
Computed: true,
76+
},
77+
},
78+
},
79+
"redirect": schema.SingleNestedAttribute{
80+
Description: "The definition of the redirect.",
81+
Computed: true,
82+
CustomType: customfield.NewNestedObjectType[ListItemsRedirectDataSourceModel](ctx),
83+
Attributes: map[string]schema.Attribute{
84+
"source_url": schema.StringAttribute{
85+
Computed: true,
86+
},
87+
"target_url": schema.StringAttribute{
88+
Computed: true,
89+
},
90+
"include_subdomains": schema.BoolAttribute{
91+
Computed: true,
92+
},
93+
"preserve_path_suffix": schema.BoolAttribute{
94+
Computed: true,
95+
},
96+
"preserve_query_string": schema.BoolAttribute{
97+
Computed: true,
98+
},
99+
"status_code": schema.Int64Attribute{
100+
Description: "Available values: 301, 302, 307, 308.",
101+
Computed: true,
102+
Validators: []validator.Int64{
103+
int64validator.OneOf(
104+
301,
105+
302,
106+
307,
107+
308,
108+
),
109+
},
110+
},
111+
"subpath_matching": schema.BoolAttribute{
112+
Computed: true,
113+
},
114+
},
115+
},
116+
"asn": schema.Int64Attribute{
117+
Description: "Defines a non-negative 32 bit integer.",
118+
Computed: true,
119+
},
120+
},
45121
},
46122
},
47123
},

0 commit comments

Comments
 (0)