프린터 만들기 및 관리

이 페이지의 샘플 요청은 Chrome 프린터 관리 API로 프린터를 관리하는 방법을 보여줍니다.

모든 샘플 요청은 다음 변수를 사용합니다.

  • TOKEN: 애플리케이션의 OAuth 2.0 토큰입니다.
  • CUSTOMER_ID: 엔터프라이즈 계정의 고유 고객 ID입니다. 앞에 'C'가 붙습니다. (예: C123abc4) my_customer을 입력하여 내 계정의 고객 ID를 나타낼 수도 있습니다.

프린터 모델 나열

이 샘플은 지원되는 모든 프린터 모델의 목록을 요청합니다.

요청

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

프린터 나열 또는 검색

이 샘플은 조직 단위 ID 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
    }
  ]
}

특정 프린터 가져오기

이 샘플은 ID가 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"
}

프린터 만들기

이 샘플은 조직 단위 ID 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"

응답

성공적인 응답에는 새로 생성된 프린터의 ID가 포함됩니다.

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

프린터 업데이트

이 샘플은 프린터 ID 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"
}

프린터 삭제

이 샘플은 프린터 ID 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"

응답

성공적인 응답에는 삭제된 인쇄 서버의 ID가 포함됩니다.

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