Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of all changes related to servicedesk #566

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions cloud/customer.go

This file was deleted.

36 changes: 36 additions & 0 deletions cloud/groupuserpicker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cloud

import (
"context"
"net/http"

"github.com/andygrunwald/go-jira/v2/cloud/model"
)

// GroupUserPickerService handles Groups for the Jira instance / API.
//
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-group-and-user-picker/
type GroupUserPickerService service

// FindGroupAndUsers
//
// Jira API docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-group-and-user-picker/#api-group-group-and-user-picker
func (s *GroupUserPickerService) FindGroupAndUsers(ctx context.Context, opts model.FindGroupAndUsersQueryOptions) (*model.FoundUsersAndGroups, *Response, error) {
u, err := addOptions("/rest/api/3/groupuserpicker", opts)
if err != nil {
return nil, nil, err
}

req, err := s.client.NewRequest(ctx, http.MethodGet, u, nil)
if err != nil {
return nil, nil, err
}

found := new(model.FoundUsersAndGroups)
resp, err := s.client.Do(req, found)
if err != nil {
return nil, resp, err
}

return found, resp, nil
}
2 changes: 2 additions & 0 deletions cloud/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Client struct {
ServiceDesk *ServiceDeskService
Customer *CustomerService
Request *RequestService
GroupUserPicker *GroupUserPickerService
}

// service is the base structure to bundle API services
Expand Down Expand Up @@ -128,6 +129,7 @@ func NewClient(baseURL string, httpClient *http.Client) (*Client, error) {
c.ServiceDesk = (*ServiceDeskService)(&c.common)
c.Customer = (*CustomerService)(&c.common)
c.Request = (*RequestService)(&c.common)
c.GroupUserPicker = (*GroupUserPickerService)(&c.common)

return c, nil
}
Expand Down
51 changes: 51 additions & 0 deletions cloud/model/groupuserpicker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package model

// FindGroupAndUsersQueryOptions specifies the optional parameters to the Edit issue
type FindGroupAndUsersQueryOptions struct {
Query string `url:"query,omitempty"`
MaxResults int `url:"maxResults,omitempty"`
ShowAvatar bool `url:"showAvatar,omitempty"`
FieldID string `url:"fieldId,omitempty"`
ProjectID []string `url:"projectId,omitempty"`
IssueTypeID []string `url:"issueTypeId,omitempty"`
AvatarSize string `url:"avatarSize,omitempty"`
CaseInsensitive bool `url:"caseInsensitive,omitempty"`
ExcludeConnectAddons bool `url:"excludeConnectAddons,omitempty"`
}

type FoundUsersAndGroups struct {
Users FoundUsers `json:"users"`
Groups FoundGroups `json:"groups"`
}

type FoundUsers struct {
Users []UserPickerUser `json:"users"`
Total int `json:"total"`
Header string `json:"header"`
}

type UserPickerUser struct {
AccountID string `json:"accountId"`
HTML string `json:"html"`
DisplayName string `json:"displayName"`
AvatarURL string `json:"avatarUrl"`
}

type FoundGroups struct {
Groups []FoundGroup `json:"groups"`
Total int `json:"total"`
Header string `json:"header"`
}

type FoundGroup struct {
GroupID string `json:"groupId"`
Name string `json:"name"`
HTML string `json:"html"`
Labels []GroupLabel `json:"labels"`
}

type GroupLabel struct {
Text string `json:"text"`
Title string `json:"title"`
Type string `json:"type"`
}
23 changes: 23 additions & 0 deletions cloud/model/jira.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package model

// PagedDTOT is response of a paged list (PagedDTO) with generic support for values
type PagedDTOT[T any] struct {
Size int `json:"size" structs:"size"`
Start int `json:"start" structs:"start"`
Limit int `json:"limit,omitempty" structs:"limit,omitempty"`
IsLastPage bool `json:"isLastPage,omitempty" structs:"isLastPage,omitempty"`
Values []T `json:"values,omitempty" structs:"values,omitempty"`
Expands []string `json:"_expands,omitempty" structs:"_expands,omitempty"`
Links *SelfLink `json:"_links,omitempty" structs:"_links,omitempty"`
}

