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 @-
"https://qualysapi.qualys.com/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>crm-70975@my-project-1513669048551.iam.gserviceaccount.com</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>-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC64ocFtknagk8N
4iQd9lhhHXGo8JLVgqSruO8ebxa002+ps8PPukPuAS9IazPrNjdyndVezOClANJu
xj3NhAOQ5xHTANFQH33CXcrxhoNKvdQLIxg0wH8HS94wCOvvDU7wKuOdkfSdLE6Z
a3FM7v2J5iZgC2QgF/stwl13pLszLsOyOuJlMiiV4nYBUMbQrZr8sJvbSBoiEXVt
enk4Dm2a6khRdRFsa9d9g3Z0t2GyXT3ln8KEAdn8plUu1C6WIHg9HJtYi3ib/4bn
2tahZ/T5C6BQk+3BTbRAoGBALMpb9z3MsEckgNJAF3P
y0pko3GuZx4nq3f20oADxsYfwRjJ5ZfchKbW/rE0IcK0enw3sEHlcFFHgcvMSnr4
Hl0zCZ6uq9rEytwXtM3JKf3ywIH6AzAdkw4s/AVQmk3ejSJkRzxly8FRPNeJjSzm
5WqpzucZNtGdP2UoMMGIv/iq
-----END PRIVATE KEY-----
</private_key>
                <private_key_id>9f5cd117dd7bcaad4</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 @-"https://qualysapi.qualys.com/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": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCWUcDEnNeOt7y/\nIlPt+v/Yx-----END PRIVATE KEY-----\n",
                    "client_email": "qualys-connector@gcp-connector.iam.gserviceaccount.com",
                    "client_id": "114756122541466997696",
                    "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"
                }
            }
        ]
    }
}