प्रिंटर बनाएं और प्रबंधित करें

इस पेज पर दिए गए सैंपल अनुरोधों से पता चलता है कि Chrome Printer Management API की मदद से, प्रिंटर को कैसे मैनेज किया जाता है.

सभी सैंपल अनुरोधों में इन वैरिएबल का इस्तेमाल किया जाता है:

  • TOKEN: आपके ऐप्लिकेशन का OAuth 2.0 टोकन.
  • CUSTOMER_ID: यह एंटरप्राइज़ खाते का यूनीक ग्राहक आईडी होता है. इसके पहले "C" लिखा होता है. (उदाहरण: C123abc4) अपने खाते के ग्राहक आईडी को दिखाने के लिए, my_customer भी डाला जा सकता है.

प्रिंटर मॉडल की सूची

इस सैंपल में, प्रिंटर के उन सभी मॉडल की सूची का अनुरोध किया गया है जिन पर यह सुविधा काम करती है.

अनुरोध

curl -X GET \
  --header "Authorization: Bearer TOKEN" \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers:listPrinterModels"

जवाब

{
  "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=="
}

प्रिंटर की सूची देखना या उन्हें खोजना

इस सैंपल में, उन सभी प्रिंटर की सूची का अनुरोध किया गया है जो संगठन की यूनिट आईडी 04fatzly26exj7b में दिखते हैं. साथ ही, जिनके प्रिंटर के डिसप्ले नेम या ब्यौरे में Lobby शब्द शामिल है. संगठन की मुख्य इकाई में जोड़े गए प्रिंटर, उप-इकाइयों को दिखते हैं. इसलिए, ऐसा हो सकता है कि जवाब में ऐसे प्रिंटर शामिल हों जो संगठन की इकाई 04fatzly26exj7b में नहीं हैं.

अनुरोध

curl -X GET \
  --header "Authorization: Bearer TOKEN" \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers?orgUnitId=04fatzly26exj7b&filter=Lobby"

जवाब

{
  "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
    }
  ]
}

किसी प्रिंटर को पाना

इस सैंपल में, 0gjdgxs2zla0y7 आईडी वाले प्रिंटर के बारे में जानकारी का अनुरोध किया गया है.

अनुरोध

curl -X GET \
  --header "Authorization: Bearer TOKEN" \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs2zla0y7"

जवाब

{
  "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"
}

प्रिंटर बनाना

इस सैंपल में, संगठन की इकाई के आईडी 04fatzly26exj7b में एक नया प्रिंटर जोड़ा गया है.

अनुरोध

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"

जवाब

अनुरोध पूरा होने पर, जवाब में नए प्रिंटर का आईडी शामिल होता है:

{
  "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"
}

प्रिंटर की जानकारी अपडेट करना

इस सैंपल में, प्रिंटर आईडी 0gjdgxs0o422uq के ब्यौरे को अपडेट किया गया है.

अनुरोध

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"

जवाब

{
  "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"
}

किसी प्रिंटर को मिटाना

इस सैंपल में, प्रिंटर आईडी 0gjdgxs0o422uq वाले प्रिंटर को मिटाया जाता है.

अनुरोध

curl -X DELETE \
  --header "Authorization: Bearer TOKEN" \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printers/0gjdgxs0o422uq"

जवाब

सफल जवाब खाली है. {}

एक अनुरोध में कई प्रिंटर बनाना

इस सैंपल में, batchCreatePrinters तरीके का इस्तेमाल करके, एक ही अनुरोध में कई प्रिंटर बनाए जाते हैं.

अनुरोध

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"

जवाब

{
  "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
    }
  ]
}

एक ही अनुरोध में कई प्रिंटर मिटाना

इस सैंपल में, एक ही अनुरोध में कई प्रिंटर मिटाए जाते हैं. इसके लिए, batchDeletePrinters तरीके का इस्तेमाल किया जाता है.

अनुरोध

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"

जवाब

अगर अनुरोध सही से काम करता है, तो जवाब में उन प्रिंट सर्वर के आईडी शामिल होते हैं जिन्हें मिटाया गया है:

{
  "printerIds": [
    "0gjdgxs2d6170e",
    "0gjdgxs0sbbh87"
  ]
}