-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from ctreminiom/dev-jira-cloud
dev
- Loading branch information
Showing
13 changed files
with
822 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"features": [ | ||
{ | ||
"projectId": 10001, | ||
"state": "ENABLED", | ||
"toggleLocked": true, | ||
"feature": "jsw.classic.roadmap", | ||
"prerequisites": [], | ||
"localisedName": "Roadmap", | ||
"localisedDescription": "Your roadmap is an optimized location to create and manage your epics.", | ||
"imageUri": "https://jira.atlassian.com/s/sb53l8/b/3/ab8a7691e4738b4f147e293f0864adfd5b8d3c85/_/download/resources/com.atlassian.jira.rest:classic-project-features/simple-roadmap-feature.svg" | ||
}, | ||
{ | ||
"projectId": 10001, | ||
"state": "ENABLED", | ||
"toggleLocked": true, | ||
"feature": "jsw.classic.backlog", | ||
"prerequisites": [], | ||
"localisedName": "Backlog", | ||
"localisedDescription": "Plan and prioritize work in a dedicated space. To enable and configure the backlog for each board, go to board settings.", | ||
"imageUri": "https://jira.atlassian.com/s/sb53l8/b/3/ab8a7691e4738b4f147e293f0864adfd5b8d3c85/_/download/resources/com.atlassian.jira.rest:classic-project-features/simple-backlog-feature.svg" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package v2 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/ctreminiom/go-atlassian/pkg/infra/models" | ||
"net/http" | ||
) | ||
|
||
type ProjectFeatureService struct{ client *Client } | ||
|
||
// Gets returns the list of features for a project. | ||
// Docs: https://docs.go-atlassian.io/jira-software-cloud/projects/features#get-project-features | ||
func (p *ProjectFeatureService) Gets(ctx context.Context, projectKeyOrID string) (result *models.ProjectFeaturesScheme, response *ResponseScheme, err error) { | ||
|
||
if projectKeyOrID == "" { | ||
return nil, nil, models.ErrNoProjectIDError | ||
} | ||
|
||
var endpoint = fmt.Sprintf("rest/api/2/project/%v/features", projectKeyOrID) | ||
|
||
request, err := p.client.newRequest(ctx, http.MethodGet, endpoint, nil) | ||
if err != nil { | ||
return | ||
} | ||
|
||
request.Header.Set("Accept", "application/json") | ||
|
||
response, err = p.client.call(request, &result) | ||
if err != nil { | ||
return | ||
} | ||
|
||
return | ||
} | ||
|
||
// Set sets the state of a project feature. | ||
// Docs: https://docs.go-atlassian.io/jira-software-cloud/projects/features#set-project-feature-state | ||
func (p *ProjectFeatureService) Set(ctx context.Context, projectKeyOrID, featureKey, state string) (result *models.ProjectFeaturesScheme, response *ResponseScheme, err error) { | ||
|
||
if projectKeyOrID == "" { | ||
return nil, nil, models.ErrNoProjectIDError | ||
} | ||
|
||
if featureKey == "" { | ||
return nil, nil, models.ErrNoProjectFeatureKeyError | ||
} | ||
|
||
payload := struct { | ||
State string `json:"state,omitempty"` | ||
}{ | ||
State: state, | ||
} | ||
|
||
payloadAsReader, _ := transformStructToReader(&payload) | ||
|
||
var endpoint = fmt.Sprintf("rest/api/2/project/%v/features/%v", projectKeyOrID, featureKey) | ||
|
||
request, err := p.client.newRequest(ctx, http.MethodPut, endpoint, payloadAsReader) | ||
if err != nil { | ||
return | ||
} | ||
|
||
request.Header.Set("Accept", "application/json") | ||
request.Header.Set("Content-Type", "application/json") | ||
|
||
response, err = p.client.call(request, &result) | ||
if err != nil { | ||
return | ||
} | ||
|
||
return | ||
} |
Oops, something went wrong.