Container Analysis API v1beta1 - Package cloud.google.com/go/containeranalysis/apiv1beta1 (v0.14.2) Stay organized with collections Save and categorize content based on your preferences.
Beta
This library is covered by thePre-GA Offerings Terms of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see thelaunch stage descriptions.
Note: To get more information about this package, such as access to older versions, viewthis package on pkg.go.dev.Package containeranalysis is an auto-generated package for theContainer Analysis API.
This API is a prerequisite for leveraging Artifact Analysis scanningcapabilities in both Artifact Registry and with Advanced VulnerabilityInsights (runtime scanning) in GKE. In addition, the Container AnalysisAPI is an implementation of the Grafeas API, which enables storing,querying, and retrieval of critical metadata about all of your softwareartifacts.
NOTE:Thispackageisinbeta.Itisnotstable,andmaybesubjecttochanges.
General documentation
For information that is relevant for all client libraries please referencehttps://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on thispage includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/containeranalysis/apiv1beta1@latestctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed.The methods of Client are safe for concurrent use by multiple goroutines.The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client, mentioned above.
req:=&containeranalysispb.ExportSBOMRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/containeranalysis/apiv1beta1/containeranalysispb#ExportSBOMRequest.}resp,err:=c.ExportSBOM(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp
Use of Context
The ctx passed to NewContainerAnalysisV1Beta1Client is used for authentication requests andfor creating the underlying connection, but is not used for subsequent calls.Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
funcDefaultAuthScopes()[]stringDefaultAuthScopes reports the default set of authentication scopes to use with this package.
ContainerAnalysisV1Beta1CallOptions
typeContainerAnalysisV1Beta1CallOptionsstruct{SetIamPolicy[]gax.CallOptionGetIamPolicy[]gax.CallOptionTestIamPermissions[]gax.CallOptionGeneratePackagesSummary[]gax.CallOptionExportSBOM[]gax.CallOption}ContainerAnalysisV1Beta1CallOptions contains the retry settings for each method of ContainerAnalysisV1Beta1Client.
ContainerAnalysisV1Beta1Client
typeContainerAnalysisV1Beta1Clientstruct{// The call options for this service.CallOptions*ContainerAnalysisV1Beta1CallOptions// contains filtered or unexported fields}ContainerAnalysisV1Beta1Client is a client for interacting with Container Analysis API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Retrieves analysis results of Cloud components such as Docker containerimages. The Container Analysis API is an implementation of theGrafeas (athttps://grafeas.io) API.
Analysis results are stored as a series of occurrences. An Occurrencecontains information about a specific analysis instance on a resource. Anoccurrence refers to a Note. A note contains details describing theanalysis and is generally stored in a separate project, called a Provider.Multiple occurrences can refer to the same note.
For example, an SSL vulnerability could affect multiple images. In this case,there would be one note for the vulnerability and an occurrence for eachimage with the vulnerability referring to that note.
func NewContainerAnalysisV1Beta1Client
funcNewContainerAnalysisV1Beta1Client(ctxcontext.Context,opts...option.ClientOption)(*ContainerAnalysisV1Beta1Client,error)NewContainerAnalysisV1Beta1Client creates a new container analysis v1 beta1 client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Retrieves analysis results of Cloud components such as Docker containerimages. The Container Analysis API is an implementation of theGrafeas (athttps://grafeas.io) API.
Analysis results are stored as a series of occurrences. An Occurrencecontains information about a specific analysis instance on a resource. Anoccurrence refers to a Note. A note contains details describing theanalysis and is generally stored in a separate project, called a Provider.Multiple occurrences can refer to the same note.
For example, an SSL vulnerability could affect multiple images. In this case,there would be one note for the vulnerability and an occurrence for eachimage with the vulnerability referring to that note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewContainerAnalysisV1Beta1RESTClient
funcNewContainerAnalysisV1Beta1RESTClient(ctxcontext.Context,opts...option.ClientOption)(*ContainerAnalysisV1Beta1Client,error)NewContainerAnalysisV1Beta1RESTClient creates a new container analysis v1 beta1 rest client.
Retrieves analysis results of Cloud components such as Docker containerimages. The Container Analysis API is an implementation of theGrafeas (athttps://grafeas.io) API.
Analysis results are stored as a series of occurrences. An Occurrencecontains information about a specific analysis instance on a resource. Anoccurrence refers to a Note. A note contains details describing theanalysis and is generally stored in a separate project, called a Provider.Multiple occurrences can refer to the same note.
For example, an SSL vulnerability could affect multiple images. In this case,there would be one note for the vulnerability and an occurrence for eachimage with the vulnerability referring to that note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1RESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*ContainerAnalysisV1Beta1Client) Close
func(c*ContainerAnalysisV1Beta1Client)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*ContainerAnalysisV1Beta1Client) Connection (deprecated)
func(c*ContainerAnalysisV1Beta1Client)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*ContainerAnalysisV1Beta1Client) ExportSBOM
func(c*ContainerAnalysisV1Beta1Client)ExportSBOM(ctxcontext.Context,req*containeranalysispb.ExportSBOMRequest,opts...gax.CallOption)(*containeranalysispb.ExportSBOMResponse,error)ExportSBOM generates an SBOM and other dependency information for the given resource.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"containeranalysispb"cloud.google.com/go/containeranalysis/apiv1beta1/containeranalysispb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&containeranalysispb.ExportSBOMRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/containeranalysis/apiv1beta1/containeranalysispb#ExportSBOMRequest.}resp,err:=c.ExportSBOM(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ContainerAnalysisV1Beta1Client) GeneratePackagesSummary
func(c*ContainerAnalysisV1Beta1Client)GeneratePackagesSummary(ctxcontext.Context,req*containeranalysispb.GeneratePackagesSummaryRequest,opts...gax.CallOption)(*containeranalysispb.PackagesSummaryResponse,error)GeneratePackagesSummary gets a summary of the packages within a given resource.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"containeranalysispb"cloud.google.com/go/containeranalysis/apiv1beta1/containeranalysispb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&containeranalysispb.GeneratePackagesSummaryRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/containeranalysis/apiv1beta1/containeranalysispb#GeneratePackagesSummaryRequest.}resp,err:=c.GeneratePackagesSummary(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ContainerAnalysisV1Beta1Client) GetIamPolicy
func(c*ContainerAnalysisV1Beta1Client)GetIamPolicy(ctxcontext.Context,req*iampb.GetIamPolicyRequest,opts...gax.CallOption)(*iampb.Policy,error)GetIamPolicy gets the access control policy for a note or an occurrence resource.Requires containeranalysis.notes.setIamPolicy orcontaineranalysis.occurrences.setIamPolicy permission if the resource isa note or occurrence, respectively.
The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] fornotes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] foroccurrences.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"iampb"cloud.google.com/go/iam/apiv1/iampb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.GetIamPolicyRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#GetIamPolicyRequest.}resp,err:=c.GetIamPolicy(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ContainerAnalysisV1Beta1Client) SetIamPolicy
func(c*ContainerAnalysisV1Beta1Client)SetIamPolicy(ctxcontext.Context,req*iampb.SetIamPolicyRequest,opts...gax.CallOption)(*iampb.Policy,error)SetIamPolicy sets the access control policy on the specified note or occurrence.Requires containeranalysis.notes.setIamPolicy orcontaineranalysis.occurrences.setIamPolicy permission if the resource isa note or an occurrence, respectively.
The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] fornotes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] foroccurrences.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"iampb"cloud.google.com/go/iam/apiv1/iampb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.SetIamPolicyRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#SetIamPolicyRequest.}resp,err:=c.SetIamPolicy(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*ContainerAnalysisV1Beta1Client) TestIamPermissions
func(c*ContainerAnalysisV1Beta1Client)TestIamPermissions(ctxcontext.Context,req*iampb.TestIamPermissionsRequest,opts...gax.CallOption)(*iampb.TestIamPermissionsResponse,error)TestIamPermissions returns the permissions that a caller has on the specified note oroccurrence. Requires list permission on the project (for example,containeranalysis.notes.list).
The resource takes the format projects/[PROJECT_ID]/notes/[NOTE_ID] fornotes and projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID] foroccurrences.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"iampb"cloud.google.com/go/iam/apiv1/iampb")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewContainerAnalysisV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&iampb.TestIamPermissionsRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/iam/apiv1/iampb#TestIamPermissionsRequest.}resp,err:=c.TestIamPermissions(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}GrafeasV1Beta1CallOptions
typeGrafeasV1Beta1CallOptionsstruct{GetOccurrence[]gax.CallOptionListOccurrences[]gax.CallOptionDeleteOccurrence[]gax.CallOptionCreateOccurrence[]gax.CallOptionBatchCreateOccurrences[]gax.CallOptionUpdateOccurrence[]gax.CallOptionGetOccurrenceNote[]gax.CallOptionGetNote[]gax.CallOptionListNotes[]gax.CallOptionDeleteNote[]gax.CallOptionCreateNote[]gax.CallOptionBatchCreateNotes[]gax.CallOptionUpdateNote[]gax.CallOptionListNoteOccurrences[]gax.CallOptionGetVulnerabilityOccurrencesSummary[]gax.CallOption}GrafeasV1Beta1CallOptions contains the retry settings for each method of GrafeasV1Beta1Client.
GrafeasV1Beta1Client
typeGrafeasV1Beta1Clientstruct{// The call options for this service.CallOptions*GrafeasV1Beta1CallOptions// contains filtered or unexported fields}GrafeasV1Beta1Client is a client for interacting with Container Analysis API.Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Grafeas (at grafeas.io) API.
Retrieves analysis results of Cloud components such as Docker containerimages.
Analysis results are stored as a series of occurrences. An Occurrencecontains information about a specific analysis instance on a resource. Anoccurrence refers to a Note. A note contains details describing theanalysis and is generally stored in a separate project, called a Provider.Multiple occurrences can refer to the same note.
For example, an SSL vulnerability could affect multiple images. In this case,there would be one note for the vulnerability and an occurrence for eachimage with the vulnerability referring to that note.
func NewGrafeasV1Beta1Client
funcNewGrafeasV1Beta1Client(ctxcontext.Context,opts...option.ClientOption)(*GrafeasV1Beta1Client,error)NewGrafeasV1Beta1Client creates a new grafeas v1 beta1 client based on gRPC.The returned client must be Closed when it is done being used to clean up its underlying connections.
Grafeas (at grafeas.io) API.
Retrieves analysis results of Cloud components such as Docker containerimages.
Analysis results are stored as a series of occurrences. An Occurrencecontains information about a specific analysis instance on a resource. Anoccurrence refers to a Note. A note contains details describing theanalysis and is generally stored in a separate project, called a Provider.Multiple occurrences can refer to the same note.
For example, an SSL vulnerability could affect multiple images. In this case,there would be one note for the vulnerability and an occurrence for eachimage with the vulnerability referring to that note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func NewGrafeasV1Beta1RESTClient
funcNewGrafeasV1Beta1RESTClient(ctxcontext.Context,opts...option.ClientOption)(*GrafeasV1Beta1Client,error)NewGrafeasV1Beta1RESTClient creates a new grafeas v1 beta1 rest client.
Grafeas (at grafeas.io) API.
Retrieves analysis results of Cloud components such as Docker containerimages.
Analysis results are stored as a series of occurrences. An Occurrencecontains information about a specific analysis instance on a resource. Anoccurrence refers to a Note. A note contains details describing theanalysis and is generally stored in a separate project, called a Provider.Multiple occurrences can refer to the same note.
For example, an SSL vulnerability could affect multiple images. In this case,there would be one note for the vulnerability and an occurrence for eachimage with the vulnerability referring to that note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1RESTClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()// TODO: Use client._=c}func (*GrafeasV1Beta1Client) BatchCreateNotes
func(c*GrafeasV1Beta1Client)BatchCreateNotes(ctxcontext.Context,req*grafeaspb.BatchCreateNotesRequest,opts...gax.CallOption)(*grafeaspb.BatchCreateNotesResponse,error)BatchCreateNotes creates new notes in batch.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.BatchCreateNotesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#BatchCreateNotesRequest.}resp,err:=c.BatchCreateNotes(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) BatchCreateOccurrences
func(c*GrafeasV1Beta1Client)BatchCreateOccurrences(ctxcontext.Context,req*grafeaspb.BatchCreateOccurrencesRequest,opts...gax.CallOption)(*grafeaspb.BatchCreateOccurrencesResponse,error)BatchCreateOccurrences creates new occurrences in batch.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.BatchCreateOccurrencesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#BatchCreateOccurrencesRequest.}resp,err:=c.BatchCreateOccurrences(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) Close
func(c*GrafeasV1Beta1Client)Close()errorClose closes the connection to the API service. The user should invoke this whenthe client is no longer required.
func (*GrafeasV1Beta1Client) Connection (deprecated)
func(c*GrafeasV1Beta1Client)Connection()*grpc.ClientConnConnection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not alwaysreturn the same resource.
func (*GrafeasV1Beta1Client) CreateNote
func(c*GrafeasV1Beta1Client)CreateNote(ctxcontext.Context,req*grafeaspb.CreateNoteRequest,opts...gax.CallOption)(*grafeaspb.Note,error)CreateNote creates a new note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.CreateNoteRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#CreateNoteRequest.}resp,err:=c.CreateNote(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) CreateOccurrence
func(c*GrafeasV1Beta1Client)CreateOccurrence(ctxcontext.Context,req*grafeaspb.CreateOccurrenceRequest,opts...gax.CallOption)(*grafeaspb.Occurrence,error)CreateOccurrence creates a new occurrence.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.CreateOccurrenceRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#CreateOccurrenceRequest.}resp,err:=c.CreateOccurrence(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) DeleteNote
func(c*GrafeasV1Beta1Client)DeleteNote(ctxcontext.Context,req*grafeaspb.DeleteNoteRequest,opts...gax.CallOption)errorDeleteNote deletes the specified note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.DeleteNoteRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#DeleteNoteRequest.}err=c.DeleteNote(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*GrafeasV1Beta1Client) DeleteOccurrence
func(c*GrafeasV1Beta1Client)DeleteOccurrence(ctxcontext.Context,req*grafeaspb.DeleteOccurrenceRequest,opts...gax.CallOption)errorDeleteOccurrence deletes the specified occurrence. For example, use this method to delete anoccurrence when the occurrence is no longer applicable for the givenresource.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.DeleteOccurrenceRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#DeleteOccurrenceRequest.}err=c.DeleteOccurrence(ctx,req)iferr!=nil{// TODO: Handle error.}}func (*GrafeasV1Beta1Client) GetNote
func(c*GrafeasV1Beta1Client)GetNote(ctxcontext.Context,req*grafeaspb.GetNoteRequest,opts...gax.CallOption)(*grafeaspb.Note,error)GetNote gets the specified note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.GetNoteRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#GetNoteRequest.}resp,err:=c.GetNote(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) GetOccurrence
func(c*GrafeasV1Beta1Client)GetOccurrence(ctxcontext.Context,req*grafeaspb.GetOccurrenceRequest,opts...gax.CallOption)(*grafeaspb.Occurrence,error)GetOccurrence gets the specified occurrence.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.GetOccurrenceRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#GetOccurrenceRequest.}resp,err:=c.GetOccurrence(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) GetOccurrenceNote
func(c*GrafeasV1Beta1Client)GetOccurrenceNote(ctxcontext.Context,req*grafeaspb.GetOccurrenceNoteRequest,opts...gax.CallOption)(*grafeaspb.Note,error)GetOccurrenceNote gets the note attached to the specified occurrence. Consumer projects canuse this method to get a note that belongs to a provider project.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.GetOccurrenceNoteRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#GetOccurrenceNoteRequest.}resp,err:=c.GetOccurrenceNote(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) GetVulnerabilityOccurrencesSummary
func(c*GrafeasV1Beta1Client)GetVulnerabilityOccurrencesSummary(ctxcontext.Context,req*grafeaspb.GetVulnerabilityOccurrencesSummaryRequest,opts...gax.CallOption)(*grafeaspb.VulnerabilityOccurrencesSummary,error)GetVulnerabilityOccurrencesSummary gets a summary of the number and severity of occurrences.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.GetVulnerabilityOccurrencesSummaryRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#GetVulnerabilityOccurrencesSummaryRequest.}resp,err:=c.GetVulnerabilityOccurrencesSummary(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) ListNoteOccurrences
func(c*GrafeasV1Beta1Client)ListNoteOccurrences(ctxcontext.Context,req*grafeaspb.ListNoteOccurrencesRequest,opts...gax.CallOption)*OccurrenceIteratorListNoteOccurrences lists occurrences referencing the specified note. Provider projects can usethis method to get all occurrences across consumer projects referencing thespecified note.
Examples
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1""google.golang.org/api/iterator"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.ListNoteOccurrencesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#ListNoteOccurrencesRequest.}it:=c.ListNoteOccurrences(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*grafeaspb.ListNoteOccurrencesResponse)}}all
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.ListNoteOccurrencesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#ListNoteOccurrencesRequest.}forresp,err:=rangec.ListNoteOccurrences(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*GrafeasV1Beta1Client) ListNotes
func(c*GrafeasV1Beta1Client)ListNotes(ctxcontext.Context,req*grafeaspb.ListNotesRequest,opts...gax.CallOption)*NoteIteratorListNotes lists notes for the specified project.
Examples
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1""google.golang.org/api/iterator"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.ListNotesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#ListNotesRequest.}it:=c.ListNotes(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*grafeaspb.ListNotesResponse)}}all
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.ListNotesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#ListNotesRequest.}forresp,err:=rangec.ListNotes(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*GrafeasV1Beta1Client) ListOccurrences
func(c*GrafeasV1Beta1Client)ListOccurrences(ctxcontext.Context,req*grafeaspb.ListOccurrencesRequest,opts...gax.CallOption)*OccurrenceIteratorListOccurrences lists occurrences for the specified project.
Examples
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1""google.golang.org/api/iterator"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.ListOccurrencesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#ListOccurrencesRequest.}it:=c.ListOccurrences(ctx,req)for{resp,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp// If you need to access the underlying RPC response,// you can do so by casting the `Response` as below.// Otherwise, remove this line. Only populated after// first call to Next(). Not safe for concurrent access._=it.Response.(*grafeaspb.ListOccurrencesResponse)}}all
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.ListOccurrencesRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#ListOccurrencesRequest.}forresp,err:=rangec.ListOccurrences(ctx,req).All(){iferr!=nil{// TODO: Handle error and break/return/continue. Iteration will stop after any error.}// TODO: Use resp._=resp}}func (*GrafeasV1Beta1Client) UpdateNote
func(c*GrafeasV1Beta1Client)UpdateNote(ctxcontext.Context,req*grafeaspb.UpdateNoteRequest,opts...gax.CallOption)(*grafeaspb.Note,error)UpdateNote updates the specified note.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.UpdateNoteRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#UpdateNoteRequest.}resp,err:=c.UpdateNote(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}func (*GrafeasV1Beta1Client) UpdateOccurrence
func(c*GrafeasV1Beta1Client)UpdateOccurrence(ctxcontext.Context,req*grafeaspb.UpdateOccurrenceRequest,opts...gax.CallOption)(*grafeaspb.Occurrence,error)UpdateOccurrence updates the specified occurrence.
Example
packagemainimport("context"containeranalysis"cloud.google.com/go/containeranalysis/apiv1beta1"grafeaspb"google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas")funcmain(){ctx:=context.Background()// This snippet has been automatically generated and should be regarded as a code template only.// It will require modifications to work:// - It may require correct/in-range values for request initialization.// - It may require specifying regional endpoints when creating the service client as shown in:// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Optionsc,err:=containeranalysis.NewGrafeasV1Beta1Client(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&grafeaspb.UpdateOccurrenceRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/google.golang.org/genproto/googleapis/devtools/containeranalysis/v1beta1/grafeas#UpdateOccurrenceRequest.}resp,err:=c.UpdateOccurrence(ctx,req)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}NoteIterator
typeNoteIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*grafeaspb.Note,nextPageTokenstring,errerror)// contains filtered or unexported fields}NoteIterator manages a stream of *grafeaspb.Note.
func (*NoteIterator) All
func(it*NoteIterator)All()iter.Seq2[*grafeaspb.Note,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*NoteIterator) Next
func(it*NoteIterator)Next()(*grafeaspb.Note,error)Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.
func (*NoteIterator) PageInfo
func(it*NoteIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
OccurrenceIterator
typeOccurrenceIteratorstruct{// Response is the raw response for the current page.// It must be cast to the RPC response type.// Calling Next() or InternalFetch() updates this value.Responseinterface{}// InternalFetch is for use by the Google Cloud Libraries only.// It is not part of the stable interface of this package.//// InternalFetch returns results from a single call to the underlying RPC.// The number of results is no greater than pageSize.// If there are no more results, nextPageToken is empty and err is nil.InternalFetchfunc(pageSizeint,pageTokenstring)(results[]*grafeaspb.Occurrence,nextPageTokenstring,errerror)// contains filtered or unexported fields}OccurrenceIterator manages a stream of *grafeaspb.Occurrence.
func (*OccurrenceIterator) All
func(it*OccurrenceIterator)All()iter.Seq2[*grafeaspb.Occurrence,error]All returns an iterator. If an error is returned by the iterator, theiterator will stop after that iteration.
func (*OccurrenceIterator) Next
func(it*OccurrenceIterator)Next()(*grafeaspb.Occurrence,error)Next returns the next result. Its second return value is iterator.Done if there are no moreresults. Once Next returns Done, all subsequent calls will return Done.
func (*OccurrenceIterator) PageInfo
func(it*OccurrenceIterator)PageInfo()*iterator.PageInfoPageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-30 UTC.