saltext.github 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. saltext/github/__init__.py +31 -0
  2. saltext/github/modules/__init__.py +0 -0
  3. saltext/github/modules/github.py +1873 -0
  4. saltext/github/modules/github_org.py +667 -0
  5. saltext/github/modules/github_repo.py +1658 -0
  6. saltext/github/modules/github_user.py +75 -0
  7. saltext/github/resources/__init__.py +0 -0
  8. saltext/github/resources/github/__init__.py +251 -0
  9. saltext/github/resources/github/modules/__init__.py +0 -0
  10. saltext/github/resources/github/modules/actions.py +175 -0
  11. saltext/github/resources/github/modules/config.py +69 -0
  12. saltext/github/resources/github/modules/deploy_key.py +122 -0
  13. saltext/github/resources/github/modules/environment.py +241 -0
  14. saltext/github/resources/github/modules/grains.py +18 -0
  15. saltext/github/resources/github/modules/issue.py +157 -0
  16. saltext/github/resources/github/modules/label.py +161 -0
  17. saltext/github/resources/github/modules/milestone.py +103 -0
  18. saltext/github/resources/github/modules/pages.py +149 -0
  19. saltext/github/resources/github/modules/pull.py +90 -0
  20. saltext/github/resources/github/modules/repo.py +155 -0
  21. saltext/github/resources/github/modules/ruleset.py +144 -0
  22. saltext/github/resources/github/modules/saltutil.py +24 -0
  23. saltext/github/resources/github/modules/state.py +116 -0
  24. saltext/github/resources/github/modules/test.py +29 -0
  25. saltext/github/resources/github/states/__init__.py +0 -0
  26. saltext/github/resources/github/states/actions.py +117 -0
  27. saltext/github/resources/github/states/deploy_key.py +130 -0
  28. saltext/github/resources/github/states/environment.py +99 -0
  29. saltext/github/resources/github/states/label.py +71 -0
  30. saltext/github/resources/github/states/pages.py +92 -0
  31. saltext/github/resources/github/states/repo.py +108 -0
  32. saltext/github/resources/github/states/ruleset.py +81 -0
  33. saltext/github/states/__init__.py +0 -0
  34. saltext/github/states/github.py +966 -0
  35. saltext/github/states/github_org.py +369 -0
  36. saltext/github/states/github_repo.py +722 -0
  37. saltext/github/utils/__init__.py +72 -0
  38. saltext/github/utils/gh/__init__.py +14 -0
  39. saltext/github/utils/gh/actions.py +195 -0
  40. saltext/github/utils/gh/cache.py +126 -0
  41. saltext/github/utils/gh/client.py +534 -0
  42. saltext/github/utils/gh/deploy_keys.py +121 -0
  43. saltext/github/utils/gh/environments.py +271 -0
  44. saltext/github/utils/gh/exceptions.py +28 -0
  45. saltext/github/utils/gh/grains_files.py +366 -0
  46. saltext/github/utils/gh/issues.py +193 -0
  47. saltext/github/utils/gh/labels.py +142 -0
  48. saltext/github/utils/gh/members.py +157 -0
  49. saltext/github/utils/gh/milestones.py +122 -0
  50. saltext/github/utils/gh/pages.py +128 -0
  51. saltext/github/utils/gh/profile.py +458 -0
  52. saltext/github/utils/gh/pulls.py +99 -0
  53. saltext/github/utils/gh/repos.py +465 -0
  54. saltext/github/utils/gh/resource.py +35 -0
  55. saltext/github/utils/gh/rulesets.py +191 -0
  56. saltext/github/utils/gh/statecores/__init__.py +70 -0
  57. saltext/github/utils/gh/statecores/actions.py +180 -0
  58. saltext/github/utils/gh/statecores/deploy_keys.py +241 -0
  59. saltext/github/utils/gh/statecores/environments.py +212 -0
  60. saltext/github/utils/gh/statecores/labels.py +116 -0
  61. saltext/github/utils/gh/statecores/pages.py +177 -0
  62. saltext/github/utils/gh/statecores/repo.py +249 -0
  63. saltext/github/utils/gh/statecores/rulesets.py +115 -0
  64. saltext/github/utils/gh/teams.py +375 -0
  65. saltext/github/utils/gh/users.py +87 -0
  66. saltext/github/version.py +1 -0
  67. saltext_github-1.1.0.dist-info/METADATA +151 -0
  68. saltext_github-1.1.0.dist-info/RECORD +73 -0
  69. saltext_github-1.1.0.dist-info/WHEEL +5 -0
  70. saltext_github-1.1.0.dist-info/entry_points.txt +2 -0
  71. saltext_github-1.1.0.dist-info/licenses/LICENSE +201 -0
  72. saltext_github-1.1.0.dist-info/licenses/NOTICE +10 -0
  73. saltext_github-1.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,241 @@
1
+ """
2
+ Manage the targeted repository's (deployment) environments.
3
+
4
+ .. versionadded:: 1.1.0
5
+
6
+ Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
7
+ repository the job was dispatched to. The ``profile`` parameter
8
+ defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
9
+ """
10
+
11
+ import logging
12
+
13
+ from salt.utils.functools import namespaced_function
14
+
15
+ from saltext.github.utils import filter_fields
16
+ from saltext.github.utils.gh import environments as gh_environments
17
+ from saltext.github.utils.gh import resource as gh_resource
18
+
19
+ log = logging.getLogger(__name__)
20
+
21
+ __func_alias__ = {"list_": "list", "set_": "set"}
22
+
23
+
24
+ _core_args = namespaced_function(gh_resource.core_args, globals())
25
+
26
+
27
+ def list_(*, fields=None, profile=None):
28
+ """
29
+ List the environments of the targeted repository, as a mapping of
30
+ environment name to details.
31
+
32
+ CLI Example:
33
+
34
+ .. code-block:: bash
35
+
36
+ salt 'my-org/my-repo' environment.list
37
+
38
+ fields
39
+ Only include these fields in the output. A single field name
40
+ reduces each entry to the field's value.
41
+
42
+ profile
43
+ Profile configuration name to use. Defaults to the resource
44
+ declaration's profile.
45
+ """
46
+ conn, owner, repo_name = _core_args(profile)
47
+ environments = gh_environments.list_all(conn, repo_name, owner=owner)
48
+ return filter_fields({env["name"]: env for env in environments}, fields)
49
+
50
+
51
+ def get(name, *, profile=None):
52
+ """
53
+ Return the data of a single environment of the targeted repository.
54
+
55
+ CLI Example:
56
+
57
+ .. code-block:: bash
58
+
59
+ salt 'my-org/my-repo' environment.get release
60
+
61
+ name
62
+ Name of the environment.
63
+
64
+ profile
65
+ Profile configuration name to use. Defaults to the resource
66
+ declaration's profile.
67
+ """
68
+ conn, owner, repo_name = _core_args(profile)
69
+ return gh_environments.get(conn, repo_name, name, owner=owner)
70
+
71
+
72
+ def set_(
73
+ name,
74
+ *,
75
+ wait_timer=None,
76
+ prevent_self_review=None,
77
+ reviewers=None,
78
+ deployment_branch_policy=None,
79
+ profile=None,
80
+ ):
81
+ """
82
+ Create or update an environment of the targeted repository,
83
+ replacing its whole configuration. Unspecified settings are reset
84
+ to their defaults. Returns the data of the environment.
85
+
86
+ CLI Example:
87
+
88
+ .. code-block:: bash
89
+
90
+ salt 'my-org/my-repo' environment.set release \\
91
+ deployment_branch_policy='{protected_branches: false, custom_branch_policies: true}'
92
+
93
+ name
94
+ Name of the environment.
95
+
96
+ wait_timer
97
+ Amount of time to delay a job after it is initially triggered,
98
+ in minutes.
99
+
100
+ prevent_self_review
101
+ Prevent a user who created a job from approving it.
102
+
103
+ reviewers
104
+ People or teams that may review jobs that reference the
105
+ environment, as a list of mappings with ``type`` (``User`` or
106
+ ``Team``) and ``id``.
107
+
108
+ deployment_branch_policy
109
+ Type of deployment branch policy for this environment, either
110
+ ``null`` (default) to allow all branches or a mapping with
111
+ ``protected_branches`` and ``custom_branch_policies`` booleans.
112
+ Branch name patterns for custom policies are managed separately,
113
+ see :py:func:`environment.add_branch_policy
114
+ <saltext.github.resources.github.modules.environment.add_branch_policy>`.
115
+
116
+ profile
117
+ Profile configuration name to use. Defaults to the resource
118
+ declaration's profile.
119
+ """
120
+ conn, owner, repo_name = _core_args(profile)
121
+ return gh_environments.set_(
122
+ conn,
123
+ repo_name,
124
+ name,
125
+ wait_timer=wait_timer,
126
+ prevent_self_review=prevent_self_review,
127
+ reviewers=reviewers,
128
+ deployment_branch_policy=deployment_branch_policy,
129
+ owner=owner,
130
+ )
131
+
132
+
133
+ def remove(name, *, profile=None):
134
+ """
135
+ Remove an environment from the targeted repository.
136
+
137
+ CLI Example:
138
+
139
+ .. code-block:: bash
140
+
141
+ salt 'my-org/my-repo' environment.remove release
142
+
143
+ name
144
+ Name of the environment.
145
+
146
+ profile
147
+ Profile configuration name to use. Defaults to the resource
148
+ declaration's profile.
149
+ """
150
+ conn, owner, repo_name = _core_args(profile)
151
+ gh_environments.delete(conn, repo_name, name, owner=owner)
152
+ return True
153
+
154
+
155
+ def list_branch_policies(environment, *, fields=None, profile=None):
156
+ """
157
+ List the deployment branch policies of an environment of the
158
+ targeted repository.
159
+
160
+ CLI Example:
161
+
162
+ .. code-block:: bash
163
+
164
+ salt 'my-org/my-repo' environment.list_branch_policies release
165
+
166
+ environment
167
+ Name of the environment.
168
+
169
+ fields
170
+ Only include these fields in the output. A single field name
171
+ reduces each entry to the field's value.
172
+
173
+ profile
174
+ Profile configuration name to use. Defaults to the resource
175
+ declaration's profile.
176
+ """
177
+ conn, owner, repo_name = _core_args(profile)
178
+ return filter_fields(
179
+ gh_environments.list_branch_policies(conn, repo_name, environment, owner=owner),
180
+ fields,
181
+ )
182
+
183
+
184
+ def add_branch_policy(environment, name, *, typ="branch", profile=None):
185
+ """
186
+ Add a deployment branch (or tag) policy to an environment of the
187
+ targeted repository. Returns the data of the created policy.
188
+
189
+ The environment's ``deployment_branch_policy`` must have ``custom_branch_policies`` enabled.
190
+
191
+ CLI Example:
192
+
193
+ .. code-block:: bash
194
+
195
+ salt 'my-org/my-repo' environment.add_branch_policy release main
196
+
197
+ environment
198
+ Name of the environment.
199
+
200
+ name
201
+ Name pattern that branches (or tags) must match in order to
202
+ deploy to the environment.
203
+
204
+ typ
205
+ Target of this rule, either ``branch`` or ``tag``.
206
+ Defaults to ``branch``.
207
+
208
+ profile
209
+ Profile configuration name to use. Defaults to the resource
210
+ declaration's profile.
211
+ """
212
+ conn, owner, repo_name = _core_args(profile)
213
+ return gh_environments.create_branch_policy(
214
+ conn, repo_name, environment, name, typ=typ, owner=owner
215
+ )
216
+
217
+
218
+ def remove_branch_policy(environment, policy_id, *, profile=None):
219
+ """
220
+ Remove a deployment branch policy from an environment of the
221
+ targeted repository.
222
+
223
+ CLI Example:
224
+
225
+ .. code-block:: bash
226
+
227
+ salt 'my-org/my-repo' environment.remove_branch_policy release 12345
228
+
229
+ environment
230
+ Name of the environment.
231
+
232
+ policy_id
233
+ ID of the branch policy.
234
+
235
+ profile
236
+ Profile configuration name to use. Defaults to the resource
237
+ declaration's profile.
238
+ """
239
+ conn, owner, repo_name = _core_args(profile)
240
+ gh_environments.delete_branch_policy(conn, repo_name, environment, policy_id, owner=owner)
241
+ return True
@@ -0,0 +1,18 @@
1
+ """
2
+ Re-expose all builtin read-only ``grains`` functions in the ``github`` resource context.
3
+ """
4
+
5
+ import salt.modules.grains
6
+ from salt.utils.functools import namespaced_function
7
+
8
+ global_dict = globals()
9
+
10
+ equals = namespaced_function(salt.modules.grains.equals, global_dict)
11
+ filter_by = namespaced_function(salt.modules.grains.filter_by, global_dict)
12
+ get = namespaced_function(salt.modules.grains.get, global_dict)
13
+ has_value = namespaced_function(salt.modules.grains.has_value, global_dict)
14
+ item = namespaced_function(salt.modules.grains.item, global_dict)
15
+ items = namespaced_function(salt.modules.grains.items, global_dict)
16
+ ls = namespaced_function(salt.modules.grains.ls, global_dict)
17
+
18
+ fetch = get
@@ -0,0 +1,157 @@
1
+ """
2
+ Inspect the targeted repository's issues (read-only).
3
+
4
+ .. versionadded:: 1.1.0
5
+
6
+ Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
7
+ repository the job was dispatched to. The ``profile`` parameter
8
+ defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
9
+ """
10
+
11
+ import logging
12
+
13
+ from salt.utils.functools import namespaced_function
14
+
15
+ from saltext.github.utils import filter_fields
16
+ from saltext.github.utils.gh import issues as gh_issues
17
+ from saltext.github.utils.gh import resource as gh_resource
18
+
19
+ log = logging.getLogger(__name__)
20
+
21
+ __func_alias__ = {"list_": "list"}
22
+
23
+
24
+ _core_args = namespaced_function(gh_resource.core_args, globals())
25
+
26
+
27
+ def list_(
28
+ *,
29
+ milestone=None,
30
+ state="open",
31
+ assignee=None,
32
+ creator=None,
33
+ mentioned=None,
34
+ labels=None,
35
+ sort="created",
36
+ direction="desc",
37
+ since=None,
38
+ per_page=None,
39
+ fields=None,
40
+ profile=None,
41
+ ):
42
+ """
43
+ Return the issues in the targeted repository, based on the search
44
+ options. Pull requests are excluded.
45
+
46
+ CLI Example:
47
+
48
+ .. code-block:: bash
49
+
50
+ salt 'my-org/my-repo' issue.list
51
+
52
+ milestone
53
+ Number of a GitHub milestone, or a string of either ``*`` or ``none``.
54
+
55
+ state
56
+ Filter returned issues by their state. Can be either ``open``,
57
+ ``closed``, or ``all``. Default is ``open``.
58
+
59
+ assignee
60
+ Filter returned issues by assigned user handle. Pass ``none`` (as a string) for issues
61
+ with no assigned user or ``*`` for issues assigned to any user.
62
+
63
+ creator
64
+ Filter by the username that created the issue.
65
+
66
+ mentioned
67
+ Filter issues for a user that's mentioned in the issue.
68
+
69
+ labels
70
+ Filter issues by associated labels. String of comma separated label names.
71
+ For example, ``bug,ui,@high``.
72
+
73
+ sort
74
+ Field to sort results by. Either ``created``, ``updated``, or
75
+ ``comments``. Default is ``created``.
76
+
77
+ direction
78
+ Sort direction. Either ``asc`` or ``desc``. Default is ``desc``.
79
+
80
+ since
81
+ Only list issues updated at or after this time. This is a
82
+ timestamp in ISO 8601 format: ``YYYY-MM-DDTHH:MM:SSZ``.
83
+
84
+ per_page
85
+ Pagination size, maximum 100.
86
+
87
+ fields
88
+ Only include these fields in the output. A single field name
89
+ reduces each entry to the field's value.
90
+
91
+ profile
92
+ Profile configuration name to use. Defaults to the resource
93
+ declaration's profile.
94
+ """
95
+ conn, owner, repo_name = _core_args(profile)
96
+ issues = gh_issues.list_all(
97
+ conn,
98
+ repo_name,
99
+ milestone=milestone,
100
+ state=state,
101
+ assignee=assignee,
102
+ creator=creator,
103
+ mentioned=mentioned,
104
+ labels=labels,
105
+ sort=sort,
106
+ direction=direction,
107
+ since=since,
108
+ per_page=per_page,
109
+ owner=owner,
110
+ )
111
+ return filter_fields(issues, fields)
112
+
113
+
114
+ def get(number, *, profile=None):
115
+ """
116
+ Return information about a single issue in the targeted repository.
117
+
118
+ CLI Example:
119
+
120
+ .. code-block:: bash
121
+
122
+ salt 'my-org/my-repo' issue.get 514
123
+
124
+ number
125
+ Issue number to retrieve.
126
+
127
+ profile
128
+ Profile configuration name to use. Defaults to the resource
129
+ declaration's profile.
130
+ """
131
+ conn, owner, repo_name = _core_args(profile)
132
+ return gh_issues.get(conn, repo_name, number, owner=owner)
133
+
134
+
135
+ def get_comments(number, *, since=None, profile=None):
136
+ """
137
+ Return the comments of an issue in the targeted repository.
138
+
139
+ CLI Example:
140
+
141
+ .. code-block:: bash
142
+
143
+ salt 'my-org/my-repo' issue.get_comments 514
144
+
145
+ number
146
+ Issue number for which to retrieve comments.
147
+
148
+ since
149
+ Only return comments updated at or after this time. This is a
150
+ timestamp in ISO 8601 format: ``YYYY-MM-DDTHH:MM:SSZ``.
151
+
152
+ profile
153
+ Profile configuration name to use. Defaults to the resource
154
+ declaration's profile.
155
+ """
156
+ conn, owner, repo_name = _core_args(profile)
157
+ return gh_issues.get_comments(conn, repo_name, number, since=since, owner=owner)
@@ -0,0 +1,161 @@
1
+ """
2
+ Manage the targeted repository's labels.
3
+
4
+ .. versionadded:: 1.1.0
5
+
6
+ Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
7
+ repository the job was dispatched to. The ``profile`` parameter
8
+ defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
9
+ """
10
+
11
+ import logging
12
+
13
+ from salt.utils.functools import namespaced_function
14
+
15
+ from saltext.github.utils import filter_fields
16
+ from saltext.github.utils.gh import labels as gh_labels
17
+ from saltext.github.utils.gh import resource as gh_resource
18
+
19
+ log = logging.getLogger(__name__)
20
+
21
+ __func_alias__ = {"list_": "list"}
22
+
23
+
24
+ _core_args = namespaced_function(gh_resource.core_args, globals())
25
+
26
+
27
+ def list_(*, fields=None, profile=None):
28
+ """
29
+ List the labels of the targeted repository, as a mapping of label
30
+ name to details.
31
+
32
+ CLI Example:
33
+
34
+ .. code-block:: bash
35
+
36
+ salt 'my-org/my-repo' label.list
37
+
38
+ fields
39
+ Only include these fields in the output. A single field name
40
+ reduces each entry to the field's value.
41
+
42
+ profile
43
+ Profile configuration name to use. Defaults to the resource
44
+ declaration's profile.
45
+ """
46
+ conn, owner, repo_name = _core_args(profile)
47
+ labels = gh_labels.list_all(conn, repo_name, owner=owner)
48
+ return filter_fields({label["name"]: label for label in labels}, fields)
49
+
50
+
51
+ def get(name, *, profile=None):
52
+ """
53
+ Return the data of a single label of the targeted repository.
54
+
55
+ CLI Example:
56
+
57
+ .. code-block:: bash
58
+
59
+ salt 'my-org/my-repo' label.get bug
60
+
61
+ name
62
+ Name of the label.
63
+
64
+ profile
65
+ Profile configuration name to use. Defaults to the resource
66
+ declaration's profile.
67
+ """
68
+ conn, owner, repo_name = _core_args(profile)
69
+ return gh_labels.get(conn, repo_name, name, owner=owner)
70
+
71
+
72
+ def add(name, *, color=None, description=None, profile=None):
73
+ """
74
+ Create a label in the targeted repository.
75
+ Returns the data of the created label.
76
+
77
+ CLI Example:
78
+
79
+ .. code-block:: bash
80
+
81
+ salt 'my-org/my-repo' label.add release color=00ff00
82
+
83
+ name
84
+ Name of the label.
85
+
86
+ color
87
+ Hexadecimal color code for the label, without the leading ``#``.
88
+ If unset, GitHub assigns a random one.
89
+
90
+ description
91
+ Short description of the label.
92
+
93
+ profile
94
+ Profile configuration name to use. Defaults to the resource
95
+ declaration's profile.
96
+ """
97
+ conn, owner, repo_name = _core_args(profile)
98
+ return gh_labels.create(
99
+ conn, repo_name, name, color=color, description=description, owner=owner
100
+ )
101
+
102
+
103
+ def edit(name, *, new_name=None, color=None, description=None, profile=None):
104
+ """
105
+ Update an existing label of the targeted repository.
106
+ Returns the data of the updated label.
107
+
108
+ CLI Example:
109
+
110
+ .. code-block:: bash
111
+
112
+ salt 'my-org/my-repo' label.edit release color=00ff00
113
+
114
+ name
115
+ Current name of the label.
116
+
117
+ new_name
118
+ New name for the label.
119
+
120
+ color
121
+ Hexadecimal color code for the label, without the leading ``#``.
122
+
123
+ description
124
+ Short description of the label.
125
+
126
+ profile
127
+ Profile configuration name to use. Defaults to the resource
128
+ declaration's profile.
129
+ """
130
+ conn, owner, repo_name = _core_args(profile)
131
+ return gh_labels.update(
132
+ conn,
133
+ repo_name,
134
+ name,
135
+ new_name=new_name,
136
+ color=color,
137
+ description=description,
138
+ owner=owner,
139
+ )
140
+
141
+
142
+ def remove(name, *, profile=None):
143
+ """
144
+ Delete a label from the targeted repository.
145
+
146
+ CLI Example:
147
+
148
+ .. code-block:: bash
149
+
150
+ salt 'my-org/my-repo' label.remove release
151
+
152
+ name
153
+ Name of the label.
154
+
155
+ profile
156
+ Profile configuration name to use. Defaults to the resource
157
+ declaration's profile.
158
+ """
159
+ conn, owner, repo_name = _core_args(profile)
160
+ gh_labels.delete(conn, repo_name, name, owner=owner)
161
+ return True
@@ -0,0 +1,103 @@
1
+ """
2
+ Inspect the targeted repository's milestones (read-only).
3
+
4
+ .. versionadded:: 1.1.0
5
+
6
+ Part of the :py:mod:`github <saltext.github.resources.github>` resource type: all functions operate on the
7
+ repository the job was dispatched to. The ``profile`` parameter
8
+ defaults to the :ghconf:`profile <resource:profile>` named in the resource declaration.
9
+ """
10
+
11
+ import logging
12
+
13
+ from salt.exceptions import CommandExecutionError
14
+ from salt.utils.functools import namespaced_function
15
+
16
+ from saltext.github.utils import filter_fields
17
+ from saltext.github.utils.gh import milestones as gh_milestones
18
+ from saltext.github.utils.gh import resource as gh_resource
19
+
20
+ log = logging.getLogger(__name__)
21
+
22
+ __func_alias__ = {"list_": "list"}
23
+
24
+
25
+ _core_args = namespaced_function(gh_resource.core_args, globals())
26
+
27
+
28
+ def list_(
29
+ *, state="open", sort="due_on", direction="asc", per_page=None, fields=None, profile=None
30
+ ):
31
+ """
32
+ Return the targeted repository's milestones.
33
+
34
+ CLI Example:
35
+
36
+ .. code-block:: bash
37
+
38
+ salt 'my-org/my-repo' milestone.list
39
+
40
+ state
41
+ Filter milestones by their state. Either ``open``, ``closed``, or ``all``.
42
+ Default is ``open``.
43
+
44
+ sort
45
+ Field to sort results by. Either ``due_on`` or ``completeness``. Default
46
+ is ``due_on``.
47
+
48
+ direction
49
+ Sort direction. Either ``asc`` or ``desc``. Default is ``asc``.
50
+
51
+ per_page
52
+ Pagination size, maximum 100.
53
+
54
+ fields
55
+ Only include these fields in the output. A single field name
56
+ reduces each entry to the field's value.
57
+
58
+ profile
59
+ Profile configuration name to use. Defaults to the resource
60
+ declaration's profile.
61
+ """
62
+ conn, owner, repo_name = _core_args(profile)
63
+ milestones = gh_milestones.list_all(
64
+ conn,
65
+ repo_name,
66
+ state=state,
67
+ sort=sort,
68
+ direction=direction,
69
+ per_page=per_page,
70
+ owner=owner,
71
+ )
72
+ return filter_fields(milestones, fields)
73
+
74
+
75
+ def get(number=None, *, name=None, profile=None):
76
+ """
77
+ Return information about a single milestone in the targeted
78
+ repository.
79
+
80
+ CLI Example:
81
+
82
+ .. code-block:: bash
83
+
84
+ salt 'my-org/my-repo' milestone.get 72
85
+ salt 'my-org/my-repo' milestone.get name=my_milestone
86
+
87
+ number
88
+ Milestone number to retrieve. If provided, overrides ``name``.
89
+
90
+ name
91
+ Title of the milestone to retrieve.
92
+
93
+ profile
94
+ Profile configuration name to use. Defaults to the resource
95
+ declaration's profile.
96
+ """
97
+ if not (number or name):
98
+ raise CommandExecutionError("Either a milestone 'name' or 'number' must be provided.")
99
+
100
+ conn, owner, repo_name = _core_args(profile)
101
+ if number:
102
+ return gh_milestones.get(conn, repo_name, number, owner=owner)
103
+ return gh_milestones.find_by_title(conn, repo_name, name, owner=owner)