Python - Jira create project with shared configuration(Existing project) with /rest/api/2 - python-3.x

We are using Jira in our organization. I'm using Python and rest API/2 to connect with Jira (Server). I wanted to create a project with existing project configuration, I found it using rest API/1. Is there any way to do the same using version 2?
I already checked here:
https://developer.atlassian.com/cloud/jira/platform/rest/v2/
https://community.atlassian.com/t5/Jira-questions/How-to-create-project-with-shared-Configuration-via-REST-API/qaq-p/650062
I'm using requests module in Python.
How to get all the configurations that are made to the project (We will use the below configurations for templates in our organization)?
Issue Type Scheme
Workflow Scheme
Issue Type Screen Scheme
Field Configuration Scheme
Permission Scheme
Notification Scheme
Issue Security

Starting from Jira 7.0.0, we can use Create project REST API which also allows setting following schemes while creating the project,
1.issueSecurityScheme
2.permissionScheme
3.notificationScheme
4.workflowSchemeId
REST Endpoint: [POST /rest/api/2/project]
Sample Request Payload:
{
"key": "EX",
"name": "Example",
"projectTypeKey": "business",
"projectTemplateKey": "com.atlassian.jira-core-project-templates:jira-core-project-management",
"description": "Example Project description",
"lead": "Charlie",
"url": "http://atlassian.com",
"assigneeType": "PROJECT_LEAD",
"avatarId": 10200,
"issueSecurityScheme": 10001,
"permissionScheme": 10011,
"notificationScheme": 10021,
"workflowSchemeId": 10031,
"categoryId": 10120
}
For issuetype and screen schemes, there is no such parameter available which can be set using the above create project rest api.
If you want to create a new jira project which needs to inherit all the configuration of any existing project(or template project) then use the following Rest endpoint to create jira project using shared configuration which will allow you to reuse all schemes which are present in the template project(existing project).
REST ENDPOINT: POST /rest/project-templates/1.0/createshared/{{projectid}}
Sample Request Payload:
{
"key": "NEWKEY",
"name": "New test project",
"lead": "lead username"
}
You can get the ProjectID of the template project using the below rest endpoint,
GET /rest/api/2/project/{projectIdOrKey}

Related

OpenSea 3.1 API Validation Errors

