Updates will be applied on October 27th between 12pm - 12:45pm EDT (UTC-0400). Gitlab may be slow during the maintenance window.

Commit ee3f77aa authored by Ben Boeckel's avatar Ben Boeckel
Browse files

api/projects: normalize EditIssue builder API

parent 4f77c3de
......@@ -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
......
......@@ -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_iid_are_necessary() {
fn project_and_issue_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 iid_is_necessary() {
fn issue_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)
......
......@@ -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()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment