Skip to content

feat(storage): insert object acl#228

Open
brianquinlan wants to merge 5 commits intogoogleapis:mainfrom
brianquinlan:make_public
Open

feat(storage): insert object acl#228
brianquinlan wants to merge 5 commits intogoogleapis:mainfrom
brianquinlan:make_public

Conversation

@brianquinlan
Copy link
Copy Markdown
Contributor

@brianquinlan brianquinlan commented Apr 2, 2026

This is the first step in implementing #179

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the insertObjectAcl method to the Storage class, enabling the creation of Access Control List entries for Google Cloud Storage objects. The implementation includes detailed documentation and a new test suite covering success cases, role updates, and error handling. Review feedback suggests fixing a documentation typo, reordering the new method for alphabetical consistency, adding support for generation and userProject parameters to achieve API parity, and removing a debug print statement from the tests.

Comment on lines +625 to +647
Future<ObjectAccessControl> insertObjectAcl(
String bucket,
String object,
String entity,
String role, {
RetryRunner retry = defaultRetry,
}) => retry.run(() async {
final serviceClient = await _serviceClient;
final url = _requestUrl([
'storage',
'v1',
'b',
bucket,
'o',
object,
'acl',
], {});
final j = await serviceClient.post(
url,
body: _JsonEncodableWrapper({'entity': entity, 'role': role}),
);
return objectAccessControlFromJson(j as Map<String, Object?>)!;
}, isIdempotent: false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The insert operation for object ACLs supports generation and userProject query parameters. Adding these provides parity with the underlying API and other methods in this class. Note that the suggestion uses the Dart conditional map entry syntax (key: ?value) to handle nullable parameters.

  Future<ObjectAccessControl> insertObjectAcl(
    String bucket,
    String object,
    String entity,
    String role, {
    BigInt? generation,
    String? userProject,
    RetryRunner retry = defaultRetry,
  }) => retry.run(() async {
    final serviceClient = await _serviceClient;
    final url = _requestUrl([
      'storage',
      'v1',
      'b',
      bucket,
      'o',
      object,
      'acl',
    ], {
      'generation': ?generation?.toString(),
      'userProject': ?userProject,
    });
    final j = await serviceClient.post(
      url,
      body: _JsonEncodableWrapper({'entity': entity, 'role': role}),
    );
    return objectAccessControlFromJson(j as Map<String, Object?>)!;
  }, isIdempotent: false);
References
  1. In Dart, the syntax key: ?value is valid in a map literal to conditionally include the entry if value is not null. This is a new language feature.

brianquinlan and others added 2 commits April 2, 2026 15:35
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants