Google Cloud IoT Core는 2023년 8월 16일에 지원 중단됩니다. 자세한 내용은 Google Cloud 계정팀에 문의하세요.

게이트웨이 삭제

지정된 ID로 게이트웨이를 삭제합니다.

코드 샘플

PHP

자세한 내용은 Cloud IoT Core PHP API 참조 문서를 확인하세요.

Cloud IoT Core에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

use Google\Cloud\Iot\V1\DeviceManagerClient;

/**
 * Delete the gateway with the given id.
 *
 * @param string $registryId IOT Device Registry ID
 * @param string $gatewayId ID for the gateway to delete
 * @param string $projectId Google Cloud project ID
 * @param string $location (Optional) Google Cloud region
 */
function delete_gateway(
    $registryId,
    $gatewayId,
    $projectId,
    $location = 'us-central1'
) {
    print('Deleting Gateway' . PHP_EOL);

    // Instantiate a client.
    $deviceManager = new DeviceManagerClient();
    $gatewayName = $deviceManager->deviceName($projectId, $location, $registryId, $gatewayId);

    // TODO: unbind all bound devices when list_devices_for_gateway
    // is working
    $response = $deviceManager->deleteDevice($gatewayName);

    printf('Deleted %s' . PHP_EOL, $gatewayName);
}

Ruby

자세한 내용은 Cloud IoT Core Ruby API 참조 문서를 확인하세요.

Cloud IoT Core에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

# project_id  = "Your Google Cloud project ID"
# location_id = "The Cloud region the registry is located in"
# registry_id = "The registry to create a device in"
# gateway_id   = "The identifier of the gateway to delete"

require "google/apis/cloudiot_v1"

# Initialize the client and authenticate with the specified scope
Cloudiot   = Google::Apis::CloudiotV1
iot_client = Cloudiot::CloudIotService.new
iot_client.authorization = Google::Auth.get_application_default(
  "https://www.googleapis.com/auth/cloud-platform"
)

# The resource name of the location associated with the project
parent = "projects/#{project_id}/locations/#{location_id}"
device_path = "#{parent}/registries/#{registry_id}/devices/#{gateway_id}"

# TODO: unbind all devices?
# Delete the gateway
result = iot_client.delete_project_location_registry_device(
  device_path
)

puts "Deleted gateway."

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.