選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

DescribeEndpoint 搭配 AWS SDK 或 CLI 使用 - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DescribeEndpoint 搭配 AWS SDK 或 CLI 使用

下列程式碼範例示範如何使用 DescribeEndpoint

C++
SDK for C++
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

//! Describe the endpoint specific to the AWS account making the call. /*! \param endpointResult: String to receive the endpoint result. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::describeEndpoint(Aws::String &endpointResult, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::String endpoint; Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::DescribeEndpointRequest describeEndpointRequest; describeEndpointRequest.SetEndpointType( "iot:Data-ATS"); // Recommended endpoint type. Aws::IoT::Model::DescribeEndpointOutcome outcome = iotClient.DescribeEndpoint( describeEndpointRequest); if (outcome.IsSuccess()) { std::cout << "Successfully described endpoint." << std::endl; endpointResult = outcome.GetResult().GetEndpointAddress(); } else { std::cerr << "Error describing endpoint" << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • 如需 API 詳細資訊,請參閱適用於 C++ 的 AWS SDK 《 API 參考》中的 DescribeEndpoint

CLI
AWS CLI

範例 1:取得您目前的 AWS 端點

下列describe-endpoint範例會擷取套用所有命令的預設 AWS 端點。

aws iot describe-endpoint

輸出:

{ "endpointAddress": "abc123defghijk.iot.us-west-2.amazonaws.com" }

如需詳細資訊,請參閱 AWS IoT 開發人員指南中的 DescribeEndpoint

範例 2:取得您的 ATS 端點

下列describe-endpoint範例會擷取 Amazon Trust Services (ATS) 端點。

aws iot describe-endpoint \ --endpoint-type iot:Data-ATS

輸出:

{ "endpointAddress": "abc123defghijk-ats.iot.us-west-2.amazonaws.com" }

如需詳細資訊,請參閱 AWS IoT 開發人員指南中的 X.509 憑證和 AWS IoT

  • 如需 API 詳細資訊,請參閱《 AWS CLI 命令參考》中的 DescribeEndpoint

Java
SDK for Java 2.x
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

/** * Describes the endpoint of the IoT service asynchronously. * * @return A CompletableFuture containing the full endpoint URL. * * This method initiates an asynchronous request to describe the endpoint of the IoT service. * If the request is successful, it prints and returns the full endpoint URL. * If an exception occurs, it prints the error message. */ public String describeEndpoint() { CompletableFuture<DescribeEndpointResponse> future = getAsyncClient().describeEndpoint(DescribeEndpointRequest.builder().endpointType("iot:Data-ATS").build()); final String[] result = {null}; future.whenComplete((endpointResponse, ex) -> { if (endpointResponse != null) { String endpointUrl = endpointResponse.endpointAddress(); String exString = getValue(endpointUrl); String fullEndpoint = "https://" + exString + "-ats.iot.us-east-1.amazonaws.com"; System.out.println("Full Endpoint URL: " + fullEndpoint); result[0] = fullEndpoint; } else { Throwable cause = (ex instanceof CompletionException) ? ex.getCause() : ex; if (cause instanceof IotException) { System.err.println(((IotException) cause).awsErrorDetails().errorMessage()); } else { System.err.println("Unexpected error: " + cause.getMessage()); } } }); future.join(); return result[0]; }
  • 如需 API 詳細資訊,請參閱AWS SDK for Java 2.x 《 API 參考》中的 DescribeEndpoint

Kotlin
SDK for Kotlin
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

suspend fun describeEndpoint(): String? { val request = DescribeEndpointRequest {} IotClient { region = "us-east-1" }.use { iotClient -> val endpointResponse = iotClient.describeEndpoint(request) val endpointUrl: String? = endpointResponse.endpointAddress val exString: String = getValue(endpointUrl) val fullEndpoint = "https://$exString-ats.iot.us-east-1.amazonaws.com" println("Full endpoint URL: $fullEndpoint") return fullEndpoint } }
  • 如需 API 詳細資訊,請參閱《適用於 AWS Kotlin 的 SDK API 參考》中的 DescribeEndpoint

Rust
SDK for Rust
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

async fn show_address(client: &Client, endpoint_type: &str) -> Result<(), Error> { let resp = client .describe_endpoint() .endpoint_type(endpoint_type) .send() .await?; println!("Endpoint address: {}", resp.endpoint_address.unwrap()); println!(); Ok(()) }
  • 如需 API 詳細資訊,請參閱《適用於 AWS Rust 的 SDK API 參考》中的 DescribeEndpoint

SDK for C++
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

//! Describe the endpoint specific to the AWS account making the call. /*! \param endpointResult: String to receive the endpoint result. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::IoT::describeEndpoint(Aws::String &endpointResult, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::String endpoint; Aws::IoT::IoTClient iotClient(clientConfiguration); Aws::IoT::Model::DescribeEndpointRequest describeEndpointRequest; describeEndpointRequest.SetEndpointType( "iot:Data-ATS"); // Recommended endpoint type. Aws::IoT::Model::DescribeEndpointOutcome outcome = iotClient.DescribeEndpoint( describeEndpointRequest); if (outcome.IsSuccess()) { std::cout << "Successfully described endpoint." << std::endl; endpointResult = outcome.GetResult().GetEndpointAddress(); } else { std::cerr << "Error describing endpoint" << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • 如需 API 詳細資訊,請參閱適用於 C++ 的 AWS SDK 《 API 參考》中的 DescribeEndpoint

下一個主題:

DescribeThing

上一個主題:

DeleteTopicRule
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。