Skip to content

Commit c09bf15

Browse files
authored
Merge pull request #245 from microsoft/users/tedchamb/dev5
Add audit and token clients. update resource area id on search client
2 parents b73e436 + fd689fe commit c09bf15

File tree

19 files changed

+1357
-2
lines changed

19 files changed

+1357
-2
lines changed

azure-devops/azure/devops/v5_0/client_factory.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,20 @@ def get_tfvc_client(self):
316316
"""
317317
return self._connection.get_client('azure.devops.v5_0.tfvc.tfvc_client.TfvcClient')
318318

319+
def get_token_admin_client(self):
320+
"""get_token_admin_client.
321+
Gets the 5.0 version of the TokenAdminClient
322+
:rtype: :class:`<TokenAdminClient> <azure.devops.v5_0.token_admin.token_admin_client.TokenAdminClient>`
323+
"""
324+
return self._connection.get_client('azure.devops.v5_0.token_admin.token_admin_client.TokenAdminClient')
325+
326+
def get_token_administration_client(self):
327+
"""get_token_administration_client.
328+
Gets the 5.0 version of the TokenAdministrationClient
329+
:rtype: :class:`<TokenAdministrationClient> <azure.devops.v5_0.token_administration.token_administration_client.TokenAdministrationClient>`
330+
"""
331+
return self._connection.get_client('azure.devops.v5_0.token_administration.token_administration_client.TokenAdministrationClient')
332+
319333
def get_upack_api_client(self):
320334
"""get_upack_api_client.
321335
Gets the 5.0 version of the UPackApiClient

azure-devops/azure/devops/v5_0/search/search_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self, base_url=None, creds=None):
2323
self._serialize = Serializer(client_models)
2424
self._deserialize = Deserializer(client_models)
2525

26-
resource_area_identifier = None
26+
resource_area_identifier = 'ea48a0a1-269c-42d8-b8ad-ddc8fcdcf578'
2727

