Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and add 5.x apis #178

Merged
merged 20 commits into from
Feb 25, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,6 @@ __pycache__/
.vscode/
vsts/build/bdist.win32/

# don't ignore release managment client
!vsts/vsts/release
# don't ignore release management client
!azure-devops/azure/devops/v5_0/release
!azure-devops/azure/devops/v5_1/release
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

# Azure DevOps Python API

This repository contains Python APIs for interacting with and managing Azure DevOps. These APIs power the Visual Studio Team Services CLI. To learn more about the VSTS CLI, visit the [Microsoft/vsts-cli](https://github.com/Microsoft/vsts-cli) repo.
This repository contains Python APIs for interacting with and managing Azure DevOps. These APIs power the Azure DevOps Extension for Azure CLI. To learn more about the Azure DevOps Extension for Azure CLI, visit the [Microsoft/azure-devops-cli-extension](https://github.com/Microsoft/azure-devops-cli-extension) repo.

## Install

```
pip install vsts
pip install azure-devops
```

## Get started
Expand All @@ -17,7 +17,7 @@ pip install vsts
To use the API, establish a connection using a [personal access token](https://docs.microsoft.com/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts) and the URL to your Azure DevOps organization. Then get a client from the connection and make API calls.

```python
from vsts.vss_connection import VssConnection
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
import pprint

Expand All @@ -27,10 +27,10 @@ organization_url = 'https://dev.azure.com/YOURORG'

# Create a connection to the org
credentials = BasicAuthentication('', personal_access_token)
connection = VssConnection(base_url=organization_url, creds=credentials)
connection = Connection(base_url=organization_url, creds=credentials)

# Get a client (the "core" client provides access to projects, teams, etc)
core_client = connection.get_client('vsts.core.v4_0.core_client.CoreClient')
core_client = connection.clients_v5_0.get_core_client()

# Get the list of projects in the org
projects = core_client.get_projects()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions azure-devops/azure/devops/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import pkg_resources
pkg_resources.declare_namespace(__name__)
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ def _check_for_initial_load(self):


def get_cache_dir():
vsts_cache_dir = os.getenv('VSTS_CACHE_DIR', None) or os.path.expanduser(os.path.join('~', '.vsts', 'python-sdk',
'cache'))
if not os.path.exists(vsts_cache_dir):
os.makedirs(vsts_cache_dir)
return vsts_cache_dir
azure_devops_cache_dir = os.getenv('AZURE_DEVOPS_CACHE_DIR', None)\
or os.path.expanduser(os.path.join('~', '.azure-devops', 'python-sdk', 'cache'))
if not os.path.exists(azure_devops_cache_dir):
os.makedirs(azure_devops_cache_dir)
return azure_devops_cache_dir


DEFAULT_MAX_AGE = 3600 * 12 # 12 hours
Expand Down
215 changes: 215 additions & 0 deletions azure-devops/azure/devops/_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Generated file, DO NOT EDIT
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class ApiResourceLocation(Model):
"""ApiResourceLocation.
"""

_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'area': {'key': 'area', 'type': 'str'},
'resource_name': {'key': 'resourceName', 'type': 'str'},
'route_template': {'key': 'routeTemplate', 'type': 'str'},
'resource_version': {'key': 'resourceVersion', 'type': 'int'},
'min_version': {'key': 'minVersion', 'type': 'float'},
'max_version': {'key': 'maxVersion', 'type': 'float'},
'released_version': {'key': 'releasedVersion', 'type': 'str'},
}

def __init__(self, id=None, area=None, resource_name=None,
route_template=None, resource_version=None,
min_version=None, max_version=None,
released_version=None):
super(ApiResourceLocation, self).__init__()
self.id = id
self.area = area
self.resource_name = resource_name
self.route_template = route_template
self.resource_version = resource_version
self.min_version = min_version
self.max_version = max_version
self.released_version = released_version


class CustomerIntelligenceEvent(Model):
"""CustomerIntelligenceEvent.

:param area:
:type area: str
:param feature:
:type feature: str
:param properties:
:type properties: dict
"""

_attribute_map = {
'area': {'key': 'area', 'type': 'str'},
'feature': {'key': 'feature', 'type': 'str'},
'properties': {'key': 'properties', 'type': '{object}'}
}

def __init__(self, area=None, feature=None, properties=None):
super(CustomerIntelligenceEvent, self).__init__()
self.area = area
self.feature = feature
self.properties = properties


class ImproperException(Model):
"""ImproperException.
:param message:
:type message: str
"""

_attribute_map = {
'message': {'key': 'Message', 'type': 'str'}
}

def __init__(self, message=None):
super(ImproperException, self).__init__()
self.message = message


class ResourceAreaInfo(Model):
"""ResourceAreaInfo.

:param id:
:type id: str
:param location_url:
:type location_url: str
:param name:
:type name: str
"""

_attribute_map = {
'id': {'key': 'id', 'type': 'str'},
'location_url': {'key': 'locationUrl', 'type': 'str'},
'name': {'key': 'name', 'type': 'str'}
}

def __init__(self, id=None, location_url=None, name=None):
super(ResourceAreaInfo, self).__init__()
self.id = id
self.location_url = location_url
self.name = name


class SystemException(Model):
"""SystemException.
:param class_name:
:type class_name: str
:param inner_exception:
:type inner_exception: :class:`SystemException`
:param message:
:type message: str
"""

_attribute_map = {
'class_name': {'key': 'ClassName', 'type': 'str'},
'message': {'key': 'Message', 'type': 'str'},
'inner_exception': {'key': 'InnerException', 'type': 'SystemException'}
}

def __init__(self, class_name=None, message=None, inner_exception=None):
super(SystemException, self).__init__()
self.class_name = class_name
self.message = message
self.inner_exception = inner_exception


class VssJsonCollectionWrapperBase(Model):
"""VssJsonCollectionWrapperBase.

:param count:
:type count: int
"""

_attribute_map = {
'count': {'key': 'count', 'type': 'int'}
}

def __init__(self, count=None):
super(VssJsonCollectionWrapperBase, self).__init__()
self.count = count


class VssJsonCollectionWrapper(VssJsonCollectionWrapperBase):
"""VssJsonCollectionWrapper.

:param count:
:type count: int
:param value:
:type value: object
"""

_attribute_map = {
'count': {'key': 'count', 'type': 'int'},
'value': {'key': 'value', 'type': 'object'}
}

def __init__(self, count=None, value=None):
super(VssJsonCollectionWrapper, self).__init__(count=count)
self.value = value


class WrappedException(Model):
"""WrappedException.
:param exception_id:
:type exception_id: str
:param inner_exception:
:type inner_exception: :class:`WrappedException`
:param message:
:type message: str
:param type_name:
:type type_name: str
:param type_key:
:type type_key: str
:param error_code:
:type error_code: int
:param event_id:
:type event_id: int
:param custom_properties:
:type custom_properties: dict
"""

_attribute_map = {
'exception_id': {'key': '$id', 'type': 'str'},
'inner_exception': {'key': 'innerException', 'type': 'WrappedException'},
'message': {'key': 'message', 'type': 'str'},
'type_name': {'key': 'typeName', 'type': 'str'},
'type_key': {'key': 'typeKey', 'type': 'str'},
'error_code': {'key': 'errorCode', 'type': 'int'},
'event_id': {'key': 'eventId', 'type': 'int'},
'custom_properties': {'key': 'customProperties', 'type': '{object}'}
}

def __init__(self, exception_id=None, inner_exception=None, message=None,
type_name=None, type_key=None, error_code=None, event_id=None, custom_properties=None):
super(WrappedException, self).__init__()
self.exception_id = exception_id
self.inner_exception = inner_exception
self.message = message
self.type_name = type_name
self.type_key = type_key
self.error_code = error_code
self.event_id = event_id
self.custom_properties = custom_properties


__all__ = [
'ApiResourceLocation',
'CustomerIntelligenceEvent',
'ImproperException',
'ResourceAreaInfo',
'SystemException',
'VssJsonCollectionWrapperBase',
'VssJsonCollectionWrapper',
'WrappedException'
]
Loading