Skip to content

Commit

Permalink
feat(origin_post_quantum_encryption): swap PUT for PATCH operation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jan 6, 2025
1 parent fdcde98 commit 9ac9789
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1489
configured_endpoints: 1490
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d52d1344e2e65f3eda2fe8fff8c7d95cebf7cad134af21eaf9d6d5b6a04d783a.yml
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7070,10 +7070,12 @@ Methods:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption">origin_post_quantum_encryption</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionEditResponse">OriginPostQuantumEncryptionEditResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption">origin_post_quantum_encryption</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionGetResponse">OriginPostQuantumEncryptionGetResponse</a>

Methods:

- <code title="patch /zones/{zone_id}/cache/origin_post_quantum_encryption">client.OriginPostQuantumEncryption.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionService.Edit">Edit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption">origin_post_quantum_encryption</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionEditParams">OriginPostQuantumEncryptionEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption">origin_post_quantum_encryption</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionEditResponse">OriginPostQuantumEncryptionEditResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_id}/cache/origin_post_quantum_encryption">client.OriginPostQuantumEncryption.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionService.Get">Get</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/v3/origin_post_quantum_encryption">origin_post_quantum_encryption</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionGetParams">OriginPostQuantumEncryptionGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption">origin_post_quantum_encryption</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption#OriginPostQuantumEncryptionGetResponse">OriginPostQuantumEncryptionGetResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Speed
Expand Down
156 changes: 156 additions & 0 deletions origin_post_quantum_encryption/originpostquantumencryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ func NewOriginPostQuantumEncryptionService(opts ...option.RequestOption) (r *Ori
return
}

// Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when
// connecting to your origin. Preferred instructs Cloudflare to opportunistically
// send a Post-Quantum keyshare in the first message to the origin (for fastest
// connections when the origin supports and prefers PQ), supported means that PQ
// algorithms are advertised but only used when requested by the origin, and off
// means that PQ algorithms are not advertised
func (r *OriginPostQuantumEncryptionService) Edit(ctx context.Context, params OriginPostQuantumEncryptionEditParams, opts ...option.RequestOption) (res *OriginPostQuantumEncryptionEditResponse, err error) {
var env OriginPostQuantumEncryptionEditResponseEnvelope
opts = append(r.Options[:], opts...)
if params.ZoneID.Value == "" {
err = errors.New("missing required zone_id parameter")
return
}
path := fmt.Sprintf("zones/%s/cache/origin_post_quantum_encryption", params.ZoneID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...)
if err != nil {
return
}
res = &env.Result
return
}

// Instructs Cloudflare to use Post-Quantum (PQ) key agreement algorithms when
// connecting to your origin. Preferred instructs Cloudflare to opportunistically
// send a Post-Quantum keyshare in the first message to the origin (for fastest
Expand All @@ -57,6 +79,69 @@ func (r *OriginPostQuantumEncryptionService) Get(ctx context.Context, query Orig
return
}

type OriginPostQuantumEncryptionEditResponse struct {
// Value of the zone setting.
ID OriginPostQuantumEncryptionEditResponseID `json:"id,required"`
// Whether the setting is editable
Editable bool `json:"editable,required"`
// The value of the feature
Value OriginPostQuantumEncryptionEditResponseValue `json:"value,required"`
// Last time this setting was modified.
ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"`
JSON originPostQuantumEncryptionEditResponseJSON `json:"-"`
}

// originPostQuantumEncryptionEditResponseJSON contains the JSON metadata for the
// struct [OriginPostQuantumEncryptionEditResponse]
type originPostQuantumEncryptionEditResponseJSON struct {
ID apijson.Field
Editable apijson.Field
Value apijson.Field
ModifiedOn apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *OriginPostQuantumEncryptionEditResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r originPostQuantumEncryptionEditResponseJSON) RawJSON() string {
return r.raw
}

// Value of the zone setting.
type OriginPostQuantumEncryptionEditResponseID string

const (
OriginPostQuantumEncryptionEditResponseIDOriginPqe OriginPostQuantumEncryptionEditResponseID = "origin_pqe"
)

func (r OriginPostQuantumEncryptionEditResponseID) IsKnown() bool {
switch r {
case OriginPostQuantumEncryptionEditResponseIDOriginPqe:
return true
}
return false
}

// The value of the feature
type OriginPostQuantumEncryptionEditResponseValue string

