Skip to content

Commit e85d033

Browse files
authored
Merge pull request #73 from atlassian/release-from-bitbucket
HEIMDALL-12352: Add service resource
2 parents 74165da + 1a5f5f6 commit e85d033

File tree

12 files changed

+1020
-1
lines changed

12 files changed

+1020
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v1.1.9
2+
3+
#### Resources:
4+
5+
Implemented Jira Service Management Service Resource
16
## v1.1.8
27

38
#### Product:

docs/resources/service.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "atlassian-operations_service Resource - atlassian-operations"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# atlassian-operations_service (Resource)
10+
11+
12+
This resource only works for Jira Service Management services. [Read more about services](https://support.atlassian.com/jira-service-management-cloud/docs/what-is-services/).
13+
14+
15+
<!-- schema generated by tfplugindocs -->
16+
## Schema
17+
18+
### Required
19+
20+
- `description` (String) The description of the JSM service
21+
- `name` (String) The name of the JSM service
22+
- `owner` (String) The owner team ID of the JSM service. If you want to remove the owner, set this to an empty string.
23+
- `tier` (Number) The tier level of the JSM service
24+
- `type` (String) The type of the JSM service
25+
26+
### Optional
27+
28+
- `change_approvers` (Attributes) Change approvers configuration for the JSM service (see [below for nested schema](#nestedatt--change_approvers))
29+
- `projects` (Attributes) Projects configuration for the JSM service (see [below for nested schema](#nestedatt--projects))
30+
- `responders` (Attributes) Responders configuration for the JSM service (see [below for nested schema](#nestedatt--responders))
31+
- `stakeholders` (Attributes) Stakeholders configuration for the JSM service (see [below for nested schema](#nestedatt--stakeholders))
32+
33+
### Read-Only
34+
35+
- `id` (String) The ID of the JSM service
36+
37+
<a id="nestedatt--change_approvers"></a>
38+
### Nested Schema for `change_approvers`
39+
40+
Optional:
41+
42+
- `groups` (List of String) List of group IDs for change approvers. If you want to remove all group change approvers, set this to an empty list.
43+
44+
45+
<a id="nestedatt--projects"></a>
46+
### Nested Schema for `projects`
47+
48+
Optional:
49+
50+
- `ids` (List of String) List of project IDs. If you want to remove all project IDs, set this to an empty list.
51+
52+
53+
<a id="nestedatt--responders"></a>
54+
### Nested Schema for `responders`
55+
56+
Optional:
57+
58+
- `teams` (List of String) List of team IDs for responders. If you want to remove all teams responders, set this to an empty list.
59+
- `users` (List of String) List of user IDs for responders. If you want to remove all users responders, set this to an empty list.
60+
61+
62+
<a id="nestedatt--stakeholders"></a>
63+
### Nested Schema for `stakeholders`
64+
65+
Optional:
66+
67+
- `users` (List of String) List of user IDs for stakeholders. If you want to remove all user stakeholders, set this to an empty list.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# JSM Service can be imported by providing the service id
2+
terraform import atlassian-operations_service.example "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
terraform {
2+
required_providers {
3+
atlassian-operations = {
4+
source = "atlassian/atlassian-operations"
5+
}
6+
}
7+
}
8+
9+
# Basic JSM service example
10+
resource "atlassian-operations_service" "basic" {
11+
name = "JSM Service Test"
12+
description = "Description"
13+
tier = 3
14+
type = "SOFTWARE_SERVICES"
15+
owner = "438a6ccd-7daf-4afb-b0ee-9b440256a0a61"
16+
change_approvers = {
17+
groups = [
18+
"6e9fbdd1-f7c8-4066-b342-413ed4133a0"
19+
]
20+
}
21+
responders = {
22+
users = [
23+
"61a11abf12351318cd0056fa95ff8"
24+
]
25+
teams = [
26+
"123123"
27+
]
28+
}
29+
stakeholders = {
30+
users = [
31+
"61a11abf3618cd004123ff8"
32+
]
33+
}
34+
projects = {
35+
ids = [
36+
"10002"
37+
]
38+
}
39+
}

internal/dto/service_dto.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dto
2+
3+
type ServiceDto struct {
4+
ID string `json:"id,omitempty"`
5+
Name string `json:"name"`
6+
Description string `json:"description"`
7+
Tier int32 `json:"tier"`
8+
Type string `json:"type"`
9+
Owner string `json:"owner"`
10+
ChangeApprovers *ChangeApproversDto `json:"changeApprovers,omitempty"`
11+
Responders *RespondersDto `json:"responders,omitempty"`
12+
Stakeholders *StakeholdersDto `json:"stakeholders,omitempty"`
13+
Projects *ProjectsDto `json:"projects,omitempty"`
14+
}
15+
16+
type ChangeApproversDto struct {
17+
Groups []string `json:"groups,omitempty"`
18+
}
19+
20+
type RespondersDto struct {
21+
Users []string `json:"users,omitempty"`
22+
Teams []string `json:"teams,omitempty"`
23+
}
24+
25+
type StakeholdersDto struct {
26+
Users []string `json:"users,omitempty"`
27+
}
28+
29+
type ProjectsDto struct {
30+
IDs []string `json:"ids,omitempty"`
31+
}

internal/httpClient/httpClientHelpers/helpers.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ func GenerateTeamsClientRequest(providerModel dto.AtlassianOpsProviderModel) *ht
3333
return req
3434
}
3535

36+
func GenerateServiceClientRequest(providerModel dto.AtlassianOpsProviderModel) *httpClient.Request {
37+
req := httpClient.NewRequest()
38+
req.SetUrl(fmt.Sprintf("%s/jsm/api/%s", getAtlassianApiDomain(providerModel.GetIsStaging()), providerModel.GetCloudId()))
39+
req.SetRetryCount(providerModel.GetApiRetryCount())
40+
req.SetRetryWaitTime(providerModel.GetApiRetryWait())
41+
req.SetRetryMaxWaitTime(providerModel.GetApiRetryWaitMax())
42+
req.SetBasicAuth(providerModel.GetEmailAddress(), providerModel.GetToken())
43+
return req
44+
}
45+
3646
func GenerateUserClientRequest(providerModel dto.AtlassianOpsProviderModel) *httpClient.Request {
3747
req := httpClient.NewRequest()
3848
switch providerModel.GetProductType() {

0 commit comments

Comments
 (0)