I believe OS's OpenApi definition is invalid at version v1.0#1e41yo45l0vihg6s. When I attempt to use it from Node using the api package in my project I get validation errors. Simple steps to reproduce:
Create a new Node project and initialize
mkdir os-api-test
cd os-api-test
npm init
Per OS docs/examples, install the api package:
npm install api --save
Create file index.js and populate it with the example code (address and API key omitted here, but they're valid and I can use them via the API UI):
const sdk = require('api')('#opensea/v1.0#1e41yo45l0vihg6s');
sdk['retrieving-a-single-contract']({
asset_contract_address: 'REDACTED',
'X-API-KEY': 'REDACTED'
})
.then(res => console.log(res))
.catch(err => console.error(err));
Run the example
node index.js
Output:
Looking at the API definition here and specifically at the /assets/get path, there are indeed duplicate owner parameters:
"parameters": [
{
"name": "owner",
"in": "query",
"description": "The address of the owner of the assets",
"schema": {
"type": "string"
}
},
...
{
"name": "owner",
"in": "query",
"schema": {
"type": "string"
}
}
...
And per the OpenApi 3.1 spec, in reference to the path item object:
A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters.
Obviously I can't change the API definition but is there any way to work around this, perhaps via configuration of the api package? I dug into its code but nothing jumped out at me. It's surprising that such a widely used API would have a bug that renders it unusable, yet I can't find any other mentions of it. I realize I may be able to use fetch to hit the API directly but I'd like to use the api package.
Interestingly the testnet API does not suffer from this same bug.
Thank you for surfacing this. We had documented the owner parameter twice, which led to this issue. It is fixed it now.

VS Code Extension Settings

I have created a working VS Code extension. The extension allows someone teaching code to provide students with real-time access to the teacher's code.
I want to add one more feature to the extension to allow the teacher to connect the VS Code extension to an account form a separate web application. The teacher would login to their account on the web application, generate a token, and place that token in the VS Code extension settings.
I have spent hours looking for documentation or examples on how to add settings to a VS Code extension but can't find anything.
Is this possible? Does anyone know how to do this? Or aware of any good documentation/examples?
Yes a little tricky as what you are looking for are configurations - which can be created by an extension and set by a user.
Configuration docs (settings)
Contribute configuration keys that will be exposed to the user. The
user will be able to set these configuration options as User Settings
or as Workspace Settings, either by using the Settings editor or by
editing the JSON settings file directly.
There are examples and extensive docs at that link above.
Here is sample code from an extension I wrote which creates 2 settings:
"configuration": [
{
"title": "Find and Transform",
"properties": {
"find-and-transform.enableContextMenus": {
"type": "boolean",
"scope": "machine",
"default": true,
"markdownDescription": "Show `Search in this File`, `Search in this Folder` and `Search in the Results Files` in the context menus."
},
"find-and-transform.enableWarningDialog": {
"type": "boolean",
"scope": "machine",
"default": true,
"markdownDescription": "Enable a warning dialog if there are bad argument keys or values in settings and keybindings."
}
}
}
]
Maybe you looking for that extension :
https://code.visualstudio.com/learn/collaboration/live-share,
it acts like google docs, with live share.

presetOverride when creating Azure Media Services v3 Job

When creating an Azure Media Services Job via the REST API, I cannot set a presetOverrides property on the JobOutputAsset as defined in the documentation: https://learn.microsoft.com/en-us/rest/api/media/jobs/create#joboutputasset
My request body is:
{
"properties": {
"input": {
"#odata.type": "#Microsoft.Media.JobInputAsset",
"assetName": "inputAsset"
},
"outputs": [
{
"#odata.type": "#Microsoft.Media.JobOutputAsset",
"assetName": "outputAsset",
"label": "en-US",
"presetOverride": {
"#odata.type": "#Microsoft.Media.AudioAnalyzerPreset",
"audioLanguage": "en-US",
"mode": "Basic"
}
}
],
"priority" : "Normal"
}
}
The error message thrown is:
{
"error": {
"code": "InvalidResource",
"message": "The property 'presetOverride' does not exist on type 'Microsoft.Media.JobOutputAsset'. Make sure to only use property names that are defined by the type."
}
}
When removing the presetOverride data, everything works as expected. The official documentation clearly states that the Microsoft.Media.JobOutputAsset does have a presetOverride property though. What am I doing wrong?
It is important to select the correct API version when communicating with the Azure Media Services REST API.
In this case, api version 2020-05-01 from the Azure Media Services Postman examples was used. But the presetOverride option is only available starting with version 2021-06-01.
Setting api-version=2021-06-01 as a GET parameter enables Preset Overrides.
couple of concerns here Rene. I would not recommend using the raw REST API directly for any Azure services. Reason being is that there are a lot of built-in retry scenarios and retry policies that are already rolled into the client SDKs. We've had many customers try to roll their own REST API library but run into massive issues in production because they failed to read up on how to handle and write their own custom retry policy code.
Unless you are really familiar with rolling your own retry policies and how Azure Resource Management gateway works, try to avoid it and just use the official client SDKs - see here - https://learn.microsoft.com/en-us/azure/architecture/best-practices/retry-service-specific#general-rest-and-retry-guidelines
Now, to answer your specific question - try using my sample here in .NET and see if it answers your question.
https://github.com/Azure-Samples/media-services-v3-dotnet/blob/3ab85647cbadd2b868aadf175afdede67b40b2fd/AudioAnalytics/AudioAnalyzer/Program.cs#L129
I can also provide a working sample of this in Node.js/Typescript in this repo if you like. It is using the latest 10.0.0 release of our Javascript SDK.
I'm working on samples in this repo today - https://github.com/Azure-Samples/media-services-v3-node-tutorials
UPDATE: Added basic audio in Typescript sample.
https://github.com/Azure-Samples/media-services-v3-node-tutorials/blob/main/AudioAnalytics/index.ts
Shows how to use the preset override per job.

Creating nested folder in Sharepoint with Graph API fails

I can create a nested folder /folder1/folder2 in (personal) OneDrive with the following Graph request (using the beta API):
POST drives/{id}/root:/folder1:/children
{
"name": "folder2",
"folder": {},
"#microsoft.graph.conflictBehavior": "fail"
}
Here, folder1 didn't exist beforehand; the one API call creates both it and folder1/folder2.
However, the same code fails for SharePoint and OneDrive for Business with a 404 error. Is this type of request supported? I'd rather not have to make a separate API call for every level of nesting.
I'm asking this because I'm not sure whether my site has policies that cause the request to fail, or because the API actually doesn't support it.
This works for me. Remove name parameter from the body and use PATCH instead of POST. Specify the path in the URL.
PATCH drives/{id}/root:/folder1/folder2
{
"folder": {},
"#microsoft.graph.conflictBehavior": "fail"
}
Tested using v1.0 and beta for OneDrive for Business.

gcloud pubsub on node.js - how to set IAM policy

Could someone walk me through setting an IAM policy in node.js using gcloud's pubsub?
I've looked through this page: https://developers.google.com/gmail/api/guides/push
And based on what I understood, I've saved this file as a .json:
POST "https://pubsub.googleapis.com/v1beta2/projects/gmail_push_project/topics/gmail_push_topic:setIamPolicy"
Content-type: application/json
{
"policy": {
"bindings": [{
"role": "roles/pubsub.publisher",
"members": ["serviceAccount:gmail-api-push#system.gserviceaccount.com"],
}],
}
}
And then, after creating a topic and subscribing to it, I've made this call in my .js script: pubsub.projects.topics.setIamPolicy('pubsub_policy.json');, however, I'm getting an error cannot read property "topics" of undefined.
Thanks for your help!
As of v0.19.0 IAM methods are supported, you can find the documentation for them on the official gcloud-node docs.
Unfortunately this is not supported yet. However, we're preparing to launch such API calls with a new set of documentation shortly (in weeks). Also all the APIs are public now so that gcloud-node developers can actually start implementing, so I filed an issue at:
https://github.com/GoogleCloudPlatform/gcloud-node/issues/758
As a short-term workaround, you can use the API explorer, or if you need to do it dynamically, you should be able to use the following library:
https://developers.google.com/api-client-library/javascript/?hl=en

Resources