Skip to content

prefect_github.mutations

This is a module containing: GitHub mutation tasks

add_comment_subject(subject_id, body, github_credentials, return_fields=None) async

Adds a comment to an Issue or Pull Request.

Parameters:

Name Type Description Default
subject_id str

The Node ID of the subject to modify.

required
body str

The contents of the comment.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
@task
async def add_comment_subject(  # noqa
    subject_id: str,
    body: str,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Adds a comment to an Issue or Pull Request.

    Args:
        subject_id: The Node ID of the subject to modify.
        body: The contents of the comment.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.add_comment(
        **strip_kwargs(
            input=dict(
                subject_id=subject_id,
                body=body,
            )
        )
    ).subject(**strip_kwargs())

    op_stack = (
        "addComment",
        "subject",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["addComment"]["subject"]

add_pull_request_review(pull_request_id, github_credentials, commit_oid=None, body=None, event=None, comments=None, threads=None, return_fields=None) async

Adds a review to a Pull Request.

Parameters:

Name Type Description Default
pull_request_id str

The Node ID of the pull request to modify.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
commit_oid Optional[datetime]

The commit OID the review pertains to.

None
body Optional[str]

The contents of the review body comment.

None
event PullRequestReviewEvent

The event to perform on the pull request review.

None
comments Iterable[DraftPullRequestReviewComment]

The review line comments.

None
threads Iterable[DraftPullRequestReviewThread]

The review line comment threads.

None
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
@task
async def add_pull_request_review(  # noqa
    pull_request_id: str,
    github_credentials: GitHubCredentials,
    commit_oid: Optional[datetime] = None,
    body: Optional[str] = None,
    event: graphql_schema.PullRequestReviewEvent = None,
    comments: Iterable[graphql_schema.DraftPullRequestReviewComment] = None,
    threads: Iterable[graphql_schema.DraftPullRequestReviewThread] = None,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Adds a review to a Pull Request.

    Args:
        pull_request_id: The Node ID of the pull request to modify.
        github_credentials: Credentials to use for authentication with GitHub.
        commit_oid: The commit OID the review pertains to.
        body: The contents of the review body comment.
        event: The event to perform on the pull request review.
        comments: The review line comments.
        threads: The review line comment threads.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.add_pull_request_review(
        **strip_kwargs(
            input=dict(
                pull_request_id=pull_request_id,
                commit_oid=commit_oid,
                body=body,
                event=event,
                comments=comments,
                threads=threads,
            )
        )
    ).pull_request_review(**strip_kwargs())

    op_stack = (
        "addPullRequestReview",
        "pullRequestReview",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["addPullRequestReview"]["pullRequestReview"]

add_reaction(subject_id, content, github_credentials, return_fields=None) async

Adds a reaction to a subject.

Parameters:

Name Type Description Default
subject_id str

The Node ID of the subject to modify.

required
content ReactionContent

The name of the emoji to react with.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
@task
async def add_reaction(  # noqa
    subject_id: str,
    content: graphql_schema.ReactionContent,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Adds a reaction to a subject.

    Args:
        subject_id: The Node ID of the subject to modify.
        content: The name of the emoji to react with.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.add_reaction(
        **strip_kwargs(
            input=dict(
                subject_id=subject_id,
                content=content,
            )
        )
    ).reaction(**strip_kwargs())

    op_stack = (
        "addReaction",
        "reaction",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["addReaction"]["reaction"]

add_reaction_subject(subject_id, content, github_credentials, return_fields=None) async

Adds a reaction to a subject.

Parameters:

Name Type Description Default
subject_id str

The Node ID of the subject to modify.

required
content ReactionContent

The name of the emoji to react with.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
@task
async def add_reaction_subject(  # noqa
    subject_id: str,
    content: graphql_schema.ReactionContent,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Adds a reaction to a subject.

    Args:
        subject_id: The Node ID of the subject to modify.
        content: The name of the emoji to react with.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.add_reaction(
        **strip_kwargs(
            input=dict(
                subject_id=subject_id,
                content=content,
            )
        )
    ).subject(**strip_kwargs())

    op_stack = (
        "addReaction",
        "subject",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["addReaction"]["subject"]

add_star_starrable(starrable_id, github_credentials, return_fields=None) async

Adds a star to a Starrable.

Parameters:

Name Type Description Default
starrable_id str

The Starrable ID to star.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
@task
async def add_star_starrable(  # noqa
    starrable_id: str,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Adds a star to a Starrable.

    Args:
        starrable_id: The Starrable ID to star.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.add_star(
        **strip_kwargs(
            input=dict(
                starrable_id=starrable_id,
            )
        )
    ).starrable(**strip_kwargs())

    op_stack = (
        "addStar",
        "starrable",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["addStar"]["starrable"]

close_issue(issue_id, github_credentials, state_reason=None, return_fields=None) async

Close an issue.

Parameters:

Name Type Description Default
issue_id str

ID of the issue to be closed.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
state_reason IssueClosedStateReason

The reason the issue is to be closed.

None
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
@task
async def close_issue(  # noqa
    issue_id: str,
    github_credentials: GitHubCredentials,
    state_reason: graphql_schema.IssueClosedStateReason = None,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Close an issue.

    Args:
        issue_id: ID of the issue to be closed.
        github_credentials: Credentials to use for authentication with GitHub.
        state_reason: The reason the issue is to be closed.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.close_issue(
        **strip_kwargs(
            input=dict(
                issue_id=issue_id,
                state_reason=state_reason,
            )
        )
    ).issue(**strip_kwargs())

    op_stack = (
        "closeIssue",
        "issue",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["closeIssue"]["issue"]

close_pull_request(pull_request_id, github_credentials, return_fields=None) async

Close a pull request.

Parameters:

Name Type Description Default
pull_request_id str

ID of the pull request to be closed.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
@task
async def close_pull_request(  # noqa
    pull_request_id: str,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Close a pull request.

    Args:
        pull_request_id: ID of the pull request to be closed.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.close_pull_request(
        **strip_kwargs(
            input=dict(
                pull_request_id=pull_request_id,
            )
        )
    ).pull_request(**strip_kwargs())

    op_stack = (
        "closePullRequest",
        "pullRequest",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["closePullRequest"]["pullRequest"]

create_issue(repository_id, title, assignee_ids, label_ids, project_ids, github_credentials, body=None, milestone_id=None, issue_template=None, return_fields=None) async

Creates a new issue.

Parameters:

Name Type Description Default
repository_id str

The Node ID of the repository.

required
title str

The title for the issue.

required
assignee_ids Iterable[str]

The Node ID for the user assignee for this issue.

required
label_ids Iterable[str]

An array of Node IDs of labels for this issue.

required
project_ids Iterable[str]

An array of Node IDs for projects associated with this issue.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
body Optional[str]

The body for the issue description.

None
milestone_id Optional[str]

The Node ID of the milestone for this issue.

None
issue_template Optional[str]

The name of an issue template in the repository, assigns labels and assignees from the template to the issue.

None
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
@task
async def create_issue(  # noqa
    repository_id: str,
    title: str,
    assignee_ids: Iterable[str],
    label_ids: Iterable[str],
    project_ids: Iterable[str],
    github_credentials: GitHubCredentials,
    body: Optional[str] = None,
    milestone_id: Optional[str] = None,
    issue_template: Optional[str] = None,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Creates a new issue.

    Args:
        repository_id: The Node ID of the repository.
        title: The title for the issue.
        assignee_ids: The Node ID for the user assignee for this issue.
        label_ids: An array of Node IDs of labels for this issue.
        project_ids: An array of Node IDs for projects associated with this
            issue.
        github_credentials: Credentials to use for authentication with GitHub.
        body: The body for the issue description.
        milestone_id: The Node ID of the milestone for this issue.
        issue_template: The name of an issue template in the repository, assigns
            labels and assignees from the template to the issue.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.create_issue(
        **strip_kwargs(
            input=dict(
                repository_id=repository_id,
                title=title,
                assignee_ids=assignee_ids,
                label_ids=label_ids,
                project_ids=project_ids,
                body=body,
                milestone_id=milestone_id,
                issue_template=issue_template,
            )
        )
    ).issue(**strip_kwargs())

    op_stack = (
        "createIssue",
        "issue",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["createIssue"]["issue"]

create_pull_request(repository_id, base_ref_name, head_ref_name, title, github_credentials, body=None, maintainer_can_modify=None, draft=None, return_fields=None) async

Create a new pull request.

Parameters:

Name Type Description Default
repository_id str

The Node ID of the repository.

required
base_ref_name str

The name of the branch you want your changes pulled into. This should be an existing branch on the current repository. You cannot update the base branch on a pull request to point to another repository.

required
head_ref_name str

The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head_ref_name with a user like this: username:branch.

required
title str

The title of the pull request.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
body Optional[str]

The contents of the pull request.

None
maintainer_can_modify Optional[bool]

Indicates whether maintainers can modify the pull request.

None
draft Optional[bool]

Indicates whether this pull request should be a draft.

None
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
@task
async def create_pull_request(  # noqa
    repository_id: str,
    base_ref_name: str,
    head_ref_name: str,
    title: str,
    github_credentials: GitHubCredentials,
    body: Optional[str] = None,
    maintainer_can_modify: Optional[bool] = None,
    draft: Optional[bool] = None,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Create a new pull request.

    Args:
        repository_id: The Node ID of the repository.
        base_ref_name: The name of the branch you want your changes pulled into.
            This should be an existing branch on the current repository.
            You cannot update the base branch on a pull request to point
            to another repository.
        head_ref_name: The name of the branch where your changes are
            implemented. For cross-repository pull requests in the same
            network, namespace `head_ref_name` with a user like this:
            `username:branch`.
        title: The title of the pull request.
        github_credentials: Credentials to use for authentication with GitHub.
        body: The contents of the pull request.
        maintainer_can_modify: Indicates whether maintainers can modify the pull
            request.
        draft: Indicates whether this pull request should be a draft.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.create_pull_request(
        **strip_kwargs(
            input=dict(
                repository_id=repository_id,
                base_ref_name=base_ref_name,
                head_ref_name=head_ref_name,
                title=title,
                body=body,
                maintainer_can_modify=maintainer_can_modify,
                draft=draft,
            )
        )
    ).pull_request(**strip_kwargs())

    op_stack = (
        "createPullRequest",
        "pullRequest",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["createPullRequest"]["pullRequest"]

remove_reaction(subject_id, content, github_credentials, return_fields=None) async

Removes a reaction from a subject.

Parameters:

Name Type Description Default
subject_id str

The Node ID of the subject to modify.

required
content ReactionContent

The name of the emoji reaction to remove.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
@task
async def remove_reaction(  # noqa
    subject_id: str,
    content: graphql_schema.ReactionContent,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Removes a reaction from a subject.

    Args:
        subject_id: The Node ID of the subject to modify.
        content: The name of the emoji reaction to remove.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.remove_reaction(
        **strip_kwargs(
            input=dict(
                subject_id=subject_id,
                content=content,
            )
        )
    ).reaction(**strip_kwargs())

    op_stack = (
        "removeReaction",
        "reaction",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["removeReaction"]["reaction"]

remove_reaction_subject(subject_id, content, github_credentials, return_fields=None) async

Removes a reaction from a subject.

Parameters:

Name Type Description Default
subject_id str

The Node ID of the subject to modify.

required
content ReactionContent

The name of the emoji reaction to remove.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
@task
async def remove_reaction_subject(  # noqa
    subject_id: str,
    content: graphql_schema.ReactionContent,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Removes a reaction from a subject.

    Args:
        subject_id: The Node ID of the subject to modify.
        content: The name of the emoji reaction to remove.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.remove_reaction(
        **strip_kwargs(
            input=dict(
                subject_id=subject_id,
                content=content,
            )
        )
    ).subject(**strip_kwargs())

    op_stack = (
        "removeReaction",
        "subject",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["removeReaction"]["subject"]

remove_star_starrable(starrable_id, github_credentials, return_fields=None) async

Removes a star from a Starrable.

Parameters:

Name Type Description Default
starrable_id str

The Starrable ID to unstar.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
@task
async def remove_star_starrable(  # noqa
    starrable_id: str,
    github_credentials: GitHubCredentials,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Removes a star from a Starrable.

    Args:
        starrable_id: The Starrable ID to unstar.
        github_credentials: Credentials to use for authentication with GitHub.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.remove_star(
        **strip_kwargs(
            input=dict(
                starrable_id=starrable_id,
            )
        )
    ).starrable(**strip_kwargs())

    op_stack = (
        "removeStar",
        "starrable",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["removeStar"]["starrable"]

request_reviews(pull_request_id, user_ids, team_ids, github_credentials, union=None, return_fields=None) async

Set review requests on a pull request.

Parameters:

Name Type Description Default
pull_request_id str

The Node ID of the pull request to modify.

required
user_ids Iterable[str]

The Node IDs of the user to request.

required
team_ids Iterable[str]

The Node IDs of the team to request.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
union Optional[bool]

Add users to the set rather than replace.

None
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
@task
async def request_reviews(  # noqa
    pull_request_id: str,
    user_ids: Iterable[str],
    team_ids: Iterable[str],
    github_credentials: GitHubCredentials,
    union: Optional[bool] = None,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Set review requests on a pull request.

    Args:
        pull_request_id: The Node ID of the pull request to modify.
        user_ids: The Node IDs of the user to request.
        team_ids: The Node IDs of the team to request.
        github_credentials: Credentials to use for authentication with GitHub.
        union: Add users to the set rather than replace.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.request_reviews(
        **strip_kwargs(
            input=dict(
                pull_request_id=pull_request_id,
                user_ids=user_ids,
                team_ids=team_ids,
                union=union,
            )
        )
    )

    op_stack = ("requestReviews",)
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["requestReviews"]

request_reviews_pull_request(pull_request_id, user_ids, team_ids, github_credentials, union=None, return_fields=None) async

Set review requests on a pull request.

Parameters:

Name Type Description Default
pull_request_id str

The Node ID of the pull request to modify.

required
user_ids Iterable[str]

The Node IDs of the user to request.

required
team_ids Iterable[str]

The Node IDs of the team to request.

required
github_credentials GitHubCredentials

Credentials to use for authentication with GitHub.

required
union Optional[bool]

Add users to the set rather than replace.

None
return_fields Optional[Iterable[str]]

Subset the return fields (as snake_case); defaults to fields listed in configs/mutation/*.json.

None

Returns:

Type Description
Dict[str, Any]

A dict of the returned fields.

Source code in prefect_github/mutations.py
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
@task
async def request_reviews_pull_request(  # noqa
    pull_request_id: str,
    user_ids: Iterable[str],
    team_ids: Iterable[str],
    github_credentials: GitHubCredentials,
    union: Optional[bool] = None,
    return_fields: Optional[Iterable[str]] = None,
) -> Dict[str, Any]:  # pragma: no cover
    """
    Set review requests on a pull request.

    Args:
        pull_request_id: The Node ID of the pull request to modify.
        user_ids: The Node IDs of the user to request.
        team_ids: The Node IDs of the team to request.
        github_credentials: Credentials to use for authentication with GitHub.
        union: Add users to the set rather than replace.
        return_fields: Subset the return fields (as snake_case); defaults to
            fields listed in configs/mutation/*.json.

    Returns:
        A dict of the returned fields.
    """
    op = Operation(graphql_schema.Mutation)
    op_selection = op.request_reviews(
        **strip_kwargs(
            input=dict(
                pull_request_id=pull_request_id,
                user_ids=user_ids,
                team_ids=team_ids,
                union=union,
            )
        )
    ).pull_request(**strip_kwargs())

    op_stack = (
        "requestReviews",
        "pullRequest",
    )
    op_selection = _subset_return_fields(
        op_selection, op_stack, return_fields, return_fields_defaults
    )

    result = await _execute_graphql_op(op, github_credentials)
    return result["requestReviews"]["pullRequest"]