Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 51ab05b

Browse files
committedMar 18, 2025·
feat(magic_cloud_networking): add endpoint mappings (#4047)
1 parent c711c7d commit 51ab05b

17 files changed

+42148
-1
lines changed
 

‎.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1617
1+
configured_endpoints: 1650
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0ed9f898b31619623e50d660d04beca50e44987bfd3eb3a6ff98d3bca2a9c569.yml

‎api.md

+112
Large diffs are not rendered by default.

‎client.go

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import (
5757
"github.com/cloudflare/cloudflare-go/v4/load_balancers"
5858
"github.com/cloudflare/cloudflare-go/v4/logpush"
5959
"github.com/cloudflare/cloudflare-go/v4/logs"
60+
"github.com/cloudflare/cloudflare-go/v4/magic_cloud_networking"
6061
"github.com/cloudflare/cloudflare-go/v4/magic_network_monitoring"
6162
"github.com/cloudflare/cloudflare-go/v4/magic_transit"
6263
"github.com/cloudflare/cloudflare-go/v4/managed_transforms"
@@ -165,6 +166,7 @@ type Client struct {
165166
Intel *intel.IntelService
166167
MagicTransit *magic_transit.MagicTransitService
167168
MagicNetworkMonitoring *magic_network_monitoring.MagicNetworkMonitoringService
169+
MagicCloudNetworking *magic_cloud_networking.MagicCloudNetworkingService
168170
NetworkInterconnects *network_interconnects.NetworkInterconnectService
169171
MTLSCertificates *mtls_certificates.MTLSCertificateService
170172
Pages *pages.PageService
@@ -288,6 +290,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
288290
r.Intel = intel.NewIntelService(opts...)
289291
r.MagicTransit = magic_transit.NewMagicTransitService(opts...)
290292
r.MagicNetworkMonitoring = magic_network_monitoring.NewMagicNetworkMonitoringService(opts...)
293+
r.MagicCloudNetworking = magic_cloud_networking.NewMagicCloudNetworkingService(opts...)
291294
r.NetworkInterconnects = network_interconnects.NewNetworkInterconnectService(opts...)
292295
r.MTLSCertificates = mtls_certificates.NewMTLSCertificateService(opts...)
293296
r.Pages = pages.NewPageService(opts...)

‎magic_cloud_networking/aliases.go

+421
Large diffs are not rendered by default.

‎magic_cloud_networking/catalogsync.go

+4,978
Large diffs are not rendered by default.
+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/magic_cloud_networking"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestCatalogSyncNewWithOptionalParams(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.MagicCloudNetworking.CatalogSyncs.New(context.TODO(), magic_cloud_networking.CatalogSyncNewParams{
31+
AccountID: cloudflare.F("account_id"),
32+
DestinationType: cloudflare.F(magic_cloud_networking.CatalogSyncNewParamsDestinationTypeNone),
33+
Name: cloudflare.F("name"),
34+
UpdateMode: cloudflare.F(magic_cloud_networking.CatalogSyncNewParamsUpdateModeAuto),
35+
Description: cloudflare.F("description"),
36+
Policy: cloudflare.F("policy"),
37+
Forwarded: cloudflare.F("forwarded"),
38+
})
39+
if err != nil {
40+
var apierr *cloudflare.Error
41+
if errors.As(err, &apierr) {
42+
t.Log(string(apierr.DumpRequest(true)))
43+
}
44+
t.Fatalf("err should be nil: %s", err.Error())
45+
}
46+
}
47+
48+
func TestCatalogSyncUpdateWithOptionalParams(t *testing.T) {
49+
baseURL := "http://localhost:4010"
50+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
51+
baseURL = envURL
52+
}
53+
if !testutil.CheckTestServer(t, baseURL) {
54+
return
55+
}
56+
client := cloudflare.NewClient(
57+
option.WithBaseURL(baseURL),
58+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
59+
option.WithAPIEmail("user@example.com"),
60+
)
61+
_, err := client.MagicCloudNetworking.CatalogSyncs.Update(
62+
context.TODO(),
63+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
64+
magic_cloud_networking.CatalogSyncUpdateParams{
65+
AccountID: cloudflare.F("account_id"),
66+
Description: cloudflare.F("description"),
67+
Name: cloudflare.F("name"),
68+
Policy: cloudflare.F("policy"),
69+
UpdateMode: cloudflare.F(magic_cloud_networking.CatalogSyncUpdateParamsUpdateModeAuto),
70+
},
71+
)
72+
if err != nil {
73+
var apierr *cloudflare.Error
74+
if errors.As(err, &apierr) {
75+
t.Log(string(apierr.DumpRequest(true)))
76+
}
77+
t.Fatalf("err should be nil: %s", err.Error())
78+
}
79+
}
80+
81+
func TestCatalogSyncList(t *testing.T) {
82+
baseURL := "http://localhost:4010"
83+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
84+
baseURL = envURL
85+
}
86+
if !testutil.CheckTestServer(t, baseURL) {
87+
return
88+
}
89+
client := cloudflare.NewClient(
90+
option.WithBaseURL(baseURL),
91+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
92+
option.WithAPIEmail("user@example.com"),
93+
)
94+
_, err := client.MagicCloudNetworking.CatalogSyncs.List(context.TODO(), magic_cloud_networking.CatalogSyncListParams{
95+
AccountID: cloudflare.F("account_id"),
96+
})
97+
if err != nil {
98+
var apierr *cloudflare.Error
99+
if errors.As(err, &apierr) {
100+
t.Log(string(apierr.DumpRequest(true)))
101+
}
102+
t.Fatalf("err should be nil: %s", err.Error())
103+
}
104+
}
105+
106+
func TestCatalogSyncDeleteWithOptionalParams(t *testing.T) {
107+
baseURL := "http://localhost:4010"
108+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
109+
baseURL = envURL
110+
}
111+
if !testutil.CheckTestServer(t, baseURL) {
112+
return
113+
}
114+
client := cloudflare.NewClient(
115+
option.WithBaseURL(baseURL),
116+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
117+
option.WithAPIEmail("user@example.com"),
118+
)
119+
_, err := client.MagicCloudNetworking.CatalogSyncs.Delete(
120+
context.TODO(),
121+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
122+
magic_cloud_networking.CatalogSyncDeleteParams{
123+
AccountID: cloudflare.F("account_id"),
124+
DeleteDestination: cloudflare.F(true),
125+
},
126+
)
127+
if err != nil {
128+
var apierr *cloudflare.Error
129+
if errors.As(err, &apierr) {
130+
t.Log(string(apierr.DumpRequest(true)))
131+
}
132+
t.Fatalf("err should be nil: %s", err.Error())
133+
}
134+
}
135+
136+
func TestCatalogSyncEditWithOptionalParams(t *testing.T) {
137+
baseURL := "http://localhost:4010"
138+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
139+
baseURL = envURL
140+
}
141+
if !testutil.CheckTestServer(t, baseURL) {
142+
return
143+
}
144+
client := cloudflare.NewClient(
145+
option.WithBaseURL(baseURL),
146+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
147+
option.WithAPIEmail("user@example.com"),
148+
)
149+
_, err := client.MagicCloudNetworking.CatalogSyncs.Edit(
150+
context.TODO(),
151+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
152+
magic_cloud_networking.CatalogSyncEditParams{
153+
AccountID: cloudflare.F("account_id"),
154+
Description: cloudflare.F("description"),
155+
Name: cloudflare.F("name"),
156+
Policy: cloudflare.F("policy"),
157+
UpdateMode: cloudflare.F(magic_cloud_networking.CatalogSyncEditParamsUpdateModeAuto),
158+
},
159+
)
160+
if err != nil {
161+
var apierr *cloudflare.Error
162+
if errors.As(err, &apierr) {
163+
t.Log(string(apierr.DumpRequest(true)))
164+
}
165+
t.Fatalf("err should be nil: %s", err.Error())
166+
}
167+
}
168+
169+
func TestCatalogSyncGet(t *testing.T) {
170+
baseURL := "http://localhost:4010"
171+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
172+
baseURL = envURL
173+
}
174+
if !testutil.CheckTestServer(t, baseURL) {
175+
return
176+
}
177+
client := cloudflare.NewClient(
178+
option.WithBaseURL(baseURL),
179+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
180+
option.WithAPIEmail("user@example.com"),
181+
)
182+
_, err := client.MagicCloudNetworking.CatalogSyncs.Get(
183+
context.TODO(),
184+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
185+
magic_cloud_networking.CatalogSyncGetParams{
186+
AccountID: cloudflare.F("account_id"),
187+
},
188+
)
189+
if err != nil {
190+
var apierr *cloudflare.Error
191+
if errors.As(err, &apierr) {
192+
t.Log(string(apierr.DumpRequest(true)))
193+
}
194+
t.Fatalf("err should be nil: %s", err.Error())
195+
}
196+
}
197+
198+
func TestCatalogSyncRefresh(t *testing.T) {
199+
baseURL := "http://localhost:4010"
200+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
201+
baseURL = envURL
202+
}
203+
if !testutil.CheckTestServer(t, baseURL) {
204+
return
205+
}
206+
client := cloudflare.NewClient(
207+
option.WithBaseURL(baseURL),
208+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
209+
option.WithAPIEmail("user@example.com"),
210+
)
211+
_, err := client.MagicCloudNetworking.CatalogSyncs.Refresh(
212+
context.TODO(),
213+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
214+
magic_cloud_networking.CatalogSyncRefreshParams{
215+
AccountID: cloudflare.F("account_id"),
216+
},
217+
)
218+
if err != nil {
219+
var apierr *cloudflare.Error
220+
if errors.As(err, &apierr) {
221+
t.Log(string(apierr.DumpRequest(true)))
222+
}
223+
t.Fatalf("err should be nil: %s", err.Error())
224+
}
225+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking
4+
5+
import (
6+
"context"
7+
"errors"
8+
"fmt"
9+
"net/http"
10+
"net/url"
11+
12+
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
13+
"github.com/cloudflare/cloudflare-go/v4/internal/apiquery"
14+
"github.com/cloudflare/cloudflare-go/v4/internal/param"
15+
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
16+
"github.com/cloudflare/cloudflare-go/v4/option"
17+
"github.com/cloudflare/cloudflare-go/v4/packages/pagination"
18+
)
19+
20+
// CatalogSyncPrebuiltPolicyService contains methods and other services that help
21+
// with interacting with the cloudflare API.
22+
//
23+
// Note, unlike clients, this service does not read variables from the environment
24+
// automatically. You should not instantiate this service directly, and instead use
25+
// the [NewCatalogSyncPrebuiltPolicyService] method instead.
26+
type CatalogSyncPrebuiltPolicyService struct {
27+
Options []option.RequestOption
28+
}
29+
30+
// NewCatalogSyncPrebuiltPolicyService generates a new service that applies the
31+
// given options to each request. These options are applied after the parent
32+
// client's options (if there is one), and before any request-specific options.
33+
func NewCatalogSyncPrebuiltPolicyService(opts ...option.RequestOption) (r *CatalogSyncPrebuiltPolicyService) {
34+
r = &CatalogSyncPrebuiltPolicyService{}
35+
r.Options = opts
36+
return
37+
}
38+
39+
// List prebuilt catalog sync policies (Closed Beta)
40+
func (r *CatalogSyncPrebuiltPolicyService) List(ctx context.Context, params CatalogSyncPrebuiltPolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[CatalogSyncPrebuiltPolicyListResponse], err error) {
41+
var raw *http.Response
42+
opts = append(r.Options[:], opts...)
43+
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
44+
if params.AccountID.Value == "" {
45+
err = errors.New("missing required account_id parameter")
46+
return
47+
}
48+
path := fmt.Sprintf("accounts/%s/magic/cloud/catalog-syncs/prebuilt-policies", params.AccountID)
49+
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...)
50+
if err != nil {
51+
return nil, err
52+
}
53+
err = cfg.Execute()
54+
if err != nil {
55+
return nil, err
56+
}
57+
res.SetPageConfig(cfg, raw)
58+
return res, nil
59+
}
60+
61+
// List prebuilt catalog sync policies (Closed Beta)
62+
func (r *CatalogSyncPrebuiltPolicyService) ListAutoPaging(ctx context.Context, params CatalogSyncPrebuiltPolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[CatalogSyncPrebuiltPolicyListResponse] {
63+
return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...))
64+
}
65+
66+
type CatalogSyncPrebuiltPolicyListResponse struct {
67+
ApplicableDestinations []CatalogSyncPrebuiltPolicyListResponseApplicableDestination `json:"applicable_destinations,required"`
68+
PolicyDescription string `json:"policy_description,required"`
69+
PolicyName string `json:"policy_name,required"`
70+
PolicyString string `json:"policy_string,required"`
71+
JSON catalogSyncPrebuiltPolicyListResponseJSON `json:"-"`
72+
}
73+
74+
// catalogSyncPrebuiltPolicyListResponseJSON contains the JSON metadata for the
75+
// struct [CatalogSyncPrebuiltPolicyListResponse]
76+
type catalogSyncPrebuiltPolicyListResponseJSON struct {
77+
ApplicableDestinations apijson.Field
78+
PolicyDescription apijson.Field
79+
PolicyName apijson.Field
80+
PolicyString apijson.Field
81+
raw string
82+
ExtraFields map[string]apijson.Field
83+
}
84+
85+
func (r *CatalogSyncPrebuiltPolicyListResponse) UnmarshalJSON(data []byte) (err error) {
86+
return apijson.UnmarshalRoot(data, r)
87+
}
88+
89+
func (r catalogSyncPrebuiltPolicyListResponseJSON) RawJSON() string {
90+
return r.raw
91+
}
92+
93+
type CatalogSyncPrebuiltPolicyListResponseApplicableDestination string
94+
95+
const (
96+
CatalogSyncPrebuiltPolicyListResponseApplicableDestinationNone CatalogSyncPrebuiltPolicyListResponseApplicableDestination = "NONE"
97+
CatalogSyncPrebuiltPolicyListResponseApplicableDestinationZeroTrustList CatalogSyncPrebuiltPolicyListResponseApplicableDestination = "ZERO_TRUST_LIST"
98+
)
99+
100+
func (r CatalogSyncPrebuiltPolicyListResponseApplicableDestination) IsKnown() bool {
101+
switch r {
102+
case CatalogSyncPrebuiltPolicyListResponseApplicableDestinationNone, CatalogSyncPrebuiltPolicyListResponseApplicableDestinationZeroTrustList:
103+
return true
104+
}
105+
return false
106+
}
107+
108+
type CatalogSyncPrebuiltPolicyListParams struct {
109+
AccountID param.Field[string] `path:"account_id,required"`
110+
// specify type of destination, omit to return all
111+
DestinationType param.Field[CatalogSyncPrebuiltPolicyListParamsDestinationType] `query:"destination_type"`
112+
}
113+
114+
// URLQuery serializes [CatalogSyncPrebuiltPolicyListParams]'s query parameters as
115+
// `url.Values`.
116+
func (r CatalogSyncPrebuiltPolicyListParams) URLQuery() (v url.Values) {
117+
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
118+
ArrayFormat: apiquery.ArrayQueryFormatRepeat,
119+
NestedFormat: apiquery.NestedQueryFormatDots,
120+
})
121+
}
122+
123+
// specify type of destination, omit to return all
124+
type CatalogSyncPrebuiltPolicyListParamsDestinationType string
125+
126+
const (
127+
CatalogSyncPrebuiltPolicyListParamsDestinationTypeNone CatalogSyncPrebuiltPolicyListParamsDestinationType = "NONE"
128+
CatalogSyncPrebuiltPolicyListParamsDestinationTypeZeroTrustList CatalogSyncPrebuiltPolicyListParamsDestinationType = "ZERO_TRUST_LIST"
129+
)
130+
131+
func (r CatalogSyncPrebuiltPolicyListParamsDestinationType) IsKnown() bool {
132+
switch r {
133+
case CatalogSyncPrebuiltPolicyListParamsDestinationTypeNone, CatalogSyncPrebuiltPolicyListParamsDestinationTypeZeroTrustList:
134+
return true
135+
}
136+
return false
137+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/magic_cloud_networking"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestCatalogSyncPrebuiltPolicyListWithOptionalParams(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.MagicCloudNetworking.CatalogSyncs.PrebuiltPolicies.List(context.TODO(), magic_cloud_networking.CatalogSyncPrebuiltPolicyListParams{
31+
AccountID: cloudflare.F("account_id"),
32+
DestinationType: cloudflare.F(magic_cloud_networking.CatalogSyncPrebuiltPolicyListParamsDestinationTypeNone),
33+
})
34+
if err != nil {
35+
var apierr *cloudflare.Error
36+
if errors.As(err, &apierr) {
37+
t.Log(string(apierr.DumpRequest(true)))
38+
}
39+
t.Fatalf("err should be nil: %s", err.Error())
40+
}
41+
}

‎magic_cloud_networking/cloudintegration.go

+6,062
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/magic_cloud_networking"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestCloudIntegrationNewWithOptionalParams(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.MagicCloudNetworking.CloudIntegrations.New(context.TODO(), magic_cloud_networking.CloudIntegrationNewParams{
31+
AccountID: cloudflare.F("account_id"),
32+
CloudType: cloudflare.F(magic_cloud_networking.CloudIntegrationNewParamsCloudTypeAws),
33+
FriendlyName: cloudflare.F("friendly_name"),
34+
Description: cloudflare.F("description"),
35+
Forwarded: cloudflare.F("forwarded"),
36+
})
37+
if err != nil {
38+
var apierr *cloudflare.Error
39+
if errors.As(err, &apierr) {
40+
t.Log(string(apierr.DumpRequest(true)))
41+
}
42+
t.Fatalf("err should be nil: %s", err.Error())
43+
}
44+
}
45+
46+
func TestCloudIntegrationUpdateWithOptionalParams(t *testing.T) {
47+
baseURL := "http://localhost:4010"
48+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
49+
baseURL = envURL
50+
}
51+
if !testutil.CheckTestServer(t, baseURL) {
52+
return
53+
}
54+
client := cloudflare.NewClient(
55+
option.WithBaseURL(baseURL),
56+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
57+
option.WithAPIEmail("user@example.com"),
58+
)
59+
_, err := client.MagicCloudNetworking.CloudIntegrations.Update(
60+
context.TODO(),
61+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
62+
magic_cloud_networking.CloudIntegrationUpdateParams{
63+
AccountID: cloudflare.F("account_id"),
64+
AwsArn: cloudflare.F("aws_arn"),
65+
AzureSubscriptionID: cloudflare.F("azure_subscription_id"),
66+
AzureTenantID: cloudflare.F("azure_tenant_id"),
67+
Description: cloudflare.F("description"),
68+
FriendlyName: cloudflare.F("friendly_name"),
69+
GcpProjectID: cloudflare.F("gcp_project_id"),
70+
GcpServiceAccountEmail: cloudflare.F("gcp_service_account_email"),
71+
},
72+
)
73+
if err != nil {
74+
var apierr *cloudflare.Error
75+
if errors.As(err, &apierr) {
76+
t.Log(string(apierr.DumpRequest(true)))
77+
}
78+
t.Fatalf("err should be nil: %s", err.Error())
79+
}
80+
}
81+
82+
func TestCloudIntegrationListWithOptionalParams(t *testing.T) {
83+
baseURL := "http://localhost:4010"
84+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
85+
baseURL = envURL
86+
}
87+
if !testutil.CheckTestServer(t, baseURL) {
88+
return
89+
}
90+
client := cloudflare.NewClient(
91+
option.WithBaseURL(baseURL),
92+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
93+
option.WithAPIEmail("user@example.com"),
94+
)
95+
_, err := client.MagicCloudNetworking.CloudIntegrations.List(context.TODO(), magic_cloud_networking.CloudIntegrationListParams{
96+
AccountID: cloudflare.F("account_id"),
97+
Cloudflare: cloudflare.F(true),
98+
Desc: cloudflare.F(true),
99+
OrderBy: cloudflare.F("order_by"),
100+
Status: cloudflare.F(true),
101+
})
102+
if err != nil {
103+
var apierr *cloudflare.Error
104+
if errors.As(err, &apierr) {
105+
t.Log(string(apierr.DumpRequest(true)))
106+
}
107+
t.Fatalf("err should be nil: %s", err.Error())
108+
}
109+
}
110+
111+
func TestCloudIntegrationDelete(t *testing.T) {
112+
baseURL := "http://localhost:4010"
113+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
114+
baseURL = envURL
115+
}
116+
if !testutil.CheckTestServer(t, baseURL) {
117+
return
118+
}
119+
client := cloudflare.NewClient(
120+
option.WithBaseURL(baseURL),
121+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
122+
option.WithAPIEmail("user@example.com"),
123+
)
124+
_, err := client.MagicCloudNetworking.CloudIntegrations.Delete(
125+
context.TODO(),
126+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
127+
magic_cloud_networking.CloudIntegrationDeleteParams{
128+
AccountID: cloudflare.F("account_id"),
129+
},
130+
)
131+
if err != nil {
132+
var apierr *cloudflare.Error
133+
if errors.As(err, &apierr) {
134+
t.Log(string(apierr.DumpRequest(true)))
135+
}
136+
t.Fatalf("err should be nil: %s", err.Error())
137+
}
138+
}
139+
140+
func TestCloudIntegrationDiscoverWithOptionalParams(t *testing.T) {
141+
baseURL := "http://localhost:4010"
142+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
143+
baseURL = envURL
144+
}
145+
if !testutil.CheckTestServer(t, baseURL) {
146+
return
147+
}
148+
client := cloudflare.NewClient(
149+
option.WithBaseURL(baseURL),
150+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
151+
option.WithAPIEmail("user@example.com"),
152+
)
153+
_, err := client.MagicCloudNetworking.CloudIntegrations.Discover(
154+
context.TODO(),
155+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
156+
magic_cloud_networking.CloudIntegrationDiscoverParams{
157+
AccountID: cloudflare.F("account_id"),
158+
V2: cloudflare.F(true),
159+
},
160+
)
161+
if err != nil {
162+
var apierr *cloudflare.Error
163+
if errors.As(err, &apierr) {
164+
t.Log(string(apierr.DumpRequest(true)))
165+
}
166+
t.Fatalf("err should be nil: %s", err.Error())
167+
}
168+
}
169+
170+
func TestCloudIntegrationDiscoverAll(t *testing.T) {
171+
baseURL := "http://localhost:4010"
172+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
173+
baseURL = envURL
174+
}
175+
if !testutil.CheckTestServer(t, baseURL) {
176+
return
177+
}
178+
client := cloudflare.NewClient(
179+
option.WithBaseURL(baseURL),
180+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
181+
option.WithAPIEmail("user@example.com"),
182+
)
183+
_, err := client.MagicCloudNetworking.CloudIntegrations.DiscoverAll(context.TODO(), magic_cloud_networking.CloudIntegrationDiscoverAllParams{
184+
AccountID: cloudflare.F("account_id"),
185+
})
186+
if err != nil {
187+
var apierr *cloudflare.Error
188+
if errors.As(err, &apierr) {
189+
t.Log(string(apierr.DumpRequest(true)))
190+
}
191+
t.Fatalf("err should be nil: %s", err.Error())
192+
}
193+
}
194+
195+
func TestCloudIntegrationEditWithOptionalParams(t *testing.T) {
196+
baseURL := "http://localhost:4010"
197+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
198+
baseURL = envURL
199+
}
200+
if !testutil.CheckTestServer(t, baseURL) {
201+
return
202+
}
203+
client := cloudflare.NewClient(
204+
option.WithBaseURL(baseURL),
205+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
206+
option.WithAPIEmail("user@example.com"),
207+
)
208+
_, err := client.MagicCloudNetworking.CloudIntegrations.Edit(
209+
context.TODO(),
210+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
211+
magic_cloud_networking.CloudIntegrationEditParams{
212+
AccountID: cloudflare.F("account_id"),
213+
AwsArn: cloudflare.F("aws_arn"),
214+
AzureSubscriptionID: cloudflare.F("azure_subscription_id"),
215+
AzureTenantID: cloudflare.F("azure_tenant_id"),
216+
Description: cloudflare.F("description"),
217+
FriendlyName: cloudflare.F("friendly_name"),
218+
GcpProjectID: cloudflare.F("gcp_project_id"),
219+
GcpServiceAccountEmail: cloudflare.F("gcp_service_account_email"),
220+
},
221+
)
222+
if err != nil {
223+
var apierr *cloudflare.Error
224+
if errors.As(err, &apierr) {
225+
t.Log(string(apierr.DumpRequest(true)))
226+
}
227+
t.Fatalf("err should be nil: %s", err.Error())
228+
}
229+
}
230+
231+
func TestCloudIntegrationGetWithOptionalParams(t *testing.T) {
232+
baseURL := "http://localhost:4010"
233+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
234+
baseURL = envURL
235+
}
236+
if !testutil.CheckTestServer(t, baseURL) {
237+
return
238+
}
239+
client := cloudflare.NewClient(
240+
option.WithBaseURL(baseURL),
241+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
242+
option.WithAPIEmail("user@example.com"),
243+
)
244+
_, err := client.MagicCloudNetworking.CloudIntegrations.Get(
245+
context.TODO(),
246+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
247+
magic_cloud_networking.CloudIntegrationGetParams{
248+
AccountID: cloudflare.F("account_id"),
249+
Status: cloudflare.F(true),
250+
},
251+
)
252+
if err != nil {
253+
var apierr *cloudflare.Error
254+
if errors.As(err, &apierr) {
255+
t.Log(string(apierr.DumpRequest(true)))
256+
}
257+
t.Fatalf("err should be nil: %s", err.Error())
258+
}
259+
}
260+
261+
func TestCloudIntegrationInitialSetup(t *testing.T) {
262+
baseURL := "http://localhost:4010"
263+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
264+
baseURL = envURL
265+
}
266+
if !testutil.CheckTestServer(t, baseURL) {
267+
return
268+
}
269+
client := cloudflare.NewClient(
270+
option.WithBaseURL(baseURL),
271+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
272+
option.WithAPIEmail("user@example.com"),
273+
)
274+
_, err := client.MagicCloudNetworking.CloudIntegrations.InitialSetup(
275+
context.TODO(),
276+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
277+
magic_cloud_networking.CloudIntegrationInitialSetupParams{
278+
AccountID: cloudflare.F("account_id"),
279+
},
280+
)
281+
if err != nil {
282+
var apierr *cloudflare.Error
283+
if errors.As(err, &apierr) {
284+
t.Log(string(apierr.DumpRequest(true)))
285+
}
286+
t.Fatalf("err should be nil: %s", err.Error())
287+
}
288+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking
4+
5+
import (
6+
"github.com/cloudflare/cloudflare-go/v4/option"
7+
)
8+
9+
// MagicCloudNetworkingService contains methods and other services that help with
10+
// interacting with the cloudflare API.
11+
//
12+
// Note, unlike clients, this service does not read variables from the environment
13+
// automatically. You should not instantiate this service directly, and instead use
14+
// the [NewMagicCloudNetworkingService] method instead.
15+
type MagicCloudNetworkingService struct {
16+
Options []option.RequestOption
17+
CatalogSyncs *CatalogSyncService
18+
OnRamps *OnRampService
19+
CloudIntegrations *CloudIntegrationService
20+
Resources *ResourceService
21+
}
22+
23+
// NewMagicCloudNetworkingService generates a new service that applies the given
24+
// options to each request. These options are applied after the parent client's
25+
// options (if there is one), and before any request-specific options.
26+
func NewMagicCloudNetworkingService(opts ...option.RequestOption) (r *MagicCloudNetworkingService) {
27+
r = &MagicCloudNetworkingService{}
28+
r.Options = opts
29+
r.CatalogSyncs = NewCatalogSyncService(opts...)
30+
r.OnRamps = NewOnRampService(opts...)
31+
r.CloudIntegrations = NewCloudIntegrationService(opts...)
32+
r.Resources = NewResourceService(opts...)
33+
return
34+
}

