SlideShare a Scribd company logo
Has this happened to you? Email to users results in 50+ undeliverable Need to verify the users in Active Directory Then “deactivate” former employees in Crowd 750 mouse clicks later, you’re done! 2 http://www.flickr.com/photos/left-hand/4231405740/
3 Automate That!
Agenda Use cases for scripting Atlassian APIs available for scripting The awesome power and simplicity of python Examples 4
When is scripting useful? Automate time consuming tasks Perform data analysis Cross-reference data from multiple systems 5
Some specific use cases Crowd – Deactivate Users and remove from all groups Bamboo – Disable all plans in a project JIRA – Release Notes Subversion – custom commit acceptance Custom build processes – pull code linked to a specific issue into a patch archive 6
Why Scripts?Why Not Plugins? 7 ,[object Object]
Installing new plugins can require a restart
Prefer to minimize ad hoc changes on the server
Need to correlate information from several systems
Need an agile process to accommodate changing requirements,[object Object]
More APIs for scripting(the ones we prefer to use) RESTful Remote APIs (now deprecated) High level interface Supports a handful of actions Now emerging:  “real” REST interfaces High level interface Supports a handful of actions http://confluence.atlassian.com/display/REST/Guidelines+for+Atlassian+REST+API+Design 9
Why Python? Powerful standard libraries Http(s) with cookie handling XML and JSON Unicode Third Party Libraries SOAP REST Templates Subversion Portable, cross-platform 10
Python Versions 2.x Ships with most linux distributions Lots of third-party packages available 3.x Latest version Deliberately incompatible with 2.x Not as many third-party libraries 11
HTTP(s) with Python Python 2 httplib – low level, all HTTP verbs urllib – GET and POST, utilities urllib2 – GET and POST using Request class, easier manipulation of headers, handlers for cookies, proxies, etc. Python 3 http.client – low level, all HTTP verbs http.parse - utilities urllib.request – similar to urllib2 Third-Party httplib2 – high-level interface with all HTTP verbs, plus caching, compression, etc. 12
Example 1JIRA Issue Query & Retrieval 13
14 Discovering URLs for XML
Simple Issue Retrieval 15 import urllib, httplib import xml.etree.ElementTree as etree jira_serverurl = 'http://jira.atlassian.com' jira_userid = 'myuserid' jira_password = 'mypassword' detailsURL = jira_serverurl + br />	"/si/jira.issueviews:issue-xml/JRA-9/JRA-9.xml" + br />	"?os_username=" + jira_userid + "&os_password=" + jira_password f = urllib.urlopen(detailsURL) tree=etree.parse(f) f.close() Construct a URL that looks like the one in the UI, with extra parms for our user auth Open the URL with one line! Parse the XML with one line!
Find details in XML 16 Find based on tag name or path to element details = tree.getroot() print "Issue: " + details.find("channel/item/key").text print "Status: " + details.find("channel/item/status").text print "Summary: " + details.find("channel/item/summary").text print "Description: " + details.find("channel/item/description").text Issue: JRA-9 Status: Open Summary: User Preference: User Time Zones Description: <p>Add time zones to user profile.     That way the dates displayed to a user are always contiguous with their local time zone, rather than the server's time zone.</p>
Behind the scenes…cookies! 17 Turn on debugging and see exactly what’s happening httplib.HTTPConnection.debuglevel= 1 f = urllib.urlopen(detailsURL) send: 'GET /si/jira.issueviews:issue-xml/JRA-9/JRA-9.xml?os_username=myuserid&os_password=mypassword HTTP/1.0Host: jira.atlassian.comUser-Agent: Python-urllib/1.17' reply: 'HTTP/1.1 200 OK' header: Date: Wed, 20 Apr 2011 12:04:37 GMT header: Server: Apache-Coyote/1.1 header: X-AREQUESTID: 424x2804517x1 header: X-Seraph-LoginReason: OK header: X-AUSERNAME: myuserid header: X-ASESSIONID: 19b3b8o header: Content-Type: text/xml;charset=UTF-8 header: Set-Cookie: JSESSIONID=A1357C4805B1345356404A65333436D3; Path=/ header: Set-Cookie: atlassian.xsrf.token=AKVY-YUFR-9LM7-97AB|e5545d754a98ea0e54f 8434fde36326fb340e8b7|lin; Path=/ header: Connection: close JSESSIONID cookie sent from JIRA
Authentication User credentials determine: The data returned The operations allowed Methods Available: Basic Authentication JSESSIONID Cookie Token Method 18
Basic Authentication Authentication credentials passed with each request Can be used with REST API 19
JSESSIONID Cookie Authentication credentials passed once; then cookie is used Used when scripting the user interface Can be used with REST API for JIRA, Confluence, and Bamboo 20
Token Method Authentication credentials passed once; then token is used Used with Fisheye/Crucible REST Used with Deprecated Bamboo Remote API 21
Obtaining a cookie Scripting the user interface login page Adding parameters to the user interface URL: “?os_username=myUserID&os_password=myPassword” Using the JIRA REST API 22
JIRA REST Authentication 23 import urllib, urllib2, cookielib, json # set up cookiejar for handling URLs cookiejar = cookielib.CookieJar() myopener= urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) creds = { "username" : jira_userid, "password" : jira_password } queryurl = jira_serverurl + "/rest/auth/latest/session" req = urllib2.Request(queryurl) req.add_data(json.dumps(creds)) req.add_header("Content-type", "application/json") req.add_header("Accept", "application/json") fp= myopener.open(req)  fp.close() urllib2 handles cookies automatically.  We just need to give it a CookieJar Request and response are both JSON We don’t care about response, just the cookie
Submitting a JIRA Querywith the user interface 24 # Search using JQL queryJQL = urllib.quote("key in watchedIssues()") queryURL = jira_serverurl + br />           "/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml" + br />           "?tempMax=1000&jqlQuery=" + queryJQL fp = myopener.open(queryURL) # Search using an existing filter filterId = "20124" queryURL = jira_serverurl + br />           "/sr/jira.issueviews:searchrequest-xml/" + br />           "{0}/SearchRequest-{0}.xml?tempMax=1000".format(filterId) fp = myopener.open(queryURL) Pass any JQL Query Or Pass the ID of an existing shared filter
A JQL Query using REST 25 # Search using JQL queryJQL= "key in watchedIssues()" IssuesQuery= {     "jql" : queryJQL,     "startAt" : 0,     "maxResults" : 1000 } queryURL = jira_serverurl + "/rest/api/latest/search" req = urllib2.Request(queryURL) req.add_data(json.dumps(IssuesQuery)) req.add_header("Content-type", "application/json") req.add_header("Accept", "application/json") fp= myopener.open(req) data = json.load(fp) fp.close() Pass any JQL Query Request and response are both JSON
XML returned from user interface query 26 An RSS Feed with all issues and requested fields that have values
JSON returnedfrom a REST query 27 {u'total': 83,  u'startAt': 0,  u'issues': [{u'self': u'http://jira.atlassian.com/rest/api/latest/issue/JRA-23969',  u'key': u'JRA-23969'},  	{u'self': u'http://jira.atlassian.com/rest/api/latest/issue/JRA-23138',  u'key': u'JRA-23138'},  	{u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-2770',  u'key': u'BAM-2770'},  	{u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-2489',  u'key': u'BAM-2489'},  	{u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-1410',  u'key': u'BAM-1410'},  	{u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-1143',  u'key': u'BAM-1143'}],  u'maxResults': 200} A list of the issues found, with links to retrieve more information
JSON issue details 28 All applicable fields are returned, even if there’s no value Expand the html property to get rendered html for description, comments
What’s the difference? 29 <reporter username="mlassau">Mark Lassau [Atlassian]</reporter> <customfield id="customfield_10160" key="com.atlassian.jira.toolkit:dayslastcommented"> 	<customfieldname>Last commented</customfieldname> 	<customfieldvalues> 			1 week ago 	</customfieldvalues> </customfield> u'reporter': { u'type': u'com.opensymphony.user.User',  u'name': u'reporter',  u'value': { u'self': u'http://jira.atlassian.com/rest/api/latest/user?username=mlassau',  u'displayName': u'MarkLassau [Atlassian]',  u'name': u'mlassau'}},  u'customfield_10160': { u'type': u'com.atlassian.jira.toolkit:dayslastcommented',  u'name': u'Last commented',  u'value': 604800},  XML values are display strings REST values are type-dependent
REST vs. non-REST 30 REST ,[object Object]
Returns all fields
Values require type-specific interpretation
Easier to transition issues
Easier to get info for projects, componentsNon-REST ,[object Object]
XML returns only fields that contain values
Values always one or more display strings
Can do anything a user can do (with a little work),[object Object]
Which build resolved my issue? Bamboo keeps track of “related issues” (based on issue IDs included in commit comments), but doesn’t know when issues are resolved. If we know the issue is resolved in JIRA, we can look to see the latest build that lists our ID as a “related issue” Not a continuous integration build?   We’ll need to look in fisheye to determine the highest revision related to this issue and then look in bamboo to see if a build using this revision has completed successfully. 32
To Fisheye for related commits! 33 queryURL= FisheyeServer + "/rest-service-fe/changeset-v1/listChangesets" + br />           "?rep={0}&comment={1}&expand=changesets".format(FisheyeRepo, myissue) req= urllib2.Request(queryURL) auth_string = '{0}:{1}'.format(fisheye_userid,fisheye_password) base64string = base64.encodestring(auth_string)[:-1] req.add_header("Authorization", "Basic {0}".format(base64string)) response = myopener.open(req) issuecommits=etree.parse(response).getroot() response.close() Query a specific fisheye repository for a commit with our JIRA issue ID in the comments Use basic auth headers to authenticate
Fisheye changesets returned 34 <results expand="changesets">     <changesets>     	<changeset> 	    <csid>130948</csid> 	    <date>2011-04-29T12:35:56.150-04:00</date> 	    <author>lc6081</author> 	    <branch>trunk</branch> 	    <comment>MYJIRAPROJECT-2823 Modified to add parameters</comment> 	    <revisions size="1" />     	</changeset>     </changesets> </results>
Parsing the changesets 35 commits = [] for changeset in issuecommits.findall("changesets/changeset"): commits.append(changeset.findtext("csid")) commits.sort() print "Highest commit is: " + commits[-1] Highest commit is: 130948

More Related Content

What's hot

Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020
Mikio L. Braun
 
Introduction to Azure Synapse Webinar
Introduction to Azure Synapse WebinarIntroduction to Azure Synapse Webinar
Introduction to Azure Synapse Webinar
Peter Ward
 
Azure training
Azure trainingAzure training
Azure training
Koenig Solutions Ltd.
 
Real time data integration best practices and architecture
Real time data integration best practices and architectureReal time data integration best practices and architecture
Real time data integration best practices and architecture
Bui Kiet
 
Big data unit 2
Big data unit 2Big data unit 2
Big data unit 2
RojaT4
 
Sysmon and Windows Event Forwarding workshop
Sysmon and Windows Event Forwarding workshopSysmon and Windows Event Forwarding workshop
Sysmon and Windows Event Forwarding workshop
Dave Willingham
 
Building a Next-Generation Security Operation Center Based on IBM QRadar and ...
Building a Next-Generation Security Operation Center Based on IBM QRadar and ...Building a Next-Generation Security Operation Center Based on IBM QRadar and ...
Building a Next-Generation Security Operation Center Based on IBM QRadar and ...
IBM Security
 
Big Data Visualization
Big Data VisualizationBig Data Visualization
Big Data Visualization
Raffael Marty
 
Azure Synapse Analytics Overview (r1)
Azure Synapse Analytics Overview (r1)Azure Synapse Analytics Overview (r1)
Azure Synapse Analytics Overview (r1)
James Serra
 
