api

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const CloudBillingBaseURL = "https://cloudbilling.googleapis.com"
View Source
const ComputeBaseURL = "https://compute.googleapis.com"
View Source
const DNSBaseURL = "https://dns.googleapis.com"
View Source
const IAMBaseURL = "https://iam.googleapis.com"
View Source
const LoggingBaseURL = "https://logging.googleapis.com"
View Source
const ResourceManagerBaseURL = "https://cloudresourcemanager.googleapis.com"
View Source
const SQLAdminBaseURL = "https://sqladmin.googleapis.com"
View Source
const StorageBaseURL = "https://storage.googleapis.com"

Variables

This section is empty.

Functions

func DecodeError

func DecodeError(statusCode int, body []byte) error

func IsAuthFailure

func IsAuthFailure(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsRateLimited

func IsRateLimited(err error) bool

func NewHTTPClient

func NewHTTPClient() *http.Client

Types

type APIError

type APIError struct {
	StatusCode int
	Code       int
	Status     string
	Message    string
	Reason     string
	Domain     string
}

func (*APIError) Error

func (e *APIError) Error() string

type AccessConfig

type AccessConfig struct {
	NatIP string `json:"natIP"`
}

type BillingAccount added in v0.3.1

type BillingAccount struct {
	Name                 string `json:"name"`
	DisplayName          string `json:"displayName"`
	Open                 bool   `json:"open"`
	MasterBillingAccount string `json:"masterBillingAccount"`
}

BillingAccount mirrors `google.cloud.billing.v1.BillingAccount`. The validation flow surfaces "open" billing accounts as the closest analogue to the alibaba/tencent "credit balance" — Google does not expose an account balance directly via API, so listing the active billing accounts is the management-plane signal CSPM detectors track.

type Binding added in v0.3.1

type Binding struct {
	Role    string   `json:"role"`
	Members []string `json:"members"`
}

Binding maps a role to one or more members.

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ts *auth.TokenSource, opts ...Option) *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req Request, out any) error

type ComputeOperation added in v0.3.1

type ComputeOperation struct {
	Name          string                 `json:"name"`
	Zone          string                 `json:"zone"`
	Status        string                 `json:"status"`
	OperationType string                 `json:"operationType"`
	TargetLink    string                 `json:"targetLink"`
	Error         *ComputeOperationError `json:"error,omitempty"`
}

ComputeOperation is the LRO surface returned by setMetadata / reset.

type ComputeOperationError added in v0.3.1

type ComputeOperationError struct {
	Errors []ComputeOperationErrorItem `json:"errors"`
}

type ComputeOperationErrorItem added in v0.3.1

type ComputeOperationErrorItem struct {
	Code     string `json:"code"`
	Location string `json:"location"`
	Message  string `json:"message"`
}

type CreateServiceAccountKeyRequest added in v0.3.1

type CreateServiceAccountKeyRequest struct {
	PrivateKeyType string `json:"privateKeyType,omitempty"`
	KeyAlgorithm   string `json:"keyAlgorithm,omitempty"`
}

CreateServiceAccountKeyRequest is the body of POST .../keys. CTK uses the default key type (TYPE_GOOGLE_CREDENTIALS_FILE) by leaving the field empty.

type GCSBucket added in v0.3.1

type GCSBucket struct {
	Kind         string `json:"kind"`
	ID           string `json:"id"`
	Name         string `json:"name"`
	StorageClass string `json:"storageClass"`
	Location     string `json:"location"`
	TimeCreated  string `json:"timeCreated"`
}

type GCSBucketsListResponse added in v0.3.1

type GCSBucketsListResponse struct {
	Items         []GCSBucket `json:"items"`
	NextPageToken string      `json:"nextPageToken"`
}

type GCSObject added in v0.3.1

type GCSObject struct {
	Kind         string `json:"kind"`
	ID           string `json:"id"`
	Name         string `json:"name"`
	Bucket       string `json:"bucket"`
	StorageClass string `json:"storageClass"`
	Size         string `json:"size"`
	Updated      string `json:"updated"`
	TimeCreated  string `json:"timeCreated"`
}

type GCSObjectsListResponse added in v0.3.1

