Create GCP Connector 3.0

POST/qps/rest/3.0/create/am/gcpassetdataconnector

 

Specify the connector details such as name, description, polling frequency, project ID and upload the configuration (JSON) file and create a new connector in the Connectors application.

Permissions required - Managers with full scope.

Input ParametersInput Parameters

Parameters

Description

id

The ID of the connector that you want to create.

name

Name of the connector you want to create.

description

Description of the connector you want to create.

type

Type of connector - GCP.

authRecord

(GCPAuthRecordSimple) The GCP authentication record the connector uses to connect to GCP. When writing/updating it is looked up by the ID field.

allRegions

(boolean) If true, the end point’s collection is ignored an all GCP regions scanned.

disabled

(boolean) Whether execution of the connector is disabled (YES). If disabled, the connector does not synchronize assets.

runFrequency

runFrequency for a connector decides the rate at which the connector should poll the cloud provider and fetch the data specified in minutes.

isRemediationEnabled

A flag to enable or disable remediation for the connector.

connectorAppInfos.set.

ConnectorAppInfoQList

A mandatory parent parameter when you need to provide the below parameter, set.ConnectorAppInfo.

set.ConnectorAppInfos

It holds the list of list of ConnectorAppInfo which includes App Name, identifiers and tag details. Connector can one or more apps from list [AI, CI, CSA].

AI-Asset Inventory, CI- Cloud Inventory, CSA- Cloud Security Assessment.

Sample: Create a new GCP connector (with a single tag)Sample: Create a new GCP connector (with a single tag)

API request

 curl -u "<username>:<password>" -H "Content-type: text/xml" -X "POST" --data-binary @-
"<qualys_base_url>/qps/rest/3.0/create/am/gcpassetdataconnector"
   

Request POST data

 
      <?xml version="1.0" encoding="UTF-8" ?>
<ServiceRequest>
    <data>
        <GcpAssetDataConnector>
            <disabled>false</disabled>
            <connectorAppInfos>
                <set>
                    <ConnectorAppInfoQList>
                        <set>
                            <ConnectorAppInfo>
                                <name>CSA</name>
                                <identifier>my-project-151366xxxx9</identifier>
                                <tagId>123489465</tagId>
                            </ConnectorAppInfo>
                        </set>
                    </ConnectorAppInfoQList>
                    <ConnectorAppInfoQList>
                        <set>
                            <ConnectorAppInfo>
                                <name>CI</name>
                                <identifier>my-project-151366xxxx9</identifier>
                                <tagId>123489465</tagId>
                            </ConnectorAppInfo>
                        </set>
                    </ConnectorAppInfoQList>
                </set>
            </connectorAppInfos>
            <runFrequency>240</runFrequency>
            <isDeleted>false</isDeleted>
            <isGovCloudConfigured>false</isGovCloudConfigured>
            <isRemediationEnabled>true</isRemediationEnabled>
            <name>Test GCP connector</name>
            <authRecord>
                <projectId>my-project-1513669048551</projectId>
                <auth_provider_x509_cert_url>https://www.googleapis.com/oauth2/v1/certs</auth_provider_x509_cert_url>
                <auth_uri>https://accounts.google.com/o/oauth2/auth</auth_uri>
                <client_email>[email protected]</client_email>
                <client_id>105994049705415737317</client_id>
                <client_x509_cert_url>https://www.googleapis.com/robot/v1/metadata/x509/crm-70975%40my-project-1513669048551.iam.gserviceaccount.com</client_x509_cert_url>
                <private_key>xxx</private_key>
                <private_key_id>xxx</private_key_id>
                <token_uri>https://oauth2.googleapis.com/token</token_uri>
                <type>service_account</type>
            </authRecord>
        </GcpAssetDataConnector>
    </data>
</ServiceRequest>
 

Response

<?xml version="1.0" encoding="UTF-8" ?>
<ServiceResponse>
    <responseCode>SUCCESS</responseCode>
    <count>1</count>
    <data>
        <GcpAssetDataConnector>
            <nextSync>2022-06-30T16:38:21Z</nextSync>
            <connectorAppInfos>
                <list>
                    <ConnectorAppInfoQList>
                        <list>
                            <ConnectorAppInfo>
                                <name>CSA</name>
                                <identifier>my-project-151366xxxx1</identifier>
                            </ConnectorAppInfo>
                        </list>
                    </ConnectorAppInfoQList>
                </list>
                <list>
                    <ConnectorAppInfoQList>
                        <list>
                            <ConnectorAppInfo>
                                <name>CI</name>
                                <identifier>my-project-151366xxxx1</identifier>
                            </ConnectorAppInfo>
                        </list>
                    </ConnectorAppInfoQList>
                </list>
            </connectorAppInfos>
            <disabled>false</disabled>
            <id>842873</id>
            <connectorState>FINISHED_SUCCESS</connectorState>
            <name>sign</name>
            <isRemediationEnabled>true</isRemediationEnabled>
            <authRecord>
                <projectId>my-project-151366xxxx1</projectId>
            </authRecord>
            <lastSync>2022-06-30T13:21:57Z</lastSync>
            <runFrequency>240</runFrequency>
            <cloudviewUuid>xxxxxxxxx-2007-xxxx-adab-9db19bd5fdb9</cloudviewUuid>
            <isDeleted>false</isDeleted>
            <isGovCloudConfigured>false</isGovCloudConfigured>
            <description>testing</description>
        </GcpAssetDataConnector>
    </data>
</ServiceResponse>

Sample 2: Create a new GCP connector (with multi-tag)Sample 2: Create a new GCP connector (with multi-tag)