Azure Synapse 101 Webinar Presentation
Azure Synapse 101 Webinar PresentationAzure Synapse 101 Webinar Presentation
Azure Synapse 101 Webinar Presentation
Matthew W. Bowers
 
Understanding Azure Disaster Recovery
Understanding Azure Disaster RecoveryUnderstanding Azure Disaster Recovery
Understanding Azure Disaster Recovery
New Horizons Ireland
 
[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트
[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트
[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트
Amazon Web Services Korea
 
Introduction to Data Analytics
Introduction to Data AnalyticsIntroduction to Data Analytics
Introduction to Data Analytics
Dr. C.V. Suresh Babu
 
ODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data Management
ODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data ManagementODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data Management
ODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data Management
Francisco Amores
 
Zero to Snowflake Presentation
Zero to Snowflake Presentation Zero to Snowflake Presentation
Zero to Snowflake Presentation
Brett VanderPlaats
 
Data Analytics PowerPoint Presentation Slides
Data Analytics PowerPoint Presentation SlidesData Analytics PowerPoint Presentation Slides
Data Analytics PowerPoint Presentation Slides
SlideTeam
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
OutsourceAX
 
Practical data science
Practical data sciencePractical data science
Practical data science
Ding Li
 
Information Security Governance and Strategy - 3
Information Security Governance and Strategy - 3Information Security Governance and Strategy - 3
Information Security Governance and Strategy - 3
Dam Frank
 

What's hot (20)

Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020Bringing ML To Production, What Is Missing? AMLD 2020
Bringing ML To Production, What Is Missing? AMLD 2020
 
Introduction to Azure Synapse Webinar
Introduction to Azure Synapse WebinarIntroduction to Azure Synapse Webinar
Introduction to Azure Synapse Webinar
 
Azure training
Azure trainingAzure training
Azure training
 
Real time data integration best practices and architecture
Real time data integration best practices and architectureReal time data integration best practices and architecture
Real time data integration best practices and architecture
 
Data analytics
Data analyticsData analytics
Data analytics
 
Big data unit 2
Big data unit 2Big data unit 2
Big data unit 2
 
Sysmon and Windows Event Forwarding workshop
Sysmon and Windows Event Forwarding workshopSysmon and Windows Event Forwarding workshop
Sysmon and Windows Event Forwarding workshop
 
Building a Next-Generation Security Operation Center Based on IBM QRadar and ...
Building a Next-Generation Security Operation Center Based on IBM QRadar and ...Building a Next-Generation Security Operation Center Based on IBM QRadar and ...
Building a Next-Generation Security Operation Center Based on IBM QRadar and ...
 
Big Data Visualization
Big Data VisualizationBig Data Visualization
Big Data Visualization
 
Azure Synapse Analytics Overview (r1)
Azure Synapse Analytics Overview (r1)Azure Synapse Analytics Overview (r1)
Azure Synapse Analytics Overview (r1)
 
Azure Synapse 101 Webinar Presentation
Azure Synapse 101 Webinar PresentationAzure Synapse 101 Webinar Presentation
Azure Synapse 101 Webinar Presentation
 
Understanding Azure Disaster Recovery
Understanding Azure Disaster RecoveryUnderstanding Azure Disaster Recovery
Understanding Azure Disaster Recovery
 
[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트
[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트
[AWS Innovate 온라인 컨퍼런스] 한국어를 위한 AWS 인공지능(AI) 서비스 소개 및 활용 방법 - 강정희, AWS 솔루션즈 아키텍트
 
Introduction to Data Analytics
Introduction to Data AnalyticsIntroduction to Data Analytics
Introduction to Data Analytics
 
ODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data Management
ODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data ManagementODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data Management
ODTUG KSCOPE 2017 - Black Belt Techniques for FDMEE and Cloud Data Management
 
Zero to Snowflake Presentation
Zero to Snowflake Presentation Zero to Snowflake Presentation
Zero to Snowflake Presentation
 
Data Analytics PowerPoint Presentation Slides
Data Analytics PowerPoint Presentation SlidesData Analytics PowerPoint Presentation Slides
Data Analytics PowerPoint Presentation Slides
 
Dynamics ax performance tuning
Dynamics ax performance tuningDynamics ax performance tuning
Dynamics ax performance tuning
 
Practical data science
Practical data sciencePractical data science
Practical data science
 
Information Security Governance and Strategy - 3
Information Security Governance and Strategy - 3Information Security Governance and Strategy - 3
Information Security Governance and Strategy - 3
 

Viewers also liked

JIRA REST Client for Python - Atlassian Summit 2012
JIRA REST Client for Python - Atlassian Summit 2012JIRA REST Client for Python - Atlassian Summit 2012
JIRA REST Client for Python - Atlassian Summit 2012Atlassian
 
The Ultimate Wallboard
The Ultimate WallboardThe Ultimate Wallboard
The Ultimate Wallboard
Atlassian User Group Netherlands
 
Kinecting with Wallboards
Kinecting with WallboardsKinecting with Wallboards
Kinecting with WallboardsAtlassian
 
Connecting HipChat to (allthethings)
Connecting HipChat to (allthethings)Connecting HipChat to (allthethings)
Connecting HipChat to (allthethings)
Atlassian
 
Guerilla marketing your service desk
Guerilla marketing your service deskGuerilla marketing your service desk
Guerilla marketing your service desk
Atlassian
 
Atlassian Overview
Atlassian OverviewAtlassian Overview
Atlassian Overview
Atlassian
 

Viewers also liked (6)

JIRA REST Client for Python - Atlassian Summit 2012
JIRA REST Client for Python - Atlassian Summit 2012JIRA REST Client for Python - Atlassian Summit 2012
JIRA REST Client for Python - Atlassian Summit 2012
 
The Ultimate Wallboard
The Ultimate WallboardThe Ultimate Wallboard
The Ultimate Wallboard
 
Kinecting with Wallboards
Kinecting with WallboardsKinecting with Wallboards
Kinecting with Wallboards
 
Connecting HipChat to (allthethings)
Connecting HipChat to (allthethings)Connecting HipChat to (allthethings)
Connecting HipChat to (allthethings)
 
Guerilla marketing your service desk
Guerilla marketing your service deskGuerilla marketing your service desk
Guerilla marketing your service desk
 
Atlassian Overview
Atlassian OverviewAtlassian Overview
Atlassian Overview
 

Similar to Automate That! Scripting Atlassian applications in Python

Apache Eagle in Action
Apache Eagle in ActionApache Eagle in Action
Apache Eagle in Action
Hao Chen
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeMarco Gralike
 
Why Managed Service Providers Should Embrace Container Technology
Why Managed Service Providers Should Embrace Container TechnologyWhy Managed Service Providers Should Embrace Container Technology
Why Managed Service Providers Should Embrace Container Technology
Sagi Brody
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
Tim Burks
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.pptwebhostingguy
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
Solution4Future
 
Top 5 things to know about sql azure for developers
Top 5 things to know about sql azure for developersTop 5 things to know about sql azure for developers
Top 5 things to know about sql azure for developers
Ike Ellis
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
DrupalcampAtlanta2012
 
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
Amazon Web Services
 
Gohan
GohanGohan
Gohan
Nachi Ueno
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
Alan Seiden
 
Apache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San JoseApache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San Jose
Hao Chen
 
Apache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real TimeApache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real Time
DataWorks Summit/Hadoop Summit
 
Apache Eagle Dublin Hadoop Summit 2016
Apache Eagle   Dublin Hadoop Summit 2016Apache Eagle   Dublin Hadoop Summit 2016
Apache Eagle Dublin Hadoop Summit 2016
Edward Zhang
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
Mykhailo Kolesnyk
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
Anil Saldanha
 
REST Api Tips and Tricks
REST Api Tips and TricksREST Api Tips and Tricks
REST Api Tips and Tricks
Maksym Bruner
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
dwm042
 

Similar to Automate That! Scripting Atlassian applications in Python (20)

Wikilims Road4
Wikilims Road4Wikilims Road4
Wikilims Road4
 
Apache Eagle in Action
Apache Eagle in ActionApache Eagle in Action
Apache Eagle in Action
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
 
Why Managed Service Providers Should Embrace Container Technology
Why Managed Service Providers Should Embrace Container TechnologyWhy Managed Service Providers Should Embrace Container Technology
Why Managed Service Providers Should Embrace Container Technology
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
WE18_Performance_Up.ppt
WE18_Performance_Up.pptWE18_Performance_Up.ppt
WE18_Performance_Up.ppt
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
 
Top 5 things to know about sql azure for developers
Top 5 things to know about sql azure for developersTop 5 things to know about sql azure for developers
Top 5 things to know about sql azure for developers
 
Talking to Web Services
Talking to Web ServicesTalking to Web Services
Talking to Web Services
 
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
(WEB301) Operational Web Log Analysis | AWS re:Invent 2014
 
Gohan
GohanGohan
Gohan
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
 
Apache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San JoseApache Eagle at Hadoop Summit 2016 San Jose
Apache Eagle at Hadoop Summit 2016 San Jose
 
Apache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real TimeApache Eagle: Secure Hadoop in Real Time
Apache Eagle: Secure Hadoop in Real Time
 
ebay
ebayebay
ebay
 
Apache Eagle Dublin Hadoop Summit 2016
Apache Eagle   Dublin Hadoop Summit 2016Apache Eagle   Dublin Hadoop Summit 2016
Apache Eagle Dublin Hadoop Summit 2016
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
REST Api Tips and Tricks
REST Api Tips and TricksREST Api Tips and Tricks
REST Api Tips and Tricks
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 

More from Atlassian

International Women's Day 2020
International Women's Day 2020International Women's Day 2020
International Women's Day 2020
Atlassian
 
10 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 202010 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 2020
Atlassian
 
Forge App Showcase
Forge App ShowcaseForge App Showcase
Forge App Showcase
Atlassian
 
Let's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UILet's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UI
Atlassian
 
Meet the Forge Runtime
Meet the Forge RuntimeMeet the Forge Runtime
Meet the Forge Runtime
Atlassian
 
Forge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User ExperienceForge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User Experience
Atlassian
 
Take Action with Forge Triggers
Take Action with Forge TriggersTake Action with Forge Triggers
Take Action with Forge Triggers
Atlassian
 
Observability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeObservability and Troubleshooting in Forge
Observability and Troubleshooting in Forge
Atlassian
 
Trusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy ModelTrusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy Model
Atlassian
 
Designing Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemDesigning Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI System
Atlassian
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the Hood
Atlassian
 
Access to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIsAccess to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIs
Atlassian
 
Design Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch PluginDesign Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch Plugin
Atlassian
 
Tear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the BuildingTear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the Building
Atlassian
 
Nailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that MatterNailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that Matter
Atlassian
 
Building Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in MindBuilding Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in Mind
Atlassian
 
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Atlassian
 
Beyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced TeamsBeyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced Teams
Atlassian
 
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed TeamThe Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
Atlassian
 
Building Apps With Enterprise in Mind
Building Apps With Enterprise in MindBuilding Apps With Enterprise in Mind
Building Apps With Enterprise in Mind
Atlassian
 

More from Atlassian (20)

International Women's Day 2020
International Women's Day 2020International Women's Day 2020
International Women's Day 2020
 
10 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 202010 emerging trends that will unbreak your workplace in 2020
10 emerging trends that will unbreak your workplace in 2020
 
Forge App Showcase
Forge App ShowcaseForge App Showcase
Forge App Showcase
 
Let's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UILet's Build an Editor Macro with Forge UI
Let's Build an Editor Macro with Forge UI
 
Meet the Forge Runtime
Meet the Forge RuntimeMeet the Forge Runtime
Meet the Forge Runtime
 
Forge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User ExperienceForge UI: A New Way to Customize the Atlassian User Experience
Forge UI: A New Way to Customize the Atlassian User Experience
 
Take Action with Forge Triggers
Take Action with Forge TriggersTake Action with Forge Triggers
Take Action with Forge Triggers
 
Observability and Troubleshooting in Forge
Observability and Troubleshooting in ForgeObservability and Troubleshooting in Forge
Observability and Troubleshooting in Forge
 
Trusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy ModelTrusted by Default: The Forge Security & Privacy Model
Trusted by Default: The Forge Security & Privacy Model
 
Designing Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI SystemDesigning Forge UI: A Story of Designing an App UI System
Designing Forge UI: A Story of Designing an App UI System
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the Hood
 
Access to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIsAccess to User Activities - Activity Platform APIs
Access to User Activities - Activity Platform APIs
 
Design Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch PluginDesign Your Next App with the Atlassian Vendor Sketch Plugin
Design Your Next App with the Atlassian Vendor Sketch Plugin
 
Tear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the BuildingTear Up Your Roadmap and Get Out of the Building
Tear Up Your Roadmap and Get Out of the Building
 
Nailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that MatterNailing Measurement: a Framework for Measuring Metrics that Matter
Nailing Measurement: a Framework for Measuring Metrics that Matter
 
Building Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in MindBuilding Apps With Color Blind Users in Mind
Building Apps With Color Blind Users in Mind
 
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
Creating Inclusive Experiences: Balancing Personality and Accessibility in UX...
 
Beyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced TeamsBeyond Diversity: A Guide to Building Balanced Teams
Beyond Diversity: A Guide to Building Balanced Teams
 
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed TeamThe Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
The Road(map) to Las Vegas - The Story of an Emerging Self-Managed Team
 
Building Apps With Enterprise in Mind
Building Apps With Enterprise in MindBuilding Apps With Enterprise in Mind
Building Apps With Enterprise in Mind
 

Recently uploaded

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 

Recently uploaded (20)

PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 

Automate That! Scripting Atlassian applications in Python

  • 1.
  • 2. Has this happened to you? Email to users results in 50+ undeliverable Need to verify the users in Active Directory Then “deactivate” former employees in Crowd 750 mouse clicks later, you’re done! 2 http://www.flickr.com/photos/left-hand/4231405740/
  • 4. Agenda Use cases for scripting Atlassian APIs available for scripting The awesome power and simplicity of python Examples 4
  • 5. When is scripting useful? Automate time consuming tasks Perform data analysis Cross-reference data from multiple systems 5
  • 6. Some specific use cases Crowd – Deactivate Users and remove from all groups Bamboo – Disable all plans in a project JIRA – Release Notes Subversion – custom commit acceptance Custom build processes – pull code linked to a specific issue into a patch archive 6
  • 7.
  • 8. Installing new plugins can require a restart
  • 9. Prefer to minimize ad hoc changes on the server
  • 10. Need to correlate information from several systems
  • 11.
  • 12. More APIs for scripting(the ones we prefer to use) RESTful Remote APIs (now deprecated) High level interface Supports a handful of actions Now emerging: “real” REST interfaces High level interface Supports a handful of actions http://confluence.atlassian.com/display/REST/Guidelines+for+Atlassian+REST+API+Design 9
  • 13. Why Python? Powerful standard libraries Http(s) with cookie handling XML and JSON Unicode Third Party Libraries SOAP REST Templates Subversion Portable, cross-platform 10
  • 14. Python Versions 2.x Ships with most linux distributions Lots of third-party packages available 3.x Latest version Deliberately incompatible with 2.x Not as many third-party libraries 11
  • 15. HTTP(s) with Python Python 2 httplib – low level, all HTTP verbs urllib – GET and POST, utilities urllib2 – GET and POST using Request class, easier manipulation of headers, handlers for cookies, proxies, etc. Python 3 http.client – low level, all HTTP verbs http.parse - utilities urllib.request – similar to urllib2 Third-Party httplib2 – high-level interface with all HTTP verbs, plus caching, compression, etc. 12
  • 16. Example 1JIRA Issue Query & Retrieval 13
  • 18. Simple Issue Retrieval 15 import urllib, httplib import xml.etree.ElementTree as etree jira_serverurl = 'http://jira.atlassian.com' jira_userid = 'myuserid' jira_password = 'mypassword' detailsURL = jira_serverurl + br /> "/si/jira.issueviews:issue-xml/JRA-9/JRA-9.xml" + br /> "?os_username=" + jira_userid + "&os_password=" + jira_password f = urllib.urlopen(detailsURL) tree=etree.parse(f) f.close() Construct a URL that looks like the one in the UI, with extra parms for our user auth Open the URL with one line! Parse the XML with one line!
  • 19. Find details in XML 16 Find based on tag name or path to element details = tree.getroot() print "Issue: " + details.find("channel/item/key").text print "Status: " + details.find("channel/item/status").text print "Summary: " + details.find("channel/item/summary").text print "Description: " + details.find("channel/item/description").text Issue: JRA-9 Status: Open Summary: User Preference: User Time Zones Description: <p>Add time zones to user profile. That way the dates displayed to a user are always contiguous with their local time zone, rather than the server's time zone.</p>
  • 20. Behind the scenes…cookies! 17 Turn on debugging and see exactly what’s happening httplib.HTTPConnection.debuglevel= 1 f = urllib.urlopen(detailsURL) send: 'GET /si/jira.issueviews:issue-xml/JRA-9/JRA-9.xml?os_username=myuserid&os_password=mypassword HTTP/1.0Host: jira.atlassian.comUser-Agent: Python-urllib/1.17' reply: 'HTTP/1.1 200 OK' header: Date: Wed, 20 Apr 2011 12:04:37 GMT header: Server: Apache-Coyote/1.1 header: X-AREQUESTID: 424x2804517x1 header: X-Seraph-LoginReason: OK header: X-AUSERNAME: myuserid header: X-ASESSIONID: 19b3b8o header: Content-Type: text/xml;charset=UTF-8 header: Set-Cookie: JSESSIONID=A1357C4805B1345356404A65333436D3; Path=/ header: Set-Cookie: atlassian.xsrf.token=AKVY-YUFR-9LM7-97AB|e5545d754a98ea0e54f 8434fde36326fb340e8b7|lin; Path=/ header: Connection: close JSESSIONID cookie sent from JIRA
  • 21. Authentication User credentials determine: The data returned The operations allowed Methods Available: Basic Authentication JSESSIONID Cookie Token Method 18
  • 22. Basic Authentication Authentication credentials passed with each request Can be used with REST API 19
  • 23. JSESSIONID Cookie Authentication credentials passed once; then cookie is used Used when scripting the user interface Can be used with REST API for JIRA, Confluence, and Bamboo 20
  • 24. Token Method Authentication credentials passed once; then token is used Used with Fisheye/Crucible REST Used with Deprecated Bamboo Remote API 21
  • 25. Obtaining a cookie Scripting the user interface login page Adding parameters to the user interface URL: “?os_username=myUserID&os_password=myPassword” Using the JIRA REST API 22
  • 26. JIRA REST Authentication 23 import urllib, urllib2, cookielib, json # set up cookiejar for handling URLs cookiejar = cookielib.CookieJar() myopener= urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) creds = { "username" : jira_userid, "password" : jira_password } queryurl = jira_serverurl + "/rest/auth/latest/session" req = urllib2.Request(queryurl) req.add_data(json.dumps(creds)) req.add_header("Content-type", "application/json") req.add_header("Accept", "application/json") fp= myopener.open(req) fp.close() urllib2 handles cookies automatically. We just need to give it a CookieJar Request and response are both JSON We don’t care about response, just the cookie
  • 27. Submitting a JIRA Querywith the user interface 24 # Search using JQL queryJQL = urllib.quote("key in watchedIssues()") queryURL = jira_serverurl + br /> "/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml" + br /> "?tempMax=1000&jqlQuery=" + queryJQL fp = myopener.open(queryURL) # Search using an existing filter filterId = "20124" queryURL = jira_serverurl + br /> "/sr/jira.issueviews:searchrequest-xml/" + br /> "{0}/SearchRequest-{0}.xml?tempMax=1000".format(filterId) fp = myopener.open(queryURL) Pass any JQL Query Or Pass the ID of an existing shared filter
  • 28. A JQL Query using REST 25 # Search using JQL queryJQL= "key in watchedIssues()" IssuesQuery= { "jql" : queryJQL, "startAt" : 0, "maxResults" : 1000 } queryURL = jira_serverurl + "/rest/api/latest/search" req = urllib2.Request(queryURL) req.add_data(json.dumps(IssuesQuery)) req.add_header("Content-type", "application/json") req.add_header("Accept", "application/json") fp= myopener.open(req) data = json.load(fp) fp.close() Pass any JQL Query Request and response are both JSON
  • 29. XML returned from user interface query 26 An RSS Feed with all issues and requested fields that have values
  • 30. JSON returnedfrom a REST query 27 {u'total': 83, u'startAt': 0, u'issues': [{u'self': u'http://jira.atlassian.com/rest/api/latest/issue/JRA-23969', u'key': u'JRA-23969'}, {u'self': u'http://jira.atlassian.com/rest/api/latest/issue/JRA-23138', u'key': u'JRA-23138'}, {u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-2770', u'key': u'BAM-2770'}, {u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-2489', u'key': u'BAM-2489'}, {u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-1410', u'key': u'BAM-1410'}, {u'self': u'http://jira.atlassian.com/rest/api/latest/issue/BAM-1143', u'key': u'BAM-1143'}], u'maxResults': 200} A list of the issues found, with links to retrieve more information
  • 31. JSON issue details 28 All applicable fields are returned, even if there’s no value Expand the html property to get rendered html for description, comments
  • 32. What’s the difference? 29 <reporter username="mlassau">Mark Lassau [Atlassian]</reporter> <customfield id="customfield_10160" key="com.atlassian.jira.toolkit:dayslastcommented"> <customfieldname>Last commented</customfieldname> <customfieldvalues> 1 week ago </customfieldvalues> </customfield> u'reporter': { u'type': u'com.opensymphony.user.User', u'name': u'reporter', u'value': { u'self': u'http://jira.atlassian.com/rest/api/latest/user?username=mlassau', u'displayName': u'MarkLassau [Atlassian]', u'name': u'mlassau'}}, u'customfield_10160': { u'type': u'com.atlassian.jira.toolkit:dayslastcommented', u'name': u'Last commented', u'value': 604800}, XML values are display strings REST values are type-dependent
  • 33.
  • 37.
  • 38. XML returns only fields that contain values
  • 39. Values always one or more display strings
  • 40.
  • 41. Which build resolved my issue? Bamboo keeps track of “related issues” (based on issue IDs included in commit comments), but doesn’t know when issues are resolved. If we know the issue is resolved in JIRA, we can look to see the latest build that lists our ID as a “related issue” Not a continuous integration build? We’ll need to look in fisheye to determine the highest revision related to this issue and then look in bamboo to see if a build using this revision has completed successfully. 32
  • 42. To Fisheye for related commits! 33 queryURL= FisheyeServer + "/rest-service-fe/changeset-v1/listChangesets" + br /> "?rep={0}&comment={1}&expand=changesets".format(FisheyeRepo, myissue) req= urllib2.Request(queryURL) auth_string = '{0}:{1}'.format(fisheye_userid,fisheye_password) base64string = base64.encodestring(auth_string)[:-1] req.add_header("Authorization", "Basic {0}".format(base64string)) response = myopener.open(req) issuecommits=etree.parse(response).getroot() response.close() Query a specific fisheye repository for a commit with our JIRA issue ID in the comments Use basic auth headers to authenticate
  • 43. Fisheye changesets returned 34 <results expand="changesets"> <changesets> <changeset> <csid>130948</csid> <date>2011-04-29T12:35:56.150-04:00</date> <author>lc6081</author> <branch>trunk</branch> <comment>MYJIRAPROJECT-2823 Modified to add parameters</comment> <revisions size="1" /> </changeset> </changesets> </results>
  • 44. Parsing the changesets 35 commits = [] for changeset in issuecommits.findall("changesets/changeset"): commits.append(changeset.findtext("csid")) commits.sort() print "Highest commit is: " + commits[-1] Highest commit is: 130948
  • 45. Logging into Bamboo 36 urllib2.HTTPCookieProcessor(cookiejar)) cookiejar = cookielib.CookieJar() myopener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) queryURL = bambooServer + "/userlogin!default.action“ params= urllib.urlencode({ "os_username" : bambooUserid, "os_password" : bambooPassword}) response = myopener.open(queryURL, params) response.close() Using a POST to the user interface login screen to retrieve a JSESSIONID cookie
  • 46. Querying for build results 37 # Warning: This is a very resource-intensive operation. # You should consider limiting the number of builds returned queryURL= bambooServer + "/rest/api/latest/result/MYPROJECT-MYPLAN" + br /> "?expand=results[-10:-1].result.jiraIssues" req = urllib2.Request(queryURL) req.add_header("Accept", "application/xml") response = myopener.open(req) results=etree.parse(response).getroot() response.close() Use negative indexes to return the last entries in build list, e.g. [-10:-1] returns last ten builds in list Request the related issues Ask for XML (JSON also available)
  • 47. Example (partial) build results 38 <results expand="results"> <link href="http://mybamboo.domain.com:8080/rest/api/latest/result/MYPROJECT-MYPLAN" rel="self" /> <results expand="result" max-result="25" size="46" start-index="0"> <result expand="comments,labels,jiraIssues,stages" id="3146125" key="MYPROJECT-MYPLAN-26" lifeCycleState="Finished" number="26" state="Successful"> <link href="http://mybamboo.domain.com:8080/rest/api/latest/result/MYPROJECT-MYPLAN-26" rel="self" /> <buildStartedTime>2011-04-29T05:04:14.460-05:00</buildStartedTime> <buildCompletedTime>2011-04-29T05:34:35.687-05:00</buildCompletedTime> <buildRelativeTime>4 days ago</buildRelativeTime> <vcsRevisionKey>4483</vcsRevisionKey> <buildReason>Code has changed</buildReason> <comments max-result="0" size="0" start-index="0" /> <labels max-result="0" size="0" start-index="0" /> <jiraIssues max-result="1" size="1" start-index="0"> <issue iconUrl="http://myjira.domain.com/images/icons/bug.gif" issueType="Defect" key="MYJIRAPROJECT-1629" summary="Need to display an error message when balance is zero."> <urlhref="http://myjira.domain.com/browse/MYJIRAPROJECT-1629" rel="self" /> </issue> </jiraIssues> <stages max-result="1" size="1" start-index="0" /> </result> </results> </results> Can also expand comments, labels, and stages jiraIssues property has been expanded here
  • 48. Walking through build results 39 for result in results.findall("results/result"): print result.get("key") + ":" print "Revision: " + result.findtext("vcsRevisionKey") issues = [issue.get("key") for issue in result.findall("jiraIssues/issue")] print "Issues: " + ", ".join(issues) MYPROJECT-MYPLAN-31: Revision: 4489 Issues: MYJIRAPROJECT-1658 MYPROJECT-MYPLAN-30: Revision: 4486 Issues: MYJIRAPROJECT-1630 MYPROJECT-MYPLAN-29: Revision: 4485 Issues: MYJIRAPROJECT-1616, MYJIRAPROJECT-1663
  • 49. Example 3Removing a user from a Crowd group 40
  • 50. Beyond GET and POST 41 Lower-level HTTPConnection needed connection = httplib.HTTPConnection('myCrowdServer.mydomain.com:8080') operation = 'DELETE' urlpath = "/rest/usermanagement/latest/user/group/direct" + br /> "?username={0}&groupname={1}".format(userToRemove, fromGroup) body = None auth_string = '{0}:{1}'.format(crowdAppName,crowdAppPassword) base64string = base64.encodestring(auth_string)[:-1] headers = {'Authorization' : "Basic {0}".format(base64string)} connection.request(operation, urlpath, body, headers) response = connection.getresponse() print response.status, response.reason connection.close() Authenticate as a Crowd Application 204 - group membership is successfully deleted 403 - not allowed to delete the group membership 404 - the user or group or membership could not be found
  • 51. A few loose ends Be prepared to handle Unicode strings Error handling – not shown here, but important! Formatting output – several python libraries for handling templates are available REST Interfaces – you can write your own! http://confluence.atlassian.com/display/DEVNET/Plugin+Tutorial+-+Writing+REST+Services 42
  • 52. Links for more information http://confluence.atlassian.com/display/JIRA/Displaying+Search+Results+in+XML http://confluence.atlassian.com/display/JIRA/JIRA+REST+API+(Alpha)+Tutorial http://confluence.atlassian.com/display/CONFDEV/Confluence+REST+APIs http://confluence.atlassian.com/display/FECRUDEV/REST+API+Guide http://confluence.atlassian.com/display/BAMBOO/Bamboo+REST+APIs http://confluence.atlassian.com/display/CROWDDEV/Crowd+REST+APIs 43

Editor's Notes

  1. FIS is part of the S&amp;P 500 and is one of the world&apos;s top-ranked technology providers to the banking industry.
  2. Three basic scenarios where scripting is useful
  3. JIRA – JQL provides amazing ability to search for issues. The presentation choices are limited, however, particularly if you want a report that you can email to others.
  4. We have 2,000 users, so we tend to value server stability
  5. All examples here in python 2
  6. No proper error handling in any of these examples
  7. Note that fields with wiki markup are returned as-is
  8. Here, we’re going to use cookies. The JSESSIONID cookie can be used interchangeably between REST and non-REST callsYou can also use basic auth
  9. No fields specified, so all fields are returned for all issues
  10. Currently not possible to search based on an existing filter using REST
  11. No fields are returned…. Just a list of the issues
  12. Custom fields are listed alongside system fields
  13. The contents of the “value” are highly dependent on the field type
  14. The revisions “size” attribute tells us how many files were committed in that changeset
  15. In practice, it seems that changesets are returned in decreasing order. The documentation doesn’t specify any order, however, so we’ll make no assumptions here
  16. Bamboo allows basic auth, but you have to supply “os_authType=basic” as a query parameter in addition to the basicauth header. Here, we elect to exercise the user interface and obtain a cookie instead.
  17. Just asking for the last 10 build results – would really want to loop backwards a chunk at a timeExpanding the related jira issues – can expand other fields as well Requesting the results in xml. Json also available
  18. Note that we can also expand comment, labels, and stages (in addition to related issues)