Create issue via python rest api jira - python-3.7

So, I have written python code which interact with Jira api via python library atlassian_python_api
from atlassian import Jira
jira = Jira(
url="https://jira.example.com/",
username='gonchik.tsymzhitov',
password='admin')
jira.issue_create(fields={
'project': {'key': 'TEST'},
'issuetype': {
"name": "Task"
},
'summary': 'test rest',
'description': 'rest rest',
})
After the issue has been created with key TEST-2045 (the number 2045 was generated automaticly).
The question is: How can I insert my own issue number? For example, TEST-15 ?

that's the 'key' field.
and you can't provide it while creating jira issue, it's predefined behavior
see the topic at atlassian forum: https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-specify-key-when-creating-issue-via-API/qaq-p/574472

For those of you who might run into the error JIRA' object has no attribute 'issue_create':
it should be "jira.create_issue".

Related

Is it possible to create a MULTI_PICKLIST with Smartsheet Python SDK?

I am trying to create a MULTI_PICKLIST column using Smartsheet's Python SDK, but receive an error saying
"errorCode": 1012,
"message": "Required object attribute(s) are missing from your request: column.type.",
I'm using the following to try and add the column:
column = smartsheet.models.Column({
'title': 'TEST COLUMN',
'type': 'MULTI_PICKLIST',
'index': 0,
'options': ['One', 'Two']
})
response = smart.Sheets.add_columns(sheetid, column)
Is it currently possible to create a MULTI_PICKLIST Column with Python or has the SDK not been updated to support this? I also tried creating a regular PICKLIST then using update_column to update its type, but I similarly receive an error.
The Python SDK has not been updated to support MULTI_PICKLIST. In the meantime you could conceivably use the passthrough option to support creating a MULTI_PICKLIST column. There is more detail in the Python SDK documentation here: https://github.com/smartsheet-platform/smartsheet-python-sdk/blob/master/ADVANCED.md#passthrough-option
The Python API docs were updated on 2019-11-08 for MULTI_PICKLIST. There may be functionality there you are looking for.

How to add Message Attributes to SNS Publish from API Gateway Integration Request

I can find formats for this using the CLI
aws sns publish --topic-arn arn:aws:sns:us-west-2:111111111111:test
--message "Testing the CLI"
--subject "From the CLI" --message-attributes "{\"somename\":
{\"DataType\":\"String\",\"StringValue\":\"somevalue\"}}"
But what I can't find (or figure out) is how to do this from the Integration Request on an API Gateway.
I believe it needs to be done as Query Parameters of the Integration Request, but the syntax is not the same as adding Message Attributes for SQS. I tested that by using a parameter naming notation along the lines of this example:
MessageBody=This+is+a+test+message
MessageAttribute.1.Name=test_attribute_name_1
MessageAttribute.1.Value.StringValue=test_attribute_value_1
MessageAttribute.1.Value.DataType=String
I also tried:
MessageAttributes '{"store":{"DataType":"String","StringValue":"example_corp"}}'
So far can't get it working, any help is much appreciated.
After thorough research into the AWS docs, I found that there is no accurate documentation of setting up SNS Publish MessageAttributes in an API Gateway Resource Method as URL Query String Parameters.
Based on the partial syntax example they give here: https://docs.aws.amazon.com/sns/latest/api/API_Publish.html, I was then able to throw things at it until something stuck.
This is the proper dot notation syntax and parameters you need to use:
MessageAttributes.entry.1.Name = "Attribute1"
MessageAttributes.entry.1.Value.DataType = 'String'
MessageAttributes.entry.1.Value.StringValue = 'Test'
Where "Name" and "DataType" are required.
Cheers!

Custom Dimensions Not Reporting Through to Google Analytics API V4

I am attempting to pass information collected as, "custom dimensions," from Google Tag Manager through Google Analytics and then extract them out via the Google Analytics V4 API.
I have set up four of the fundamental custom dimensions suggested by Simo Ahava in this article.
My variable setup looks like the following:
variable setup
Essentially, I have been able to successfully pass through userID_dimension, hittimestamp_dimension, clientid_dimension and sessionid_dimension to the Google Analytics dashboard, but for some reason I am not able to extract out the hittimestamp_dimension through the API.
Here's what I am able to see on the dashboard:
Google Analytics Dashboard
As far as the API itself, I am using the HelloAnalytics.py python version supplied by Google, and I am able to extract out all of the above information, minus the timestamps dimensions on the right hand side of each.
I'm storing the timestamp information in dimension2, but upon making the below call (again, using API V4) I get blank...nothing.
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}]
}]
}
).execute()
Upon making this call, one would expect that the above would report out dimensions similar to what the Google Analytics dashboard would show. E.g. one would think that the dashboard itself is using the API. However what prints out is blank. All other custom dimensions print out as expected.
If I try to call the above function on just dimension2 itself with no other dimension, it is also blank.
Is there something special one has to do in order to extract hit-scoped variables within the API? Or does the API just not allow hit-scoped variables to pass through?
thanks,
You forgot to add a 'metrics' field to your request, it is required as per documentation
Source: Reporting API v4 - Method: reports.batchGet
The metrics requested. Requests must specify at least one metric. Requests can have a total of 10 metrics.
The below modified request should work:
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}],
'metrics': [{'expression': 'ga:sessions'}]
}]
}
).execute()

Invoking JIRA Rest API to create an issue containing a locked custom fields like Epic Name

I'm trying to create an Epic Issue in JIRA using the REST API.
There is a field called "Epic Name", which is required and locked.
When I submit the following JSON
URL: https://jira:443/jira/rest/api/latest/issue
{"fields":{"project":{"key":"TEST"},"issuetype":{"name":"Epic"},"summary":"TestSummary","Epic Name":"TestName"}}
The Response is:
Http Error : 400{"errorMessages":[],"errors":{"Epic Name":"Field 'Epic Name' cannot be set. It is not on the appropriate screen, or unknown."}}
What is wrong, since in the screen Epic Name is there and required (obviously, since it is a required attribute). What could be the problem?
Thanks
The problem is not that the field is not on the screen but that for JIRA API, the field name Epic Name is invalid/unknown. The actual ID of that field is customfield_10016 which you have to put in the query. The value should be the Issue Key for that specific Epic instead of just a name.
{
"fields": {
//other data
"customfield_10016": "PROJECTKEY-69"
}
}
I tried with customfield_10016 but it didn't work for me.
I have researched more about the same and got to know the custom field may differ for JIRA instance.
We can get custom field for our JIRA insatnce and project using below API and use it - http://<JIRA_URL>/rest/api/2/issue/createmeta?projectKeys=<ProjectKey>&issuetypeNames=<IssueType>&expand=projects.issuetypes.fields

How do I export issues from a Google Code project to Github?

I'm trying to move a project from Google Code to Github, and I can't find a way to migrate the issue tickets.
I found https://github.com/arthur-debert/google-code-issues-migrator which appears to be the top hit in a google search for "migrate issues from google code to github", but all I ever get when I attempt to use it is a 404.
It appears that I can export Google Code tickets as CSV, but a) I don't see a way to import CSV into github, and b) it only seems to be the barest data about each ticket.
Is there another way to migrate my issues from Google Code to Github?
I exported my google code issues into CSV (which sadly does not include comments), and then used the following script to import them into github:
#!/usr/bin/env ruby
# Based on https://gist.github.com/visnup/1117145
require 'rubygems'
require 'FasterCSV'
require 'httparty'
require 'json'
github_user = 'xxx'
github_repo = 'xxx'
gcode_repo = 'xxx'
class GitHub
include HTTParty
base_uri 'https://api.github.com'
basic_auth "xxx", "xxx"
end
FasterCSV.open ARGV.shift, :headers => true do |csv|
csv.each do |r|
# title, body, assignee, milestone, labels
body = {
:title => r['Summary'],
:body => "Issue Migrated from http://code.google.com/p/#{gcode_repo}/issues/detail?id=#{r['ID']}",
:labels => [ "gcode"]
}
issue = GitHub.post "/repos/#{github_user}/#{github_repo}/issues", :body => JSON.generate(body)
p issue
end
end
Replace xxx with the appropriate values for your usage, and make sure you run it on a test repo first.
I then closed all the issues in google code with a comment pointing to the github issue list. Using the advanced tab of the Admin menu in Google code, I replaced the Issues tab with a wiki page that also pointed people to the github issue list.
As per the issue mentioned in the original post, there has since been a pull request which supposedly fixes the 404 error.