Skip to content

Conversation

@msyyc
Copy link
Member

@msyyc msyyc commented Sep 3, 2021

autorest --version=3.4.5 --python --track2 --use=D:\dev3\autorest.python --use=@autorest\[email protected] --python-sdks-folder=D:\dev3\azure-sdk-for-python\sdk --python-mode=update D:\dev3\azure-sdk-for-python\sdk\webpubsub\azure-messaging-webpubsubservice\swagger\README.md --version-tolerant

Copy link
Contributor

@iscai-msft iscai-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall @msyyc since a lot of this API is handwritten, generating autorest deleted a lot of the handwritten code. We don't want to delete any of the handwritten code, can you go back and add it back? thanks!

@msyyc msyyc requested a review from johanste September 8, 2021 07:12
@msyyc
Copy link
Member Author

msyyc commented Sep 8, 2021

overall @msyyc Yuchao Yan FTE since a lot of this API is handwritten, generating autorest deleted a lot of the handwritten code. We don't want to delete any of the handwritten code, can you go back and add it back? thanks!

Got it. I add necessary code back, including from_connection_string

}

@classmethod
def from_connection_string(cls, connection_string, **kwargs):
Copy link
Member

@johanste johanste Sep 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than modifying the generated code (and thus it being susceptible to being overwritten when regenerating), we should attempt to use the patch_sdk() method in the _patch.py file to make modifications. Not needed for this release, however.

Copy link
Member Author

@msyyc msyyc Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense. But I can't find an example what patch_sdk() should look like in Azure/azure-sdk-for-python

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add all the handwritten code into patch_sdk() to avoid changing generated code. Two problems left:
(1) aio does not have _patch.py and it will be deleted by codegen. I think we need to add it in autorest @iscai-msft
(2) do not have better ways to change __all__ in __init__ (). So every time these code will be covered.

@msyyc msyyc self-assigned this Sep 10, 2021
@msyyc msyyc marked this pull request as ready for review September 13, 2021 07:31
@msyyc msyyc requested a review from weshaggard as a code owner September 13, 2021 07:31
@msyyc msyyc changed the title [webpubsub] codegen [webpubsub] support AAD, Api management proxy Sep 13, 2021
@msyyc msyyc force-pushed the webpubsub-2021-09-03 branch from 319d416 to be9026e Compare September 13, 2021 11:55
Copy link
Member

@vicancy vicancy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the effort! Some little comments from service team.

"""Create a new WebPubSubServiceClient from a connection string.
:param connection_string: Connection string
:type connection_string: ~str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ~str will render weirdly in the docs, this can be flattened into one line and just be :param str connection_string: Connection string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to keep same annotation style with generated code. Anyway, I change ~str to str

exit()

# Build a client through AAD
client = WebPubSubServiceClient(credential=DefaultAzureCredential(), endpoint=endpoint, reverse_proxy_endpoint=reverse_proxy_endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msyyc looking at this sample, I'm still not sure what a reverse proxy endpoint is, and why I should use it. Can you highlight why I would add a reverse proxy endpoint? Since this sample is the same as the AAD one, I don't know why I would add these extra lines of code. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iscai-msft actually I don't have rich domain knowledge to explain the usage about Api management proxy. @vicancy could you help to update the sample?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# Build a client from the connection string. And for this example, we have enabled debug
# tracing. For production code, this should be turned off.
client = WebPubSubServiceClient.from_connection_string(connection_string, logging_enable=True, reverse_proxy_endpoint=reverse_proxy_endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also one thing I noticed in these samples: The actual calls you're doing with webpubsub are the same, the only difference is how to authenticate them. Do you think a better sample structure would be to have one sample with all of the different ways to authenticate (thinking something like this, where we show multiple ways to authenticate), and then having one sample that is client.send_to_all, with just one way of authenticating (either DefaultAzureCredential or AzureKeyCredential, since those are the ones that most people will use)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I also think about that way. I hope customers could run sample file directly so the sample code should be simple asap. And for overall description about authentication, there is detailed info in README.md. So I hope to keep the sample like this format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants