Yazdırma sunucusu oluşturma ve yönetme

Bu sayfadaki örnek istekler, yazdırma sunucularının Chrome Printer Management API ile nasıl yönetileceğini göstermektedir.

Tüm örnek istekler aşağıdaki değişkenleri kullanır:

  • $TOKEN: Uygulamanızın OAuth 2.0 jetonu.
  • $CUSTOMER: Kurumsal hesabın benzersiz müşteri kimliği. Başında "C" vardır. (Örnek: C123abc4) Kendi kuruluşunuzun müşteri kimliğini belirtmek için my_customer de girebilirsiniz.

Yazdırma sunucularını listeleme veya arama

Bu örnek, kuruluşta görünür olan tüm yazdırma sunucularının bir listesini ister.

İstek

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

Yanıt

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

Belirli bir yazdırma sunucusunu alma

Bu örnekte, 0gjdgxs2zla0y7 kimliğine sahip bir yazdırma sunucusu için ayrıntılar istenir.

İstek

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

Yanıt

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

Yazdırma sunucusu oluşturma

Bu örnek, 04fatzly26exj7b kimliğine sahip bir kuruluş birimine yeni bir yazdırma sunucusu ekler.

İstek

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/chrome/printServers"

Yanıt

{
  "name": "customers/C0234nab1/chrome/printServers/0gjdgxs0o422uq",
  "id": "0gjdgxs0o422uq", // Note: This is the ID of the newly created print server.
  "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"
}

Yazdırma sunucusunu güncelleme

Bu örnek, 0gjdgxs0o422uq yazdırma sunucusu kimliğinin açıklamasını günceller.

İstek

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/chrome/printServers/0gjdgxs0o422uq?updateMask=description"

Yanıt

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

Yazdırma sunucusunu silme

Bu örnek, 0gjdgxs0o422uq kimliğine sahip yazdırma sunucusunu siler.

İstek

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

Yanıt

Başarılı bir yanıt boş.

Tek bir istekte birden fazla yazdırma sunucusu oluşturma

Bu örnek, batchCreatePrintServers yöntemini kullanarak birden fazla yazdırma sunucusu oluşturur.

İstek

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

Yanıt

{
  "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": "Eng print server",
      "description": "Print server for Eng use only",
      "uri": "ipp://192.168.10.16",
      "createTime": "2021-03-12T01:10:32.956735Z",
      "orgUnitId": "04fatzly26exj7b"
    }
  ]
}

Tek bir istekte birden çok yazdırma sunucusunu silme

Bu örnek, batchDeletePrintServers yöntemini kullanarak tek bir istekte birden fazla yazdırma sunucusunu siler.

İstek

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/chrome/printServers:batchDeletePrintServers"

Yanıt

{
  "printServerIds": [ // Successfully deleted print servers.
    "0gjdgxs2d6170e",
    "0gjdgxs0sbbh87"
  ]
}