You can use the SDK to add a Google Cloud Platform (GCP) connector and synchronize virtual machines (VMs) from GCP to Workload Security. For an overview, see Create a Google Cloud Platform service account.
Before you begin, you must prepare a GCP service account for use with Workload Security.
Use the following procedure to add a GCP connector:

Procedure

  1. Create a GcpConnector object and set the name and service account. The name and service account are required properties. The length of the name cannot exceed 255 characters.
  2. Create a GcpConnectorsApi object and use it to create the GcpConnector on Workload Security.
    For a list of properties that you can configure, see the Create a Computer operation in the API Reference.
    def create_gcp_connector(api, configuration, api_version, api_exception, name, service_account):
       api_instance = api.GCPConnectorsApi(api.ApiClient(configuration))
       gcp_connector = api.GCPConnector()
       gcp_connector.name = name
       gcp_connector.service_account = service_account
    
      api_response = api_instance.create_gcp_connector(gcp_connector, api_version)
      return api_response

Submit a Synchronization Action for a GCP Connector Parent topic

After you create a GCP connector successfully, you can indicate to the GCP connector to trigger synchronization.
Use the following high-level procedure to submit a synchronization action:

Procedure

  1. Create anAction object and set the type to synchronize. The type is a required property.
  2. Create a GcpConnectorActionsApi object and use it to submit an action by a specific GCP connector ID to Workload Security.
    def create_gcp_connector_action(api, configuration, api_version, api_exception, gcp_connector_id):
       api_instance = api.GCPConnectorActionsApi(api.ApiClient(configuration))
       gcp_connector_action = api.Action()
       gcp_connector_action.type = "synchronize"
    
      api_response = api_instance.create_gcp_connector_action(gcp_connector_id, gcp_connector_action, api_version)
      return api_response