Add a Google Cloud Platform Connector
You can use the SDK to add a Google Cloud Platform (GCP) connector and sync virtual machines (VMs) from GCP to Deep Security Manager. For an overview, see this article in the Deep Security Help Center.
Prerequisite: You must prepare a GCP service account for use with Deep Security.
Use the following procedure to add a GCP connector:
- 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. - Create a
GcpConnectorsApi
object and use it to create theGcpConnector
on Deep Security Manager.
To see the properties that you can configure, see the Create a Computer operation in the API reference.
Python
View source
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 try: api_response = api_instance.create_gcp_connector(gcp_connector, api_version) return api_response except api_exception as e: print("An exception occurred when calling GCPConnectorsApi.create_gcp_connector: %s\n" % e)
JavaScript
View source
exports.createGcpConnector = function(api, name, serviceAccount, apiVersion){ let apiInstance = new api.GCPConnectorsApi(); let gcpConnector = new api.GCPConnector(); // Set the GCP connector properties. gcpConnector.name = name; gcpConnector.serviceAccount = serviceAccount; return apiInstance.createGCPConnector(gcpConnector, apiVersion); }
Java
View source
public static GCPConnector createGcpConnector(String name, String serviceAccount, String apiVersion) throws ApiException { GcpConnectorsApi apiInstance = new GcpConnectorsApi(); // Create a GCP connector GCPConnector gcpConnector = new GCPConnector(); gcpConnector.setName(name); gcpConnector.setServiceAccount(serviceAccount); // Add a GCP connector to Deep Security Manager GCPConnector result = null; result = apiInstance.createGCPConnector(gcpConnector, apiVersion); return result; }
Submit a Sync Action for a GCP Connector
After you create a GCP connector successfully, you can indicate to the GCP connector to trigger a sync.
Use the following high-level procedure to submit a sync action:
- Create an
Action
object and set the type to "synchronize". The type is a required property. - Create a
GcpConnectorActionsApi
object and use it to submit an action by a specific GCP connector ID to Deep Security Manager.
Python
View source
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" try: api_response = api_instance.create_gcp_connector_action(gcp_connector_id, gcp_connector_action, api_version) return api_response except api_exception as e: print("An exception occurred when calling GCPConnectorActionsApi.create_gcp_connector_action: %s\n" % e)
JavaScript
View source
exports.createGcpConnectorAction = function(api, gcpConnectorID, apiVersion){ let apiInstance = new api.GCPConnectorActionsApi(); // Set the action. let gcpConnectorAction = new api.Action(); gcpConnectorAction.type = "synchronize"; return apiInstance.createGCPConnectorAction(gcpConnectorID, gcpConnectorAction, apiVersion); }
Java
View source
public static Action createGCPConnectorAction(Integer gcpConnectorID, String apiVersion) throws ApiException { GcpConnectorActionsApi apiInstance = new GcpConnectorActionsApi(); // Set up synchronize action Action gcpConnectorAction = new Action(); gcpConnectorAction.setType(Action.TypeEnum.SYNCHRONIZE); Action result = apiInstance.createGCPConnectorAction(gcpConnectorID, gcpConnectorAction, apiVersion); return result; }