HealthImaging exemplos de uso AWS CLI com o script Bash - AWS SDKExemplos de código

Há mais AWS SDK exemplos disponíveis no GitHub repositório AWS Doc SDK Examples.

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á.

HealthImaging exemplos de uso AWS CLI com o script Bash

Os exemplos de código a seguir mostram como realizar ações e implementar cenários comuns usando o script AWS Command Line Interface with Bash with HealthImaging.

Ações são trechos de código de programas maiores e devem ser executadas em contexto. Embora as ações mostrem como chamar funções de serviço individuais, é possível ver as ações no contexto em seus cenários relacionados.

Cada exemplo inclui um link para o código-fonte completo, onde você pode encontrar instruções sobre como configurar e executar o código no contexto.

Tópicos

Ações

O código de exemplo a seguir mostra como usar CreateDatastore.

AWS CLI com script Bash
############################################################################### # function errecho # # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho() { printf "%s\n" "$*" 1>&2 } ############################################################################### # function imaging_create_datastore # # This function creates an AWS HealthImaging data store for importing DICOM P10 files. # # Parameters: # -n data_store_name - The name of the data store. # # Returns: # The datastore ID. # And: # 0 - If successful. # 1 - If it fails. ############################################################################### function imaging_create_datastore() { local datastore_name response local option OPTARG # Required to use getopts command in a function. # bashsupport disable=BP5008 function usage() { echo "function imaging_create_datastore" echo "Creates an AWS HealthImaging data store for importing DICOM P10 files." echo " -n data_store_name - The name of the data store." echo "" } # Retrieve the calling parameters. while getopts "n:h" option; do case "${option}" in n) datastore_name="${OPTARG}" ;; h) usage return 0 ;; \?) echo "Invalid parameter" usage return 1 ;; esac done export OPTIND=1 if [[ -z "$datastore_name" ]]; then errecho "ERROR: You must provide a data store name with the -n parameter." usage return 1 fi response=$(aws medical-imaging create-datastore \ --datastore-name "$datastore_name" \ --output text \ --query 'datastoreId') local error_code=${?} if [[ $error_code -ne 0 ]]; then aws_cli_error_log $error_code errecho "ERROR: AWS reports medical-imaging create-datastore operation failed.$response" return 1 fi echo "$response" return 0 }
  • Para API obter detalhes, consulte CreateDatastorena Referência de AWS CLI Comandos.

nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

O código de exemplo a seguir mostra como usar DeleteDatastore.

AWS CLI com script Bash
############################################################################### # function errecho # # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho() { printf "%s\n" "$*" 1>&2 } ############################################################################### # function imaging_delete_datastore # # This function deletes an AWS HealthImaging data store. # # Parameters: # -i datastore_id - The ID of the data store. # # Returns: # 0 - If successful. # 1 - If it fails. ############################################################################### function imaging_delete_datastore() { local datastore_id response local option OPTARG # Required to use getopts command in a function. # bashsupport disable=BP5008 function usage() { echo "function imaging_delete_datastore" echo "Deletes an AWS HealthImaging data store." echo " -i datastore_id - The ID of the data store." echo "" } # Retrieve the calling parameters. while getopts "i:h" option; do case "${option}" in i) datastore_id="${OPTARG}" ;; h) usage return 0 ;; \?) echo "Invalid parameter" usage return 1 ;; esac done export OPTIND=1 if [[ -z "$datastore_id" ]]; then errecho "ERROR: You must provide a data store ID with the -i parameter." usage return 1 fi response=$(aws medical-imaging delete-datastore \ --datastore-id "$datastore_id") local error_code=${?} if [[ $error_code -ne 0 ]]; then aws_cli_error_log $error_code errecho "ERROR: AWS reports medical-imaging delete-datastore operation failed.$response" return 1 fi return 0 }
  • Para API obter detalhes, consulte DeleteDatastorena Referência de AWS CLI Comandos.

nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

O código de exemplo a seguir mostra como usar GetDatastore.

AWS CLI com script Bash
############################################################################### # function errecho # # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho() { printf "%s\n" "$*" 1>&2 } ############################################################################### # function imaging_get_datastore # # Get a data store's properties. # # Parameters: # -i data_store_id - The ID of the data store. # # Returns: # [datastore_name, datastore_id, datastore_status, datastore_arn, created_at, updated_at] # And: # 0 - If successful. # 1 - If it fails. ############################################################################### function imaging_get_datastore() { local datastore_id option OPTARG # Required to use getopts command in a function. local error_code # bashsupport disable=BP5008 function usage() { echo "function imaging_get_datastore" echo "Gets a data store's properties." echo " -i datastore_id - The ID of the data store." echo "" } # Retrieve the calling parameters. while getopts "i:h" option; do case "${option}" in i) datastore_id="${OPTARG}" ;; h) usage return 0 ;; \?) echo "Invalid parameter" usage return 1 ;; esac done export OPTIND=1 if [[ -z "$datastore_id" ]]; then errecho "ERROR: You must provide a data store ID with the -i parameter." usage return 1 fi local response response=$( aws medical-imaging get-datastore \ --datastore-id "$datastore_id" \ --output text \ --query "[ datastoreProperties.datastoreName, datastoreProperties.datastoreId, datastoreProperties.datastoreStatus, datastoreProperties.datastoreArn, datastoreProperties.createdAt, datastoreProperties.updatedAt]" ) error_code=${?} if [[ $error_code -ne 0 ]]; then aws_cli_error_log $error_code errecho "ERROR: AWS reports list-datastores operation failed.$response" return 1 fi echo "$response" return 0 }
  • Para API obter detalhes, consulte GetDatastorena Referência de AWS CLI Comandos.

nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

O código de exemplo a seguir mostra como usar ListDatastores.

AWS CLI com script Bash
############################################################################### # function errecho # # This function outputs everything sent to it to STDERR (standard error output). ############################################################################### function errecho() { printf "%s\n" "$*" 1>&2 } ############################################################################### # function imaging_list_datastores # # List the HealthImaging data stores in the account. # # Returns: # [[datastore_name, datastore_id, datastore_status]] # And: # 0 - If successful. # 1 - If it fails. ############################################################################### function imaging_list_datastores() { local option OPTARG # Required to use getopts command in a function. local error_code # bashsupport disable=BP5008 function usage() { echo "function imaging_list_datastores" echo "Lists the AWS HealthImaging data stores in the account." echo "" } # Retrieve the calling parameters. while getopts "h" option; do case "${option}" in h) usage return 0 ;; \?) echo "Invalid parameter" usage return 1 ;; esac done export OPTIND=1 local response response=$(aws medical-imaging list-datastores \ --output text \ --query "datastoreSummaries[*][datastoreName, datastoreId, datastoreStatus]") error_code=${?} if [[ $error_code -ne 0 ]]; then aws_cli_error_log $error_code errecho "ERROR: AWS reports list-datastores operation failed.$response" return 1 fi echo "$response" return 0 }
  • Para API obter detalhes, consulte ListDatastoresna Referência de AWS CLI Comandos.

nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.