API Request (JSON)

 curl -u "<username>:<password>"-X "POST" --data-binary @-"<qualys_base_url>/qps/rest/3.0/create/am/gcpassetdataconnector"
--header 'Accept: application/json'
--header 'Content-Type: application/json'
    

 

Request POST Data (JSON)

{
    "ServiceRequest": {
        "data": {
            "GcpAssetDataConnector": {
                "disabled": false,
                "isDeleted": false,
                 "defaultTags": {                    
                    "add": {
                        "TagSimple": [{
                                "id": 21423674
                            },
                            {
                                "id": 21423675
                            }]
                    }                    
                },
                "activation": {
                   "set": {
                      "ActivationModule": ["VM","SCA"]
                  }
                 }, 
                "connectorAppInfos": {
                    "set": {
                        "ConnectorAppInfoQList": [
                            {
                                "set": {
                                    "ConnectorAppInfo": [
                                        {
                                            "name": "AI",
                                            "identifier": "gcp-connector",
                                            "tagId": 137547818
                                        }
                                    ]
                                }
                            },
                            {
                                "set": {
                                    "ConnectorAppInfo": [
                                        {
                                            "name": "CI",
                                            "identifier": "gcp-connector",
                                            "tagId": 137547818
                                        }
                                    ]
                                }
                            },
                            {
                                "set": {
                                    "ConnectorAppInfo": [
                                        {
                                            "name": "CSA",
                                            "identifier": "gcp-connector",
                                            "tagId": 137547818
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                },
                "runFrequency": 240,
                "isRemediationEnabled": true,
                "isGovCloudConfigured": false,
                "name": "GCP CONNECTOR PUBLIC API",
                "description": "Connector Created from API",
                "authRecord": {
                    "type": "service_account",
                    "project_id": "gcp-connector",
                    "private_key_id": "345717xxxxxxxxxxxxxxxxx7a0bcec93e0001e7",
                    "private_key": "xxx",
                    "client_email": "[email protected]",
                    "client_id": "xxx",
                    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
                    "token_uri": "https://oauth2.googleapis.com/token",
                    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
                    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-name%40my-project-1513669048551.iam.gserviceaccount.com"
                }
            }
        }
    }
}
    

Response (JSON)

{
    "ServiceResponse": {
        "responseCode": "SUCCESS",
        "count": 1,
        "data": [
            {
                "GcpAssetDataConnector": {
                    "nextSync": "2022-06-30T16:38:21Z",
                      "defaultTags": {
                        "list": [
                            {
                                "TagSimple": {
                                    "name": "Tag1",
                                    "id": 138176864
                                }
                            },
                            {
                                "TagSimple": {
                                    "name": "Tag2",
                                    "id": 138176865
                                }
                            }
                        ]
                    },
                    "connectorAppInfos": {
                        "list": [
                            {
                                "ConnectorAppInfoQList": {
                                    "list": [
                                        {
                                            "ConnectorAppInfo": {
                                                "name": "CSA",
                                                "identifier": "my-project-151366xxxx1"
                                            }
                                        }
                                    ]
                                }
                            },
                            {
                                "ConnectorAppInfoQList": {
                                    "list": [
                                        {
                                            "ConnectorAppInfo": {
                                                "name": "CI",
                                                "identifier": "my-project-151366xxxx1"
                                            }
                                        }
                                    ]
                                }
                            }
                        ]
                    },
                    "disabled": "false",
                    "id": 842873,
                    "connectorState": "FINISHED_SUCCESS",
                    "name": "sign",
                    "isRemediationEnabled": "true",
                    "authRecord": {
                        "projectId": "my-project-151366xxxx1"
                    },
                    "lastSync": "2022-06-30T13:21:57Z",
                    "runFrequency": 240,
                    "cloudviewUuid": "xxxxxx-2007-xxxx-adab-9db19bd5fdb9",
                    "isDeleted": "false",
                    "isGovCloudConfigured": "false",
                    "description": "testing"
                }
            }
        ]
    }
}
    

Sample 3 - Create GCP connector with Cloud Perimeter Scan EnabledSample 3 - Create GCP connector with Cloud Perimeter Scan Enabled

API request

curl -u "<username>:<password>"-X "POST" --data-binary @-"<qualys_base_url>/qps/rest/3.0/create/am/gcpassetdataconnector" --header 'Accept: application/json' --header 'Content-Type: application/json' 

Request POST data

{
  "isCPSEnabled": true,
  "gcpConnectorScanConfig": {
    "set": {
      "GcpConnectorScanConfiguration": {
        "scanPrefix": "cps-enabled-test",
        "optionProfileId": 178135,
        "recurrence": "DAILY",
        "startDate": "04/15/2025",
        "startTime": "02:00",
        "timezone": "MX-PUE",
        "observeDst": false,
        "pauseAfterHours": 1,
        "pauseAfterMinutes": 10,
        "resumeAfterHours": 20,
        "resumeDays": 5,
        "dailyOccurrence": {
          "set": {
            "DailyOccurrence": {
              "frequencyDays": 1
            }
          }
        }
      }
    }
  }
}
   
    

JSON Output

{ 
  "ServiceResponse":{
  "gcpConnectorScanConfig": {
    "list": [
      {
        "GcpConnectorScanConfiguration": {
          "recurrence": "DAILY",
          "dailyOccurrence": {
            "list": [
              {
                "DailyOccurrence": {
                  "frequencyDays": 1
                }
              }
            ]
          },
          "scanPrefix": "cps-enabled-test",
          "startDate": "04/15/2025",
          "startTime": "02:00",
          "timezone": "MX-PUE",
          "observeDst": "false",
          "optionProfileId": 178135
        }
      }
    ]
  },
  "isCPSEnabled": true
 }