• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tylernathanreed / jira-client-php / 13678007438

05 Mar 2025 02:15PM UTC coverage: 2.081% (+0.01%) from 2.067%
13678007438

push

github

tylernathanreed
Merge branch 'master' of github.com:tylernathanreed/jira-client-php

141 of 6775 relevant lines covered (2.08%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Operations/ProjectComponents.php
1
<?php
2

3
namespace Jira\Client\Operations;
4

5
use Jira\Client\Client;
6
use Jira\Client\Schema;
7

8
/** @phpstan-require-extends Client */
9
trait ProjectComponents
10
{
11
    /**
12
     * Returns a "paginated" list of all components in a project, including global (Compass) components when applicable
13
     * 
14
     * This operation can be accessed anonymously
15
     * 
16
     * **"Permissions" required:** *Browse Projects* "project permission" for the project.
17
     * 
18
     * @link https://confluence.atlassian.com/x/yodKLg
19
     * 
20
     * @param ?list<string> $projectIdsOrKeys The project IDs and/or project keys (case sensitive).
21
     * @param int $startAt The index of the first item to return in a page of results (page offset).
22
     * @param int $maxResults The maximum number of items to return per page.
23
     * @param 'description'|'-description'|'+description'|'name'|'-name'|'+name'|null $orderBy
24
     *        "Order" the results by a field:
25
     *         - `description` Sorts by the component description
26
     *         - `name` Sorts by component name.
27
     * @param string $query Filter the results using a literal string.
28
     *                      Components with a matching `name` or `description` are returned (case insensitive).
29
     */
30
    public function findComponentsForProjects(
×
31
        ?array $projectIdsOrKeys = null,
32
        ?int $startAt = 0,
33
        ?int $maxResults = 50,
34
        ?string $orderBy = null,
35
        ?string $query = null,
36
    ): Schema\PageBean2ComponentJsonBean {
37
        return $this->call(
×
38
            uri: '/rest/api/3/component',
×
39
            method: 'get',
×
40
            query: compact('projectIdsOrKeys', 'startAt', 'maxResults', 'orderBy', 'query'),
×
41
            success: 200,
×
42
            schema: Schema\PageBean2ComponentJsonBean::class,
×
43
        );
×
44
    }
45

46
    /**
47
     * Creates a component.
48
     * Use components to provide containers for issues within a project.
49
     * Use components to provide containers for issues within a project
50
     * 
51
     * This operation can be accessed anonymously
52
     * 
53
     * **"Permissions" required:** *Administer projects* "project permission" for the project in which the component is created or *Administer Jira* "global permission".
54
     * 
55
     * @link https://confluence.atlassian.com/x/yodKLg
56
     * @link https://confluence.atlassian.com/x/x4dKLg
57
     */
58
    public function createComponent(
×
59
        Schema\ProjectComponent $request,
60
    ): Schema\ProjectComponent {
61
        return $this->call(
×
62
            uri: '/rest/api/3/component',
×
63
            method: 'post',
×
64
            body: $request,
×
65
            success: 201,
×
66
            schema: Schema\ProjectComponent::class,
×
67
        );
×
68
    }
69

70
    /**
71
     * Returns a component
72
     * 
73
     * This operation can be accessed anonymously
74
     * 
75
     * **"Permissions" required:** *Browse projects* "project permission" for project containing the component.
76
     * 
77
     * @link https://confluence.atlassian.com/x/yodKLg
78
     * 
79
     * @param string $id The ID of the component.
80
     */
81
    public function getComponent(
×
82
        string $id,
83
    ): Schema\ProjectComponent {
84
        return $this->call(
×
85
            uri: '/rest/api/3/component/{id}',
×
86
            method: 'get',
×
87
            path: compact('id'),
×
88
            success: 200,
×
89
            schema: Schema\ProjectComponent::class,
×
90
        );
×
91
    }
92

93
    /**
94
     * Updates a component.
95
     * Any fields included in the request are overwritten.
96
     * If `leadAccountId` is an empty string ("") the component lead is removed
97
     * 
98
     * This operation can be accessed anonymously
99
     * 
100
     * **"Permissions" required:** *Administer projects* "project permission" for the project containing the component or *Administer Jira* "global permission".
101
     * 
102
     * @link https://confluence.atlassian.com/x/yodKLg
103
     * @link https://confluence.atlassian.com/x/x4dKLg
104
     * 
105
     * @param string $id The ID of the component.
106
     */
107
    public function updateComponent(
×
108
        Schema\ProjectComponent $request,
109
        string $id,
110
    ): Schema\ProjectComponent {
111
        return $this->call(
×
112
            uri: '/rest/api/3/component/{id}',
×
113
            method: 'put',
×
114
            body: $request,
×
115
            path: compact('id'),
×
116
            success: 200,
×
117
            schema: Schema\ProjectComponent::class,
×
118
        );
×
119
    }
120

121
    /**
122
     * Deletes a component
123
     * 
124
     * This operation can be accessed anonymously
125
     * 
126
     * **"Permissions" required:** *Administer projects* "project permission" for the project containing the component or *Administer Jira* "global permission".
127
     * 
128
     * @link https://confluence.atlassian.com/x/yodKLg
129
     * @link https://confluence.atlassian.com/x/x4dKLg
130
     * 
131
     * @param string $id The ID of the component.
132
     * @param string $moveIssuesTo The ID of the component to replace the deleted component.
133
     *                             If this value is null no replacement is made.
134
     */
135
    public function deleteComponent(
×
136
        string $id,
137
        ?string $moveIssuesTo = null,
138
    ): true {
139
        return $this->call(
×
140
            uri: '/rest/api/3/component/{id}',
×
141
            method: 'delete',
×
142
            query: compact('moveIssuesTo'),
×
143
            path: compact('id'),
×
144
            success: 204,
×
145
            schema: true,
×
146
        );
×
147
    }
148

149
    /**
150
     * Returns the counts of issues assigned to the component
151
     * 
152
     * This operation can be accessed anonymously
153
     * 
154
     * **Deprecation notice:** The required OAuth 2.0 scopes will be updated on June 15, 2024
155
     * 
156
     *  - **Classic**: `read:jira-work`
157
     *  - **Granular**: `read:field:jira`, `read:project.component:jira`
158
     * 
159
     * **"Permissions" required:** None.
160
     * 
161
     * @param string $id The ID of the component.
162
     */
163
    public function getComponentRelatedIssues(
×
164
        string $id,
165
    ): Schema\ComponentIssuesCount {
166
        return $this->call(
×
167
            uri: '/rest/api/3/component/{id}/relatedIssueCounts',
×
168
            method: 'get',
×
169
            path: compact('id'),
×
170
            success: 200,
×
171
            schema: Schema\ComponentIssuesCount::class,
×
172
        );
×
173
    }
174

175
    /**
176
     * Returns a "paginated" list of all components in a project.
177
     * See the "Get project components" resource if you want to get a full list of versions without pagination
178
     * 
179
     * If your project uses Compass components, this API will return a list of Compass components that are linked to issues in that project
180
     * 
181
     * This operation can be accessed anonymously
182
     * 
183
     * **"Permissions" required:** *Browse Projects* "project permission" for the project.
184
     * 
185
     * @link https://confluence.atlassian.com/x/yodKLg
186
     * 
187
     * @param string $projectIdOrKey The project ID or project key (case sensitive).
188
     * @param int $startAt The index of the first item to return in a page of results (page offset).
189
     * @param int $maxResults The maximum number of items to return per page.
190
     * @param 'description'|'-description'|'+description'|'issueCount'|'-issueCount'|'+issueCount'|'lead'|'-lead'|'+lead'|'name'|'-name'|'+name'|null $orderBy
191
     *        "Order" the results by a field:
192
     *         - `description` Sorts by the component description
193
     *         - `issueCount` Sorts by the count of issues associated with the component
194
     *         - `lead` Sorts by the user key of the component's project lead
195
     *         - `name` Sorts by component name.
196
     * @param 'jira'|'compass'|'auto'|null $componentSource
197
     *        The source of the components to return.
198
     *        Can be `jira` (default), `compass` or `auto`.
199
     *        When `auto` is specified, the API will return connected Compass components if the project is opted into Compass, otherwise it will return Jira components.
200
     *        Defaults to `jira`.
201
     * @param string $query Filter the results using a literal string.
202
     *                      Components with a matching `name` or `description` are returned (case insensitive).
203
     */
204
    public function getProjectComponentsPaginated(
×
205
        string $projectIdOrKey,
206
        ?int $startAt = 0,
207
        ?int $maxResults = 50,
208
        ?string $orderBy = null,
209
        ?string $componentSource = 'jira',
210
        ?string $query = null,
211
    ): Schema\PageBeanComponentWithIssueCount {
212
        return $this->call(
×
213
            uri: '/rest/api/3/project/{projectIdOrKey}/component',
×
214
            method: 'get',
×
215
            query: compact('startAt', 'maxResults', 'orderBy', 'componentSource', 'query'),
×
216
            path: compact('projectIdOrKey'),
×
217
            success: 200,
×
218
            schema: Schema\PageBeanComponentWithIssueCount::class,
×
219
        );
×
220
    }
221

222
    /**
223
     * Returns all components in a project.
224
     * See the "Get project components paginated" resource if you want to get a full list of components with pagination
225
     * 
226
     * If your project uses Compass components, this API will return a paginated list of Compass components that are linked to issues in that project
227
     * 
228
     * This operation can be accessed anonymously
229
     * 
230
     * **"Permissions" required:** *Browse Projects* "project permission" for the project.
231
     * 
232
     * @link https://confluence.atlassian.com/x/yodKLg
233
     * 
234
     * @param string $projectIdOrKey The project ID or project key (case sensitive).
235
     * @param 'jira'|'compass'|'auto'|null $componentSource
236
     *        The source of the components to return.
237
     *        Can be `jira` (default), `compass` or `auto`.
238
     *        When `auto` is specified, the API will return connected Compass components if the project is opted into Compass, otherwise it will return Jira components.
239
     *        Defaults to `jira`.
240
     * 
241
     * @return list<Schema\ProjectComponent>
242
     */
243
    public function getProjectComponents(
×
244
        string $projectIdOrKey,
245
        ?string $componentSource = 'jira',
246
    ): array {
247
        return $this->call(
×
248
            uri: '/rest/api/3/project/{projectIdOrKey}/components',
×
249
            method: 'get',
×
250
            query: compact('componentSource'),
×
251
            path: compact('projectIdOrKey'),
×
252
            success: 200,
×
253
            schema: [Schema\ProjectComponent::class],
×
254
        );
×
255
    }
256
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc