Skip to content

Version 7.2 and deprecation of msrest #478

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

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Changes from all 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
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -18,15 +18,15 @@ To use the API, establish a connection using a [personal access token](https://d

```python
from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from azure.identity import UsernamePasswordCredential
import pprint

# Fill in with your personal access token and org URL
personal_access_token = 'YOURPAT'
organization_url = 'https://dev.azure.com/YOURORG'

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

# Get a client (the "core" client provides access to projects, teams, etc)
2 changes: 1 addition & 1 deletion azure-devops/azure/devops/_models.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model
from azure.core.serialization import Model


class ApiResourceLocation(Model):
24 changes: 24 additions & 0 deletions azure-devops/azure/devops/azure_devops_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.core import PipelineClient
from azure.core.pipeline.policies import UserAgentPolicy, HeadersPolicy
from .version import VERSION


class AzureDevOpsClient(PipelineClient):
def __init__(self, base_url=None, credentials=None, user_agent=None):
if not base_url:
raise ValueError('base_url is required.')
if not credentials:
raise ValueError('credentials is required.')
base_url = base_url.rstrip('/')
user_agent_policy = UserAgentPolicy('azure-devops/{}'.format(VERSION))
if user_agent is not None:
user_agent_policy.add_user_agent(user_agent)
headers_policy = HeadersPolicy()
headers_policy.add_header('Authentication', credentials)
policies = [user_agent_policy, headers_policy]
super(AzureDevOpsClient, self).__init__(base_url=base_url, policies=policies)
12 changes: 4 additions & 8 deletions azure-devops/azure/devops/client.py
Original file line number Diff line number Diff line change
@@ -10,12 +10,10 @@
import re
import uuid

from msrest import Deserializer, Serializer
from msrest.exceptions import DeserializationError, SerializationError
from msrest.universal_http import ClientRequest
from msrest.service_client import ServiceClient
from azure.core.rest import HttpRequest, HttpResponse
from azure.core.exceptions import DeserializationError, SerializationError
from .exceptions import AzureDevOpsAuthenticationError, AzureDevOpsClientRequestError, AzureDevOpsServiceError
from .client_configuration import ClientConfiguration
from .azure_devops_client import AzureDevOpsClient
from . import _models
from ._file_cache import OPTIONS_CACHE as OPTIONS_FILE_CACHE

@@ -30,9 +28,7 @@ class Client(object):
"""

def __init__(self, base_url=None, creds=None):
self.config = ClientConfiguration(base_url)
self.config.credentials = creds
self._client = ServiceClient(creds, config=self.config)
self._client = AzureDevOpsClient(base_url=base_url, credentials=creds)
_base_client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._base_deserialize = Deserializer(_base_client_models)
self._base_serialize = Serializer(_base_client_models)
17 changes: 0 additions & 17 deletions azure-devops/azure/devops/client_configuration.py

This file was deleted.

19 changes: 7 additions & 12 deletions azure-devops/azure/devops/connection.py
Original file line number Diff line number Diff line change
@@ -5,14 +5,13 @@

import logging

from msrest.service_client import ServiceClient
from ._file_cache import RESOURCE_CACHE as RESOURCE_FILE_CACHE
from .client_configuration import ClientConfiguration
from .azure_devops_client import AzureDevOpsClient
from .exceptions import AzureDevOpsClientRequestError
from .released.client_factory import ClientFactory
from .v7_1.location.location_client import LocationClient
from .v7_2.location.location_client import LocationClient
from .v7_2.client_factory import ClientFactoryV7_2
from .v7_1.client_factory import ClientFactoryV7_1
from .v7_0.client_factory import ClientFactoryV7_0

logger = logging.getLogger(__name__)

@@ -21,20 +20,16 @@ class Connection(object):
"""Connection.
"""

def __init__(self, base_url=None, creds=None, user_agent=None):
self._config = ClientConfiguration(base_url)
self._config.credentials = creds
def __init__(self, base_url=None, credentials=None, user_agent=None):
self._addition_user_agent = user_agent
if user_agent is not None:
self._config.add_user_agent(user_agent)
self._client = ServiceClient(creds, self._config)
self._client = AzureDevOpsClient(base_url=base_url, credentials=credentials, user_agent=user_agent)
self._client_cache = {}
self.base_url = base_url
self._creds = creds
self._creds = credentials
self._resource_areas = None
self.clients = ClientFactory(self)
self.clients_v7_2 = ClientFactoryV7_2(self)
self.clients_v7_1 = ClientFactoryV7_1(self)
self.clients_v7_0 = ClientFactoryV7_0(self)
self.use_fiddler = False

def get_client(self, client_type):
2 changes: 1 addition & 1 deletion azure-devops/azure/devops/credentials.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from msrest.authentication import (
from azure.core.rest.authentication import (
BasicAuthentication,
BasicTokenAuthentication,
OAuthTokenAuthentication)
15 changes: 5 additions & 10 deletions azure-devops/azure/devops/exceptions.py
Original file line number Diff line number Diff line change
@@ -3,22 +3,17 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from msrest.exceptions import (
ClientException,
ClientRequestError,
AuthenticationError,
from azure.core.exceptions import (
ClientAuthenticationError,
ServiceResponseError
)


class AzureDevOpsClientError(ClientException):
class AzureDevOpsAuthenticationError(ClientAuthenticationError):
pass


class AzureDevOpsAuthenticationError(AuthenticationError):
pass


class AzureDevOpsClientRequestError(ClientRequestError):
class AzureDevOpsClientRequestError(ServiceResponseError):
pass


3 changes: 1 addition & 2 deletions azure-devops/azure/devops/issue_tests/test_issue_268.py
Original file line number Diff line number Diff line change
@@ -6,8 +6,7 @@
import pprint
import unittest

from msrest import Deserializer
from msrest.universal_http import HTTPClientResponse
from azure.core.rest import HttpRequest, HttpResponse


class _TestResponse(HTTPClientResponse):
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.accounts import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/build/build_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.build import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/cix/cix_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.cix import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/core/core_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.core import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.elastic import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/feed/feed_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.feed import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/git/git_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8

from msrest.universal_http import ClientRequest
from azure.core.rest import HttpRequest, HttpResponse
from .git_client_base import GitClientBase


2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/git/git_client_base.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.git import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/graph/graph_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.graph import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.identity import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.member_entitlement_management import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.notification import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/npm/npm_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.npm import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/nuget/nuget_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.nuget import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.operations import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.pipelines import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/policy/policy_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.policy import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.profile import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.project_analysis import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.release import models

2 changes: 1 addition & 1 deletion azure-devops/azure/devops/released/search/search_client.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.search import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.security import models

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------------------------

from msrest import Serializer, Deserializer
from azure.core.rest import HttpRequest, HttpResponse
from ...client import Client
from ...v7_0.service_endpoint import models

Loading
Oops, something went wrong.
Loading
Oops, something went wrong.