@@ -64,7 +64,12 @@ def set_repo(
64
64
installation_id = None
65
65
):
66
66
"""
67
- Activate repository for Cirun
67
+ Activate or deactivate a repository for Cirun.
68
+
69
+ This method allows you to enable or disable a repository's integration with Cirun.
70
+ When activating a repository, it can also handle the installation of the Cirun
71
+ GitHub App if an `installation_id` is provided and `GITHUB_TOKEN` environment
72
+ variable is set.
68
73
69
74
Parameters
70
75
----------
@@ -173,7 +178,8 @@ def _create_access_control_repo_resource_data(
173
178
174
179
def remove_repo_from_resources (self , org , repo , resources ):
175
180
"""
176
- Removes the access to the resource for the repository.
181
+ Creates a Pull request in the `<org>/.cirun` repository updating the `.access.yml`
182
+ to revoke access to specified resources for a repository within an organization.
177
183
178
184
Parameters
179
185
----------
@@ -205,31 +211,40 @@ def add_repo_to_resources(
205
211
policy_args = None ,
206
212
):
207
213
"""
208
- Grants access to the resource for the repository
214
+ Creates a Pull request in the `<org>/.cirun` repository updating the `.access.yml`
215
+ to grant access to specified resources for a repository within an organization,
216
+ with constraints for teams, roles, users, users_from_json, policy_args.
209
217
210
218
Parameters
211
219
----------
212
- org: str
213
- GitHub Organization
214
- repo: str
215
- GitHub Repository
216
- resources: List[str]
217
- List of resources
218
- teams: List[str]
219
- List of teams
220
- roles: List[str]
221
- List of roles
222
- users: List[str]
223
- List of users
224
- users_from_json: List[str]
225
- List of users from a json url
226
- policy_args: Optional[Dict[str, Any]]
227
- Policy arguments, this is a dictionary of key values, currently the only
228
- supported argument is ``{"pull_request": True}`` or ``{"pull_request": False}``
220
+ org : str
221
+ The GitHub organization name.
222
+ repo : str
223
+ The name of the repository to which resources are to be added.
224
+ resources : list of str
225
+ A list of resource identifiers to grant access to.
226
+ teams : list of str, optional
227
+ Teams to grant access to the resources.
228
+ roles : list of str, optional
229
+ Roles to grant access to the resource, i.e. users with specified roles
230
+ will have access to the resources.
231
+ users : list of str, optional
232
+ Users to grant access to the resources.
233
+ users_from_json : str, optional
234
+ Users specified via a JSON URL
235
+ policy_args : dict, optional
236
+ Additional policy arguments, such as `{"pull_request": True}` to enforce
237
+ specific policies on access.
229
238
230
239
Returns
231
240
-------
232
241
requests.Response
242
+ The response object from the API after attempting to add access.
243
+
244
+ Raises
245
+ ------
246
+ CirunAPIException
247
+ If the API call fails with an error status code.
233
248
"""
234
249
repository_resource_access = self ._create_access_control_repo_resource_data (
235
250
repo , resources , action = "add" , teams = teams , roles = roles ,
@@ -243,6 +258,30 @@ def _get_repo_policy(self, access_yml, repo):
243
258
return policy ['id' ]
244
259
245
260
def get_repo_resources (self , org , repo ):
261
+ """
262
+ Retrieve the list of resources that a repository has access to within an organization.
263
+
264
+ This method parses the access control configuration to determine which resources
265
+ the specified repository is permitted to access based on its assigned policies.
266
+
267
+ Parameters
268
+ ----------
269
+ org : str
270
+ The GitHub organization name.
271
+ repo : str
272
+ The repository name whose accessible resources are to be retrieved.
273
+
274
+ Returns
275
+ -------
276
+ list of str or None
277
+ A list of resource identifiers that the repository has access to, or `None`
278
+ if access control configuration is not found.
279
+
280
+ Raises
281
+ ------
282
+ KeyError
283
+ If the repository does not have an associated policy in the access control configuration.
284
+ """
246
285
access_control = self .get_access_control (org )
247
286
if not access_control :
248
287
return
@@ -255,7 +294,28 @@ def get_repo_resources(self, org, repo):
255
294
return repo_resources
256
295
257
296
def clouds (self , print_error = False ):
258
- """Returns all the connected cloud"""
297
+ """
298
+ Retrieve all cloud providers connected to Cirun.
299
+
300
+ This method fetches the list of cloud providers that have been integrated
301
+ with Cirun (have credentials added to cirun).
302
+
303
+ Parameters
304
+ ----------
305
+ print_error : bool, optional
306
+ If set to True, errors encountered during the API call will be printed.
307
+ Default is False.
308
+
309
+ Returns
310
+ -------
311
+ dict
312
+ A dictionary containing information about connected cloud providers.
313
+
314
+ Raises
315
+ ------
316
+ CirunAPIException
317
+ If the API call fails and `print_error` is False.
318
+ """
259
319
response = self ._get ("cloud-connect" )
260
320
if response .status_code not in [200 , 201 ]:
261
321
if print_error :
@@ -264,7 +324,11 @@ def clouds(self, print_error=False):
264
324
265
325
def cloud_connect (self , name , credentials , print_error = False ):
266
326
"""
267
- Connect a cloud provider to cirun.
327
+ Connect a new cloud provider to Cirun.
328
+
329
+ This method integrates a specified cloud provider with Cirun by providing the
330
+ necessary credentials. Once connected, the cloud provider can be used to create
331
+ GitHub Actions runners.
268
332
269
333
Parameters
270
334
----------
@@ -277,6 +341,11 @@ def cloud_connect(self, name, credentials, print_error=False):
277
341
-------
278
342
dict:
279
343
Response json
344
+
345
+ Raises
346
+ ------
347
+ CirunAPIException
348
+ If the API call fails and `print_error` is False.
280
349
"""
281
350
282
351
data = {
0 commit comments