Atlassian BitBucket server addon web-item section name - bitbucket

After trying a number of different sections, I figured I'd ask - would anyone know the name of the WORKFLOW section depicted on the screenshot below? The snippet below should give an idea of what I am trying to do.
<web-item key="my-project-item" name="My Title" section="stash.repository.settings.panel/repository-settings-section" weight="300" application="stash"> .... </web-item>

I think this is the information you are looking for:
Web Item: bitbucket.repository.settings.panel/repository-workflow-section
Web Panel: example-web-item.badge
Context Items: request, principal, repository, project
You can get this by appending ?web.items&web.panels&web.sections to the URL in Bitbucket Server.

Related

ResolveFully option does not resolve all schemas in some paths

Swagger-parser version: 2.1.1
Example swagger spec:
The test case is quite large, so I put it in a github gist. Don't be surprised by the names of the paths and schemes - I masked the critical data.
Description:
When using the ResolveFully option, I get requests with unresolved links. For example, take the request POST /v1/BusinePEH0JF. In swagger-ui it renders correctly - in the request body in the manager field, the Emplo4XN6X schema is resolved:
enter image description here
But swagger-parser gives this result:
enter image description here
Here the link is not resolved. This is most likely due to the fact that the parent schema BusinesYD77B4X in this request is stored as such in resolvedModels due to the fact that it is also used in other requests, such as POST /v1/ApprovalSetU0C9RY71SHD/manager-to-employees. Here, the manager field is empty, because this scheme has already been used above in the approver field.
enter image description here
Reproduction of the error:
val parseOptions = new ParseOptions()
parseOptions.setResolve(true)
parseOptions.setResolveFully(true)
val openAPI = new OpenAPIV3Parser().read(swaggerSpec, null, parseOptions)
Expected result:
Like on the first screen in swagger-ui
Thanks!

How to set swagger config properties from config file

I am using Azure API Management to host three versions of an API - dev, qa, stage. These are basically three different build configurations of the api, so when imported to APIM - "MyAPI-dev", "MyAPI-qa", "MyAPI-stage".
I am using swagger for documentation. When I trigger a revision in Terraform to build/re-create the API definitions, i am getting error:
"my-ApiM-dev" / Resource Group "rg-myApim"): apimanagement.APIClient#CreateOrUpdate: Failure sending
request: StatusCode=409 -- Original Error: Code="IdentifierAlreadyInUse" Message="Resource already exists."
I am 99% sure this is due to the "title" in SwaggerConfig.cs file, it is the same value for all configurations. Thus deploying two of the APIs with the same title is throwing the error.
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "MyApiTitle");
}
How can I get the title to be unique based on the configuration?
I tried creating config values in web.config value for each configuration and referencing the key in the config file, but it didn't work, SwaggerUi picked up the default value in web.config file only.
web.dev.config:
<add key="BuildConfig" value="dev" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
SwaggerConfig.cs:
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "MyApiTitle-" + ConfigurationManager.AppSettings["BuildConfig"]);
}
Another option is to script deleting the API, import the API and rename the title, but I would do that as a last resort.
Would like to do this dynamically in the project code though.
I am able to achieve this with PowerShell, please check if that helps to you
https://medium.com/#rakesh.suryawanshi/deploy-azure-web-api-into-azure-api-management-with-powershell-3d14d1610b07
also, check if you are able to deploy it manually with your approach.

How to create JIRA issue ticket from a template using REST api?

