From 5de64eef4d8dcf88ac3dd6445fee82a2debdacd3 Mon Sep 17 00:00:00 2001 From: Li-Yu Yu Date: Wed, 21 Sep 2022 23:54:30 +0800 Subject: [PATCH] changes: Add RemoveAttention (#124) --- changes.go | 25 ------------------------- changes_attention.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 changes_attention.go diff --git a/changes.go b/changes.go index bb78868..788dfe4 100644 --- a/changes.go +++ b/changes.go @@ -354,31 +354,6 @@ type FixReplacementInfo struct { Replacement string `json:"replacement,omitempty"` } -// AttentionSetInfo entity contains details of users that are in the attention set. -// -// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#attention-set-info -type AttentionSetInfo struct { - // AccountInfo entity. - Account AccountInfo `json:"account"` - // The timestamp of the last update. - LastUpdate Timestamp `json:"last_update"` - // The reason of for adding or removing the user. - Reason string `json:"reason"` -} -// Doc: https://gerrit-review.googlesource.com/Documentation/user-notify.html#recipient-types -type RecipientType string - -// AttentionSetInput entity contains details for adding users to the attention -// set and removing them from it. -// -// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#attention-set-input -type AttentionSetInput struct { - User string `json:"user,omitempty"` - Reason string `json:"reason"` - Notify string `json:"notify,omitempty"` - NotifyDetails map[RecipientType]NotifyInfo `json:"notify_details,omitempty"` -} - // DiffIntralineInfo entity contains information about intraline edits in a file. // // The information consists of a list of pairs, diff --git a/changes_attention.go b/changes_attention.go new file mode 100644 index 0000000..5b489b7 --- /dev/null +++ b/changes_attention.go @@ -0,0 +1,40 @@ +package gerrit + +import "fmt" + +// AttentionSetInfo entity contains details of users that are in the attention set. +// +// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#attention-set-info +type AttentionSetInfo struct { + // AccountInfo entity. + Account AccountInfo `json:"account"` + // The timestamp of the last update. + LastUpdate Timestamp `json:"last_update"` + // The reason of for adding or removing the user. + Reason string `json:"reason"` +} + +// Doc: https://gerrit-review.googlesource.com/Documentation/user-notify.html#recipient-types +type RecipientType string + +// AttentionSetInput entity contains details for adding users to the attention +// set and removing them from it. +// +// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#attention-set-input +type AttentionSetInput struct { + User string `json:"user,omitempty"` + Reason string `json:"reason"` + Notify string `json:"notify,omitempty"` + NotifyDetails map[RecipientType]NotifyInfo `json:"notify_details,omitempty"` +} + +// RemoveAttention deletes a single user from the attention set of a change. +// +// AttentionSetInput.Input must be provided +// +// https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#remove-from-attention-set +func (s *ChangesService) RemoveAttention(changeID, accountID string, input *AttentionSetInput) (*Response, error) { + u := fmt.Sprintf("changes/%s/attention/%s", changeID, accountID) + + return s.client.DeleteRequest(u, input) +}