@@ -100,6 +100,66 @@ async fn main() {
100100}
101101```
102102
103+ ## Python Usage
104+
105+ The Python bindings are built using PyO3 and maturin. Install from the local source:
106+
107+ ``` bash
108+ # From the `ixaccess` project root directory
109+ cd py/ixaccess
110+ pip install maturin
111+ maturin develop
112+ ```
113+
114+ Or build and install a wheel:
115+
116+ ``` bash
117+ cd py/ixaccess
118+ pip install maturin
119+ maturin build --release
120+ pip install target/wheels/* .whl
121+ ```
122+
123+ ### Example
124+
125+ ``` python
126+ from ixaccess import IxAccessClient
127+
128+ # Initialize the client with a path to the state file in Google Cloud Storage.
129+ # This will create the file if it doesn't exist.
130+ client = IxAccessClient(" gs://your-bucket/access-control.ix" )
131+
132+ # --- Role Management ---
133+ print (" Adding roles..." )
134+ client.add_role(" admin" )
135+ client.add_role(" editor" )
136+ client.add_role(" viewer" )
137+
138+ # --- Role Assignment (Inheritance) ---
139+ # 'admin' inherits all permissions from 'editor'.
140+ # 'editor' inherits all permissions from 'viewer'.
141+ print (" Assigning roles..." )
142+ client.assign_role(" admin" , " editor" )
143+ client.assign_role(" editor" , " viewer" )
144+
145+ # --- Resource Assignment ---
146+ # Assign a GCS bucket to the 'viewer' role.
147+ print (" Assigning resources..." )
148+ client.assign_resource_to_role(" viewer" , " gcs_bucket" , " data-bucket-1" )
149+
150+ # --- Access Checks ---
151+ print (" Performing access checks..." )
152+ # The 'admin' role has access because it inherits from 'viewer'.
153+ admin_buckets = client.get_all_resources_for_role_by_tag(" admin" , " gcs_bucket" )
154+ assert " data-bucket-1" in admin_buckets
155+ print (f " 'admin' has access to: { admin_buckets} " )
156+
157+ # The 'viewer' role has direct access.
158+ viewer_buckets = client.get_all_resources_for_role_by_tag(" viewer" , " gcs_bucket" )
159+ assert " data-bucket-1" in viewer_buckets
160+ print (f " 'viewer' has access to: { viewer_buckets} " )
161+ ```
162+
103163## R Usage
104164
105165Install the R package from the local source:
0 commit comments