Skip to content

Commit

Permalink
feat(api): add endpoint mappings (#3877)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 30, 2025
1 parent 82c768f commit 4005c7a
Show file tree
Hide file tree
Showing 52 changed files with 6,505 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1504
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-04299b899e2bbf8ba1b4ad96d5e9f9c3e0c9b6246bfeac3f9ab684b855b0e412.yml
configured_endpoints: 1525
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8973dde42d42a39c8fbc5f3f1eb1328e6ac0c805ca4d3e5920796749ed58eb0a.yml
172 changes: 171 additions & 1 deletion api.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import (
"github.com/cloudflare/cloudflare-go/v4/rules"
"github.com/cloudflare/cloudflare-go/v4/rulesets"
"github.com/cloudflare/cloudflare-go/v4/rum"
"github.com/cloudflare/cloudflare-go/v4/security_center"
"github.com/cloudflare/cloudflare-go/v4/security_txt"
"github.com/cloudflare/cloudflare-go/v4/snippets"
"github.com/cloudflare/cloudflare-go/v4/spectrum"
Expand Down Expand Up @@ -198,6 +199,7 @@ type Client struct {
ContentScanning *content_scanning.ContentScanningService
AbuseReports *abuse_reports.AbuseReportService
AI *ai.AIService
SecurityCenter *security_center.SecurityCenterService
}

// NewClient generates a new client with the default option read from the
Expand Down Expand Up @@ -310,6 +312,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
r.ContentScanning = content_scanning.NewContentScanningService(opts...)
r.AbuseReports = abuse_reports.NewAbuseReportService(opts...)
r.AI = ai.NewAIService(opts...)
r.SecurityCenter = security_center.NewSecurityCenterService(opts...)

return
}
Expand Down
28 changes: 28 additions & 0 deletions custom_hostnames/certificatepack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package custom_hostnames

import (
"github.com/cloudflare/cloudflare-go/v4/option"
)

// CertificatePackService contains methods and other services that help with
// interacting with the cloudflare API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewCertificatePackService] method instead.
type CertificatePackService struct {
Options []option.RequestOption
Certificates *CertificatePackCertificateService
}

// NewCertificatePackService generates a new service that applies the given options
// to each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewCertificatePackService(opts ...option.RequestOption) (r *CertificatePackService) {
r = &CertificatePackService{}
r.Options = opts
r.Certificates = NewCertificatePackCertificateService(opts...)
return
}
617 changes: 617 additions & 0 deletions custom_hostnames/certificatepackcertificate.go

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions custom_hostnames/certificatepackcertificate_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package custom_hostnames_test

import (
"context"
"errors"
"os"
"testing"

"github.com/cloudflare/cloudflare-go/v4"
"github.com/cloudflare/cloudflare-go/v4/custom_hostnames"
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
"github.com/cloudflare/cloudflare-go/v4/option"
)

func TestCertificatePackCertificateUpdate(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := cloudflare.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("user@example.com"),
)
_, err := client.CustomHostnames.CertificatePack.Certificates.Update(
context.TODO(),
"023e105f4ecef8ad9ca31a8372d0c353",
"023e105f4ecef8ad9ca31a8372d0c353",
"023e105f4ecef8ad9ca31a8372d0c353",
custom_hostnames.CertificatePackCertificateUpdateParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
CustomCertificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDdjCCAl6gAwIBAgIJAPnMg0Fs+/B0MA0GCSqGSIb3DQEBCwUAMFsx...\n-----END CERTIFICATE-----\n"),
CustomKey: cloudflare.F("-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC/SCB5...\n-----END PRIVATE KEY-----\n"),
},
)
if err != nil {
var apierr *cloudflare.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestCertificatePackCertificateDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
}
if !testutil.CheckTestServer(t, baseURL) {
return
}
client := cloudflare.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
option.WithAPIEmail("user@example.com"),
)
_, err := client.CustomHostnames.CertificatePack.Certificates.Delete(
context.TODO(),
"023e105f4ecef8ad9ca31a8372d0c353",
"023e105f4ecef8ad9ca31a8372d0c353",
"023e105f4ecef8ad9ca31a8372d0c353",
custom_hostnames.CertificatePackCertificateDeleteParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
},
)
if err != nil {
var apierr *cloudflare.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}
6 changes: 4 additions & 2 deletions custom_hostnames/customhostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ import (
// automatically. You should not instantiate this service directly, and instead use
// the [NewCustomHostnameService] method instead.
type CustomHostnameService struct {
Options []option.RequestOption
FallbackOrigin *FallbackOriginService
Options []option.RequestOption
FallbackOrigin *FallbackOriginService
CertificatePack *CertificatePackService
}

// NewCustomHostnameService generates a new service that applies the given options
Expand All @@ -37,6 +38,7 @@ func NewCustomHostnameService(opts ...option.RequestOption) (r *CustomHostnameSe
r = &CustomHostnameService{}
r.Options = opts
r.FallbackOrigin = NewFallbackOriginService(opts...)
r.CertificatePack = NewCertificatePackService(opts...)
return
}

Expand Down
4 changes: 4 additions & 0 deletions r2/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type BucketService struct {
CORS *BucketCORSService
Domains *BucketDomainService
EventNotifications *BucketEventNotificationService
Locks *BucketLockService
Metrics *BucketMetricService
Sippy *BucketSippyService
}

Expand All @@ -42,6 +44,8 @@ func NewBucketService(opts ...option.RequestOption) (r *BucketService) {
r.CORS = NewBucketCORSService(opts...)
r.Domains = NewBucketDomainService(opts...)
r.EventNotifications = NewBucketEventNotificationService(opts...)
r.Locks = NewBucketLockService(opts...)
r.Metrics = NewBucketMetricService(opts...)
r.Sippy = NewBucketSippyService(opts...)
return
}
Expand Down
Loading

0 comments on commit 4005c7a

Please sign in to comment.