I want to create JIRA Change Request Ticket using a template.
I use JIRA API endpoint '/rest/api/2/issue'.
Below is the format of the data sent to JIRA.
Could anyone please help?
payload =
{ fields:
{ project: { key: "CRQ"},
customfield_15630: "SampleTemplateName",
summary: "Testing",
customfield_17679: "N.A" ,
customfield_14530:"2018-06-17T00:00:00.0+0000 ",
customfield_14531: "2018-06-17T00:00:00.0+0000 " } }
Here is the XML format of template I want to use in the issue ticket.
<item>
<title>[TMPL-167] NTW-8 [Network_Interface_configuration]</title>
<link>https://jiraqa.com/browse/TMPL-167</link>
<project id="15980" key="TMPL">Templates</project>
<description>Test</description>
<environment />
<key id="492895">TMPL-167</key>
<summary>NTW-8 [Network_Interface_configuration]</summary>
</item>
You are definitely lacking an issue type there. Here is an example of a proper issue creation using the REST API: https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/issue-createIssue
Certain fields may be required or not depending on the project settings, but the project ID, the summary and the issue type are an absolute minimum.
Another thing is that you want to use a template in addition to this. Jira may simply not be able to automatically fetch the data from there, but if anything went wrong, you'd receive an error message anyway.
Could you describe in more detail what exactly do you need to do? It would be easier to come up with a solution ;)

JQL: Get list of sprints