type SelfLink struct {
Self string `json:"self,omitempty" structs:"self,omitempty"`
}

type DateDTO struct {
ISO8601 string `json:"iso8601,omitempty" structs:"iso8601,omitempty"`
JIRA string `json:"jira,omitempty" structs:"jira,omitempty"`
Friendly string `json:"friendly,omitempty" structs:"friendly,omitempty"`
EpochMillis int64 `json:"epochMillis,omitempty" structs:"epochMillis,omitempty"`
}
64 changes: 64 additions & 0 deletions cloud/model/servicedesk/attachment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package servicedesk

import (
"io"

"github.com/andygrunwald/go-jira/v2/cloud/model"
)

type TemporaryFile struct {
Name string
File io.Reader
}

type AttachedTemporaryFile struct {
TemporaryAttachments []TemporaryAttachment `json:"temporaryAttachments,omitempty" structs:"temporaryAttachments,omitempty"`
}

type TemporaryAttachment struct {
TemporaryAttachmentID string `json:"temporaryAttachmentId,omitempty" structs:"temporaryAttachmentId,omitempty"`
FileName string `json:"fileName,omitempty" structs:"fileName,omitempty"`
}

type AttachmentDTO struct {
Filename string `json:"filename,omitempty" structs:"filename,omitempty"`
Author UserDTO `json:"author,omitempty" structs:"author,omitempty"`
Created model.DateDTO `json:"created,omitempty" structs:"created,omitempty"`
Size int64 `json:"size,omitempty" structs:"size,omitempty"`
MIMEType string `json:"mimeType,omitempty" structs:"mimeType,omitempty"`
Links AttachmentLinkDTO `json:"_links,omitempty" structs:"_links,omitempty"`
}

type AttachmentLinkDTO struct {
Self string `json:"self,omitempty" structs:"self,omitempty"`
JIRARest string `json:"jiraRest,omitempty" structs:"jiraRest,omitempty"`
Content string `json:"content,omitempty" structs:"content,omitempty"`
Thumbnail string `json:"thumbnail,omitempty" structs:"thumbnail,omitempty"`
}

type AttachmentCreateResultDTO struct {
Comment CommentDTO `json:"comment,omitempty" structs:"comment,omitempty"`
Attachments model.PagedDTOT[AttachmentDTO] `json:"attachments,omitempty" structs:"attachments,omitempty"`
}

type CreateRequestAttachment struct {
TemporaryAttachmentIDs []string `json:"temporaryAttachmentIds,omitempty" structs:"temporaryAttachmentIds,omitempty"`
AdditionalComment *AdditionalCommentDTO `json:"additionalComment,omitempty" structs:"additionalComment,omitempty"`
Public bool `json:"public" structs:"public"`
}

type AdditionalCommentDTO struct {
Body string `json:"body,omitempty" structs:"body,omitempty"`
}

type CommentDTO struct {
ID string
Body string `json:"body,omitempty" structs:"body,omitempty"`
RenderedBody *RenderedValueDTO `json:"renderedBody,omitempty" structs:"renderedBody,omitempty"`
Author UserDTO `json:"author,omitempty" structs:"author,omitempty"`
Created model.DateDTO `json:"created,omitempty" structs:"created,omitempty"`
Attachments model.PagedDTOT[AttachmentDTO] `json:"attachments,omitempty" structs:"attachments,omitempty"`
Public bool `json:"public,omitempty" structs:"public,omitempty"`
Expands []string `json:"_expands,omitempty" structs:"_expands,omitempty"`
Links *model.SelfLink `json:"_links,omitempty" structs:"_links,omitempty"`
}
22 changes: 22 additions & 0 deletions cloud/model/servicedesk/customer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package servicedesk

import "github.com/andygrunwald/go-jira/v2/cloud/model"

// Customer represents a ServiceDesk customer.
type Customer struct {
AccountID string `json:"accountId,omitempty" structs:"accountId,omitempty"`
Name string `json:"name,omitempty" structs:"name,omitempty"`
Key string `json:"key,omitempty" structs:"key,omitempty"`
EmailAddress string `json:"emailAddress,omitempty" structs:"emailAddress,omitempty"`
DisplayName string `json:"displayName,omitempty" structs:"displayName,omitempty"`
Active *bool `json:"active,omitempty" structs:"active,omitempty"`
TimeZone string `json:"timeZone,omitempty" structs:"timeZone,omitempty"`
Links *model.SelfLink `json:"_links,omitempty" structs:"_links,omitempty"`
}

