Skip to content

Commit 3fc80d9

Browse files
feat(api): api update (#3855)
1 parent b17ebd4 commit 3fc80d9

File tree

9 files changed

+265
-45
lines changed

9 files changed

+265
-45
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1493
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-1e73ee53fddc61d4ddfa1837bcbc2792e682a435439373fff24a718b4d8f7783.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ed24ef293c8f10ea1c884e533b435244b266e97c6e01211430ac9d39e6daebb0.yml

shared/union.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsBodyDeviceEnr
6969
}
7070
func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsBodyBrowserIsolationPermissionsApplicationPolicyUnion() {
7171
}
72+
func (UnionString) ImplementsZeroTrustDLPEmailRuleNewResponseConditionsValueUnion() {}
73+
func (UnionString) ImplementsZeroTrustDLPEmailRuleUpdateResponseConditionsValueUnion() {}
74+
func (UnionString) ImplementsZeroTrustDLPEmailRuleListResponseConditionsValueUnion() {}
75+
func (UnionString) ImplementsZeroTrustDLPEmailRuleDeleteResponseConditionsValueUnion() {}
76+
func (UnionString) ImplementsZeroTrustDLPEmailRuleBulkEditResponseConditionsValueUnion() {}
77+
func (UnionString) ImplementsZeroTrustDLPEmailRuleGetResponseConditionsValueUnion() {}
78+
func (UnionString) ImplementsZeroTrustDLPEmailRuleNewParamsConditionsValueUnion() {}
79+
func (UnionString) ImplementsZeroTrustDLPEmailRuleUpdateParamsConditionsValueUnion() {}
7280
func (UnionString) ImplementsRadarRankingTimeseriesGroupsResponseSerie0Union() {}
7381
func (UnionString) ImplementsHostnamesSettingValueUnionParam() {}
7482
func (UnionString) ImplementsHostnamesSettingValueUnion() {}

url_scanner/scan.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ func (r *ScanService) New(ctx context.Context, params ScanNewParams, opts ...opt
5959
// "microsoft".<br/>- 'apikey:me AND date:[2024-01 TO 2024-10]': my scans from 2024
6060
// January to 2024 October.<br/>- 'page.domain:(blogspot OR www.blogspot)':
6161
// Searches for scans whose main domain starts with "blogspot" or with
62-
// "www.blogspot"<br/>- 'date:>now-7d AND path:okta-sign-in.min.js: scans from the
63-
// last 7 days with any request path that ends with "okta-sign-in.min.js"<br/>-
64-
// 'page.asn:AS24940 AND hash:xxx': Websites hosted in AS24940 where a resource
65-
// with the given hash was downloaded.
62+
// "www.blogspot"<br/>- 'page.asn:AS24940 AND hash:xxx': Websites hosted in AS24940
63+
// where a resource with the given hash was downloaded.
6664
func (r *ScanService) List(ctx context.Context, params ScanListParams, opts ...option.RequestOption) (res *ScanListResponse, err error) {
6765
opts = append(r.Options[:], opts...)
6866
if params.AccountID.Value == "" {

zero_trust/dlpdatasetupload.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
package zero_trust
44

55
import (
6+
"bytes"
67
"context"
78
"errors"
89
"fmt"
10+
"io"
11+
"mime/multipart"
912
"net/http"
1013

14+
"github.com/cloudflare/cloudflare-go/v4/internal/apiform"
1115
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
1216
"github.com/cloudflare/cloudflare-go/v4/internal/param"
1317
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
@@ -201,11 +205,22 @@ func (r DLPDatasetUploadNewResponseEnvelopeSuccess) IsKnown() bool {
201205

202206
type DLPDatasetUploadEditParams struct {
203207
AccountID param.Field[string] `path:"account_id,required"`
204-
Body string `json:"body,required"`
208+
Body io.Reader `json:"body,required" format:"binary"`
205209
}
206210

207-
func (r DLPDatasetUploadEditParams) MarshalJSON() (data []byte, err error) {
208-
return apijson.MarshalRoot(r.Body)
211+
func (r DLPDatasetUploadEditParams) MarshalMultipart() (data []byte, contentType string, err error) {
212+
buf := bytes.NewBuffer(nil)
213+
writer := multipart.NewWriter(buf)
214+
err = apiform.MarshalRoot(r, writer)
215+
if err != nil {
216+
writer.Close()
217+
return nil, "", err
218+
}
219+
err = writer.Close()
220+
if err != nil {
221+
return nil, "", err
222+
}
223+
return buf.Bytes(), writer.FormDataContentType(), nil
209224
}
210225

211226
type DLPDatasetUploadEditResponseEnvelope struct {

zero_trust/dlpdatasetupload_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
package zero_trust_test
44

55
import (
6+
"bytes"
67
"context"
78
"errors"
9+
"io"
810
"os"
911
"testing"
1012

@@ -63,7 +65,7 @@ func TestDLPDatasetUploadEdit(t *testing.T) {
6365
int64(0),
6466
zero_trust.DLPDatasetUploadEditParams{
6567
AccountID: cloudflare.F("account_id"),
66-
Body: "body",
68+
Body: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
6769
},
6870
)
6971
if err != nil {

zero_trust/dlpdatasetversionentry.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
package zero_trust
44

55
import (
6+
"bytes"
67
"context"
78
"errors"
89
"fmt"
10+
"io"
11+
"mime/multipart"
912
"net/http"
1013

14+
"github.com/cloudflare/cloudflare-go/v4/internal/apiform"
1115
"github.com/cloudflare/cloudflare-go/v4/internal/apijson"
1216
"github.com/cloudflare/cloudflare-go/v4/internal/param"
1317
"github.com/cloudflare/cloudflare-go/v4/internal/requestconfig"
@@ -107,11 +111,22 @@ func (r DLPDatasetVersionEntryNewResponseUploadStatus) IsKnown() bool {
107111

108112
type DLPDatasetVersionEntryNewParams struct {
109113
AccountID param.Field[string] `path:"account_id,required"`
110-
Body string `json:"body,required"`
114+
Body io.Reader `json:"body,required" format:"binary"`
111115
}
112116

113-
func (r DLPDatasetVersionEntryNewParams) MarshalJSON() (data []byte, err error) {
114-
return apijson.MarshalRoot(r.Body)
117+
func (r DLPDatasetVersionEntryNewParams) MarshalMultipart() (data []byte, contentType string, err error) {
118+
buf := bytes.NewBuffer(nil)
119+
writer := multipart.NewWriter(buf)
120+
err = apiform.MarshalRoot(r, writer)
121+
if err != nil {
122+
writer.Close()
123+
return nil, "", err
124+
}
125+
err = writer.Close()
126+
if err != nil {
127+
return nil, "", err
128+
}
129+
return buf.Bytes(), writer.FormDataContentType(), nil
115130
}
116131

117132
type DLPDatasetVersionEntryNewResponseEnvelope struct {

zero_trust/dlpdatasetversionentry_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
package zero_trust_test
44

55
import (
6+
"bytes"
67
"context"
78
"errors"
9+
"io"
810
"os"
911
"testing"
1012

@@ -35,7 +37,7 @@ func TestDLPDatasetVersionEntryNew(t *testing.T) {
3537
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
3638
zero_trust.DLPDatasetVersionEntryNewParams{
3739
AccountID: cloudflare.F("account_id"),
38-
Body: "body",
40+
Body: io.Reader(bytes.NewBuffer([]byte("some file contents"))),
3941
},
4042
)
4143
if err != nil {

0 commit comments

Comments
 (0)