Is it possible to get a list of sprints for a particular project ? I know there is a way to find issues by a sprint, but haven't found any way to get all the sprints.
I use the following rest call to find all the sprints:
https://yourjira.com/rest/greenhopper/1.0/integration/teamcalendars/sprint/list?jql=project+%3D+YOURPROJECTKEY
To find only the open sprint of the project I run this:
https://yourjira.com/rest/greenhopper/1.0/integration/teamcalendars/sprint/list?jql=project+%3D+YOURPROJECTKEY+and+Sprint+not+in+closedSprints()
In JQL it's not yet possible but you can use the new jira agile API. Here is the documentation for jira cloud and for jira server 7.2.3.
First, you need to find the board of your project. This REST endpoint to get the list of your boards is:
[jira-url]/rest/agile/1.0/board
Next you can get their project with:
[jira-url]/rest/agile/1.0/[board-id]/project
So in this manner you can find the board id of your project. At the end, you can get the sprints list of this board with:
[jira-url]/rest/agile/1.0/[board-id]/sprint
[jira-url]/rest/greenhopper/1.0/sprint/picker
Delivers "allMatches" array containing active sprints including id and boardName.
It was useful to me when i was searching a list of active sprints in all projects to clean up not completed or not well named sprints.
Based on this answer: answers.atlassian.com/questions/65920/answers/3599592, the best Web API to get the list of sprints is:
https://<your_site>/rest/greenhopper/1.0/sprintquery/<rapidBoardId>?includeFutureSprints=true&includeHistoricSprints=false
<rapidBoardId> is different in each system, I just saw it in the address bar of my browser when I was surfing in JIRA, then I hard coded it into the code which is calling the API.
https://<your_site>/secure/RapidBoard.jspa?rapidView=<rapidBoardId is here on your browser address bar>
There is no REST endpoint to do this, you can only query the sprints that are visible for a particular Rapid Board and you need to use the GreenHoppper plugin for this.
The endpoint for that is: https://yourjira.com/rest/greenhopper/1.0/sprints/{rapidBoardId}
You can enumerate the Rapid Boards at another REST endpoint: https://yourjira.com/rest/greenhopper/1.0/rapidviews/list
Read more here: https://answers.atlassian.com/questions/65920/how-can-i-list-all-sprints-from-greenhopper-using-the-rest-api
I did not invent this, a colleague did. However, you can easily access all of the sprints in the "search issues" screen by using this JQL: Sprint is not EMPTY
That's it. Enjoy.
There is no straightforward solution, only workarounds. What is ridiculous why Jira doesn't provide such API calls.
You can use this endpoint:
https://api.atlassian.com/ex/jira/{cloudId}/rest/api/2/jql/autocompletedata/suggestions?fieldName=Sprint&fieldValue=
Take notice of whitespace character on the end of query. It implies that every name of sprint includes whitespace char inside.
Output:
{
"results": [
{
"value": "2",
"displayName": "Sprint 4 - 2020-06-17 04:00 (12)"
},
{
"value": "1",
"displayName": "Sprint 2 - 2020-06-20 06:45 (6)"
}
}
Have you looked at the sprint report? The dropdown will show you a list of all sprints for that board. Of course you can have multiple boards per project, so you might need to search all related boards.
Here is my solution.
call rest/api/2/search?jql=project%20%3D%20ABCD%20AND%20Sprint%20in%20openSprints() to get the issues in current active sprint. Then you could get the active sprint.
make another call rest/api/2/search?jql=Sprint%20%3D%2014343 to get the issues.
Below the code to parse the active sprint.
fetch(sprintUrl, {
headers: requestHeader,
})
.then((res) => res.json())
.then((data) => {
const regex = new RegExp("state=ACTIVE");
let activeSprint = data.issues[0].fields.customfield_14400.filter(
(e: string) => regex.test(e)
)[0];
const sprintParser =
/id=(\d+).*?name=(.*?),startDate=([\d-]+).*?endDate=([\d-]+)/g;
const group = [...activeSprint.matchAll(sprintParser)][0];
setSprint(
Object.create({
id: parseInt(group[1]),
name: group[2],
startDate: group[3],
endDate: group[4],
})
);
});

How to Add Tag via Asana API

I am trying to do a simple Salesforce-Asana integration. I have many functions working, but I am having trouble with adding a tag to a workspace. Since I can't find documentation on the addTag method, I'm sort of guessing at what is required.
If I post the following JSON to https://app.asana.com/api/1.0/workspaces/WORKSPACEID/tasks:
{"data":{"name":"MyTagName","notes":"Test Notes"}}
The tag gets created in Asana, but with blank notes and name fields. If I try to get a bit more fancy and post:
{"data":{"name":"MyTagName","notes":"Test Notes","followers":[{"id":"MY_USER_ID"}]}}
I receive:
{"errors":[{"message":"Invalid field: {\"data\":{\"name\":\"MyTagName\",\"notes\":\"Test Notes\",\"followers\":[{\"id\":\"MY_USER_ID\"}]}}"}]}
I'm thinking the backslashes may mean that my request is being modified by the post, though debug output shows a properly formatted json string before the post.
Sample Code:
JSONGenerator jsongen = JSON.createGenerator(false);
jsongen.writeStartObject();
jsongen.writeFieldName('data');
jsongen.writeStartObject();
jsongen.writeStringField('name', 'MyTagName');
jsongen.writeStringField('notes', 'Test Notes');
jsongen.writeFieldName('followers');
jsongen.writeStartArray();
jsongen.writeStartObject();
jsongen.writeStringField('id', 'MY_USER_ID');
jsongen.writeEndObject();
jsongen.writeEndArray();
jsongen.writeEndObject();
jsongen.writeEndObject();
String requestbody = jsongen.getAsString();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://app.asana.com/api/1.0/workspaces/WORKSPACEID/tags');
req.setMethod('POST');
//===Auth header created here - working fine===
req.setBody(requestbody);
Http http = new Http();
HTTPResponse res = http.send(req);
return res.getBody();
Any help appreciated. I am inexperienced using JSON as well as the Asana API.
The problem was that I was posting to the wrong endpoint. Instead of workspaces/workspaceid/tags, I should have been using /tags and including workspaceid in the body of the request.
Aha, so you can add tags and even set followers despite the API not mentioning that you can or claiming that followers are read-only.
So to sum up for anyone else interested: POSTing to the endpoint https://app.asana.com/api/1.0/tags you can create a tag like this:
{ "data" : { "workspace": 1234567, "name" : "newtagname", "followers": [45678, 6789] } }
where 1234567 is your workspace ID and 45678 and 6789 are your new followers.
Since you posted this question, Asana's API and developer has introduced Tags. You documentation lays out the answer to your question pretty clearly:
https://asana.com/developers/api-reference/tags
I'm a bit confused by your question. Your ask "how to add a tag" but the first half of your question talks about adding a task. The problem with what you describe there is that you are trying to set a task's followers but the followers field is currently read-only according to Asana's API documentation. That is why you are getting an error. You can not set followers with the API right now.
The second part of your question - with the sample code - does look like you are trying to add a tag. However, right now the Asana API does not support this (at least according to the API documentation). You can update an existing tag but you can't add one.
So, to sum up: at this time the API does not allow you to add followers to a task or to create new tags.

Resources