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

tylernathanreed / jira-client-php / 13834920235

13 Mar 2025 12:45PM UTC coverage: 71.089% (-2.2%) from 73.289%
13834920235

push

github

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

3976 of 5593 relevant lines covered (71.09%)

9.76 hits per line

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

70.49
/src/Operations/IssueCustomFieldOptions.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 IssueCustomFieldOptions
10
{
11
    /**
12
     * Returns a custom field option.
13
     * For example, an option in a select list
14
     * 
15
     * Note that this operation **only works for issue field select list options created in Jira or using operations from the "Issue custom field options" resource**, it cannot be used with issue field select list options created by Connect apps
16
     * 
17
     * This operation can be accessed anonymously
18
     * 
19
     * **"Permissions" required:** The custom field option is returned as follows:
20
     * 
21
     *  - if the user has the *Administer Jira* "global permission"
22
     *  - if the user has the *Browse projects* "project permission" for at least one project the custom field is used in, and the field is visible in at least one layout the user has permission to view.
23
     * 
24
     * @link https://confluence.atlassian.com/x/x4dKLg
25
     * @link https://confluence.atlassian.com/x/yodKLg
26
     * 
27
     * @param string $id The ID of the custom field option.
28
     */
29
    public function getCustomFieldOption(
1✔
30
        string $id,
31
    ): Schema\CustomFieldOption {
32
        return $this->call(
1✔
33
            uri: '/rest/api/3/customFieldOption/{id}',
1✔
34
            method: 'get',
1✔
35
            path: compact('id'),
1✔
36
            success: 200,
1✔
37
            schema: Schema\CustomFieldOption::class,
1✔
38
        );
1✔
39
    }
40

41
    /**
42
     * Returns a "paginated" list of all custom field option for a context.
43
     * Options are returned first then cascading options, in the order they display in Jira
44
     * 
45
     * This operation works for custom field options created in Jira or the operations from this resource.
46
     * **To work with issue field select list options created for Connect apps use the "Issue custom field options (apps)" operations.**
47
     * 
48
     * **"Permissions" required:** *Administer Jira* "global permission".
49
     * 
50
     * @link https://confluence.atlassian.com/x/x4dKLg
51
     * 
52
     * @param string $fieldId The ID of the custom field.
53
     * @param int $contextId The ID of the context.
54
     * @param int $optionId The ID of the option.
55
     * @param bool $onlyOptions Whether only options are returned.
56
     * @param int $startAt The index of the first item to return in a page of results (page offset).
57
     * @param int $maxResults The maximum number of items to return per page.
58
     */
59
    public function getOptionsForContext(
×
60
        string $fieldId,
61
        int $contextId,
62
        ?int $optionId = null,
63
        ?bool $onlyOptions = false,
64
        ?int $startAt = 0,
65
        ?int $maxResults = 100,
66
    ): Schema\PageBeanCustomFieldContextOption {
67
        return $this->call(
×
68
            uri: '/rest/api/3/field/{fieldId}/context/{contextId}/option',
×
69
            method: 'get',
×
70
            query: compact('optionId', 'onlyOptions', 'startAt', 'maxResults'),
×
71
            path: compact('fieldId', 'contextId'),
×
72
            success: 200,
×
73
            schema: Schema\PageBeanCustomFieldContextOption::class,
×
74
        );
×
75
    }
76

77
    /**
78
     * Updates the options of a custom field
79
     * 
80
     * If any of the options are not found, no options are updated.
81
     * Options where the values in the request match the current values aren't updated and aren't reported in the response
82
     * 
83
     * Note that this operation **only works for issue field select list options created in Jira or using operations from the "Issue custom field options" resource**, it cannot be used with issue field select list options created by Connect apps
84
     * 
85
     * **"Permissions" required:** *Administer Jira* "global permission".
86
     * 
87
     * @link https://confluence.atlassian.com/x/x4dKLg
88
     * 
89
     * @param string $fieldId The ID of the custom field.
90
     * @param int $contextId The ID of the context.
91
     */
92
    public function updateCustomFieldOption(
1✔
93
        Schema\BulkCustomFieldOptionUpdateRequest $request,
94
        string $fieldId,
95
        int $contextId,
96
    ): Schema\CustomFieldUpdatedContextOptionsList {
97
        return $this->call(
1✔
98
            uri: '/rest/api/3/field/{fieldId}/context/{contextId}/option',
1✔
99
            method: 'put',
1✔
100
            body: $request,
1✔
101
            path: compact('fieldId', 'contextId'),
1✔
102
            success: 200,
1✔
103
            schema: Schema\CustomFieldUpdatedContextOptionsList::class,
1✔
104
        );
1✔
105
    }
106

107
    /**
108
     * Creates options and, where the custom select field is of the type Select List (cascading), cascading options for a custom select field.
109
     * The options are added to a context of the field
110
     * 
111
     * The maximum number of options that can be created per request is 1000 and each field can have a maximum of 10000 options
112
     * 
113
     * This operation works for custom field options created in Jira or the operations from this resource.
114
     * **To work with issue field select list options created for Connect apps use the "Issue custom field options (apps)" operations.**
115
     * 
116
     * **"Permissions" required:** *Administer Jira* "global permission".
117
     * 
118
     * @link https://confluence.atlassian.com/x/x4dKLg
119
     * 
120
     * @param string $fieldId The ID of the custom field.
121
     * @param int $contextId The ID of the context.
122
     */
123
    public function createCustomFieldOption(
1✔
124
        Schema\BulkCustomFieldOptionCreateRequest $request,
125
        string $fieldId,
126
        int $contextId,
127
    ): Schema\CustomFieldCreatedContextOptionsList {
128
        return $this->call(
1✔
129
            uri: '/rest/api/3/field/{fieldId}/context/{contextId}/option',
1✔
130
            method: 'post',
1✔
131
            body: $request,
1✔
132
            path: compact('fieldId', 'contextId'),
1✔
133
            success: 200,
1✔
134
            schema: Schema\CustomFieldCreatedContextOptionsList::class,
1✔
135
        );
1✔
136
    }
137

138
    /**
139
     * Changes the order of custom field options or cascading options in a context
140
     * 
141
     * This operation works for custom field options created in Jira or the operations from this resource.
142
     * **To work with issue field select list options created for Connect apps use the "Issue custom field options (apps)" operations.**
143
     * 
144
     * **"Permissions" required:** *Administer Jira* "global permission".
145
     * 
146
     * @link https://confluence.atlassian.com/x/x4dKLg
147
     * 
148
     * @param string $fieldId The ID of the custom field.
149
     * @param int $contextId The ID of the context.
150
     */
151
    public function reorderCustomFieldOptions(
1✔
152
        Schema\OrderOfCustomFieldOptions $request,
153
        string $fieldId,
154
        int $contextId,
155
    ): true {
156
        return $this->call(
1✔
157
            uri: '/rest/api/3/field/{fieldId}/context/{contextId}/option/move',
1✔
158
            method: 'put',
1✔
159
            body: $request,
1✔
160
            path: compact('fieldId', 'contextId'),
1✔
161
            success: 204,
1✔
162
            schema: true,
1✔
163
        );
1✔
164
    }
165

166
    /**
167
     * Deletes a custom field option
168
     * 
169
     * Options with cascading options cannot be deleted without deleting the cascading options first
170
     * 
171
     * This operation works for custom field options created in Jira or the operations from this resource.
172
     * **To work with issue field select list options created for Connect apps use the "Issue custom field options (apps)" operations.**
173
     * 
174
     * **"Permissions" required:** *Administer Jira* "global permission".
175
     * 
176
     * @link https://confluence.atlassian.com/x/x4dKLg
177
     * 
178
     * @param string $fieldId The ID of the custom field.
179
     * @param int $contextId The ID of the context from which an option should be deleted.
180
     * @param int $optionId The ID of the option to delete.
181
     */
182
    public function deleteCustomFieldOption(
1✔
183
        string $fieldId,
184
        int $contextId,
185
        int $optionId,
186
    ): true {
187
        return $this->call(
1✔
188
            uri: '/rest/api/3/field/{fieldId}/context/{contextId}/option/{optionId}',
1✔
189
            method: 'delete',
1✔
190
            path: compact('fieldId', 'contextId', 'optionId'),
1✔
191
            success: 204,
1✔
192
            schema: true,
1✔
193
        );
1✔
194
    }
195

196
    /**
197
     * Replaces the options of a custom field
198
     * 
199
     * Note that this operation **only works for issue field select list options created in Jira or using operations from the "Issue custom field options" resource**, it cannot be used with issue field select list options created by Connect or Forge apps
200
     * 
201
     * **"Permissions" required:** *Administer Jira* "global permission".
202
     * 
203
     * @link https://confluence.atlassian.com/x/x4dKLg
204
     * 
205
     * @param string $fieldId The ID of the custom field.
206
     * @param int $optionId The ID of the option to be deselected.
207
     * @param int $contextId The ID of the context.
208
     * @param int $replaceWith The ID of the option that will replace the currently selected option.
209
     * @param string $jql A JQL query that specifies the issues to be updated.
210
     *                    For example, *project=10000*.
211
     */
212
    public function replaceCustomFieldOption(
×
213
        string $fieldId,
214
        int $optionId,
215
        int $contextId,
216
        ?int $replaceWith = null,
217
        ?string $jql = null,
218
    ): Schema\TaskProgressBeanRemoveOptionFromIssuesResult {
219
        return $this->call(
×
220
            uri: '/rest/api/3/field/{fieldId}/context/{contextId}/option/{optionId}/issue',
×
221
            method: 'delete',
×
222
            query: compact('replaceWith', 'jql'),
×
223
            path: compact('fieldId', 'optionId', 'contextId'),
×
224
            success: 303,
×
225
            schema: Schema\TaskProgressBeanRemoveOptionFromIssuesResult::class,
×
226
        );
×
227
    }
228
}
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