Skip to content

Commit 55c8742

Browse files
Merge pull request #3 from lsundaralingam/identity-redesign-personal
Updated sync identity client based on latest swagger
2 parents 65e3f3a + cf291c1 commit 55c8742

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

sdk/communication/azure-communication-administration/azure/communication/administration/_communication_identity_client.py

+35-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from ._identity._generated._communication_identity_client\
1010
import CommunicationIdentityClient as CommunicationIdentityClientGen
11-
from ._identity._generated.models import CommunicationIdentityToken
11+
from ._identity._generated.models import CommunicationIdentityAccessToken
1212
from ._shared.utils import parse_connection_str, get_authentication_policy
1313
from ._shared.models import CommunicationUser
1414
from ._version import SDK_MONIKER
@@ -82,13 +82,35 @@ def create_user(self, **kwargs):
8282
# type: (...) -> CommunicationUser
8383
"""create a single Communication user
8484
85-
return: CommunicationUser
86-
rtype: ~azure.communication.administration.CommunicationUser
85+
:return: CommunicationUser
86+
:rtype: ~azure.communication.administration.CommunicationUser
8787
"""
88-
return self._identity_service_client.communication_identity.create(
88+
return self._identity_service_client.communication_identity.create_identity(
8989
cls=lambda pr, u, e: CommunicationUser(u.id),
9090
**kwargs)
9191

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+
92114
@distributed_trace
93115
def delete_user(
94116
self,
@@ -104,28 +126,29 @@ def delete_user(
104126
:return: None
105127
:rtype: None
106128
"""
107-
self._identity_service_client.communication_identity.delete(
129+
self._identity_service_client.communication_identity.delete_identity(
108130
communication_user.identifier, **kwargs)
109131

110132
@distributed_trace
111133
def issue_token(
112134
self,
113135
user, # type: CommunicationUser
114-
scopes, # type: List[str]
136+
scopes, # List[Union[str, "_model.CommunicationIdentityTokenScope"]]
115137
**kwargs # type: Any
116138
):
117-
# type: (...) -> CommunicationIdentityToken
139+
# type: (...) -> CommunicationIdentityAccessToken
118140
"""Generates a new token for an identity.
119141
120142
:param user: Azure Communication User
121143
:type user: ~azure.communication.administration.CommunicationUser
122144
:param scopes:
123145
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
127150
"""
128-
return self._identity_service_client.communication_identity.issue_token(
151+
return self._identity_service_client.communication_identity.issue_access_token(
129152
user.identifier,
130153
scopes,
131154
**kwargs)
@@ -134,20 +157,16 @@ def issue_token(
134157
def revoke_tokens(
135158
self,
136159
user, # type: CommunicationUser
137-
issued_before=None, # type: Optional[datetime.datetime]
138160
**kwargs # type: Any
139161
):
140162
# type: (...) -> None
141163
"""Schedule revocation of all tokens of an identity.
142164
143165
:param user: Azure Communication User.
144166
: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.
147167
:return: None
148168
:rtype: None
149169
"""
150-
return self._identity_service_client.communication_identity.update(
170+
return self._identity_service_client.communication_identity.revoke_access_tokens(
151171
user.identifier if user else None,
152-
tokens_valid_from=issued_before,
153172
**kwargs)

0 commit comments

Comments
 (0)