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

[Communication] - Identity - Renaming create_user_with_token identity function #17066

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/communication/azure-communication-identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ user = identity_client.create_user()
print("User created with id:" + user.identifier)
```

Alternatively, use the `create_user_with_token` method to create a new user and issue a token for it.\
Alternatively, use the `create_user_and_token` method to create a new user and issue a token for it.\
For this option, a list of `CommunicationTokenScope` must be defined (see "Issuing an access token" for more information)

```python
user, tokenresponse = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User id:" + user.identifier)
print("Token issued with value: " + tokenresponse.token)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def create_user(self, **kwargs):
**kwargs)

@distributed_trace
def create_user_with_token(
def create_user_and_token(
self,
scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]]
**kwargs # type: Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def create_user(self, **kwargs):
**kwargs)

@distributed_trace_async
async def create_user_with_token(
async def create_user_and_token(
self,
scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]]
**kwargs # type: Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create_user(self):
user = identity_client.create_user()
print("User created with id:" + user.identifier)

def create_user_with_token(self):
def create_user_and_token(self):
from azure.communication.identity import (
CommunicationIdentityClient,
CommunicationTokenScope
Expand All @@ -84,7 +84,7 @@ def create_user_with_token(self):
else:
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
print("Creating new user with token")
user, tokenresponse = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User created with id:" + user.identifier)
print("Token issued with value: " + tokenresponse.token)

Expand All @@ -104,7 +104,7 @@ def delete_user(self):
if __name__ == '__main__':
sample = CommunicationIdentityClientSamples()
sample.create_user()
sample.create_user_with_token()
sample.create_user_and_token()
sample.get_token()
sample.revoke_tokens()
sample.delete_user()
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def create_user(self):
user = await identity_client.create_user()
print("User created with id:" + user.identifier)

async def create_user_with_token(self):
async def create_user_and_token(self):
from azure.communication.identity.aio import CommunicationIdentityClient
from azure.communication.identity import CommunicationTokenScope
if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None:
Expand All @@ -86,7 +86,7 @@ async def create_user_with_token(self):

async with identity_client:
print("Creating new user with token")
user, tokenresponse = await identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, tokenresponse = await identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User created with id:" + user.identifier)
print("Token issued with value: " + tokenresponse.token)

Expand All @@ -107,7 +107,7 @@ async def delete_user(self):
async def main():
sample = CommunicationIdentityClientSamples()
await sample.create_user()
await sample.create_user_with_token()
await sample.create_user_and_token()
await sample.get_token()
await sample.revoke_tokens()
await sample.delete_user()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def test_create_user(self, connection_string):

@ResourceGroupPreparer(random_name_enabled=True)
@CommunicationServicePreparer()
def test_create_user_with_token(self, connection_string):
def test_create_user_and_token(self, connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
user, token_response = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, token_response = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])

assert user.identifier is not None
assert token_response.token is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ async def test_create_user(self, connection_string):

@ResourceGroupPreparer(random_name_enabled=True)
@CommunicationServicePreparer()
async def test_create_user_with_token(self, connection_string):
async def test_create_user_and_token(self, connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
async with identity_client:
user, token_response = await identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, token_response = await identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])

assert user.identifier is not None
assert token_response.token is not None
Expand Down