or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

audit-logging.mdgrpc-services.mdiam-policies.mdindex.md
tile.json

tessl/pypi-grpc-google-iam-v1

gRPC client library for Google Cloud Identity and Access Management (IAM) services with protocol buffer definitions.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/grpc-google-iam-v1@0.14.x

To install, run

npx @tessl/cli install tessl/pypi-grpc-google-iam-v1@0.14.0

index.mddocs/

grpc-google-iam-v1

A gRPC client library providing Python protocol buffer definitions and service stubs for Google Cloud Identity and Access Management (IAM) services. This low-level library enables direct interaction with IAM APIs for managing access control policies, role bindings, and permission evaluation across Google Cloud resources.

Package Information

  • Package Name: grpc-google-iam-v1
  • Language: Python
  • Installation: pip install grpc-google-iam-v1
  • Python Support: >= 3.7

Core Imports

from google.iam.v1 import policy_pb2
from google.iam.v1 import iam_policy_pb2
from google.iam.v1 import iam_policy_pb2_grpc
from google.iam.v1 import options_pb2

For audit and logging:

from google.iam.v1.logging import audit_data_pb2

For resource policy members:

from google.iam.v1 import resource_policy_member_pb2

Basic Usage

import grpc
from google.iam.v1 import policy_pb2
from google.iam.v1 import iam_policy_pb2
from google.iam.v1 import iam_policy_pb2_grpc

# Create a gRPC channel to your service
channel = grpc.insecure_channel('your-service-endpoint:443')

# Create client stub
client = iam_policy_pb2_grpc.IAMPolicyStub(channel)

# Create a policy with role bindings
policy = policy_pb2.Policy()
binding = policy_pb2.Binding()
binding.role = "roles/viewer"
binding.members.extend(["user:alice@example.com", "serviceAccount:my-service@project.iam.gserviceaccount.com"])
policy.bindings.append(binding)

# Set IAM policy on a resource
set_request = iam_policy_pb2.SetIamPolicyRequest()
set_request.resource = "projects/my-project/topics/my-topic"
set_request.policy.CopyFrom(policy)

response = client.SetIamPolicy(set_request)
print(f"Policy set with etag: {response.etag}")

# Get IAM policy from a resource
get_request = iam_policy_pb2.GetIamPolicyRequest()
get_request.resource = "projects/my-project/topics/my-topic"

policy_response = client.GetIamPolicy(get_request)
print(f"Retrieved policy with {len(policy_response.bindings)} bindings")

# Test permissions on a resource
test_request = iam_policy_pb2.TestIamPermissionsRequest()
test_request.resource = "projects/my-project/topics/my-topic"
test_request.permissions.extend(["pubsub.topics.get", "pubsub.topics.publish"])

permissions_response = client.TestIamPermissions(test_request)
print(f"User has permissions: {list(permissions_response.permissions)}")

Architecture

This library follows Google's protocol buffer and gRPC patterns:

  • Protocol Buffer Messages: Structured data types for IAM policies, bindings, and requests
  • gRPC Service Stubs: Client interfaces for remote IAM service calls
  • Namespace Organization: Uses google.iam.v1 namespace following Google's conventions
  • Generated Code: All classes are auto-generated from .proto definitions

The library provides both client-side stubs for making IAM service calls and server-side servicer base classes for implementing IAM services.

Capabilities

IAM Policy Management

Core IAM policy data structures and operations for managing access control policies with role bindings, conditions, and audit configurations.

class Policy:
    version: int
    bindings: List[Binding]
    audit_configs: List[AuditConfig]
    etag: bytes

class Binding:
    role: str
    members: List[str]
    condition: google.type.Expr

IAM Policies

gRPC Service Operations

Client and server classes for IAM policy service operations including setting, getting, and testing permissions on Google Cloud resources.

class IAMPolicyStub:
    def __init__(self, channel): ...
    def SetIamPolicy(self, request: SetIamPolicyRequest) -> Policy: ...
    def GetIamPolicy(self, request: GetIamPolicyRequest) -> Policy: ...
    def TestIamPermissions(self, request: TestIamPermissionsRequest) -> TestIamPermissionsResponse: ...

gRPC Services

Audit and Logging

Support for audit trails and policy change tracking through specialized message types for logging IAM operations and policy modifications.

class AuditData:
    policy_delta: PolicyDelta

class PolicyDelta:
    binding_deltas: List[BindingDelta]
    audit_config_deltas: List[AuditConfigDelta]

Audit and Logging

Types

Core Request/Response Types

class SetIamPolicyRequest:
    resource: str
    policy: Policy
    update_mask: google.protobuf.FieldMask

class GetIamPolicyRequest:
    resource: str
    options: GetPolicyOptions

class TestIamPermissionsRequest:
    resource: str
    permissions: List[str]

class TestIamPermissionsResponse:
    permissions: List[str]

Configuration Types

class GetPolicyOptions:
    requested_policy_version: int

class ResourcePolicyMember:
    iam_policy_name_principal: str  # output only
    iam_policy_uid_principal: str   # output only