Tạo và quản lý máy chủ máy in

Các yêu cầu mẫu trên trang này minh hoạ cách quản lý máy chủ in bằng Chrome Printer Management API.

Tất cả các yêu cầu mẫu đều sử dụng các biến sau:

  • TOKEN: Mã thông báo OAuth 2.0 của ứng dụng.
  • CUSTOMER_ID: Mã khách hàng duy nhất của tài khoản doanh nghiệp, có thêm "C" ở đầu. (Ví dụ: C123abc4) Bạn cũng có thể nhập my_customer để biểu thị mã khách hàng của tổ chức mình.

Liệt kê hoặc tìm kiếm máy chủ máy in

Mẫu này yêu cầu danh sách tất cả các máy chủ in mà tổ chức có thể thấy.

Yêu cầu

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

Phản hồi

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

Nhận một máy chủ in cụ thể

Mẫu này yêu cầu thông tin chi tiết cho một máy chủ in có mã nhận dạng là 0gjdgxs2zla0y7.

Yêu cầu

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

Phản hồi

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

Tạo máy chủ in

Mẫu này thêm một máy chủ in mới vào một đơn vị tổ chức có mã nhận dạng 04fatzly26exj7b.

Yêu cầu

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"

Phản hồi

Phản hồi thành công sẽ bao gồm mã nhận dạng của máy chủ in mới được tạo:

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

Cập nhật máy chủ in

Mẫu này cập nhật nội dung mô tả của mã nhận dạng máy chủ in 0gjdgxs0o422uq.

Yêu cầu

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"

Phản hồi

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

Xoá máy chủ in

Mẫu này sẽ xoá máy chủ in có mã nhận dạng 0gjdgxs0o422uq.

Yêu cầu

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

Phản hồi

Phản hồi thành công là phản hồi trống.

Tạo nhiều máy chủ in trong một yêu cầu

Mẫu này tạo nhiều máy chủ in bằng phương thức batchCreatePrintServers.

Yêu cầu

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"

Phản hồi

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

Xoá nhiều máy chủ in trong một yêu cầu

Mẫu này sẽ xoá nhiều máy chủ in trong một yêu cầu duy nhất bằng phương thức batchDeletePrintServers.

Yêu cầu

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"

Phản hồi

Phản hồi thành công bao gồm mã nhận dạng của các máy chủ in đã bị xoá:

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