‎magic_cloud_networking/onramp.go

+23,114
Large diffs are not rendered by default.

‎magic_cloud_networking/onramp_test.go

+327
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking_test
4+
5+
import (
6+
"bytes"
7+
"context"
8+
"errors"
9+
"io"
10+
"net/http"
11+
"net/http/httptest"
12+
"os"
13+
"testing"
14+
15+
"github.com/cloudflare/cloudflare-go/v4"
16+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
17+
"github.com/cloudflare/cloudflare-go/v4/magic_cloud_networking"
18+
"github.com/cloudflare/cloudflare-go/v4/option"
19+
)
20+
21+
func TestOnRampNewWithOptionalParams(t *testing.T) {
22+
baseURL := "http://localhost:4010"
23+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
24+
baseURL = envURL
25+
}
26+
if !testutil.CheckTestServer(t, baseURL) {
27+
return
28+
}
29+
client := cloudflare.NewClient(
30+
option.WithBaseURL(baseURL),
31+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
32+
option.WithAPIEmail("user@example.com"),
33+
)
34+
_, err := client.MagicCloudNetworking.OnRamps.New(context.TODO(), magic_cloud_networking.OnRampNewParams{
35+
AccountID: cloudflare.F("account_id"),
36+
CloudType: cloudflare.F(magic_cloud_networking.OnRampNewParamsCloudTypeAws),
37+
InstallRoutesInCloud: cloudflare.F(true),
38+
InstallRoutesInMagicWAN: cloudflare.F(true),
39+
Name: cloudflare.F("name"),
40+
Type: cloudflare.F(magic_cloud_networking.OnRampNewParamsTypeOnrampTypeSingle),
41+
AdoptedHubID: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
42+
AttachedHubs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
43+
AttachedVPCs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
44+
Description: cloudflare.F("description"),
45+
HubProviderID: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
46+
ManageHubToHubAttachments: cloudflare.F(true),
47+
ManageVPCToHubAttachments: cloudflare.F(true),
48+
Region: cloudflare.F("region"),
49+
VPC: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
50+
Forwarded: cloudflare.F("forwarded"),
51+
})
52+
if err != nil {
53+
var apierr *cloudflare.Error
54+
if errors.As(err, &apierr) {
55+
t.Log(string(apierr.DumpRequest(true)))
56+
}
57+
t.Fatalf("err should be nil: %s", err.Error())
58+
}
59+
}
60+
61+
func TestOnRampUpdateWithOptionalParams(t *testing.T) {
62+
baseURL := "http://localhost:4010"
63+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
64+
baseURL = envURL
65+
}
66+
if !testutil.CheckTestServer(t, baseURL) {
67+
return
68+
}
69+
client := cloudflare.NewClient(
70+
option.WithBaseURL(baseURL),
71+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
72+
option.WithAPIEmail("user@example.com"),
73+
)
74+
_, err := client.MagicCloudNetworking.OnRamps.Update(
75+
context.TODO(),
76+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
77+
magic_cloud_networking.OnRampUpdateParams{
78+
AccountID: cloudflare.F("account_id"),
79+
AttachedHubs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
80+
AttachedVPCs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
81+
Description: cloudflare.F("description"),
82+
InstallRoutesInCloud: cloudflare.F(true),
83+
InstallRoutesInMagicWAN: cloudflare.F(true),
84+
ManageHubToHubAttachments: cloudflare.F(true),
85+
ManageVPCToHubAttachments: cloudflare.F(true),
86+
Name: cloudflare.F("name"),
87+
VPC: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
88+
},
89+
)
90+
if err != nil {
91+
var apierr *cloudflare.Error
92+
if errors.As(err, &apierr) {
93+
t.Log(string(apierr.DumpRequest(true)))
94+
}
95+
t.Fatalf("err should be nil: %s", err.Error())
96+
}
97+
}
98+
99+
func TestOnRampListWithOptionalParams(t *testing.T) {
100+
baseURL := "http://localhost:4010"
101+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
102+
baseURL = envURL
103+
}
104+
if !testutil.CheckTestServer(t, baseURL) {
105+
return
106+
}
107+
client := cloudflare.NewClient(
108+
option.WithBaseURL(baseURL),
109+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
110+
option.WithAPIEmail("user@example.com"),
111+
)
112+
_, err := client.MagicCloudNetworking.OnRamps.List(context.TODO(), magic_cloud_networking.OnRampListParams{
113+
AccountID: cloudflare.F("account_id"),
114+
Desc: cloudflare.F(true),
115+
OrderBy: cloudflare.F("order_by"),
116+
Status: cloudflare.F(true),
117+
VPCs: cloudflare.F(true),
118+
})
119+
if err != nil {
120+
var apierr *cloudflare.Error
121+
if errors.As(err, &apierr) {
122+
t.Log(string(apierr.DumpRequest(true)))
123+
}
124+
t.Fatalf("err should be nil: %s", err.Error())
125+
}
126+
}
127+
128+
func TestOnRampDeleteWithOptionalParams(t *testing.T) {
129+
baseURL := "http://localhost:4010"
130+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
131+
baseURL = envURL
132+
}
133+
if !testutil.CheckTestServer(t, baseURL) {
134+
return
135+
}
136+
client := cloudflare.NewClient(
137+
option.WithBaseURL(baseURL),
138+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
139+
option.WithAPIEmail("user@example.com"),
140+
)
141+
_, err := client.MagicCloudNetworking.OnRamps.Delete(
142+
context.TODO(),
143+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
144+
magic_cloud_networking.OnRampDeleteParams{
145+
AccountID: cloudflare.F("account_id"),
146+
Destroy: cloudflare.F(true),
147+
Force: cloudflare.F(true),
148+
},
149+
)
150+
if err != nil {
151+
var apierr *cloudflare.Error
152+
if errors.As(err, &apierr) {
153+
t.Log(string(apierr.DumpRequest(true)))
154+
}
155+
t.Fatalf("err should be nil: %s", err.Error())
156+
}
157+
}
158+
159+
func TestOnRampApply(t *testing.T) {
160+
baseURL := "http://localhost:4010"
161+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
162+
baseURL = envURL
163+
}
164+
if !testutil.CheckTestServer(t, baseURL) {
165+
return
166+
}
167+
client := cloudflare.NewClient(
168+
option.WithBaseURL(baseURL),
169+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
170+
option.WithAPIEmail("user@example.com"),
171+
)
172+
_, err := client.MagicCloudNetworking.OnRamps.Apply(
173+
context.TODO(),
174+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
175+
magic_cloud_networking.OnRampApplyParams{
176+
AccountID: cloudflare.F("account_id"),
177+
},
178+
)
179+
if err != nil {
180+
var apierr *cloudflare.Error
181+
if errors.As(err, &apierr) {
182+
t.Log(string(apierr.DumpRequest(true)))
183+
}
184+
t.Fatalf("err should be nil: %s", err.Error())
185+
}
186+
}
187+
188+
func TestOnRampEditWithOptionalParams(t *testing.T) {
189+
baseURL := "http://localhost:4010"
190+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
191+
baseURL = envURL
192+
}
193+
if !testutil.CheckTestServer(t, baseURL) {
194+
return
195+
}
196+
client := cloudflare.NewClient(
197+
option.WithBaseURL(baseURL),
198+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
199+
option.WithAPIEmail("user@example.com"),
200+
)
201+
_, err := client.MagicCloudNetworking.OnRamps.Edit(
202+
context.TODO(),
203+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
204+
magic_cloud_networking.OnRampEditParams{
205+
AccountID: cloudflare.F("account_id"),
206+
AttachedHubs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
207+
AttachedVPCs: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
208+
Description: cloudflare.F("description"),
209+
InstallRoutesInCloud: cloudflare.F(true),
210+
InstallRoutesInMagicWAN: cloudflare.F(true),
211+
ManageHubToHubAttachments: cloudflare.F(true),
212+
ManageVPCToHubAttachments: cloudflare.F(true),
213+
Name: cloudflare.F("name"),
214+
VPC: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"),
215+
},
216+
)
217+
if err != nil {
218+
var apierr *cloudflare.Error
219+
if errors.As(err, &apierr) {
220+
t.Log(string(apierr.DumpRequest(true)))
221+
}
222+
t.Fatalf("err should be nil: %s", err.Error())
223+
}
224+
}
225+
226+
func TestOnRampExport(t *testing.T) {
227+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
228+
w.WriteHeader(200)
229+
w.Write([]byte("abc"))
230+
}))
231+
defer server.Close()
232+
baseURL := server.URL
233+
client := cloudflare.NewClient(
234+
option.WithBaseURL(baseURL),
235+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
236+
option.WithAPIEmail("user@example.com"),
237+
)
238+
resp, err := client.MagicCloudNetworking.OnRamps.Export(
239+
context.TODO(),
240+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
241+
magic_cloud_networking.OnRampExportParams{
242+
AccountID: cloudflare.F("account_id"),
243+
},
244+
)
245+
if err != nil {
246+
var apierr *cloudflare.Error
247+
if errors.As(err, &apierr) {
248+
t.Log(string(apierr.DumpRequest(true)))
249+
}
250+
t.Fatalf("err should be nil: %s", err.Error())
251+
}
252+
defer resp.Body.Close()
253+
254+
b, err := io.ReadAll(resp.Body)
255+
if err != nil {
256+
var apierr *cloudflare.Error
257+
if errors.As(err, &apierr) {
258+
t.Log(string(apierr.DumpRequest(true)))
259+
}
260+
t.Fatalf("err should be nil: %s", err.Error())
261+
}
262+
if !bytes.Equal(b, []byte("abc")) {
263+
t.Fatalf("return value not %s: %s", "abc", b)
264+
}
265+
}
266+
267+
func TestOnRampGetWithOptionalParams(t *testing.T) {
268+
baseURL := "http://localhost:4010"
269+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
270+
baseURL = envURL
271+
}
272+
if !testutil.CheckTestServer(t, baseURL) {
273+
return
274+
}
275+
client := cloudflare.NewClient(
276+
option.WithBaseURL(baseURL),
277+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
278+
option.WithAPIEmail("user@example.com"),
279+
)
280+
_, err := client.MagicCloudNetworking.OnRamps.Get(
281+
context.TODO(),
282+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
283+
magic_cloud_networking.OnRampGetParams{
284+
AccountID: cloudflare.F("account_id"),
285+
PlannedResources: cloudflare.F(true),
286+
PostApplyResources: cloudflare.F(true),
287+
Status: cloudflare.F(true),
288+
VPCs: cloudflare.F(true),
289+
},
290+
)
291+
if err != nil {
292+
var apierr *cloudflare.Error
293+
if errors.As(err, &apierr) {
294+
t.Log(string(apierr.DumpRequest(true)))
295+
}
296+
t.Fatalf("err should be nil: %s", err.Error())
297+
}
298+
}
299+
300+
func TestOnRampPlan(t *testing.T) {
301+
baseURL := "http://localhost:4010"
302+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
303+
baseURL = envURL
304+
}
305+
if !testutil.CheckTestServer(t, baseURL) {
306+
return
307+
}
308+
client := cloudflare.NewClient(
309+
option.WithBaseURL(baseURL),
310+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
311+
option.WithAPIEmail("user@example.com"),
312+
)
313+
_, err := client.MagicCloudNetworking.OnRamps.Plan(
314+
context.TODO(),
315+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
316+
magic_cloud_networking.OnRampPlanParams{
317+
AccountID: cloudflare.F("account_id"),
318+
},
319+
)
320+
if err != nil {
321+
var apierr *cloudflare.Error
322+
if errors.As(err, &apierr) {
323+
t.Log(string(apierr.DumpRequest(true)))
324+
}
325+
t.Fatalf("err should be nil: %s", err.Error())
326+
}
327+
}

‎magic_cloud_networking/onrampaddressspace.go

+1,703
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking_test
4+
5+
import (
6+
"context"
7+
"errors"
8+
"os"
9+
"testing"
10+
11+
"github.com/cloudflare/cloudflare-go/v4"
12+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
13+
"github.com/cloudflare/cloudflare-go/v4/magic_cloud_networking"
14+
"github.com/cloudflare/cloudflare-go/v4/option"
15+
)
16+
17+
func TestOnRampAddressSpaceUpdate(t *testing.T) {
18+
baseURL := "http://localhost:4010"
19+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
20+
baseURL = envURL
21+
}
22+
if !testutil.CheckTestServer(t, baseURL) {
23+
return
24+
}
25+
client := cloudflare.NewClient(
26+
option.WithBaseURL(baseURL),
27+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
28+
option.WithAPIEmail("user@example.com"),
29+
)
30+
_, err := client.MagicCloudNetworking.OnRamps.AddressSpaces.Update(context.TODO(), magic_cloud_networking.OnRampAddressSpaceUpdateParams{
31+
AccountID: cloudflare.F("account_id"),
32+
Prefixes: cloudflare.F([]string{"192.168.0.0/16"}),
33+
})
34+
if err != nil {
35+
var apierr *cloudflare.Error
36+
if errors.As(err, &apierr) {
37+
t.Log(string(apierr.DumpRequest(true)))
38+
}
39+
t.Fatalf("err should be nil: %s", err.Error())
40+
}
41+
}
42+
43+
func TestOnRampAddressSpaceList(t *testing.T) {
44+
baseURL := "http://localhost:4010"
45+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
46+
baseURL = envURL
47+
}
48+
if !testutil.CheckTestServer(t, baseURL) {
49+
return
50+
}
51+
client := cloudflare.NewClient(
52+
option.WithBaseURL(baseURL),
53+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
54+
option.WithAPIEmail("user@example.com"),
55+
)
56+
_, err := client.MagicCloudNetworking.OnRamps.AddressSpaces.List(context.TODO(), magic_cloud_networking.OnRampAddressSpaceListParams{
57+
AccountID: cloudflare.F("account_id"),
58+
})
59+
if err != nil {
60+
var apierr *cloudflare.Error
61+
if errors.As(err, &apierr) {
62+
t.Log(string(apierr.DumpRequest(true)))
63+
}
64+
t.Fatalf("err should be nil: %s", err.Error())
65+
}
66+
}
67+
68+
func TestOnRampAddressSpaceEdit(t *testing.T) {
69+
baseURL := "http://localhost:4010"
70+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
71+
baseURL = envURL
72+
}
73+
if !testutil.CheckTestServer(t, baseURL) {
74+
return
75+
}
76+
client := cloudflare.NewClient(
77+
option.WithBaseURL(baseURL),
78+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
79+
option.WithAPIEmail("user@example.com"),
80+
)
81+
_, err := client.MagicCloudNetworking.OnRamps.AddressSpaces.Edit(context.TODO(), magic_cloud_networking.OnRampAddressSpaceEditParams{
82+
AccountID: cloudflare.F("account_id"),
83+
Prefixes: cloudflare.F([]string{"192.168.0.0/16"}),
84+
})
85+
if err != nil {
86+
var apierr *cloudflare.Error
87+
if errors.As(err, &apierr) {
88+
t.Log(string(apierr.DumpRequest(true)))
89+
}
90+
t.Fatalf("err should be nil: %s", err.Error())
91+
}
92+
}

‎magic_cloud_networking/resource.go

+4,451
Large diffs are not rendered by default.
+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
package magic_cloud_networking_test
4+
5+
import (
6+
"bytes"
7+
"context"
8+
"errors"
9+
"io"
10+
"net/http"
11+
"net/http/httptest"
12+
"os"
13+
"testing"
14+
15+
"github.com/cloudflare/cloudflare-go/v4"
16+
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
17+
"github.com/cloudflare/cloudflare-go/v4/magic_cloud_networking"
18+
"github.com/cloudflare/cloudflare-go/v4/option"
19+
)
20+
21+
func TestResourceListWithOptionalParams(t *testing.T) {
22+
baseURL := "http://localhost:4010"
23+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
24+
baseURL = envURL
25+
}
26+
if !testutil.CheckTestServer(t, baseURL) {
27+
return
28+
}
29+
client := cloudflare.NewClient(
30+
option.WithBaseURL(baseURL),
31+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
32+
option.WithAPIEmail("user@example.com"),
33+
)
34+
_, err := client.MagicCloudNetworking.Resources.List(context.TODO(), magic_cloud_networking.ResourceListParams{
35+
AccountID: cloudflare.F("account_id"),
36+
Cloudflare: cloudflare.F(true),
37+
Desc: cloudflare.F(true),
38+
Managed: cloudflare.F(true),
39+
OrderBy: cloudflare.F("order_by"),
40+
Page: cloudflare.F(int64(1)),
41+
PerPage: cloudflare.F(int64(1)),
42+
ProviderID: cloudflare.F("provider_id"),
43+
Region: cloudflare.F("region"),
44+
ResourceGroup: cloudflare.F("resource_group"),
45+
ResourceID: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
46+
ResourceType: cloudflare.F([]magic_cloud_networking.ResourceListParamsResourceType{magic_cloud_networking.ResourceListParamsResourceTypeAwsCustomerGateway}),
47+
Search: cloudflare.F([]string{"string"}),
48+
V2: cloudflare.F(true),
49+
})
50+
if err != nil {
51+
var apierr *cloudflare.Error
52+
if errors.As(err, &apierr) {
53+
t.Log(string(apierr.DumpRequest(true)))
54+
}
55+
t.Fatalf("err should be nil: %s", err.Error())
56+
}
57+
}
58+
59+
func TestResourceExportWithOptionalParams(t *testing.T) {
60+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
61+
w.WriteHeader(200)
62+
w.Write([]byte("abc"))
63+
}))
64+
defer server.Close()
65+
baseURL := server.URL
66+
client := cloudflare.NewClient(
67+
option.WithBaseURL(baseURL),
68+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
69+
option.WithAPIEmail("user@example.com"),
70+
)
71+
resp, err := client.MagicCloudNetworking.Resources.Export(context.TODO(), magic_cloud_networking.ResourceExportParams{
72+
AccountID: cloudflare.F("account_id"),
73+
Desc: cloudflare.F(true),
74+
OrderBy: cloudflare.F("order_by"),
75+
ProviderID: cloudflare.F("provider_id"),
76+
Region: cloudflare.F("region"),
77+
ResourceGroup: cloudflare.F("resource_group"),
78+
ResourceID: cloudflare.F([]string{"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"}),
79+
ResourceType: cloudflare.F([]magic_cloud_networking.ResourceExportParamsResourceType{magic_cloud_networking.ResourceExportParamsResourceTypeAwsCustomerGateway}),
80+
Search: cloudflare.F([]string{"string"}),
81+
V2: cloudflare.F(true),
82+
})
83+
if err != nil {
84+
var apierr *cloudflare.Error
85+
if errors.As(err, &apierr) {
86+
t.Log(string(apierr.DumpRequest(true)))
87+
}
88+
t.Fatalf("err should be nil: %s", err.Error())
89+
}
90+
defer resp.Body.Close()
91+
92+
b, err := io.ReadAll(resp.Body)
93+
if err != nil {
94+
var apierr *cloudflare.Error
95+
if errors.As(err, &apierr) {
96+
t.Log(string(apierr.DumpRequest(true)))
97+
}
98+
t.Fatalf("err should be nil: %s", err.Error())
99+
}
100+
if !bytes.Equal(b, []byte("abc")) {
101+
t.Fatalf("return value not %s: %s", "abc", b)
102+
}
103+
}
104+
105+
func TestResourceGetWithOptionalParams(t *testing.T) {
106+
baseURL := "http://localhost:4010"
107+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
108+
baseURL = envURL
109+
}
110+
if !testutil.CheckTestServer(t, baseURL) {
111+
return
112+
}
113+
client := cloudflare.NewClient(
114+
option.WithBaseURL(baseURL),
115+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
116+
option.WithAPIEmail("user@example.com"),
117+
)
118+
_, err := client.MagicCloudNetworking.Resources.Get(
119+
context.TODO(),
120+
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
121+
magic_cloud_networking.ResourceGetParams{
122+
AccountID: cloudflare.F("account_id"),
123+
V2: cloudflare.F(true),
124+
},
125+
)
126+
if err != nil {
127+
var apierr *cloudflare.Error
128+
if errors.As(err, &apierr) {
129+
t.Log(string(apierr.DumpRequest(true)))
130+
}
131+
t.Fatalf("err should be nil: %s", err.Error())
132+
}
133+
}
134+
135+
func TestResourcePolicyPreview(t *testing.T) {
136+
baseURL := "http://localhost:4010"
137+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
138+
baseURL = envURL
139+
}
140+
if !testutil.CheckTestServer(t, baseURL) {
141+
return
142+
}
143+
client := cloudflare.NewClient(
144+
option.WithBaseURL(baseURL),
145+
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
146+
option.WithAPIEmail("user@example.com"),
147+
)
148+
_, err := client.MagicCloudNetworking.Resources.PolicyPreview(context.TODO(), magic_cloud_networking.ResourcePolicyPreviewParams{
149+
AccountID: cloudflare.F("account_id"),
150+
Policy: cloudflare.F("policy"),
151+
})
152+
if err != nil {
153+
var apierr *cloudflare.Error
154+
if errors.As(err, &apierr) {
155+
t.Log(string(apierr.DumpRequest(true)))
156+
}
157+
t.Fatalf("err should be nil: %s", err.Error())
158+
}
159+
}

0 commit comments

Comments
 (0)
Please sign in to comment.