// CustomerListOptions is the query options for listing customers.
type CustomerListOptions struct {
Query string `url:"query,omitempty"`
Start int `url:"start,omitempty"`
Limit int `url:"limit,omitempty"`
}
73 changes: 73 additions & 0 deletions cloud/model/servicedesk/request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package servicedesk

import (
"github.com/andygrunwald/go-jira/v2/cloud/model"
)

type CreateRequest struct {
ServiceDeskID string `json:"serviceDeskId,omitempty" structs:"serviceDeskId,omitempty"`
TypeID string `json:"requestTypeId,omitempty" structs:"requestTypeId,omitempty"`
FieldValues map[string]any `json:"requestFieldValues,omitempty" structs:"requestFieldValues,omitempty"`
Participants []string `json:"requestParticipants,omitempty" structs:"requestParticipants,omitempty"`
Requester string `json:"raiseOnBehalfOf,omitempty" structs:"raiseOnBehalfOf,omitempty"`
}

// Request represents a ServiceDesk customer request.
type Request struct {
IssueID string `json:"issueId,omitempty" structs:"issueId,omitempty"`
IssueKey string `json:"issueKey,omitempty" structs:"issueKey,omitempty"`
TypeID string `json:"requestTypeId,omitempty" structs:"requestTypeId,omitempty"`
ServiceDeskID string `json:"serviceDeskId,omitempty" structs:"serviceDeskId,omitempty"`
Reporter *Customer `json:"reporter,omitempty" structs:"reporter,omitempty"`
FieldValues []RequestFieldValue `json:"requestFieldValues,omitempty" structs:"requestFieldValues,omitempty"`
Status *RequestStatus `json:"currentStatus,omitempty" structs:"currentStatus,omitempty"`
Links *model.SelfLink `json:"_links,omitempty" structs:"_links,omitempty"`
Expands []string `json:"_expands,omitempty" structs:"_expands,omitempty"`
}

// RequestFieldValue is a request field.
type RequestFieldValue struct {
FieldID string `json:"fieldId,omitempty" structs:"fieldId,omitempty"`
Label string `json:"label,omitempty" structs:"label,omitempty"`
Value any `json:"value,omitempty" structs:"value,omitempty"`
}

// RequestDate is the date format used in requests.
type RequestDate struct {
ISO8601 string `json:"iso8601,omitempty" structs:"iso8601,omitempty"`
Jira string `json:"jira,omitempty" structs:"jira,omitempty"`
Friendly string `json:"friendly,omitempty" structs:"friendly,omitempty"`
Epoch int64 `json:"epoch,omitempty" structs:"epoch,omitempty"`
}

// RequestStatus is the status for a request.
type RequestStatus struct {
Status string
Category string
Date RequestDate
}

// RequestComment is a comment for a request.
type RequestComment struct {
ID string `json:"id,omitempty" structs:"id,omitempty"`
Body string `json:"body,omitempty" structs:"body,omitempty"`
Public bool `json:"public" structs:"public"`
Author *Customer `json:"author,omitempty" structs:"author,omitempty"`
Created *RequestDate `json:"created,omitempty" structs:"created,omitempty"`
Links *model.SelfLink `json:"_links,omitempty" structs:"_links,omitempty"`
Expands []string `json:"_expands,omitempty" structs:"_expands,omitempty"`
}

// RequestCommentListOptions is the query options for listing comments for a ServiceDesk request.
type RequestCommentListOptions struct {
Public *bool `url:"public,omitempty" query:"public"`
Internal *bool `url:"internal,omitempty" query:"internal"`
Expand []string `url:"expand,omitempty" query:"expand"`
Start int `url:"start,omitempty" query:"start"`
Limit int `url:"limit,omitempty" query:"limit"`
}

type CreateRequestComment struct {
Body string `json:"body" structs:"body"`
Public bool `json:"public" structs:"public"`
}
Loading