Bu sayfadaki örnek istekler, Chrome Printer Management API ile yazıcıların nasıl yönetileceğini gösterir.
Tüm örnek isteklerde aşağıdaki değişkenler kullanılır:
TOKEN: Uygulamanızın OAuth 2.0 jetonu.CUSTOMER_ID: "C" ile başlayan, kurumsal hesabın benzersiz müşteri kimliği. (Örnek:C123abc4) Kendi hesabınızın müşteri kimliğini belirtmek içinmy_customerde girebilirsiniz.
Yazıcı modellerini listeleme
Bu örnek, desteklenen tüm yazıcı modellerinin listesini ister.
İstek
curl -X GET \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers:listPrinterModels"
Yanıt
{
"printerModels": [
{
"manufacturer": "Anitech",
"displayName": "Anitech M24",
"makeAndModel": "anitech m24"
},
{
"manufacturer": "Apollo",
"displayName": "Apollo P-2100",
"makeAndModel": "apollo apollo 2100"
},
//...
{
"manufacturer": "Brother",
"displayName": "Brother DCP-7025",
"makeAndModel": "brother dcp-7025"
},
//...
],
"nextPageToken": "CGQQAQ=="
}
Yazıcıları listeleme veya arama
Bu örnek, kuruluş birimi kimliğinde 04fatzly26exj7b görünür olan ve yazıcı görünen adında veya açıklamasında Lobby kelimesini içeren tüm yazıcıların listesini ister. Üst kuruluş birimine eklenen yazıcılar alt kuruluş birimlerinde görünür. Bu nedenle, yanıtta 04fatzly26exj7b kuruluş biriminde olmayan yazıcılar yer alabilir.
İstek
curl -X GET \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers?orgUnitId=04fatzly26exj7b&filter=Lobby"
Yanıt
{
"printers": [
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs2zla0y7",
"id": "0gjdgxs2zla0y7",
"displayName": "Jupiter",
"description": "Guest printer in lobby Building C.",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.13",
"createTime": "2021-03-11T21:41:34.779587Z",
"orgUnitId": "04fatzly26exj7b"
},
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs1eqkb60",
"id": "0gjdgxs1eqkb60",
"displayName": "Mars",
"description": "Printer in Lobby Building A",
"uri": "ipp://192.168.10.11",
"createTime": "2021-03-11T22:02:06.048469Z",
"orgUnitId": "04fatzly4jbjho9",
"useDriverlessConfig": true
}
]
}
Belirli bir yazıcıyı edinme
Bu örnekte, 0gjdgxs2zla0y7 kimlikli bir yazıcıyla ilgili ayrıntılar isteniyor.
İstek
curl -X GET \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs2zla0y7"
Yanıt
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs2zla0y7",
"id": "0gjdgxs2zla0y7",
"displayName": "Jupiter",
"description": "Guest printer in lobby Building C.",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.13",
"createTime": "2021-03-11T21:41:34.779587Z",
"orgUnitId": "04fatzly26exj7b"
}
Yazıcı oluşturma
Bu örnek, kuruluş birimi kimliği 04fatzly26exj7b olan birime yeni bir yazıcı ekler.
İstek
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"displayName": "Mercury",
"description": "Printer in the kitchen",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.14",
"orgUnitId": "04fatzly26exj7b"
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers"
Yanıt
Başarılı bir yanıt, yeni oluşturulan yazıcının kimliğini içerir:
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs0o422uq",
"id": "0gjdgxs0o422uq",
"displayName": "Mercury",
"description": "Printer in the kitchen",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.14",
"createTime": "2021-03-11T23:19:27.180846Z",
"orgUnitId": "04fatzly26exj7b"
}
Yazıcıyı güncelleme
Bu örnek, 0gjdgxs0o422uq yazıcı kimliğinin açıklamasını günceller.
İstek
curl -X PATCH \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"description": "Printer in the office"
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs0o422uq?updateMask=description"
Yanıt
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs0o422uq",
"id": "0gjdgxs0o422uq",
"displayName": "Mercury",
"description": "Printer in the office",
"makeAndModel": "xerox able 1406",
"uri": "ipp://192.168.10.14",
"createTime": "2021-03-11T23:19:27.180846Z",
"orgUnitId": "04fatzly26exj7b"
}
Yazıcı silme
Bu örnek, yazıcı kimliği 0gjdgxs0o422uq olan yazıcıyı siler.
İstek
curl -X DELETE \
--header "Authorization: Bearer TOKEN" \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs0o422uq"
Yanıt
Başarılı yanıt boş. {}
Tek bir istekte birden fazla yazıcı oluşturma
Bu örnek, batchCreatePrinters yöntemini kullanarak tek bir istekte birden fazla yazıcı oluşturur.
İstek
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"requests": [
{
"parent": "customers/CUSTOMER_ID",
"printer": {
"displayName": "Earth",
"description": "Color printer",
"useDriverlessConfig": true,
"uri": "ipp://192.168.10.15",
"orgUnitId": "04fatzly26exj7b"
}
},
{
"parent": "customers/CUSTOMER_ID",
"printer": {
"displayName": "Saturn",
"description": "Color printer",
"useDriverlessConfig": true,
"uri": "ipp://192.168.10.16",
"orgUnitId": "04fatzly26exj7b"
}
}
]
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers:batchCreatePrinters"
Yanıt
{
"printers": [
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs0sbbh87",
"id": "0gjdgxs0sbbh87",
"displayName": "Saturn",
"description": "Color printer",
"uri": "ipp://192.168.10.16",
"createTime": "2021-03-12T01:10:32.957084Z",
"orgUnitId": "04fatzly26exj7b",
"useDriverlessConfig": true
},
{
"name": "customers/C0202nabg/chrome/printers/0gjdgxs2d6170e",
"id": "0gjdgxs2d6170e",
"displayName": "Earth",
"description": "Color printer",
"uri": "ipp://192.168.10.15",
"createTime": "2021-03-12T01:10:32.956735Z",
"orgUnitId": "04fatzly26exj7b",
"useDriverlessConfig": true
}
]
}
Tek bir istekte birden fazla yazıcıyı silme
Bu örnekte, batchDeletePrinters yöntemi kullanılarak tek bir istekte birden fazla yazıcı silinir.
İstek
curl -X POST \
-H "Content-Type: application/json" \
--header "Authorization: Bearer TOKEN" \
-d '{
"printerIds": ["0gjdgxs0sbbh87", "0gjdgxs2d6170e"]
}' \
"https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers:batchDeletePrinters"
Yanıt
Başarılı bir yanıt, silinen yazdırma sunucularının kimliklerini içerir:
{
"printerIds": [
"0gjdgxs2d6170e",
"0gjdgxs0sbbh87"
]
}