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

[core] connection string parser only #17640

Merged
merged 10 commits into from
Mar 31, 2021

Conversation

swathipil
Copy link
Member

This is an attempt to create a generic connection string parsing function that will be used across SDKs to minimize redundant logic and validation, addressing #16782.

Split from PR: #17049

This parsed connection string will be returned as a dict of connection string keys (ie. Endpoint, SharedAccessKey, etc.) and values, with an option for allowing case insensitive keys. This option is useful when checking a connection string with keys that don't match expected case, without looping through all the keys. For example:

conn_str = "Endpoint=XXXXENDPOINT;ACcEsSKEY=XXXXKEY"
parsed = parse_connection_string(conn_str, case_sensitive_keys=False)
endpoint = parsed.get("endpoint")   # value is XXXXENDPOINT
accesskey = parsed.get("accesskey")  # value is XXXXKEY

gist: https://gist.github.com/swathipil/0640998161b2b9fb41dee053e16a770c


def parse_connection_string(conn_str, case_sensitive_keys=False):
# type: (str, bool) -> Mapping[str, str]
"""Parses the connection string into a dict of its component parts, with the option of preserving case
Copy link
Member

Choose a reason for hiding this comment

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

For some reason the documentation for this doesn't seem to be rendering?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 looking into it!

Copy link
Member Author

@swathipil swathipil Mar 31, 2021

Choose a reason for hiding this comment

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

I copied the _connection_string_parser.py file to azure/core and imported parse_connection_string in azure/core/__init__.py. The change showed up in the docs, so I don't think _connection_string_parser.py has errors that would cause rendering failure.

I also copied the azure/core/tracing folder to a azure/core/tracing_copy folder and assumed that if tracing is working, then tracing_copy should also render. This didn't work either, so I believe this might not be a problem with the code/the __init__.py file either. Thoughts, @annatisch ?

@swathipil swathipil merged commit abba261 into Azure:master Mar 31, 2021
@swathipil swathipil linked an issue Mar 31, 2021 that may be closed by this pull request
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-python that referenced this pull request Feb 9, 2022
Adding xms-ids to ContainerService (Azure#17640)

* Adding xms-ids to ContainerService

* prettier fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ConnectionString parsing
3 participants