@@ -96,7 +96,7 @@ describe("r2", () => {
9696 wrangler r2 bucket list List R2 buckets
9797 wrangler r2 bucket delete <name> Delete an R2 bucket
9898 wrangler r2 bucket sippy Manage Sippy incremental migration on an R2 bucket
99- wrangler r2 bucket notification Manage event notifications for an R2 bucket
99+ wrangler r2 bucket notification Manage event notifications for an R2 bucket [open beta]
100100
101101 GLOBAL FLAGS
102102 -j, --experimental-json-config Experimental: support wrangler.json [boolean]
@@ -130,7 +130,7 @@ describe("r2", () => {
130130 wrangler r2 bucket list List R2 buckets
131131 wrangler r2 bucket delete <name> Delete an R2 bucket
132132 wrangler r2 bucket sippy Manage Sippy incremental migration on an R2 bucket
133- wrangler r2 bucket notification Manage event notifications for an R2 bucket
133+ wrangler r2 bucket notification Manage event notifications for an R2 bucket [open beta]
134134
135135 GLOBAL FLAGS
136136 -j, --experimental-json-config Experimental: support wrangler.json [boolean]
@@ -772,6 +772,61 @@ describe("r2", () => {
772772 describe ( "notification" , ( ) => {
773773 describe ( "get" , ( ) => {
774774 it ( "follows happy path as expected" , async ( ) => {
775+ const bucketName = "my-bucket" ;
776+ const queueId = "471537e8-6e5a-4163-a4d4-9478087c32c3" ;
777+ const queueName = "my-queue" ;
778+ msw . use (
779+ http . get (
780+ "*/accounts/:accountId/event_notifications/r2/:bucketName/configuration" ,
781+ async ( { request, params } ) => {
782+ const { accountId, bucketName : bucketParam } = params ;
783+ expect ( accountId ) . toEqual ( "some-account-id" ) ;
784+ expect ( bucketName ) . toEqual ( bucketParam ) ;
785+ expect ( request . headers . get ( "authorization" ) ) . toEqual (
786+ "Bearer some-api-token"
787+ ) ;
788+ const getResponse = {
789+ bucketName,
790+ queues : [
791+ {
792+ queueId : queueId ,
793+ queueName,
794+ rules : [
795+ {
796+ ruleId : "8cdcce8a-89b3-474f-a087-3eb4fcacfa37" ,
797+ createdAt : "2024-09-05T01:02:03.000Z" ,
798+ prefix : "" ,
799+ suffix : "" ,
800+ actions : [
801+ "PutObject" ,
802+ "CompleteMultipartUpload" ,
803+ "CopyObject" ,
804+ ] ,
805+ } ,
806+ ] ,
807+ } ,
808+ ] ,
809+ } ;
810+ return HttpResponse . json ( createFetchResult ( getResponse ) ) ;
811+ } ,
812+ { once : true }
813+ )
814+ ) ;
815+ await expect (
816+ await runWrangler ( `r2 bucket notification get ${ bucketName } ` )
817+ ) . toBe ( undefined ) ;
818+ expect ( std . out ) . toMatchInlineSnapshot ( `
819+ "Fetching notification configuration for bucket my-bucket...
820+ rule_id: 8cdcce8a-89b3-474f-a087-3eb4fcacfa37
821+ created_at: 2024-09-05T01:02:03.000Z
822+ queue_name: my-queue
823+ prefix:
824+ suffix:
825+ event_type: PutObject,CompleteMultipartUpload,CopyObject"
826+ ` ) ;
827+ } ) ;
828+
829+ it ( "is backwards compatible with old API version" , async ( ) => {
775830 const bucketName = "my-bucket" ;
776831 const queueId = "471537e8-6e5a-4163-a4d4-9478087c32c3" ;
777832 const queueName = "my-queue" ;
@@ -828,11 +883,12 @@ describe("r2", () => {
828883 ) . toBe ( undefined ) ;
829884 expect ( std . out ) . toMatchInlineSnapshot ( `
830885 "Fetching notification configuration for bucket my-bucket...
831- ┌────────────┬────────┬────────┬───────────────┐
832- │ queue_name │ prefix │ suffix │ event_type │
833- ├────────────┼────────┼────────┼───────────────┤
834- │ my-queue │ │ │ object-create │
835- └────────────┴────────┴────────┴───────────────┘"
886+ rule_id:
887+ created_at:
888+ queue_name: my-queue
889+ prefix:
890+ suffix:
891+ event_type: PutObject,CompleteMultipartUpload,CopyObject"
836892 ` ) ;
837893 } ) ;
838894
@@ -846,7 +902,7 @@ describe("r2", () => {
846902 "
847903 wrangler r2 bucket notification get <bucket>
848904
849- Get event notification configuration for a bucket
905+ Get event notification configuration for a bucket [open beta]
850906
851907 POSITIONALS
852908 bucket The name of the bucket for which notifications will be emitted [string] [required]
@@ -937,7 +993,7 @@ describe("r2", () => {
937993 )
938994 ) . resolves . toBe ( undefined ) ;
939995 expect ( std . out ) . toMatchInlineSnapshot ( `
940- "Creating event notification rule for object creation and deletion (PutObject,CompleteMultipartUpload,CopyObject,DeleteObject)
996+ "Creating event notification rule for object creation and deletion (PutObject,CompleteMultipartUpload,CopyObject,DeleteObject,LifecycleDeletion )
941997 Configuration created successfully!"
942998 ` ) ;
943999 } ) ;
@@ -952,7 +1008,7 @@ describe("r2", () => {
9521008 "
9531009 wrangler r2 bucket notification create <bucket>
9541010
955- Create new event notification configuration for an R2 bucket
1011+ Create new event notification configuration for an R2 bucket [open beta]
9561012
9571013 POSITIONALS
9581014 bucket The name of the bucket for which notifications will be emitted [string] [required]
@@ -1044,7 +1100,7 @@ describe("r2", () => {
10441100 "
10451101 wrangler r2 bucket notification delete <bucket>
10461102
1047- Delete event notification configuration for an R2 bucket and queue
1103+ Delete event notification configuration for an R2 bucket and queue [open beta]
10481104
10491105 POSITIONALS
10501106 bucket The name of the bucket for which notifications will be emitted [string] [required]
0 commit comments