type GCSObjectsListResponse struct {
	Items         []GCSObject `json:"items"`
	Prefixes      []string    `json:"prefixes"`
	NextPageToken string      `json:"nextPageToken"`
}

type GCSPolicy added in v0.3.1

type GCSPolicy struct {
	Version  int             `json:"version"`
	Bindings []GCSPolicyBind `json:"bindings"`
	Etag     string          `json:"etag"`
}

GCSPolicy mirrors the IAM policy returned by the GCS bucket `getIamPolicy` action and accepted by `setIamPolicy`.

type GCSPolicyBind added in v0.3.1

type GCSPolicyBind struct {
	Role    string   `json:"role"`
	Members []string `json:"members"`
}

type GetIamPolicyRequest added in v0.3.1

type GetIamPolicyRequest struct {
	Options *GetPolicyOptions `json:"options,omitempty"`
}

GetIamPolicyRequest is the body of projects:getIamPolicy. The requestedPolicyVersion lets the caller select v3 features (conditions); CTK does not use conditions and asks for v1.

type GetPolicyOptions added in v0.3.1

type GetPolicyOptions struct {
	RequestedPolicyVersion int `json:"requestedPolicyVersion,omitempty"`
}

type IamPolicy added in v0.3.1

type IamPolicy struct {
	Version  int       `json:"version,omitempty"`
	Etag     string    `json:"etag,omitempty"`
	Bindings []Binding `json:"bindings,omitempty"`
}

IamPolicy is the policy document used by both projects:getIamPolicy and projects:setIamPolicy. Etag must be round-tripped to detect concurrent modifications.

type Instance

type Instance struct {
	Hostname          string             `json:"hostname"`
	Name              string             `json:"name"`
	Zone              string             `json:"zone"`
	Status            string             `json:"status"`
	NetworkInterfaces []NetworkInterface `json:"networkInterfaces"`
}

type InstanceMetadata added in v0.3.1

type InstanceMetadata struct {
	Fingerprint string                 `json:"fingerprint"`
	Items       []InstanceMetadataItem `json:"items"`
	Kind        string                 `json:"kind,omitempty"`
}

InstanceMetadata is the wrapper Compute Engine returns; SetMetadata requires the fingerprint to detect concurrent edits.

type InstanceMetadataItem added in v0.3.1

type InstanceMetadataItem struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

InstanceMetadataItem mirrors GCE's instance metadata key/value pair.

type InstanceWithMetadata added in v0.3.1

type InstanceWithMetadata struct {
	Name     string           `json:"name"`
	Zone     string           `json:"zone"`
	Status   string           `json:"status"`
	Metadata InstanceMetadata `json:"metadata"`
}

InstanceWithMetadata is the subset of `compute.instances.get` we need to run the metadata startup-script + reboot path. Compute Engine's full Instance shape is much larger; we only project metadata + the basics.

type ListBillingAccountsResponse added in v0.3.1

type ListBillingAccountsResponse struct {
	BillingAccounts []BillingAccount `json:"billingAccounts"`
	NextPageToken   string           `json:"nextPageToken"`
}

type ListInstancesResponse

type ListInstancesResponse struct {
	Items         []Instance `json:"items"`
	NextPageToken string     `json:"nextPageToken"`
}

type ListLogEntriesRequest added in v0.3.1

type ListLogEntriesRequest struct {
	ResourceNames []string `json:"resourceNames"`
	Filter        string   `json:"filter,omitempty"`
	OrderBy       string   `json:"orderBy,omitempty"`
	PageSize      int      `json:"pageSize,omitempty"`
	PageToken     string   `json:"pageToken,omitempty"`
}

type ListLogEntriesResponse added in v0.3.1

type ListLogEntriesResponse struct {
	Entries       []LogEntry `json:"entries"`
	NextPageToken string     `json:"nextPageToken"`
}

type ListLogsResponse added in v0.3.1

type ListLogsResponse struct {
	LogNames      []string `json:"logNames"`
	NextPageToken string   `json:"nextPageToken"`
}

ListLogsResponse is the typed result of `projects/<p>/logs.list`. Returns just the log names available in the project — one per cloudlist `log` asset entry, which is a closer fit than the heavy `entries.list` payload.

