HealthImaging を使用するためのコード例 AWS SDKs - AWS SDK コード例

AWS Doc SDK Examples GitHub リポジトリには他にも AWS SDK例があります。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

HealthImaging を使用するためのコード例 AWS SDKs

次のコード例は、 AWS ソフトウェア開発キット () AWS HealthImaging で を使用する方法を示していますSDK。

「基本」は、重要なオペレーションをサービス内で実行する方法を示すコード例です。

アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

「シナリオ」は、1 つのサービス内から、または他の AWS のサービスと組み合わせて複数の関数を呼び出し、特定のタスクを実行する方法を示すコード例です。

その他のリソース

開始方法

次のコード例は、 の使用を開始する方法を示しています HealthImaging。

C++
SDK C++ 用

CMakeLists.txt CMakeファイルのコード。

# Set the minimum required version of CMake for this project. cmake_minimum_required(VERSION 3.13) # Set the AWS service components used by this project. set(SERVICE_COMPONENTS medical-imaging) # Set this project's name. project("hello_health-imaging") # Set the C++ standard to use to build this target. # At least C++ 11 is required for the AWS SDK for C++. set(CMAKE_CXX_STANDARD 11) # Use the MSVC variable to determine if this is a Windows build. set(WINDOWS_BUILD ${MSVC}) if (WINDOWS_BUILD) # Set the location where CMake can find the installed libraries for the AWS SDK. string(REPLACE ";" "/aws-cpp-sdk-all;" SYSTEM_MODULE_PATH "${CMAKE_SYSTEM_PREFIX_PATH}/aws-cpp-sdk-all") list(APPEND CMAKE_PREFIX_PATH ${SYSTEM_MODULE_PATH}) endif () # Find the AWS SDK for C++ package. find_package(AWSSDK REQUIRED COMPONENTS ${SERVICE_COMPONENTS}) if (WINDOWS_BUILD AND AWSSDK_INSTALL_AS_SHARED_LIBS) # Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging. # set(BIN_SUB_DIR "/Debug") # If you are building from the command line, you may need to uncomment this # and set the proper subdirectory to the executable location. AWSSDK_CPY_DYN_LIBS(SERVICE_COMPONENTS "" ${CMAKE_CURRENT_BINARY_DIR}${BIN_SUB_DIR}) endif () add_executable(${PROJECT_NAME} hello_health_imaging.cpp) target_link_libraries(${PROJECT_NAME} ${AWSSDK_LINK_LIBRARIES})

hello_health_imaging.cpp ソースファイルのコード。

#include <aws/core/Aws.h> #include <aws/medical-imaging/MedicalImagingClient.h> #include <aws/medical-imaging/model/ListDatastoresRequest.h> #include <iostream> /* * A "Hello HealthImaging" starter application which initializes an AWS HealthImaging (HealthImaging) client * and lists the HealthImaging data stores in the current account. * * main function * * Usage: 'hello_health-imaging' * */ #include <aws/core/auth/AWSCredentialsProviderChain.h> #include <aws/core/platform/Environment.h> int main(int argc, char **argv) { (void) argc; (void) argv; Aws::SDKOptions options; // Optional: change the log level for debugging. // options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Debug; Aws::InitAPI(options); // Should only be called once. { Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::MedicalImaging::MedicalImagingClient medicalImagingClient(clientConfig); Aws::MedicalImaging::Model::ListDatastoresRequest listDatastoresRequest; Aws::Vector<Aws::MedicalImaging::Model::DatastoreSummary> allDataStoreSummaries; Aws::String nextToken; // Used for paginated results. do { if (!nextToken.empty()) { listDatastoresRequest.SetNextToken(nextToken); } Aws::MedicalImaging::Model::ListDatastoresOutcome listDatastoresOutcome = medicalImagingClient.ListDatastores(listDatastoresRequest); if (listDatastoresOutcome.IsSuccess()) { const Aws::Vector<Aws::MedicalImaging::Model::DatastoreSummary> &dataStoreSummaries = listDatastoresOutcome.GetResult().GetDatastoreSummaries(); allDataStoreSummaries.insert(allDataStoreSummaries.cend(), dataStoreSummaries.cbegin(), dataStoreSummaries.cend()); nextToken = listDatastoresOutcome.GetResult().GetNextToken(); } else { std::cerr << "ListDatastores error: " << listDatastoresOutcome.GetError().GetMessage() << std::endl; break; } } while (!nextToken.empty()); std::cout << allDataStoreSummaries.size() << " HealthImaging data " << ((allDataStoreSummaries.size() == 1) ? "store was retrieved." : "stores were retrieved.") << std::endl; for (auto const &dataStoreSummary: allDataStoreSummaries) { std::cout << " Datastore: " << dataStoreSummary.GetDatastoreName() << std::endl; std::cout << " Datastore ID: " << dataStoreSummary.GetDatastoreId() << std::endl; } } Aws::ShutdownAPI(options); // Should only be called once. return 0; }
  • API 詳細については、 リファレンスListDatastoresの「」を参照してください。 AWS SDK for C++ API

注記

の詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

JavaScript
SDK JavaScript (v3) の場合
import { ListDatastoresCommand, MedicalImagingClient, } from "@aws-sdk/client-medical-imaging"; // When no region or credentials are provided, the SDK will use the // region and credentials from the local AWS config. const client = new MedicalImagingClient({}); export const helloMedicalImaging = async () => { const command = new ListDatastoresCommand({}); const { datastoreSummaries } = await client.send(command); console.log("Datastores: "); console.log(datastoreSummaries.map((item) => item.datastoreName).join("\n")); return datastoreSummaries; };
  • API 詳細については、 リファレンスListDatastoresの「」を参照してください。 AWS SDK for JavaScript API

注記

の詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。

Python
SDK Python 用 (Boto3)
import logging import boto3 from botocore.exceptions import ClientError logger = logging.getLogger(__name__) def hello_medical_imaging(medical_imaging_client): """ Use the AWS SDK for Python (Boto3) to create an AWS HealthImaging client and list the data stores in your account. This example uses the default settings specified in your shared credentials and config files. :param medical_imaging_client: A Boto3 AWS HealthImaging Client object. """ print("Hello, Amazon Health Imaging! Let's list some of your data stores:\n") try: paginator = medical_imaging_client.get_paginator("list_datastores") page_iterator = paginator.paginate() datastore_summaries = [] for page in page_iterator: datastore_summaries.extend(page["datastoreSummaries"]) print("\tData Stores:") for ds in datastore_summaries: print(f"\t\tDatastore: {ds['datastoreName']} ID {ds['datastoreId']}") except ClientError as err: logger.error( "Couldn't list data stores. Here's why: %s: %s", err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise if __name__ == "__main__": hello_medical_imaging(boto3.client("medical-imaging"))
  • API 詳細については、AWS SDK「 Python (Boto3) APIリファレンスListDatastores」の「」を参照してください。

注記

の詳細については、「」を参照してください GitHub。用例一覧を検索し、AWS コード例リポジトリでの設定と実行の方法を確認してください。