Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nicholas Bailey
rust-gitlab
Commits
ee3f77aa
Commit
ee3f77aa
authored
May 27, 2020
by
Ben Boeckel
⛰
Browse files
api/projects: normalize EditIssue builder API
parent
4f77c3de
Changes
3
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
ee3f77aa
...
...
@@ -20,6 +20,11 @@ been added.
*
The
`api::projects::environments::Environment`
endpoint uses the correct
path now.
## Changes
*
The
`api::projects::issues::EditIssue`
now uses
`issue`
rather than
`issue_iid`
for consistency.
# v0.1210.1
## New API strategy
...
...
src/api/projects/issues/edit.rs
View file @
ee3f77aa
...
...
@@ -68,7 +68,7 @@ pub struct EditIssue<'a> {
#[builder(setter(into))]
project
:
NameOrId
<
'a
>
,
/// The internal IID of the issue.
issue
_iid
:
u64
,
issue
:
u64
,
/// The title of the new issue.
#[builder(setter(into),
default)]
...
...
@@ -119,6 +119,13 @@ impl<'a> EditIssue<'a> {
}
impl
<
'a
>
EditIssueBuilder
<
'a
>
{
/// Set the issue ID.
#[deprecated(note
=
"use `issue` instead"
)]
pub
fn
issue_iid
(
&
mut
self
,
issue_iid
:
u64
)
->
&
mut
Self
{
self
.issue
=
Some
(
issue_iid
);
self
}
/// Unassign the issue.
pub
fn
unassign
(
&
mut
self
)
->
&
mut
Self
{
self
.assignee_ids
=
Some
(
Some
(
IssueAssignees
::
Unassigned
));
...
...
@@ -210,7 +217,7 @@ impl<'a> Endpoint for EditIssue<'a> {
}
fn
endpoint
(
&
self
)
->
Cow
<
'static
,
str
>
{
format!
(
"projects/{}/issues/{}"
,
self
.project
,
self
.issue
_iid
)
.into
()
format!
(
"projects/{}/issues/{}"
,
self
.project
,
self
.issue
)
.into
()
}
fn
body
(
&
self
)
->
Result
<
Option
<
(
&
'static
str
,
Vec
<
u8
>
)
>
,
BodyError
>
{
...
...
@@ -265,25 +272,31 @@ mod tests {
}
#[test]
fn
project_and_i
id
_are_necessary
()
{
fn
project_and_i
ssue
_are_necessary
()
{
let
err
=
EditIssue
::
builder
()
.build
()
.unwrap_err
();
assert_eq!
(
err
,
"`project` must be initialized"
);
}
#[test]
fn
project_is_necessary
()
{
let
err
=
EditIssue
::
builder
()
.issue
_iid
(
1
)
.build
()
.unwrap_err
();
let
err
=
EditIssue
::
builder
()
.issue
(
1
)
.build
()
.unwrap_err
();
assert_eq!
(
err
,
"`project` must be initialized"
);
}
#[test]
fn
i
id
_is_necessary
()
{
fn
i
ssue
_is_necessary
()
{
let
err
=
EditIssue
::
builder
()
.project
(
1
)
.build
()
.unwrap_err
();
assert_eq!
(
err
,
"`issue_iid` must be initialized"
);
assert_eq!
(
err
,
"`issue` must be initialized"
);
}
#[test]
fn
project_and_issue_are_sufficient
()
{
EditIssue
::
builder
()
.project
(
1
)
.issue
(
1
)
.build
()
.unwrap
();
}
#[test]
fn
project_and_iid_are_sufficient
()
{
#[allow(deprecated)]
fn
project_and_issue_iid_are_sufficient
()
{
EditIssue
::
builder
()
.project
(
1
)
.issue_iid
(
1
)
...
...
src/gitlab.rs
View file @
ee3f77aa
...
...
@@ -2257,7 +2257,7 @@ impl Gitlab {
pub
fn
close_issue
(
&
self
,
project
:
ProjectId
,
issue
:
IssueInternalId
)
->
GitlabResult
<
Issue
>
{
Ok
(
projects
::
issues
::
EditIssue
::
builder
()
.project
(
project
.value
())
.issue
_iid
(
issue
.value
())
.issue
(
issue
.value
())
.state_event
(
projects
::
issues
::
IssueStateEvent
::
Close
)
.build
()
.unwrap
()
...
...
@@ -2281,7 +2281,7 @@ impl Gitlab {
{
Ok
(
projects
::
issues
::
EditIssue
::
builder
()
.project
(
project
.value
())
.issue
_iid
(
issue
.value
())
.issue
(
issue
.value
())
.labels
(
labels
.into_iter
()
.map
(|
label
|
format!
(
"{}"
,
label
)))
.build
()
.unwrap
()
...
...
@@ -2306,7 +2306,7 @@ impl Gitlab {
{
Ok
(
projects
::
issues
::
EditIssue
::
builder
()
.project
(
project
.as_ref
())
.issue
_iid
(
issue
.value
())
.issue
(
issue
.value
())
.labels
(
labels
.into_iter
()
.map
(|
label
|
format!
(
"{}"
,
label
)))
.build
()
.unwrap
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment