8
8
9
9
from ._identity ._generated ._communication_identity_client \
10
10
import CommunicationIdentityClient as CommunicationIdentityClientGen
11
- from ._identity ._generated .models import CommunicationIdentityToken
11
+ from ._identity ._generated .models import CommunicationIdentityAccessToken
12
12
from ._shared .utils import parse_connection_str , get_authentication_policy
13
13
from ._shared .models import CommunicationUser
14
14
from ._version import SDK_MONIKER
@@ -82,13 +82,35 @@ def create_user(self, **kwargs):
82
82
# type: (...) -> CommunicationUser
83
83
"""create a single Communication user
84
84
85
- return: CommunicationUser
86
- rtype: ~azure.communication.administration.CommunicationUser
85
+ : return: CommunicationUser
86
+ : rtype: ~azure.communication.administration.CommunicationUser
87
87
"""
88
- return self ._identity_service_client .communication_identity .create (
88
+ return self ._identity_service_client .communication_identity .create_identity (
89
89
cls = lambda pr , u , e : CommunicationUser (u .id ),
90
90
** kwargs )
91
91
92
+ @distributed_trace
93
+ def create_user_with_token (
94
+ self ,
95
+ scopes , # type: List[Union[str, "_model.CommunicationIdentityTokenScope"]]
96
+ ** kwargs # type: Any
97
+ ):
98
+ # type: (...) -> Tuple[CommunicationUser, CommunicationIdentityAccessToken]
99
+ """create a single Communication user with an identity token.
100
+
101
+ :param scopes:
102
+ List of scopes to be added to the token.
103
+ :type scopes: list[str or
104
+ ~azure.communication.administration.models.CommunicationIdentityTokenScope]
105
+ :return: A CommunicationUser and a CommunicationIdentityToken tuple.
106
+ :rtype: tuple of (~azure.communication.administration.CommunicationUser,
107
+ ~azure.communication.administration.CommunicationIdentityToken)
108
+ """
109
+ return self ._identity_service_client .communication_identity .create_identity (
110
+ cls = lambda pr , u , e : CommunicationUser (u .id ),
111
+ create_token_with_scopes = scopes ,
112
+ ** kwargs )
113
+
92
114
@distributed_trace
93
115
def delete_user (
94
116
self ,
@@ -104,28 +126,29 @@ def delete_user(
104
126
:return: None
105
127
:rtype: None
106
128
"""
107
- self ._identity_service_client .communication_identity .delete (
129
+ self ._identity_service_client .communication_identity .delete_identity (
108
130
communication_user .identifier , ** kwargs )
109
131
110
132
@distributed_trace
111
133
def issue_token (
112
134
self ,
113
135
user , # type: CommunicationUser
114
- scopes , # type: List[str]
136
+ scopes , # List[Union[ str, "_model.CommunicationIdentityTokenScope"] ]
115
137
** kwargs # type: Any
116
138
):
117
- # type: (...) -> CommunicationIdentityToken
139
+ # type: (...) -> CommunicationIdentityAccessToken
118
140
"""Generates a new token for an identity.
119
141
120
142
:param user: Azure Communication User
121
143
:type user: ~azure.communication.administration.CommunicationUser
122
144
:param scopes:
123
145
List of scopes to be added to the token.
124
- :type scopes: list[str]
125
- :return: CommunicationIdentityToken
126
- :rtype: ~azure.communication.administration.CommunicationIdentityToken
146
+ :type scopes: list[str or
147
+ ~azure.communication.administration.models.CommunicationIdentityTokenScope]
148
+ :return: CommunicationIdentityAccessToken
149
+ :rtype: ~azure.communication.administration.CommunicationIdentityAccessToken
127
150
"""
128
- return self ._identity_service_client .communication_identity .issue_token (
151
+ return self ._identity_service_client .communication_identity .issue_access_token (
129
152
user .identifier ,
130
153
scopes ,
131
154
** kwargs )
@@ -134,20 +157,16 @@ def issue_token(
134
157
def revoke_tokens (
135
158
self ,
136
159
user , # type: CommunicationUser
137
- issued_before = None , # type: Optional[datetime.datetime]
138
160
** kwargs # type: Any
139
161
):
140
162
# type: (...) -> None
141
163
"""Schedule revocation of all tokens of an identity.
142
164
143
165
:param user: Azure Communication User.
144
166
:type user: ~azure.communication.administration.CommunicationUser.
145
- :param issued_before: All tokens that are issued prior to this time should get revoked.
146
- :type issued_before: ~datetime.datetime.
147
167
:return: None
148
168
:rtype: None
149
169
"""
150
- return self ._identity_service_client .communication_identity .update (
170
+ return self ._identity_service_client .communication_identity .revoke_access_tokens (
151
171
user .identifier if user else None ,
152
- tokens_valid_from = issued_before ,
153
172
** kwargs )
0 commit comments