Geräte erstellen

Auf dieser Seite wird beschrieben, wie Sie Geräte erstellen.

Hinweis

Führen Sie folgende Aufgaben aus, bevor Sie die Informationen auf dieser Seite umsetzen:

Gerät erstellen

Die folgenden Beispiele zeigen, wie Sie ein Gerät erstellen.

REST

Rufen Sie zum Erstellen eines Geräts devices.create() mit dem Namen von customer (Organisation) und einem Geräteobjekt auf.

Python

Im folgenden Beispiel wird gezeigt, wie Sie ein Gerät mit der Python-Clientbibliothek erstellen:

"""Example script to use the create method of the Devices API."""
from google.oauth2 import service_account
from googleapiclient.discovery import build

SCOPES = ['https://www.googleapis.com/auth/cloud-identity.devices']

# Change this to the location of the service account key
SA_FILE = ''

# Enter the administrator to call as here.
ADMIN_EMAIL = ''

if not SA_FILE:
  print('Please specify the location of the service account key file')
if not ADMIN_EMAIL:
  print('Please specify the email of the administrator to call as')

if not SA_FILE or not ADMIN_EMAIL:
  exit(-1)

credentials = service_account.Credentials.from_service_account_file(
    SA_FILE, scopes=SCOPES, subject=ADMIN_EMAIL)

service = build('cloudidentity', 'v1', credentials=credentials)

device = {
    'serialNumber': 'someSerial',  # the serial number of your device.
    # see values in
    # https://cloud.google.com/identity/docs/reference/rest/v1/devices#DeviceType
    'deviceType': 'LINUX'
}
request = service.devices().create(body=device)
response = request.execute()
print(response)