

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

# Ativar o cliente Amazon Braket Boto3
<a name="braket-using-boto3-client"></a>

Para usar o Boto3 com o Amazon Braket, você deve importar o Boto3 e depois definir um cliente que você usa para se conectar à API do Amazon Braket. No exemplo a seguir, o cliente Boto3 é nomeado `braket`.

```
import boto3
import botocore

braket = boto3.client("braket")
```

**nota**  
[Suportes de suporte. IPv6](https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html) [Se você estiver usando uma rede IPv6 somente ou quiser garantir que sua carga de trabalho use IPv6 tráfego, use os endpoints de pilha dupla conforme descrito no guia de endpoints de pilha dupla e FIPS.](https://docs.aws.amazon.com/sdkref/latest/guide/feature-endpoints.html)

Agora que você tem um cliente `braket` estabelecido, você pode fazer solicitações e processar respostas do serviço Amazon Braket. Você pode obter mais detalhes sobre os dados de solicitação e resposta na [Referência da API](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/braket.html).

**Topics**
+ [Pesquisar dispositivos](#braket-using-boto3-example-search-devices)
+ [Recuperar um dispositivo](#braket-using-boto3-example-retrieve-devices)
+ [Crie uma tarefa quântica](#braket-using-boto3-example-create-task)
+ [Recupere uma tarefa quântica](#braket-using-boto3-example-retrieve-task)
+ [Pesquise tarefas quânticas](#braket-using-boto3-example-search-tasks)
+ [Cancele tarefa quântica](#braket-using-boto3-example-cancel-task)

## Pesquisar dispositivos
<a name="braket-using-boto3-example-search-devices"></a>
+  `search_devices(**kwargs)` 

Pesquise dispositivos usando os filtros especificados.

```
# Pass search filters and optional parameters when sending the
# request and capture the response
response = braket.search_devices(filters=[{
    'name': 'deviceArn',
    'values': ['arn:aws:braket:::device/quantum-simulator/amazon/sv1']
}], maxResults=10)

print(f"Found {len(response['devices'])} devices")

for i in range(len(response['devices'])):
    device = response['devices'][i]
    print(device['deviceArn'])
```

## Recuperar um dispositivo
<a name="braket-using-boto3-example-retrieve-devices"></a>
+  `get_device(deviceArn)` 

Recupere os dispositivos disponíveis no Amazon Braket.

```
# Pass the device ARN when sending the request and capture the repsonse
response = braket.get_device(deviceArn='arn:aws:braket:::device/quantum-simulator/amazon/sv1')

print(f"Device {response['deviceName']} is {response['deviceStatus']}")
```

## Crie uma tarefa quântica
<a name="braket-using-boto3-example-create-task"></a>
+  `create_quantum_task(**kwargs)` 

Crie uma tarefa quântica.

```
# Create parameters to pass into create_quantum_task()
kwargs = {
    # Create a Bell pair
    'action': '{"braketSchemaHeader": {"name": "braket.ir.jaqcd.program", "version": "1"}, "results": [], "basis_rotation_instructions": [], "instructions": [{"type": "h", "target": 0}, {"type": "cnot", "control": 0, "target": 1}]}',
    # Specify the SV1 Device ARN
    'deviceArn': 'arn:aws:braket:::device/quantum-simulator/amazon/sv1',
    # Specify 2 qubits for the Bell pair
    'deviceParameters': '{"braketSchemaHeader": {"name": "braket.device_schema.simulators.gate_model_simulator_device_parameters", "version": "1"}, "paradigmParameters": {"braketSchemaHeader": {"name": "braket.device_schema.gate_model_parameters", "version": "1"}, "qubitCount": 2}}',
    # Specify where results should be placed when the quantum task completes.
    # You must ensure the S3 Bucket exists before calling create_quantum_task()
    'outputS3Bucket': 'amazon-braket-examples',
    'outputS3KeyPrefix': 'boto-examples',
    # Specify number of shots for the quantum task
    'shots': 100
}

# Send the request and capture the response
response = braket.create_quantum_task(**kwargs)

print(f"Quantum task {response['quantumTaskArn']} created")
```

## Recupere uma tarefa quântica
<a name="braket-using-boto3-example-retrieve-task"></a>
+  `get_quantum_task(quantumTaskArn)` 

Recupere a tarefa quântica especificada.

```
# Pass the quantum task ARN when sending the request and capture the response
response = braket.get_quantum_task(quantumTaskArn='arn:aws:braket:us-west-1:123456789012:quantum-task/ce78c429-cef5-45f2-88da-123456789012')

print(response['status'])
```

## Pesquise tarefas quânticas
<a name="braket-using-boto3-example-search-tasks"></a>
+  `search_quantum_tasks(**kwargs)` 

Pesquise tarefas quânticas que correspondam aos valores de filtro especificados.

```
# Pass search filters and optional parameters when sending the
# request and capture the response
response = braket.search_quantum_tasks(filters=[{
    'name': 'deviceArn',
    'operator': 'EQUAL',
    'values': ['arn:aws:braket:::device/quantum-simulator/amazon/sv1']
}], maxResults=25)

print(f"Found {len(response['quantumTasks'])} quantum tasks")

for n in range(len(response['quantumTasks'])):
    task = response['quantumTasks'][n]
    print(f"Quantum task {task['quantumTaskArn']} for {task['deviceArn']} is {task['status']}")
```

## Cancele tarefa quântica
<a name="braket-using-boto3-example-cancel-task"></a>
+  `cancel_quantum_task(quantumTaskArn)` 

Cancele a tarefa quântica especificada.

```
# Pass the quantum task ARN when sending the request and capture the response
response = braket.cancel_quantum_task(quantumTaskArn='arn:aws:braket:us-west-1:123456789012:quantum-task/ce78c429-cef5-45f2-88da-123456789012')

print(f"Quantum task {response['quantumTaskArn']} is {response['cancellationStatus']}")
```