Skip to content
This repository was archived by the owner on Jun 8, 2022. It is now read-only.

Commit b848f26

Browse files
committed
Support for new dev.azure.com url
1 parent 1053b4e commit b848f26

File tree

4 files changed

+105
-74
lines changed

4 files changed

+105
-74
lines changed

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,22 @@ In order to connect to Azure DevOps, you need to obtain a [personal access token
1414
# Import the VstsClient module
1515
from vstsclient.vstsclient import VstsClient
1616

17-
# Initialize the VSTS client using the VSTS instance and personal access token
17+
# Initialize the VSTS client using the Azure DevOps url and personal access token
18+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
19+
```
20+
Or using the 'old' url.
21+
```python
1822
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
1923
```
2024
### What about TFS?
2125
To connect to an on-premises TFS environment you supply the server name and port number (default is 8080).
2226
```python
2327
client = VstsClient('tfs.contoso.com:8080', '<personalaccesstoken>')
2428
```
29+
The VSTS client will pick the `DefaultCollection` by default. You can specify a different collection using the optional `collection` parameter.
30+
```python
31+
client = VstsClient('tfs.contoso.com:8080', '<personalaccesstoken>', '<your collection>')
32+
```
2533
### Connecting from behind a proxy
2634
```python
2735
client.set_proxy('proxy.contoso.com', 8080, '<username>', '<password>')
@@ -34,7 +42,7 @@ Get all team projects in the project collection that the authenticated user has
3442
from vstsclient.vstsclient import VstsClient
3543
from vstsclient.constants import StateFilter
3644

37-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
45+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
3846

3947
# StateFilter options are WellFormed (default), New, Deleting, CreatePending and All
4048
projects = client.get_projects(StateFilter.WELL_FORMED)
@@ -43,7 +51,7 @@ projects = client.get_projects(StateFilter.WELL_FORMED)
4351
```python
4452
from vstsclient.vstsclient import VstsClient
4553

46-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
54+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
4755
project = client.get_project('Self-flying car')
4856
```
4957
### Create a team project
@@ -55,7 +63,7 @@ from vstsclient.constants import (
5563
SourceControlType
5664
)
5765

58-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
66+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
5967
project = client.create_project(
6068
'Self-flying car', # Project name
6169
'A project for our self-flying car', # Project description
@@ -70,14 +78,14 @@ All work items have an area and an iteration field. The values that these fields
7078
```python
7179
from vstsclient.vstsclient import VstsClient
7280

73-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
81+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
7482
areas = client.get_areas('Self-flying car')
7583
```
7684
#### Get the area tree with 2 levels of children
7785
```python
7886
from vstsclient.vstsclient import VstsClient
7987

80-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
88+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
8189
areas = client.get_areas('Self-flying car', 2)
8290

8391
for area in areas.children:
@@ -87,14 +95,14 @@ for area in areas.children:
8795
```python
8896
from vstsclient.vstsclient import VstsClient
8997

90-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
98+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
9199
iterations = client.get_iterations('Self-flying car')
92100
```
93101
#### Get the iteration tree with 2 levels of children
94102
```python
95103
from vstsclient.vstsclient import VstsClient
96104

97-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
105+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
98106
iterations = client.get_iterations(
99107
'Self-flying car', # Team project name
100108
2) # Hierarchy depth
@@ -107,22 +115,22 @@ for iteration in iterations.children:
107115
```python
108116
from vstsclient.vstsclient import VstsClient
109117

110-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
118+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
111119
area = client.get_area('Self-flying car', 'Engine')
112120
```
113121
#### Get an iteration
114122
```python
115123
from vstsclient.vstsclient import VstsClient
116124

117-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
125+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
118126
iteration = client.get_iteration('Self-flying car', 'Sprint 1')
119127
```
120128
### Create an area and iteration
121129
#### Create an area
122130
```python
123131
from vstsclient.vstsclient import VstsClient
124132

125-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
133+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
126134
area = client.create_area(
127135
'Self-flying car', # Team project name
128136
'Engine') # Area name
@@ -134,7 +142,7 @@ from vstsclient.vstsclient import VstsClient
134142
start_date = datetime.datetime.utcnow() # Sprint starts today
135143
finish_date = start_date + datetime.timedelta(days=21) # Ends in 3 weeks
136144

137-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
145+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
138146
iteration = client.create_iteration(
139147
'Self-flying car', # Team project name
140148
'Sprint 1', # Iteration name
@@ -147,14 +155,14 @@ iteration = client.create_iteration(
147155
```python
148156
from vstsclient.vstsclient import VstsClient
149157

150-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
158+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
151159
workitems = client.get_workitems_by_id('1,2,3,5,8,13,21,34')
152160
```
153161
### Get a work item
154162
```python
155163
from vstsclient.vstsclient import VstsClient
156164

157-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
165+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
158166
workitem = client.get_workitem(13)
159167
```
160168
### Create a work item
@@ -164,7 +172,7 @@ from vstsclient.vstsclient import VstsClient
164172
from vstsclient.models import JsonPatchDocument, JsonPatchOperation
165173
from vstsclient.constants import SystemFields, MicrosoftFields
166174

167-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
175+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
168176

169177
# Create a JsonPatchDocument and provide the values for the work item fields
170178
doc = JsonPatchDocument()
@@ -184,7 +192,7 @@ from vstsclient.vstsclient import VstsClient
184192
from vstsclient.models import JsonPatchDocument, JsonPatchOperation
185193
from vstsclient.constants import SystemFields
186194

187-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
195+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
188196

189197
# Create a JsonPatchDocument and provide the values for the fields to update
190198
doc = JsonPatchDocument()
@@ -196,13 +204,13 @@ workitem = client.update_workitem(13, doc)
196204
#### Change work item type
197205
NOTE: Only supported on Azure DevOps (not on TFS).
198206
```python
199-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
207+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
200208
client.change_workitem_type(13, 'Task')
201209
```
202210
#### Move a work item
203211
NOTE: Only supported on Azure DevOps (not on TFS).
204212
```python
205-
client = VstsClient('<account>.visualstudio.com', '<personalaccesstoken>')
213+
client = VstsClient('dev.azure.com/<account>', '<personalaccesstoken>')
206214

207215
# To move a work item, provide the Team Project, Area path and Iteration path to move to
208216
client.move_workitem(13, 'Contoso', 'Contoso', 'Sprint 1')

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
if __name__ == "__main__":
3030
setup(
3131
name='vsts-client',
32-
version='0.1.0',
33-
description='VSTS client library',
34-
long_description='A Python client library for VSTS/TFS.',
32+
version='1.1.0',
33+
description='Azure DevOps client library',
34+
long_description='A Python client library for Azure DevOps/TFS.',
3535
license='MIT License',
3636
author='Robbie Coenmans',
3737
author_email='robbie.coenmans@outlook.com',
3838
url='https://github.com/rcoenmans/vsts-client',
3939
classifiers=[
40-
'Development Status :: 3 - Alpha',
40+
'Development Status :: 5 - Production/Stable',
4141
'Intended Audience :: Developers',
4242

4343
'Programming Language :: Python :: 3',

vstsclient/_hosts.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -----------------------------------------------------------------------------
2+
# The MIT License (MIT)
3+
# Copyright (c) 2018 Robbie Coenmans
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
# -----------------------------------------------------------------------------
23+
import re
24+
25+
def _is_new_azure_devops_host(instance):
26+
# VSTS: {account}.visualstudio.com/{collection}
27+
# TFS: server:port/{collection} (the default port is 8080)
28+
# Azure DevOps: dev.azure.com/{account}
29+
return re.search(r'^dev\.azure\.com', instance)

0 commit comments

Comments
 (0)