Skip to content

Commit 511b36f

Browse files
feat: docs(zero_trust_gateway_policy): add /rules/tenants endpoint to Gateway API docs
* docs(zero_trust_gateway_policy): add /rules/tenants endpoint to Gateway API docs
1 parent da98270 commit 511b36f

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1818
1+
configured_endpoints: 1819
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-cceecd20dfd89884f795e75b433848994bed610b79802c65104f0c70d3ada54e.yml
33
openapi_spec_hash: c33c0e26e48c004c1781a36748d0144c
4-
config_hash: eab23d0b8fa818f1d1dc0e9e18de4266
4+
config_hash: e3e634649e3d70e58e153b878d29e446

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6450,6 +6450,7 @@ Methods:
64506450
- <code title="get /accounts/{account_id}/gateway/rules">client.ZeroTrust.Gateway.Rules.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleListParams">GatewayRuleListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRule">GatewayRule</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
64516451
- <code title="delete /accounts/{account_id}/gateway/rules/{rule_id}">client.ZeroTrust.Gateway.Rules.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, ruleID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleDeleteParams">GatewayRuleDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleDeleteResponse">GatewayRuleDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
64526452
- <code title="get /accounts/{account_id}/gateway/rules/{rule_id}">client.ZeroTrust.Gateway.Rules.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, ruleID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleGetParams">GatewayRuleGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRule">GatewayRule</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
6453+
- <code title="get /accounts/{account_id}/gateway/rules/tenant">client.ZeroTrust.Gateway.Rules.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleService.ListTenant">ListTenant</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleListTenantParams">GatewayRuleListTenantParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/packages/pagination#SinglePage">SinglePage</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRule">GatewayRule</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
64536454
- <code title="post /accounts/{account_id}/gateway/rules/{rule_id}/reset_expiration">client.ZeroTrust.Gateway.Rules.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleService.ResetExpiration">ResetExpiration</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, ruleID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRuleResetExpirationParams">GatewayRuleResetExpirationParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust">zero_trust</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v6/zero_trust#GatewayRule">GatewayRule</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
64546455

64556456
### Certificates

zero_trust/gatewayrule.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,35 @@ func (r *GatewayRuleService) Get(ctx context.Context, ruleID string, query Gatew
144144
return
145145
}
146146

147+
// List Zero Trust Gateway rules for the parent account of an account in the MSP
148+
// configuration.
149+
func (r *GatewayRuleService) ListTenant(ctx context.Context, query GatewayRuleListTenantParams, opts ...option.RequestOption) (res *pagination.SinglePage[GatewayRule], err error) {
150+
var raw *http.Response
151+
opts = slices.Concat(r.Options, opts)
152+
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
153+
if query.AccountID.Value == "" {
154+
err = errors.New("missing required account_id parameter")
155+
return
156+
}
157+
path := fmt.Sprintf("accounts/%s/gateway/rules/tenant", query.AccountID)
158+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...)
159+
if err != nil {
160+
return nil, err
161+
}
162+
err = cfg.Execute()
163+
if err != nil {
164+
return nil, err
165+
}
166+
res.SetPageConfig(cfg, raw)
167+
return res, nil
168+
}
169+
170+
// List Zero Trust Gateway rules for the parent account of an account in the MSP
171+
// configuration.
172+
func (r *GatewayRuleService) ListTenantAutoPaging(ctx context.Context, query GatewayRuleListTenantParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[GatewayRule] {
173+
return pagination.NewSinglePageAutoPager(r.ListTenant(ctx, query, opts...))
174+
}
175+
147176
// Resets the expiration of a Zero Trust Gateway Rule if its duration elapsed and
148177
// it has a default duration. The Zero Trust Gateway Rule must have values for both
149178
// `expiration.expires_at` and `expiration.duration`.
@@ -2001,6 +2030,10 @@ func (r GatewayRuleGetResponseEnvelopeSuccess) IsKnown() bool {
20012030
return false
20022031
}
20032032

2033+
type GatewayRuleListTenantParams struct {
2034+
AccountID param.Field[string] `path:"account_id,required"`
2035+
}
2036+
20042037
type GatewayRuleResetExpirationParams struct {
20052038
AccountID param.Field[string] `path:"account_id,required"`
20062039
}

zero_trust/gatewayrule_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,31 @@ func TestGatewayRuleGet(t *testing.T) {
376376
}
377377
}
378378

379+
func TestGatewayRuleListTenant(t *testing.T) {
380+
baseURL := "http://localhost:4010"
381+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
382+
baseURL = envURL
383+
}
384+
if !testutil.CheckTestServer(t, baseURL) {
385+
return
386+
}
387+
client := cloudflare.NewClient(
388+
option.WithBaseURL(baseURL),
389+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
390+
option.WithAPIEmail("user@example.com"),
391+
)
392+
_, err := client.ZeroTrust.Gateway.Rules.ListTenant(context.TODO(), zero_trust.GatewayRuleListTenantParams{
393+
AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"),
394+
})
395+
if err != nil {
396+
var apierr *cloudflare.Error
397+
if errors.As(err, &apierr) {
398+
t.Log(string(apierr.DumpRequest(true)))
399+
}
400+
t.Fatalf("err should be nil: %s", err.Error())
401+
}
402+
}
403+
379404
func TestGatewayRuleResetExpiration(t *testing.T) {
380405
baseURL := "http://localhost:4010"
381406
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {

0 commit comments

Comments
 (0)