Package settings is an auto-generated package for the Cloud Security Command Center API.
Cloud Security Command Center Settings API provides functionality to retrieve and update configurations.
NOTE: This package is in beta. It is not stable, and may be subject to changes.
General documentation
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page 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.
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 := settings.NewSecurityCenterSettingsClient(ctx) if err != nil { // TODO: Handle error. } defer c.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.
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 := settings.NewSecurityCenterSettingsClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close() req := &settingspb.BatchCalculateEffectiveSettingsRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#BatchCalculateEffectiveSettingsRequest. } resp, err := c.BatchCalculateEffectiveSettings(ctx, req) if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp
Use of Context
The ctx passed to NewSecurityCenterSettingsClient is used for authentication requests and for 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
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
DetectorIterator
type DetectorIterator struct {
// 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.
Response interface{}
// 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.
InternalFetch func(pageSize int, pageToken string) (results []*settingspb.Detector, nextPageToken string, err error)
// contains filtered or unexported fields
}
DetectorIterator manages a stream of *settingspb.Detector.
func (*DetectorIterator) All
func (it *DetectorIterator) All() iter.Seq2[*settingspb.Detector, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*DetectorIterator) Next
func (it *DetectorIterator) Next() (*settingspb.Detector, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*DetectorIterator) PageInfo
func (it *DetectorIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
SecurityCenterSettingsCallOptions
type SecurityCenterSettingsCallOptions struct {
GetServiceAccount []gax.CallOption
GetSettings []gax.CallOption
UpdateSettings []gax.CallOption
ResetSettings []gax.CallOption
BatchGetSettings []gax.CallOption
CalculateEffectiveSettings []gax.CallOption
BatchCalculateEffectiveSettings []gax.CallOption
GetComponentSettings []gax.CallOption
UpdateComponentSettings []gax.CallOption
ResetComponentSettings []gax.CallOption
CalculateEffectiveComponentSettings []gax.CallOption
ListDetectors []gax.CallOption
ListComponents []gax.CallOption
}
SecurityCenterSettingsCallOptions contains the retry settings for each method of SecurityCenterSettingsClient.
SecurityCenterSettingsClient
type SecurityCenterSettingsClient struct {
// The call options for this service.
CallOptions *SecurityCenterSettingsCallOptions
// contains filtered or unexported fields
}
SecurityCenterSettingsClient is a client for interacting with Cloud Security Command Center API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
API OverviewThe SecurityCenterSettingsService is a sub-api of securitycenter.googleapis.com. The service provides methods to manage Security Center Settings, and Component Settings for GCP organizations, folders, projects, and clusters.
func NewSecurityCenterSettingsClient
func NewSecurityCenterSettingsClient(ctx context.Context, opts ...option.ClientOption) (*SecurityCenterSettingsClient, error)
NewSecurityCenterSettingsClient creates a new security center settings service client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.
API OverviewThe SecurityCenterSettingsService is a sub-api of securitycenter.googleapis.com. The service provides methods to manage Security Center Settings, and Component Settings for GCP organizations, folders, projects, and clusters.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func NewSecurityCenterSettingsRESTClient
func NewSecurityCenterSettingsRESTClient(ctx context.Context, opts ...option.ClientOption) (*SecurityCenterSettingsClient, error)
NewSecurityCenterSettingsRESTClient creates a new security center settings service rest client.
API OverviewThe SecurityCenterSettingsService is a sub-api of securitycenter.googleapis.com. The service provides methods to manage Security Center Settings, and Component Settings for GCP organizations, folders, projects, and clusters.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
)
func main() {
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 := settings.NewSecurityCenterSettingsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*SecurityCenterSettingsClient) BatchCalculateEffectiveSettings
func (c *SecurityCenterSettingsClient) BatchCalculateEffectiveSettings(ctx context.Context, req *settingspb.BatchCalculateEffectiveSettingsRequest, opts ...gax.CallOption) (*settingspb.BatchCalculateEffectiveSettingsResponse, error)
BatchCalculateEffectiveSettings gets a list of effective settings.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.BatchCalculateEffectiveSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#BatchCalculateEffectiveSettingsRequest.
}
resp, err := c.BatchCalculateEffectiveSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) BatchGetSettings
func (c *SecurityCenterSettingsClient) BatchGetSettings(ctx context.Context, req *settingspb.BatchGetSettingsRequest, opts ...gax.CallOption) (*settingspb.BatchGetSettingsResponse, error)
BatchGetSettings gets a list of settings.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.BatchGetSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#BatchGetSettingsRequest.
}
resp, err := c.BatchGetSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) CalculateEffectiveComponentSettings
func (c *SecurityCenterSettingsClient) CalculateEffectiveComponentSettings(ctx context.Context, req *settingspb.CalculateEffectiveComponentSettingsRequest, opts ...gax.CallOption) (*settingspb.ComponentSettings, error)
CalculateEffectiveComponentSettings gets the Effective Component Settings.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.CalculateEffectiveComponentSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#CalculateEffectiveComponentSettingsRequest.
}
resp, err := c.CalculateEffectiveComponentSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) CalculateEffectiveSettings
func (c *SecurityCenterSettingsClient) CalculateEffectiveSettings(ctx context.Context, req *settingspb.CalculateEffectiveSettingsRequest, opts ...gax.CallOption) (*settingspb.Settings, error)
CalculateEffectiveSettings calculateEffectiveSettings looks up all of the Security Center Settings resources in the GCP resource hierarchy, and calculates the effective settings on that resource by applying the following rules:
Settings provided closer to the target resource take precedence over
those further away (e.g. folder will override organization level
settings).
Product defaults can be overridden at org, folder, project, and cluster
levels.
Detectors will be filtered out if they belong to a billing tier the
customer
has not configured.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.CalculateEffectiveSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#CalculateEffectiveSettingsRequest.
}
resp, err := c.CalculateEffectiveSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) Close
func (c *SecurityCenterSettingsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*SecurityCenterSettingsClient) Connection (deprecated)
func (c *SecurityCenterSettingsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*SecurityCenterSettingsClient) GetComponentSettings
func (c *SecurityCenterSettingsClient) GetComponentSettings(ctx context.Context, req *settingspb.GetComponentSettingsRequest, opts ...gax.CallOption) (*settingspb.ComponentSettings, error)
GetComponentSettings gets the Component Settings.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.GetComponentSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#GetComponentSettingsRequest.
}
resp, err := c.GetComponentSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) GetServiceAccount
func (c *SecurityCenterSettingsClient) GetServiceAccount(ctx context.Context, req *settingspb.GetServiceAccountRequest, opts ...gax.CallOption) (*settingspb.ServiceAccount, error)
GetServiceAccount retrieves the organizations service account, if it exists, otherwise it creates the organization service account. This API is idempotent and will only create a service account once. On subsequent calls it will return the previously created service account. SHA, SCC and CTD Infra Automation will use this SA. This SA will not have any permissions when created. The UI will provision this via IAM or the user will using their own internal process. This API only creates SAs on the organization. Folders are not supported and projects will use per-project SAs associated with APIs enabled on a project. This API will be called by the UX onboarding workflow.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.GetServiceAccountRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#GetServiceAccountRequest.
}
resp, err := c.GetServiceAccount(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) GetSettings
func (c *SecurityCenterSettingsClient) GetSettings(ctx context.Context, req *settingspb.GetSettingsRequest, opts ...gax.CallOption) (*settingspb.Settings, error)
GetSettings gets the Settings.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.GetSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#GetSettingsRequest.
}
resp, err := c.GetSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) ListComponents
func (c *SecurityCenterSettingsClient) ListComponents(ctx context.Context, req *settingspb.ListComponentsRequest, opts ...gax.CallOption) *StringIterator
ListComponents retrieves an unordered list of available SCC components.
Examples
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
"google.golang.org/api/iterator"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.ListComponentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#ListComponentsRequest.
}
it := c.ListComponents(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.(*settingspb.ListComponentsResponse)
}
}
all
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.ListComponentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#ListComponentsRequest.
}
for resp, err := range c.ListComponents(ctx, req).All() {
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*SecurityCenterSettingsClient) ListDetectors
func (c *SecurityCenterSettingsClient) ListDetectors(ctx context.Context, req *settingspb.ListDetectorsRequest, opts ...gax.CallOption) *DetectorIterator
ListDetectors retrieves an unordered list of available detectors.
Examples
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
"google.golang.org/api/iterator"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.ListDetectorsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#ListDetectorsRequest.
}
it := c.ListDetectors(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.(*settingspb.ListDetectorsResponse)
}
}
all
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.ListDetectorsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#ListDetectorsRequest.
}
for resp, err := range c.ListDetectors(ctx, req).All() {
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*SecurityCenterSettingsClient) ResetComponentSettings
func (c *SecurityCenterSettingsClient) ResetComponentSettings(ctx context.Context, req *settingspb.ResetComponentSettingsRequest, opts ...gax.CallOption) error
ResetComponentSettings reset the organization, folder or project’s component settings and return the settings to the default. Settings are present at the organization, folder and project levels. Using Reset for a folder or project will remove the override that was set and result in the organization-level settings being used.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.ResetComponentSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#ResetComponentSettingsRequest.
}
err = c.ResetComponentSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*SecurityCenterSettingsClient) ResetSettings
func (c *SecurityCenterSettingsClient) ResetSettings(ctx context.Context, req *settingspb.ResetSettingsRequest, opts ...gax.CallOption) error
ResetSettings reset the organization, folder or project’s settings and return the settings of just that resource to the default.
Settings are present at the organization, folder, project, and cluster levels. Using Reset on a sub-organization level will remove that resource’s override and result in the parent’s settings being used (eg: if Reset on a cluster, project settings will be used).
Using Reset on organization will remove the override that was set and result in default settings being used.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.ResetSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#ResetSettingsRequest.
}
err = c.ResetSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*SecurityCenterSettingsClient) UpdateComponentSettings
func (c *SecurityCenterSettingsClient) UpdateComponentSettings(ctx context.Context, req *settingspb.UpdateComponentSettingsRequest, opts ...gax.CallOption) (*settingspb.ComponentSettings, error)
UpdateComponentSettings updates the Component Settings.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.UpdateComponentSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#UpdateComponentSettingsRequest.
}
resp, err := c.UpdateComponentSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SecurityCenterSettingsClient) UpdateSettings
func (c *SecurityCenterSettingsClient) UpdateSettings(ctx context.Context, req *settingspb.UpdateSettingsRequest, opts ...gax.CallOption) (*settingspb.Settings, error)
UpdateSettings updates the Settings.
Example
package main
import (
"context"
settings "cloud.google.com/go/securitycenter/settings/apiv1beta1"
settingspb "cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb"
)
func main() {
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 := settings.NewSecurityCenterSettingsClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &settingspb.UpdateSettingsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1/settingspb#UpdateSettingsRequest.
}
resp, err := c.UpdateSettings(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
StringIterator
type StringIterator struct {
// 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.
Response interface{}
// 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.
InternalFetch func(pageSize int, pageToken string) (results []string, nextPageToken string, err error)
// contains filtered or unexported fields
}
StringIterator manages a stream of string.
func (*StringIterator) All
func (it *StringIterator) All() iter.Seq2[string, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*StringIterator) Next
func (it *StringIterator) Next() (string, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*StringIterator) PageInfo
func (it *StringIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.