type ListManagedZonesResponse

type ListManagedZonesResponse struct {
	ManagedZones  []ManagedZone `json:"managedZones"`
	NextPageToken string        `json:"nextPageToken"`
}

type ListRRSetsResponse

type ListRRSetsResponse struct {
	RRSets        []RRSet `json:"rrsets"`
	NextPageToken string  `json:"nextPageToken"`
}

type ListServiceAccountKeysResponse added in v0.3.1

type ListServiceAccountKeysResponse struct {
	Keys []ServiceAccountKey `json:"keys"`
}

type ListServiceAccountsResponse

type ListServiceAccountsResponse struct {
	Accounts      []ServiceAccount `json:"accounts"`
	NextPageToken string           `json:"nextPageToken"`
}

type ListZonesResponse

type ListZonesResponse struct {
	Items         []Zone `json:"items"`
	NextPageToken string `json:"nextPageToken"`
}

type LogEntry added in v0.3.1

type LogEntry struct {
	InsertID         string            `json:"insertId"`
	LogName          string            `json:"logName"`
	Timestamp        string            `json:"timestamp"`
	ReceiveTimestamp string            `json:"receiveTimestamp"`
	Severity         string            `json:"severity"`
	Resource         LogEntryResource  `json:"resource"`
	ProtoPayload     LogProtoPayload   `json:"protoPayload"`
	Operation        LogEntryOperation `json:"operation"`
	Labels           map[string]string `json:"labels"`
}

LogEntry maps the subset of a Cloud Logging LogEntry resource that event-check surfaces. Real responses include many more fields (json / proto payloads, severity, labels) we don't need.

type LogEntryOperation added in v0.3.1

type LogEntryOperation struct {
	ID       string `json:"id"`
	Producer string `json:"producer"`
	First    bool   `json:"first"`
	Last     bool   `json:"last"`
}

type LogEntryResource added in v0.3.1

type LogEntryResource struct {
	Type   string            `json:"type"`
	Labels map[string]string `json:"labels"`
}

type LogProtoAuthInfo added in v0.3.1

type LogProtoAuthInfo struct {
	PrincipalEmail string `json:"principalEmail"`
}

type LogProtoAuthorize added in v0.3.1

type LogProtoAuthorize struct {
	Resource   string `json:"resource"`
	Permission string `json:"permission"`
	Granted    bool   `json:"granted"`
}

type LogProtoPayload added in v0.3.1

type LogProtoPayload struct {
	Type              string              `json:"@type"`
	ServiceName       string              `json:"serviceName"`
	MethodName        string              `json:"methodName"`
	ResourceName      string              `json:"resourceName"`
	AuthInfo          LogProtoAuthInfo    `json:"authenticationInfo"`
	RequestMeta       LogProtoRequestMeta `json:"requestMetadata"`
	Status            LogProtoStatus      `json:"status"`
	AuthorizationInfo []LogProtoAuthorize `json:"authorizationInfo"`
}

type LogProtoRequestMeta added in v0.3.1

type LogProtoRequestMeta struct {
	CallerIP                string `json:"callerIp"`
	CallerSuppliedUserAgent string `json:"callerSuppliedUserAgent"`
}

type LogProtoStatus added in v0.3.1

type LogProtoStatus struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type ManagedZone

type ManagedZone struct {
	Name    string `json:"name"`
	DNSName string `json:"dnsName"`
}

type NetworkInterface

type NetworkInterface struct {
	NetworkIP     string         `json:"networkIP"`
	AccessConfigs []AccessConfig `json:"accessConfigs"`
}

type Option

type Option func(*Client)

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

func WithRetryPolicy

func WithRetryPolicy(p RetryPolicy) Option

type Pager

type Pager[T any] struct {
	// contains filtered or unexported fields
}

func NewPager

func NewPager[T any](c *Client, initial Request, itemsField string) *Pager[T]

func (*Pager[T]) All

func (p *Pager[T]) All(ctx context.Context) ([]T, error)

type RRSet

type RRSet struct {
	Name    string   `json:"name"`
	Type    string   `json:"type"`
	RRDatas []string `json:"rrdatas"`
}

type Request

