blob: b7607d79c66b798f2f319c8e3289f645afad88e4 [file] [log] [blame]
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go_gapic. DO NOT EDIT.
package securitycenter_test
import (
"context"
iampb "cloud.google.com/go/iam/apiv1/iampb"
securitycenter "cloud.google.com/go/securitycenter/apiv1p1beta1"
securitycenterpb "cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb"
"google.golang.org/api/iterator"
)
func ExampleNewClient() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func ExampleNewRESTClient() {
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_Options
c, err := securitycenter.NewRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func ExampleClient_CreateFinding() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.CreateFindingRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#CreateFindingRequest.
}
resp, err := c.CreateFinding(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_CreateNotificationConfig() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.CreateNotificationConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#CreateNotificationConfigRequest.
}
resp, err := c.CreateNotificationConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_CreateSource() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.CreateSourceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#CreateSourceRequest.
}
resp, err := c.CreateSource(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_DeleteNotificationConfig() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.DeleteNotificationConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#DeleteNotificationConfigRequest.
}
err = c.DeleteNotificationConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func ExampleClient_GetIamPolicy() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_GetNotificationConfig() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.GetNotificationConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#GetNotificationConfigRequest.
}
resp, err := c.GetNotificationConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_GetOrganizationSettings() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.GetOrganizationSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#GetOrganizationSettingsRequest.
}
resp, err := c.GetOrganizationSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_GetSource() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.GetSourceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#GetSourceRequest.
}
resp, err := c.GetSource(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_GroupAssets() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.GroupAssetsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#GroupAssetsRequest.
}
it := c.GroupAssets(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*securitycenterpb.GroupAssetsResponse)
}
}
func ExampleClient_GroupFindings() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.GroupFindingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#GroupFindingsRequest.
}
it := c.GroupFindings(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*securitycenterpb.GroupFindingsResponse)
}
}
func ExampleClient_ListAssets() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.ListAssetsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#ListAssetsRequest.
}
it := c.ListAssets(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*securitycenterpb.ListAssetsResponse)
}
}
func ExampleClient_ListFindings() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.ListFindingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#ListFindingsRequest.
}
it := c.ListFindings(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*securitycenterpb.ListFindingsResponse)
}
}
func ExampleClient_ListNotificationConfigs() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.ListNotificationConfigsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#ListNotificationConfigsRequest.
}
it := c.ListNotificationConfigs(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*securitycenterpb.ListNotificationConfigsResponse)
}
}
func ExampleClient_ListSources() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.ListSourcesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#ListSourcesRequest.
}
it := c.ListSources(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != 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.(*securitycenterpb.ListSourcesResponse)
}
}
func ExampleClient_RunAssetDiscovery() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.RunAssetDiscoveryRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#RunAssetDiscoveryRequest.
}
op, err := c.RunAssetDiscovery(ctx, req)
if err != nil {
// TODO: Handle error.
}
resp, err := op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_SetFindingState() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.SetFindingStateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#SetFindingStateRequest.
}
resp, err := c.SetFindingState(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_SetIamPolicy() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_TestIamPermissions() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.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)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_UpdateFinding() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.UpdateFindingRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#UpdateFindingRequest.
}
resp, err := c.UpdateFinding(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_UpdateNotificationConfig() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.UpdateNotificationConfigRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#UpdateNotificationConfigRequest.
}
resp, err := c.UpdateNotificationConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_UpdateOrganizationSettings() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.UpdateOrganizationSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#UpdateOrganizationSettingsRequest.
}
resp, err := c.UpdateOrganizationSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_UpdateSecurityMarks() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.UpdateSecurityMarksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#UpdateSecurityMarksRequest.
}
resp, err := c.UpdateSecurityMarks(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_UpdateSource() {
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_Options
c, err := securitycenter.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &securitycenterpb.UpdateSourceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/apiv1p1beta1/securitycenterpb#UpdateSourceRequest.
}
resp, err := c.UpdateSource(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}