2828
def fetch_code_search_results(self, request, project=None):
2929
"""FetchCodeSearchResults.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
# Generated file, DO NOT EDIT
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------------------------
8+
9+
from .models import *
10+
from .token_admin_client import TokenAdminClient
11+
12+
__all__ = [
13+
'SessionToken',
14+
'TokenAdminPagedSessionTokens',
15+
'TokenAdminRevocation',
16+
'TokenAdminRevocationRule',
17+
'TokenAdminClient'
18+
]
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
# Generated file, DO NOT EDIT
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------------------------
8+
9+
from msrest.serialization import Model
10+
11+
12+
class SessionToken(Model):
13+
"""SessionToken.
14+
15+
:param access_id:
16+
:type access_id: str
17+
:param alternate_token: This is populated when user requests a compact token. The alternate token value is self describing token.
18+
:type alternate_token: str
19+
:param authorization_id:
20+
:type authorization_id: str
21+
:param client_id:
22+
:type client_id: str
23+
:param display_name:
24+
:type display_name: str
25+
:param host_authorization_id:
26+
:type host_authorization_id: str
27+
:param is_public:
28+
:type is_public: bool
29+
:param is_valid:
30+
:type is_valid: bool
31+
:param public_data:
32+
:type public_data: str
33+
:param scope:
34+
:type scope: str
35+
:param source:
36+
:type source: str
37+
:param target_accounts:
38+
:type target_accounts: list of str
39+
:param token: This is computed and not returned in Get queries
40+
:type token: str
41+
:param user_id:
42+
:type user_id: str
43+
:param valid_from:
44+
:type valid_from: datetime
45+
:param valid_to:
46+
:type valid_to: datetime
47+
"""
48+
49+
_attribute_map = {
50+
'access_id': {'key': 'accessId', 'type': 'str'},
51+
'alternate_token': {'key': 'alternateToken', 'type': 'str'},
52+
'authorization_id': {'key': 'authorizationId', 'type': 'str'},
53+
'client_id': {'key': 'clientId', 'type': 'str'},
54+
'display_name': {'key': 'displayName', 'type': 'str'},
55+
'host_authorization_id': {'key': 'hostAuthorizationId', 'type': 'str'},
56+
'is_public': {'key': 'isPublic', 'type': 'bool'},
57+
'is_valid': {'key': 'isValid', 'type': 'bool'},
58+
'public_data': {'key': 'publicData', 'type': 'str'},
59+
'scope': {'key': 'scope', 'type': 'str'},
60+
'source': {'key': 'source', 'type': 'str'},
61+
'target_accounts': {'key': 'targetAccounts', 'type': '[str]'},
62+
'token': {'key': 'token', 'type': 'str'},
63+
'user_id': {'key': 'userId', 'type': 'str'},
64+
'valid_from': {'key': 'validFrom', 'type': 'iso-8601'},
65+
'valid_to': {'key': 'validTo', 'type': 'iso-8601'}
66+
}
67+
68+
def __init__(self, access_id=None, alternate_token=None, authorization_id=None, client_id=None, display_name=None, host_authorization_id=None, is_public=None, is_valid=None, public_data=None, scope=None, source=None, target_accounts=None, token=None, user_id=None, valid_from=None, valid_to=None):
69+
super(SessionToken, self).__init__()
70+
self.access_id = access_id
71+
self.alternate_token = alternate_token
72+
self.authorization_id = authorization_id
73+
self.client_id = client_id
74+
self.display_name = display_name
75+
self.host_authorization_id = host_authorization_id
76+
self.is_public = is_public
77+
self.is_valid = is_valid
78+
self.public_data = public_data
79+
self.scope = scope
80+
self.source = source
81+
self.target_accounts = target_accounts
82+
self.token = token
83+
self.user_id = user_id
84+
self.valid_from = valid_from
85+
self.valid_to = valid_to
86+
87+
88+
class TokenAdminPagedSessionTokens(Model):
89+
"""TokenAdminPagedSessionTokens.
90+
91+
:param continuation_token: The continuation token that can be used to retrieve the next page of session tokens, or <code>null</code> if there is no next page.
92+
:type continuation_token: str
93+
:param value: The list of all session tokens in the current page.
94+
:type value: list of :class:`SessionToken <azure.devops.v5_0.token_admin.models.SessionToken>`
95+
"""
96+
97+
_attribute_map = {
98+
'continuation_token': {'key': 'continuationToken', 'type': 'str'},
99+
'value': {'key': 'value', 'type': '[SessionToken]'}
100+
}
101+
102+
def __init__(self, continuation_token=None, value=None):
103+
super(TokenAdminPagedSessionTokens, self).__init__()
104+
self.continuation_token = continuation_token
105+
self.value = value
106+
107+
108+
class TokenAdminRevocation(Model):
109+
"""TokenAdminRevocation.
110+
111+
:param authorization_id: The authorization ID of the OAuth authorization to revoke.
112+
:type authorization_id: str
113+
"""
114+
115+
_attribute_map = {
116+
'authorization_id': {'key': 'authorizationId', 'type': 'str'}
117+
}
118+
119+
def __init__(self, authorization_id=None):
120+
super(TokenAdminRevocation, self).__init__()
121+
self.authorization_id = authorization_id
122+
123+
124+
class TokenAdminRevocationRule(Model):
125+
"""TokenAdminRevocationRule.
126+
127+
:param created_before: A datetime cutoff. Tokens created before this time will be rejected. This is an optional paramter. If omitted, defaults to the time at which the rule was created.
128+
:type created_before: datetime
129+
:param scopes: A string containing a space-delimited list of OAuth scopes. A token matching any one of the scopes will be rejected. For a list of all OAuth scopes supported by VSTS, see: https://docs.microsoft.com/en-us/vsts/integrate/get-started/authentication/oauth?view=vsts#scopes. This is a mandatory parameter.
130+
:type scopes: str
131+
"""
132+
133+
_attribute_map = {
134+
'created_before': {'key': 'createdBefore', 'type': 'iso-8601'},
135+
'scopes': {'key': 'scopes', 'type': 'str'}
136+
}
137+
138+
def __init__(self, created_before=None, scopes=None):
139+
super(TokenAdminRevocationRule, self).__init__()
140+
self.created_before = created_before
141+
self.scopes = scopes
142+
143+
144+
__all__ = [
145+
'SessionToken',
146+
'TokenAdminPagedSessionTokens',
147+
'TokenAdminRevocation',
148+
'TokenAdminRevocationRule',
149+
]
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
# Generated file, DO NOT EDIT
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------------------------
8+
9+
from msrest import Serializer, Deserializer
10+
from ...client import Client
11+
from . import models
12+
13+
14+
class TokenAdminClient(Client):
15+
"""TokenAdmin
16+
:param str base_url: Service URL
17+
:param Authentication creds: Authenticated credentials.
18+
"""
19+
20+
def __init__(self, base_url=None, creds=None):
21+
super(TokenAdminClient, self).__init__(base_url, creds)
22+
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
23+
self._serialize = Serializer(client_models)
24+
self._deserialize = Deserializer(client_models)
25+
26+
resource_area_identifier = 'af68438b-ed04-4407-9eb6-f1dbae3f922e'
27+
28+
def list_personal_access_tokens(self, subject_descriptor, page_size=None, continuation_token=None, is_public=None):
29+
"""ListPersonalAccessTokens.
30+
[Preview API] Lists of all the session token details of the personal access tokens (PATs) for a particular user.
31+
:param :class:`<str> <azure.devops.v5_0.token_admin.models.str>` subject_descriptor: The descriptor of the target user.
32+
:param int page_size: The maximum number of results to return on each page.
33+
:param str continuation_token: An opaque data blob that allows the next page of data to resume immediately after where the previous page ended. The only reliable way to know if there is more data left is the presence of a continuation token.
34+
:param bool is_public: Set to false for PAT tokens and true for SSH tokens.
35+
:rtype: :class:`<TokenAdminPagedSessionTokens> <azure.devops.v5_0.token_admin.models.TokenAdminPagedSessionTokens>`
36+
"""
37+
route_values = {}
38+
if subject_descriptor is not None:
39+
route_values['subjectDescriptor'] = self._serialize.url('subject_descriptor', subject_descriptor, 'str')
40+
query_parameters = {}
41+
if page_size is not None:
42+
query_parameters['pageSize'] = self._serialize.query('page_size', page_size, 'int')
43+
if continuation_token is not None:
44+
query_parameters['continuationToken'] = self._serialize.query('continuation_token', continuation_token, 'str')
45+
if is_public is not None:
46+
query_parameters['isPublic'] = self._serialize.query('is_public', is_public, 'bool')
47+
response = self._send(http_method='GET',
48+
location_id='af68438b-ed04-4407-9eb6-f1dbae3f922e',
49+
version='5.0-preview.1',
50+
route_values=route_values,
51+
query_parameters=query_parameters)
52+
return self._deserialize('TokenAdminPagedSessionTokens', response)
53+
54+
def create_revocation_rule(self, revocation_rule):
55+
"""CreateRevocationRule.
56+
[Preview API] Creates a revocation rule to prevent the further usage of any OAuth authorizations that were created before the current point in time and which match the conditions in the rule.
57+
:param :class:`<TokenAdminRevocationRule> <azure.devops.v5_0.token_admin.models.TokenAdminRevocationRule>` revocation_rule: The revocation rule to create. The rule must specify a space-separated list of scopes, after which preexisting OAuth authorizations that match that any of the scopes will be rejected. For a list of all OAuth scopes supported by VSTS, see: https://docs.microsoft.com/en-us/vsts/integrate/get-started/authentication/oauth?view=vsts#scopes The rule may also specify the time before which to revoke tokens.
58+
"""
59+
content = self._serialize.body(revocation_rule, 'TokenAdminRevocationRule')
60+
self._send(http_method='POST',
61+
location_id='ee4afb16-e7ab-4ed8-9d4b-4ef3e78f97e4',
62+
version='5.0-preview.1',
63+
content=content)
64+
65+
def revoke_authorizations(self, revocations, is_public=None):
66+
"""RevokeAuthorizations.
67+
[Preview API] Revokes the listed OAuth authorizations.
68+
:param [TokenAdminRevocation] revocations: The list of objects containing the authorization IDs of the OAuth authorizations, such as session tokens retrieved by listed a users PATs, that should be revoked.
69+
:param bool is_public: Set to false for PAT tokens and true for SSH tokens.
70+
"""
71+
query_parameters = {}
72+
if is_public is not None:
73+
query_parameters['isPublic'] = self._serialize.query('is_public', is_public, 'bool')
74+
content = self._serialize.body(revocations, '[TokenAdminRevocation]')
75+
self._send(http_method='POST',
76+
location_id='a9c08b2c-5466-4e22-8626-1ff304ffdf0f',
77+
version='5.0-preview.1',
78+
query_parameters=query_parameters,
79+
content=content)
80+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
# Generated file, DO NOT EDIT
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------------------------
8+
9+
from .models import *
10+
from .token_administration_client import TokenAdministrationClient
11+
12+
__all__ = [
13+
'SessionToken',
14+
'TokenAdministrationRevocation',
15+
'TokenAdminPagedSessionTokens',
16+
'TokenAdminRevocation',
17+
'TokenAdministrationClient'
18+
]

0 commit comments

Comments
 (0)