प्रिंट सर्वर बनाना और मैनेज करना

इस पेज पर दिए गए सैंपल अनुरोधों से पता चलता है कि 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/printServers"

जवाब

{
  "printServers": [
     {
      "name": "customers/C0202nabg/chrome/printServers/0gjdgxs2zla0y7",
      "id": "0gjdgxs2zla0y7",
      "displayName": "Marketing Print Server",
      "description": "Queue for corp marketing oversize jobs",
      "uri": "ipp://192.168.10.13",
      "createTime": "2021-03-11T21:41:34.779587Z",
      "orgUnitId": "04fatzly26exj7b"
    },
    {
      "name": "customers/C0202nabg/chrome/printServers/0gjdgxs1eqkb32",
      "id": "0gjdgxs1eqkb32",
      "displayName": "Production",
      "description": "Production print server for user manuals",
      "uri": "ipp://192.168.10.11",
      "createTime": "2021-03-11T22:02:06.048469Z",
      "orgUnitId": "04fatzly4jbjho9"
    }
  ]
}

किसी प्रिंट सर्वर की जानकारी पाना

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

अनुरोध

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

जवाब

{
  "name": "customers/C0234nab1/chrome/printServers/0gjdgxs2zla0y7",
  "id": "0gjdgxs2zla0y7",
  "displayName": "Marketing Print Server",
  "description": "Queue for corp marketing oversize jobs",
  "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": "hr-dept",
    "description": "HR queue for sensitive documents",
    "uri": "ipp://192.168.10.14",
    "orgUnitId": "04fatzly26exj7b"
  }' \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers"

जवाब

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

{
  "name": "customers/C0234nab1/chrome/printServers/0gjdgxs0o422uq",
  "id": "0gjdgxs0o422uq",
  "displayName": "hr-dept",
  "description": "HR queue for sensitive documents",
  "uri": "ipp://192.168.10.14",
  "orgUnitId": "04fatzly26exj7b",
  "createTime": "2021-03-11T23:19:27.180846Z",
  "orgUnitId": "04fatzly26exj7b"
}

प्रिंट सर्वर अपडेट करना

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

अनुरोध

curl -X PATCH \
  -H "Content-Type: application/json" \
  --header "Authorization: Bearer TOKEN" \
  -d '{
    "description": "General HR dept print server",
  }' \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers/0gjdgxs0o422uq?updateMask=description"

जवाब

{
  "name": "customers/C0234nab1/chrome/printServers/0gjdgxs0o422uq",
  "id": "0gjdgxs0o422uq",
  "displayName": "hr-dept",
  "description": "General HR dept print server",
  "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/printServers/0gjdgxs0o422uq"

जवाब

जवाब में कोई डेटा नहीं है.

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

इस सैंपल में, batchCreatePrintServers तरीके का इस्तेमाल करके कई प्रिंट सर्वर बनाए जाते हैं.

अनुरोध

curl -X POST \
  -H "Content-Type: application/json" \
  --header "Authorization: Bearer TOKEN" \
  -d '{
    "requests": [
      {
        "parent": "customers/CUSTOMER_ID",
        "printServer": {
          "displayName": "General print server",
          "description": "Org-wide print queue",
          "uri": "ipp://192.168.10.15",
          "orgUnitId": "04fatzly26exj7b"
        }
    },
    {
        "parent": "customers/CUSTOMER_ID",
        "printServer": {
          "displayName": "Engineering print server",
          "description": "Print server for Engineering use only",
          "uri": "ipp://192.168.10.16",
          "orgUnitId": "04fatzly26exj7b"
        }
    }
  ]
  }' \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers:batchCreatePrintServers"

जवाब

{
  "printServers": [
    {
      "name": "customers/C0234nab1/chrome/printServers/0gjdgxs0sbbh87",
      "id": "0gjdgxs0sbbh87",
      "displayName": "General print server",
      "description": "Org-wide print queue",
      "uri": "ipp://192.168.10.15",
      "createTime": "2021-03-12T01:10:32.957084Z",
      "orgUnitId": "04fatzly26exj7b"
    },
    {
      "name": "customers/C0234nab1/chrome/printServers/0gjdgxs2d6170e",
      "id": "0gjdgxs2d6170e",
      "displayName": "Engineering print server",
      "description": "Print server for Engineering use only",
      "uri": "ipp://192.168.10.16",
      "createTime": "2021-03-12T01:10:32.956735Z",
      "orgUnitId": "04fatzly26exj7b"
    }
  ]
}

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

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

अनुरोध

curl -X POST \
  -H "Content-Type: application/json" \
  --header "Authorization: Bearer TOKEN" \
  -d '{
    "printServerIds": ["0gjdgxs0sbbh87", "0gjdgxs2d6170e"]
  }' \
  "https://admin.googleapis.com/admin/directory/v1/customers/CUSTOMER_ID/chrome/printServers:batchDeletePrintServers"

जवाब

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

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