Skip to content

Commit

Permalink
add newline cushion between tags and python snippet in snippet update…
Browse files Browse the repository at this point in the history
… script (#29170)

* add newline cushion between tags and python snippet in snippet updater script

* run snippet updater script on libraries that use sample tags in readme
  • Loading branch information
kristapratico authored Mar 8, 2023
1 parent cb74cf2 commit 90d9bdc
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 1 deletion.
18 changes: 18 additions & 0 deletions sdk/appconfiguration/azure-appconfiguration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Alternatively, get the connection string from the Azure Portal.
Once you have the value of the connection string, you can create the AzureAppConfigurationClient:

<!-- SNIPPET:hello_world_sample.create_app_config_client -->

```python
import os
from azure.appconfiguration import AzureAppConfigurationClient
Expand All @@ -67,6 +68,7 @@ CONNECTION_STRING = os.environ['APPCONFIGURATION_CONNECTION_STRING']
# Create app config client
client = AzureAppConfigurationClient.from_connection_string(CONNECTION_STRING)
```

<!-- END SNIPPET -->

#### Use AAD token
Expand Down Expand Up @@ -167,6 +169,7 @@ There are two ways to store a Configuration Setting:
- add_configuration_setting creates a setting only if the setting does not already exist in the store.

<!-- SNIPPET:hello_world_advanced_sample.create_config_setting -->

```python
config_setting = ConfigurationSetting(
key="MyKey",
Expand All @@ -177,53 +180,62 @@ config_setting = ConfigurationSetting(
)
added_config_setting = client.add_configuration_setting(config_setting)
```

<!-- END SNIPPET -->

- set_configuration_setting creates a setting if it doesn't exist or overrides an existing setting.

<!-- SNIPPET:hello_world_advanced_sample.set_config_setting -->

```python
added_config_setting.value = "new value"
added_config_setting.content_type = "new content type"
updated_config_setting = client.set_configuration_setting(config_setting)
```

<!-- END SNIPPET -->

### Get a Configuration Setting

Get a previously stored Configuration Setting.

<!-- SNIPPET:hello_world_sample.get_config_setting -->

```python
fetched_config_setting = client.get_configuration_setting(
key="MyKey"
)
```

<!-- END SNIPPET -->

### Delete a Configuration Setting

Delete an existing Configuration Setting.

<!-- SNIPPET:hello_world_advanced_sample.delete_config_setting -->

```python
client.delete_configuration_setting(
key="MyKey",
label="MyLabel",
)
```

<!-- END SNIPPET -->

### List Configuration Settings

List all configuration settings filtered with label_filter and/or key_filter.

<!-- SNIPPET:hello_world_advanced_sample.list_config_setting -->

```python
config_settings = client.list_configuration_settings(label_filter="MyLabel")
for item in config_settings:
print_configuration_setting(item)
```

<!-- END SNIPPET -->

### Async APIs
Expand All @@ -232,6 +244,7 @@ Async client is supported.
To use the async client library, import the AzureAppConfigurationClient from package azure.appconfiguration.aio instead of azure.appconfiguration

<!-- SNIPPET:hello_world_sample_async.create_app_config_client -->

```python
import os
from azure.appconfiguration.aio import AzureAppConfigurationClient
Expand All @@ -240,27 +253,32 @@ CONNECTION_STRING = os.environ['APPCONFIGURATION_CONNECTION_STRING']
# Create app config client
client = AzureAppConfigurationClient.from_connection_string(CONNECTION_STRING)
```

<!-- END SNIPPET -->

This async AzureAppConfigurationClient has the same method signatures as the sync ones except that they're async.
For instance, to retrieve a Configuration Setting asynchronously, async_client can be used:

<!-- SNIPPET:hello_world_sample_async.get_config_setting -->

```python
fetched_config_setting = await client.get_configuration_setting(
key="MyKey"
)
```

<!-- END SNIPPET -->

To use list_configuration_settings, call it synchronously and iterate over the returned async iterator asynchronously

<!-- SNIPPET:hello_world_advanced_sample_async.list_config_setting -->

```python
config_settings = client.list_configuration_settings(label_filter="MyLabel")
async for item in config_settings:
print_configuration_setting(item)
```

<!-- END SNIPPET -->

## Troubleshooting
Expand Down
4 changes: 4 additions & 0 deletions sdk/eventgrid/azure-eventgrid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ With the `azure-identity` package, you can seamlessly authorize requests in both
For example, you can use `DefaultAzureCredential` to construct a client which will authenticate using Azure Active Directory:

<!-- SNIPPET:sample_authentication.client_auth_with_token_cred -->

```python
from azure.identity import DefaultAzureCredential
from azure.eventgrid import EventGridPublisherClient, EventGridEvent
Expand All @@ -61,6 +62,7 @@ credential = DefaultAzureCredential()
endpoint = os.environ["EVENTGRID_TOPIC_ENDPOINT"]
client = EventGridPublisherClient(endpoint, credential)
```

<!-- END SNIPPET -->

#### Looking up the endpoint
Expand All @@ -75,6 +77,7 @@ pass the key as a string into an instance of [AzureKeyCredential][azure-key-cred
> **Note:** The Access Key may be found in the azure portal in the "Access Keys" menu of the Event Grid Topic resource. They may also be obtained via the azure CLI, or the `azure-mgmt-eventgrid` library. A guide for getting access keys can be found [here](https://docs.microsoft.com/azure/event-grid/get-access-keys).
<!-- SNIPPET:sample_authentication.client_auth_with_key_cred -->

```python
import os
from azure.eventgrid import EventGridPublisherClient
Expand All @@ -86,6 +89,7 @@ endpoint = os.environ["EVENTGRID_TOPIC_ENDPOINT"]
credential = AzureKeyCredential(topic_key)
client = EventGridPublisherClient(endpoint, credential)
```

<!-- END SNIPPET -->

> **Note:** A client may also be authenticated via SAS signature, using the `AzureSasCredential`. A sample demonstrating this, is available [here][python-eg-sample-send-using-sas] ([async_version][python-eg-sample-send-using-sas-async]).
Expand Down
4 changes: 4 additions & 0 deletions sdk/eventhub/azure-eventhub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ The following sections provide several code snippets covering some of the most c
Get the partition ids of an Event Hub.

<!-- SNIPPET:connection_string_authentication.connection_string_authentication -->

```python
import os
from azure.eventhub import EventHubConsumerClient
Expand All @@ -128,6 +129,7 @@ consumer_client = EventHubConsumerClient.from_connection_string(
with consumer_client:
pass # consumer_client is now ready to be used.
```

<!-- END SNIPPET -->

### Publish events to an Event Hub
Expand All @@ -136,6 +138,7 @@ Use the `create_batch` method on `EventHubProducerClient` to create an `EventDat
Events may be added to the `EventDataBatch` using the `add` method until the maximum batch size limit in bytes has been reached.

<!-- SNIPPET:send.send_event_data_batch -->

```python
def send_event_data_batch(producer):
# Without specifying partition_id or partition_key
Expand All @@ -144,6 +147,7 @@ def send_event_data_batch(producer):
event_data_batch.add(EventData('Single message'))
producer.send_batch(event_data_batch)
```

<!-- END SNIPPET -->

### Consume events from an Event Hub
Expand Down
2 changes: 2 additions & 0 deletions sdk/keyvault/azure-keyvault-certificates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ See [azure-identity][azure_identity] documentation for more information about ot
After configuring your environment for the [DefaultAzureCredential][default_cred_ref] to use a suitable method of authentication, you can do the following to create a certificate client (replacing the value of `VAULT_URL` with your vault's URL):

<!-- SNIPPET:hello_world.create_a_certificate_client -->

```python
VAULT_URL = os.environ["VAULT_URL"]
credential = DefaultAzureCredential()
client = CertificateClient(vault_url=VAULT_URL, credential=credential)
```

<!-- END SNIPPET -->

> **NOTE:** For an asynchronous client, import `azure.keyvault.certificates.aio`'s `CertificateClient` instead.
Expand Down
2 changes: 2 additions & 0 deletions sdk/keyvault/azure-keyvault-keys/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ See [azure-identity][azure_identity] documentation for more information about ot
After configuring your environment for the [DefaultAzureCredential][default_cred_ref] to use a suitable method of authentication, you can do the following to create a key client (replacing the value of `VAULT_URL` with your vault's URL):

<!-- SNIPPET:hello_world.create_a_key_client -->

```python
VAULT_URL = os.environ["VAULT_URL"]
credential = DefaultAzureCredential()
client = KeyClient(vault_url=VAULT_URL, credential=credential)
```

<!-- END SNIPPET -->

> **NOTE:** For an asynchronous client, import `azure.keyvault.keys.aio`'s `KeyClient` instead.
Expand Down
2 changes: 2 additions & 0 deletions sdk/keyvault/azure-keyvault-secrets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ See [azure-identity][azure_identity] documentation for more information about ot
After configuring your environment for the [DefaultAzureCredential][default_cred_ref] to use a suitable method of authentication, you can do the following to create a secret client (replacing the value of `VAULT_URL` with your vault's URL):

<!-- SNIPPET:hello_world.create_secret_client -->

```python
VAULT_URL = os.environ["VAULT_URL"]
credential = DefaultAzureCredential()
client = SecretClient(vault_url=VAULT_URL, credential=credential)
```

<!-- END SNIPPET -->

> **NOTE:** For an asynchronous client, import `azure.keyvault.secrets.aio`'s `SecretClient` instead.
Expand Down
Loading

0 comments on commit 90d9bdc

Please sign in to comment.