type Request struct {
	Method     string
	BaseURL    string
	Path       string
	Query      url.Values
	Headers    http.Header
	Body       []byte
	Idempotent bool
}

type RetryPolicy

type RetryPolicy = httpclient.RetryPolicy

func DefaultRetryPolicy

func DefaultRetryPolicy() RetryPolicy

type SQLInstance added in v0.3.1

type SQLInstance struct {
	Name            string                 `json:"name"`
	DatabaseVersion string                 `json:"databaseVersion"`
	Region          string                 `json:"region"`
	State           string                 `json:"state"`
	IPAddresses     []SQLInstanceIPAddress `json:"ipAddresses"`
	BackendType     string                 `json:"backendType"`
	InstanceType    string                 `json:"instanceType"`
	GceZone         string                 `json:"gceZone"`
	ConnectionName  string                 `json:"connectionName"`
	Settings        SQLInstanceSettings    `json:"settings"`
}

SQLInstance is the typed Cloud SQL instance shape (instances.list).

type SQLInstanceIPAddress added in v0.3.1

type SQLInstanceIPAddress struct {
	Type      string `json:"type"`
	IPAddress string `json:"ipAddress"`
}

type SQLInstanceSettings added in v0.3.1

type SQLInstanceSettings struct {
	Tier            string `json:"tier"`
	IPConfiguration struct {
		IPv4Enabled    bool   `json:"ipv4Enabled"`
		PrivateNetwork string `json:"privateNetwork,omitempty"`
	} `json:"ipConfiguration"`
}

type SQLInstancesListResponse added in v0.3.1

type SQLInstancesListResponse struct {
	Items         []SQLInstance `json:"items"`
	NextPageToken string        `json:"nextPageToken"`
	Kind          string        `json:"kind,omitempty"`
}

SQLInstancesListResponse is the typed result of `instances.list`.

type SQLOperation added in v0.3.1

type SQLOperation struct {
	Name          string `json:"name"`
	Status        string `json:"status"`
	OperationType string `json:"operationType,omitempty"`
}

type SQLUser added in v0.3.1

type SQLUser struct {
	Name     string `json:"name"`
	Host     string `json:"host,omitempty"`
	Password string `json:"password,omitempty"`
	Project  string `json:"project,omitempty"`
	Instance string `json:"instance,omitempty"`
	Type     string `json:"type,omitempty"`
}

type SQLUsersListResponse added in v0.3.1

type SQLUsersListResponse struct {
	Items []SQLUser `json:"items"`
	Kind  string    `json:"kind,omitempty"`
}

type ServiceAccount

type ServiceAccount struct {
	Name           string `json:"name"`
	ProjectID      string `json:"projectId"`
	UniqueID       string `json:"uniqueId"`
	Email          string `json:"email"`
	DisplayName    string `json:"displayName"`
	OAuth2ClientID string `json:"oauth2ClientId"`
	Disabled       bool   `json:"disabled"`
}

type ServiceAccountKey added in v0.3.1

type ServiceAccountKey struct {
	Name            string `json:"name"`
	KeyAlgorithm    string `json:"keyAlgorithm,omitempty"`
	PrivateKeyType  string `json:"privateKeyType,omitempty"`
	PrivateKeyData  string `json:"privateKeyData,omitempty"`
	ValidAfterTime  string `json:"validAfterTime,omitempty"`
	ValidBeforeTime string `json:"validBeforeTime,omitempty"`
	KeyOrigin       string `json:"keyOrigin,omitempty"`
	KeyType         string `json:"keyType,omitempty"`
	Disabled        bool   `json:"disabled,omitempty"`
}

ServiceAccountKey represents the resource returned by projects.serviceAccounts.keys.{list,create,get}. PrivateKeyData is only populated by `create` and is base64 of the credential JSON.

type SetIamPolicyRequest added in v0.3.1

type SetIamPolicyRequest struct {
	Policy IamPolicy `json:"policy"`
}

SetIamPolicyRequest is the body of projects:setIamPolicy. The Policy embeds the etag returned by the previous Get for optimistic concurrency.

type Zone

type Zone struct {
	Name   string `json:"name"`
	Status string `json:"status"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL