{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-cloud-build/json-schema/google-cloud-build-connection-schema.json",
  "title": "Connection",
  "description": "A connection to a SCM like GitHub, GitHub Enterprise, Bitbucket Data Center, Bitbucket Cloud or GitLab.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-cloud-build-projects-api-openapi.yml#/components/schemas/Connection",
  "properties": {
    "installationState": {
      "$ref": "#/$defs/InstallationState",
      "description": "Output only. Installation state of the Connection."
    },
    "gitlabConfig": {
      "$ref": "#/$defs/GoogleDevtoolsCloudbuildV2GitLabConfig",
      "description": "Configuration for connections to gitlab.com or an instance of GitLab Enterprise."
    },
    "updateTime": {
      "format": "google-datetime",
      "description": "Output only. Server assigned timestamp for when the connection was updated.",
      "readOnly": true,
      "type": "string"
    },
    "disabled": {
      "description": "Optional. If disabled is set to true, functionality is disabled for this connection. Repository based API methods and webhooks processing for repositories in this connection will be disabled.",
      "type": "boolean"
    },
    "githubConfig": {
      "$ref": "#/$defs/GitHubConfig",
      "description": "Configuration for connections to github.com."
    },
    "createTime": {
      "type": "string",
      "description": "Output only. Server assigned timestamp for when the connection was created.",
      "format": "google-datetime",
      "readOnly": true
    },
    "bitbucketCloudConfig": {
      "$ref": "#/$defs/BitbucketCloudConfig",
      "description": "Configuration for connections to Bitbucket Cloud."
    },
    "bitbucketDataCenterConfig": {
      "$ref": "#/$defs/BitbucketDataCenterConfig",
      "description": "Configuration for connections to Bitbucket Data Center."
    },
    "etag": {
      "type": "string",
      "description": "This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding."
    },
    "annotations": {
      "additionalProperties": {
        "type": "string"
      },
      "description": "Optional. Allows clients to store small amounts of arbitrary data.",
      "type": "object"
    },
    "githubEnterpriseConfig": {
      "$ref": "#/$defs/GoogleDevtoolsCloudbuildV2GitHubEnterpriseConfig",
      "description": "Configuration for connections to an instance of GitHub Enterprise."
    },
    "name": {
      "type": "string",
      "description": "Immutable. The resource name of the connection, in the format `projects/{project}/locations/{location}/connections/{connection_id}`."
    },
    "reconciling": {
      "readOnly": true,
      "type": "boolean",
      "description": "Output only. Set to true when the connection is being set up or updated in the background."
    }
  },
  "type": "object",
  "$defs": {
    "BitbucketCloudConfig": {
      "description": "Configuration for connections to Bitbucket Cloud.",
      "properties": {
        "authorizerCredential": {
          "$ref": "#/$defs/UserCredential",
          "description": "Required. An access token with the `webhook`, `repository`, `repository:admin` and `pullrequest` scope access. It can be either a workspace, project or repository access token. It's recommended to use a system account to generate these credentials."
        },
        "readAuthorizerCredential": {
          "$ref": "#/$defs/UserCredential",
          "description": "Required. An access token with the `repository` access. It can be either a workspace, project or repository access token. It's recommended to use a system account to generate the credentials."
        },
        "workspace": {
          "type": "string",
          "description": "Required. The Bitbucket Cloud Workspace ID to be connected to Google Cloud Platform."
        },
        "webhookSecretSecretVersion": {
          "description": "Required. SecretManager resource containing the webhook secret used to verify webhook events, formatted as `projects/*/secrets/*/versions/*`.",
          "type": "string"
        }
      },
      "type": "object"
    },
    "BitbucketDataCenterConfig": {
      "type": "object",
      "properties": {
        "webhookSecretSecretVersion": {
          "description": "Required. Immutable. SecretManager resource containing the webhook secret used to verify webhook events, formatted as `projects/*/secrets/*/versions/*`.",
          "type": "string"
        },
        "serverVersion": {
          "type": "string",
          "description": "Output only. Version of the Bitbucket Data Center running on the `host_uri`.",
          "readOnly": true
        },
        "serviceDirectoryConfig": {
          "$ref": "#/$defs/GoogleDevtoolsCloudbuildV2ServiceDirectoryConfig",
          "description": "Optional. Configuration for using Service Directory to privately connect to a Bitbucket Data Center. This should only be set if the Bitbucket Data Center is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the Bitbucket Data Center will be made over the public internet."
        },
        "hostUri": {
          "type": "string",
          "description": "Required. The URI of the Bitbucket Data Center instance or cluster this connection is for."
        },
        "sslCa": {
          "description": "Optional. SSL certificate to use for requests to the Bitbucket Data Center.",
          "type": "string"
        },
        "authorizerCredential": {
          "$ref": "#/$defs/UserCredential",
          "description": "Required. A http access token with the `REPO_ADMIN` scope access."
        },
        "readAuthorizerCredential": {
          "$ref": "#/$defs/UserCredential",
          "description": "Required. A http access token with the `REPO_READ` access."
        }
      },
      "description": "Configuration for connections to Bitbucket Data Center."
    },
    "GitHubConfig": {
      "properties": {
        "authorizerCredential": {
          "$ref": "#/$defs/OAuthCredential",
          "description": "Optional. OAuth credential of the account that authorized the Cloud Build GitHub App. It is recommended to use a robot account instead of a human user account. The OAuth token must be tied to the Cloud Build GitHub App."
        },
        "appInstallationId": {
          "format": "int64",
          "type": "string",
          "description": "Optional. GitHub App installation id."
        }
      },
      "type": "object",
      "description": "Configuration for connections to github.com."
    },
    "GoogleDevtoolsCloudbuildV2GitHubEnterpriseConfig": {
      "type": "object",
      "description": "Configuration for connections to an instance of GitHub Enterprise.",
      "properties": {
        "hostUri": {
          "description": "Required. The URI of the GitHub Enterprise host this connection is for.",
          "type": "string"
        },
        "webhookSecretSecretVersion": {
          "description": "Optional. SecretManager resource containing the webhook secret of the GitHub App, formatted as `projects/*/secrets/*/versions/*`.",
          "type": "string"
        },
        "apiKey": {
          "description": "Required. API Key used for authentication of webhook events.",
          "type": "string"
        },
        "appSlug": {
          "description": "Optional. The URL-friendly name of the GitHub App.",
          "type": "string"
        },
        "sslCa": {
          "description": "Optional. SSL certificate to use for requests to GitHub Enterprise.",
          "type": "string"
        },
        "privateKeySecretVersion": {
          "type": "string",
          "description": "Optional. SecretManager resource containing the private key of the GitHub App, formatted as `projects/*/secrets/*/versions/*`."
        },
        "serviceDirectoryConfig": {
          "$ref": "#/$defs/GoogleDevtoolsCloudbuildV2ServiceDirectoryConfig",
          "description": "Optional. Configuration for using Service Directory to privately connect to a GitHub Enterprise server. This should only be set if the GitHub Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitHub Enterprise server will be made over the public internet."
        },
        "appInstallationId": {
          "description": "Optional. ID of the installation of the GitHub App.",
          "type": "string",
          "format": "int64"
        },
        "appId": {
          "format": "int64",
          "type": "string",
          "description": "Optional. Id of the GitHub App created from the manifest."
        },
        "serverVersion": {
          "type": "string",
          "readOnly": true,
          "description": "Output only. GitHub Enterprise version installed at the host_uri."
        }
      }
    },
    "GoogleDevtoolsCloudbuildV2GitLabConfig": {
      "description": "Configuration for connections to gitlab.com or an instance of GitLab Enterprise.",
      "type": "object",
      "properties": {
        "sslCa": {
          "description": "Optional. SSL certificate to use for requests to GitLab Enterprise.",
          "type": "string"
        },
        "webhookSecretSecretVersion": {
          "type": "string",
          "description": "Required. Immutable. SecretManager resource containing the webhook secret of a GitLab Enterprise project, formatted as `projects/*/secrets/*/versions/*`."
        },
        "authorizerCredential": {
          "$ref": "#/$defs/UserCredential",
          "description": "Required. A GitLab personal access token with the `api` scope access."
        },
        "serverVersion": {
          "description": "Output only. Version of the GitLab Enterprise server running on the `host_uri`.",
          "readOnly": true,
          "type": "string"
        },
        "serviceDirectoryConfig": {
          "$ref": "#/$defs/GoogleDevtoolsCloudbuildV2ServiceDirectoryConfig",
          "description": "Optional. Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet."
        },
        "readAuthorizerCredential": {
          "$ref": "#/$defs/UserCredential",
          "description": "Required. A GitLab personal access token with the minimum `read_api` scope access."
        },
        "hostUri": {
          "description": "Optional. The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com.",
          "type": "string"
        }
      }
    },
    "GoogleDevtoolsCloudbuildV2ServiceDirectoryConfig": {
      "description": "ServiceDirectoryConfig represents Service Directory configuration for a connection.",
      "properties": {
        "service": {
          "type": "string",
          "description": "Required. The Service Directory service name. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}."
        }
      },
      "type": "object"
    },
    "InstallationState": {
      "type": "object",
      "description": "Describes stage and necessary actions to be taken by the user to complete the installation. Used for GitHub and GitHub Enterprise based connections.",
      "properties": {
        "message": {
          "readOnly": true,
          "description": "Output only. Message of what the user should do next to continue the installation. Empty string if the installation is already complete.",
          "type": "string"
        },
        "actionUri": {
          "description": "Output only. Link to follow for next action. Empty string if the installation is already complete.",
          "type": "string",
          "readOnly": true
        },
        "stage": {
          "description": "Output only. Current step of the installation process.",
          "readOnly": true,
          "type": "string",
          "enum": [
            "STAGE_UNSPECIFIED",
            "PENDING_CREATE_APP",
            "PENDING_USER_OAUTH",
            "PENDING_INSTALL_APP",
            "COMPLETE"
          ]
        }
      }
    },
    "OAuthCredential": {
      "description": "Represents an OAuth token of the account that authorized the Connection, and associated metadata.",
      "properties": {
        "oauthTokenSecretVersion": {
          "description": "Optional. A SecretManager resource containing the OAuth token that authorizes the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`.",
          "type": "string"
        },
        "username": {
          "description": "Output only. The username associated to this token.",
          "type": "string",
          "readOnly": true
        }
      },
      "type": "object"
    },
    "UserCredential": {
      "type": "object",
      "description": "Represents a personal access token that authorized the Connection, and associated metadata.",
      "properties": {
        "username": {
          "description": "Output only. The username associated to this token.",
          "type": "string",
          "readOnly": true
        },
        "userTokenSecretVersion": {
          "description": "Required. A SecretManager resource containing the user token that authorizes the Cloud Build connection. Format: `projects/*/secrets/*/versions/*`.",
          "type": "string"
        }
      }
    }
  }
}