File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
bigquery/cloud-client/src Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ async function revokeTableOrViewAccess({
3232 memberToRevoke,
3333 roleToRevoke = 'roles/bigquery.dataViewer' ,
3434} ) {
35+ // Validate required parameters
36+ if ( ! projectId || ! datasetId || ! resourceId ) {
37+ throw new Error (
38+ 'projectId, datasetId and resourceID are required parameters'
39+ ) ;
40+ }
3541 try {
3642 // Create BigQuery client
3743 const bigquery = new BigQuery ( {
@@ -52,7 +58,7 @@ async function revokeTableOrViewAccess({
5258 // Filter bindings based on parameters
5359 let newBindings = policy . bindings ;
5460
55- if ( memberToRevoke ) {
61+ if ( memberToRevoke && roleToRevoke ) {
5662 // Remove specific member from specific role
5763 newBindings = policy . bindings
5864 . map ( binding => ( {
@@ -63,11 +69,14 @@ async function revokeTableOrViewAccess({
6369 : binding . members ,
6470 } ) )
6571 . filter ( binding => binding . members . length > 0 ) ;
66- } else {
72+ } else if ( ! memberToRevoke && roleToRevoke ) {
6773 // Remove all bindings for the specified role
6874 newBindings = policy . bindings . filter (
6975 binding => binding . role !== roleToRevoke
7076 ) ;
77+ } else {
78+ // Keep the current binding as is
79+ newBindings = policy . bindings ;
7180 }
7281
7382 // Create new policy with updated bindings
You can’t perform that action at this time.
0 commit comments