const (
OriginPostQuantumEncryptionEditResponseValuePreferred OriginPostQuantumEncryptionEditResponseValue = "preferred"
OriginPostQuantumEncryptionEditResponseValueSupported OriginPostQuantumEncryptionEditResponseValue = "supported"
OriginPostQuantumEncryptionEditResponseValueOff OriginPostQuantumEncryptionEditResponseValue = "off"
)

func (r OriginPostQuantumEncryptionEditResponseValue) IsKnown() bool {
switch r {
case OriginPostQuantumEncryptionEditResponseValuePreferred, OriginPostQuantumEncryptionEditResponseValueSupported, OriginPostQuantumEncryptionEditResponseValueOff:
return true
}
return false
}

type OriginPostQuantumEncryptionGetResponse struct {
// Value of the zone setting.
ID OriginPostQuantumEncryptionGetResponseID `json:"id,required"`
Expand Down Expand Up @@ -120,6 +205,77 @@ func (r OriginPostQuantumEncryptionGetResponseValue) IsKnown() bool {
return false
}

type OriginPostQuantumEncryptionEditParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
// Value of the Origin Post Quantum Encryption Setting.
Value param.Field[OriginPostQuantumEncryptionEditParamsValue] `json:"value,required"`
}

func (r OriginPostQuantumEncryptionEditParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

// Value of the Origin Post Quantum Encryption Setting.
type OriginPostQuantumEncryptionEditParamsValue string

const (
OriginPostQuantumEncryptionEditParamsValuePreferred OriginPostQuantumEncryptionEditParamsValue = "preferred"
OriginPostQuantumEncryptionEditParamsValueSupported OriginPostQuantumEncryptionEditParamsValue = "supported"
OriginPostQuantumEncryptionEditParamsValueOff OriginPostQuantumEncryptionEditParamsValue = "off"
)

func (r OriginPostQuantumEncryptionEditParamsValue) IsKnown() bool {
switch r {
case OriginPostQuantumEncryptionEditParamsValuePreferred, OriginPostQuantumEncryptionEditParamsValueSupported, OriginPostQuantumEncryptionEditParamsValueOff:
return true
}
return false
}

type OriginPostQuantumEncryptionEditResponseEnvelope struct {
Errors []shared.ResponseInfo `json:"errors,required"`
Messages []shared.ResponseInfo `json:"messages,required"`
// Whether the API call was successful
Success OriginPostQuantumEncryptionEditResponseEnvelopeSuccess `json:"success,required"`
Result OriginPostQuantumEncryptionEditResponse `json:"result"`
JSON originPostQuantumEncryptionEditResponseEnvelopeJSON `json:"-"`
}

// originPostQuantumEncryptionEditResponseEnvelopeJSON contains the JSON metadata
// for the struct [OriginPostQuantumEncryptionEditResponseEnvelope]
type originPostQuantumEncryptionEditResponseEnvelopeJSON struct {
Errors apijson.Field
Messages apijson.Field
Success apijson.Field
Result apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *OriginPostQuantumEncryptionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r originPostQuantumEncryptionEditResponseEnvelopeJSON) RawJSON() string {
return r.raw
}

// Whether the API call was successful
type OriginPostQuantumEncryptionEditResponseEnvelopeSuccess bool

const (
OriginPostQuantumEncryptionEditResponseEnvelopeSuccessTrue OriginPostQuantumEncryptionEditResponseEnvelopeSuccess = true
)

func (r OriginPostQuantumEncryptionEditResponseEnvelopeSuccess) IsKnown() bool {
switch r {
case OriginPostQuantumEncryptionEditResponseEnvelopeSuccessTrue:
return true
}
return false
}

type OriginPostQuantumEncryptionGetParams struct {
// Identifier
ZoneID param.Field[string] `path:"zone_id,required"`
Expand Down
27 changes: 27 additions & 0 deletions origin_post_quantum_encryption/originpostquantumencryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ import (
"github.com/cloudflare/cloudflare-go/v3/origin_post_quantum_encryption"
)

func TestOriginPostQuantumEncryptionEdit(t *testing.T) {
t.Skip("TODO: investigate broken test")
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("[email protected]"),
)
_, err := client.OriginPostQuantumEncryption.Edit(context.TODO(), origin_post_quantum_encryption.OriginPostQuantumEncryptionEditParams{
ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Value: cloudflare.F(origin_post_quantum_encryption.OriginPostQuantumEncryptionEditParamsValuePreferred),
})
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 TestOriginPostQuantumEncryptionGet(t *testing.T) {
t.Skip("TODO: investigate broken test")
baseURL := "http://localhost:4010"
Expand Down

0 comments on commit 9ac9789

Please sign in to comment.