Connectors API için kod örnekleri

API özellikleri hakkında bilgi için Connectors API başlıklı makaleye bakın.

Bu sayfadaki tüm isteklerde aşağıdaki değişkenler kullanılır:

  • $TOKEN - OAuth 2.0 jetonu
  • $CUSTOMER - Müşterinin kimliği veya hazır değer my_customer
  • $PAGE_TOKEN: Önceki sayfa yanıtlarından alınan sayfa jetonu
  • $CONNECTOR_CONFIG_ID - Bağlayıcı yapılandırmasının kimliği. Oluşturulan kimlikler büyük harfli UUID biçimindedir (örneğin, 550E8400-E29B-41D4-A716-446655440000).

Bağlayıcı yapılandırmalarını listeleme

Müşteri alanınız için bağlayıcı yapılandırmalarını listelemek üzere list yöntemini kullanın. Sonuçlar arasında sayfalara ayırırken isteğe bağlı olarak page_size (veya pageSize) ve page_token (veya pageToken) sorgu parametrelerini sağlayabilirsiniz:

  • page_size / pageSize: Döndürülecek maksimum bağlayıcı yapılandırması sayısı. Belirtilmediyse varsayılan sayfa boyutu 50'dir ve maksimum 100 olabilir.
  • page_token / pageToken: Önceki bir list çağrısından alınan sayfa jetonu.

İstek

curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/connectorConfigs?page_size=50&page_token=$PAGE_TOKEN"

Yanıt

{
  "connectorConfigs": [
    {
      "name": "customers/my_customer/connectorConfigs/550E8400-E29B-41D4-A716-446655440000",
      "displayName": "Configuration 1",
      "type": "REPORTING",
      "details": {
        "googleSecOpsConfig": {
          "host": "example.googlesecops.com",
          "reportingSettings": {
            "enabledDefaultEvents": [
              "ALL_DEFAULT_EVENTS"
            ],
            "enabledOptInEvents": [
              "PASSWORD_BREACH_EVENT",
              "URL_NAVIGATION_EVENT"
            ],
            "enabledDeviceEvents": [
              "ALL_DEVICE_EVENTS"
            ]
          }
        }
      },
      "status": {
        "state": "ENABLED"
      }
    }
  ],
  "nextPageToken": "<next_page_token>"
}

Bağlayıcı yapılandırması alma

Belirli bir bağlayıcı yapılandırmasını kimliğe göre almak için get yöntemini kullanın.

İstek

curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/connectorConfigs/$CONNECTOR_CONFIG_ID"

Yanıt

{
  "name": "customers/my_customer/connectorConfigs/550E8400-E29B-41D4-A716-446655440000",
  "displayName": "Configuration 1",
  "type": "REPORTING",
  "details": {
    "googleSecOpsConfig": {
      "host": "example.googlesecops.com",
      "reportingSettings": {
        "enabledDefaultEvents": [
          "ALL_DEFAULT_EVENTS"
        ],
        "enabledOptInEvents": [
          "PASSWORD_BREACH_EVENT",
          "URL_NAVIGATION_EVENT"
        ],
        "enabledDeviceEvents": [
          "ALL_DEVICE_EVENTS"
        ]
      }
    }
  },
  "status": {
    "state": "ENABLED"
  }
}

Bağlayıcı yapılandırması oluşturma

Müşteri alanınız için yeni bir bağlayıcı yapılandırması oluşturmak üzere create yöntemini kullanın. İsteğe bağlı olarak connector_config_id (veya connectorConfigId) sorgu parametresini ayarlayarak özel bir kimlik sağlayabilirsiniz. Kimlik sağlanmazsa sunucu tarafından büyük harflerle yazılmış bir UUID oluşturulur.

İstek

curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "Configuration 1",
    "type": "REPORTING",
    "details": {
      "googleSecOpsConfig": {
        "apiKey": "api-key",
        "host": "example.googlesecops.com",
        "reportingSettings": {
          "enabledDefaultEvents": [
            "ALL_DEFAULT_EVENTS"
          ],
          "enabledOptInEvents": [
            "PASSWORD_BREACH_EVENT"
          ],
          "enabledDeviceEvents": [
            "ALL_DEVICE_EVENTS"
          ]
        }
      }
    }
  }' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/connectorConfigs?connector_config_id=$CONNECTOR_CONFIG_ID"

Yanıt

{
  "name": "customers/my_customer/connectorConfigs/550E8400-E29B-41D4-A716-446655440000",
  "displayName": "Configuration 1",
  "type": "REPORTING",
  "details": {
    "googleSecOpsConfig": {
      "host": "example.googlesecops.com",
      "reportingSettings": {
        "enabledDefaultEvents": [
          "ALL_DEFAULT_EVENTS"
        ],
        "enabledOptInEvents": [
          "PASSWORD_BREACH_EVENT"
        ],
        "enabledDeviceEvents": [
          "ALL_DEVICE_EVENTS"
        ]
      }
    }
  },
  "status": {
    "state": "ENABLED"
  }
}

Bağlayıcı yapılandırmasını güncelleme

Bağlayıcı yapılandırması aşağıdaki yöntemlerden biriyle güncellenebilir:

  • Güncelleme maskesi yok: updateMask sorgu parametresi sağlanmazsa istekte ayarlanan tüm alanlar güncellenir.
  • Güncelleme maskesiyle: Bir updateMask sorgu parametresi belirtilirse yalnızca maskede listelenen alanlar güncellenir.
  • * ile eşleşen güncelleme maskesiyle: updateMask, * olarak ayarlanırsa güncelleme tam değiştirme (oluşturmaya eşdeğer) olarak değerlendirilir.

1. örnek: Yalnızca hedeflemeyi güncelleme displayName

Bu seçenekte, updateMask=displayName sağlanması, gövdede ek alanlar verilmiş olsa bile yalnızca displayName değerinin güncellenmesini sağlar.

İstek

curl -X PATCH \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "Updated name"
  }' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/connectorConfigs/$CONNECTOR_CONFIG_ID?updateMask=displayName"

Yanıt

{
  "name": "customers/my_customer/connectorConfigs/550E8400-E29B-41D4-A716-446655440000",
  "displayName": "Updated name",
  "type": "REPORTING",
  "details": {
    "googleSecOpsConfig": {
      "host": "example.googlesecops.com",
      "reportingSettings": {
        "enabledDefaultEvents": [
          "BROWSER_EXTENSION_INSTALL_EVENT"
        ],
        "enabledOptInEvents": [
          "PASSWORD_BREACH_EVENT"
        ],
        "enabledDeviceEvents": [
          "LOGIN_LOGOUT_EVENT"
        ]
      }
    }
  },
  "status": {
    "state": "ENABLED"
  }
}

Örnek 2: Güncelleme maskesi yok (istekteki tüm alanları günceller)

İstek sorgu dizesinden updateMask çıkarılırsa JSON yükünde sağlanan tüm alanlar güncellenir.

İstek

curl -X PATCH \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "Updated again",
    "details": {
      "googleSecOpsConfig": {
        "reportingSettings": {
          "enabledDefaultEvents": [
            "BROWSER_EXTENSION_INSTALL_EVENT",
            "CONTENT_TRANSFER_EVENT",
            "CONTENT_UNSCANNED_EVENT",
            "DATA_ACCESS_CONTROL_EVENT",
            "MALWARE_TRANSFER_EVENT"
          ]
        }
      }
    }
  }' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/connectorConfigs/$CONNECTOR_CONFIG_ID"

Yanıt

{
  "name": "customers/my_customer/connectorConfigs/550E8400-E29B-41D4-A716-446655440000",
  "displayName": "Updated again",
  "type": "REPORTING",
  "details": {
    "googleSecOpsConfig": {
      "host": "example.googlesecops.com",
      "reportingSettings": {
        "enabledDefaultEvents": [
          "BROWSER_EXTENSION_INSTALL_EVENT",
          "CONTENT_TRANSFER_EVENT",
          "CONTENT_UNSCANNED_EVENT",
          "DATA_ACCESS_CONTROL_EVENT",
          "MALWARE_TRANSFER_EVENT"
        ],
        "enabledOptInEvents": [
          "PASSWORD_BREACH_EVENT"
        ],
        "enabledDeviceEvents": [
          "ALL_DEVICE_EVENTS"
        ]
      }
    }
  },
  "status": {
    "state": "ENABLED"
  }
}

3. örnek: * öğesinin güncelleme maskesi (tam değiştirme)

Ayar updateMask=*, mevcut yapılandırmayı istek gövdesinde sağlanan yükle tamamen değiştirir.

İstek

curl -X PATCH \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "displayName": "New Updated Display Name",
    "type": "REPORTING",
    "details": {
      "googleSecOpsConfig": {
        "apiKey": "api-key",
        "host": "example.googlesecops.com",
        "reportingSettings": {
          "enabledOptInEvents": [
            "PASSWORD_BREACH_EVENT"
          ]
        }
      }
    }
  }' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/connectorConfigs/$CONNECTOR_CONFIG_ID?updateMask=*"

Yanıt

{
  "name": "customers/my_customer/connectorConfigs/550E8400-E29B-41D4-A716-446655440000",
  "displayName": "New Updated Display Name",
  "type": "REPORTING",
  "details": {
    "googleSecOpsConfig": {
      "host": "example.googlesecops.com",
      "reportingSettings": {
        "enabledOptInEvents": [
          "PASSWORD_BREACH_EVENT"
        ]
      }
    }
  },
  "status": {
    "state": "ENABLED"
  }
}

Bağlayıcı yapılandırmasını silme

Bir bağlayıcı yapılandırmasını silmek için delete yöntemini kullanın.

İstek

curl -X DELETE \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/connectorConfigs/$CONNECTOR_CONFIG_ID"

Yanıt

{}