Skip to content

Commit

Permalink
Merge pull request #172 from wstcliyu/master
Browse files Browse the repository at this point in the history
Add method SetSecurityPolicy to RegionBackendServices
  • Loading branch information
google-oss-prow[bot] authored Feb 26, 2024
2 parents 067736f + 82f2ec8 commit 93f2a9a
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 21 deletions.
198 changes: 177 additions & 21 deletions pkg/cloud/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7914,6 +7914,7 @@ type RegionBackendServices interface {
Delete(ctx context.Context, key *meta.Key, options ...Option) error
GetHealth(context.Context, *meta.Key, *computega.ResourceGroupReference, ...Option) (*computega.BackendServiceGroupHealth, error)
Patch(context.Context, *meta.Key, *computega.BackendService, ...Option) error
SetSecurityPolicy(context.Context, *meta.Key, *computega.SecurityPolicyReference, ...Option) error
Update(context.Context, *meta.Key, *computega.BackendService, ...Option) error
}

Expand Down Expand Up @@ -7950,13 +7951,14 @@ type MockRegionBackendServices struct {
// order to add your own logic. Return (true, _, _) to prevent the normal
// execution flow of the mock. Return (false, nil, nil) to continue with
// normal mock behavior/ after the hook function executes.
GetHook func(ctx context.Context, key *meta.Key, m *MockRegionBackendServices, options ...Option) (bool, *computega.BackendService, error)
ListHook func(ctx context.Context, region string, fl *filter.F, m *MockRegionBackendServices, options ...Option) (bool, []*computega.BackendService, error)
InsertHook func(ctx context.Context, key *meta.Key, obj *computega.BackendService, m *MockRegionBackendServices, options ...Option) (bool, error)
DeleteHook func(ctx context.Context, key *meta.Key, m *MockRegionBackendServices, options ...Option) (bool, error)
GetHealthHook func(context.Context, *meta.Key, *computega.ResourceGroupReference, *MockRegionBackendServices, ...Option) (*computega.BackendServiceGroupHealth, error)
PatchHook func(context.Context, *meta.Key, *computega.BackendService, *MockRegionBackendServices, ...Option) error
UpdateHook func(context.Context, *meta.Key, *computega.BackendService, *MockRegionBackendServices, ...Option) error
GetHook func(ctx context.Context, key *meta.Key, m *MockRegionBackendServices, options ...Option) (bool, *computega.BackendService, error)
ListHook func(ctx context.Context, region string, fl *filter.F, m *MockRegionBackendServices, options ...Option) (bool, []*computega.BackendService, error)
InsertHook func(ctx context.Context, key *meta.Key, obj *computega.BackendService, m *MockRegionBackendServices, options ...Option) (bool, error)
DeleteHook func(ctx context.Context, key *meta.Key, m *MockRegionBackendServices, options ...Option) (bool, error)
GetHealthHook func(context.Context, *meta.Key, *computega.ResourceGroupReference, *MockRegionBackendServices, ...Option) (*computega.BackendServiceGroupHealth, error)
PatchHook func(context.Context, *meta.Key, *computega.BackendService, *MockRegionBackendServices, ...Option) error
SetSecurityPolicyHook func(context.Context, *meta.Key, *computega.SecurityPolicyReference, *MockRegionBackendServices, ...Option) error
UpdateHook func(context.Context, *meta.Key, *computega.BackendService, *MockRegionBackendServices, ...Option) error

// X is extra state that can be used as part of the mock. Generated code
// will not use this field.
Expand Down Expand Up @@ -8122,6 +8124,14 @@ func (m *MockRegionBackendServices) Patch(ctx context.Context, key *meta.Key, ar
return nil
}

// SetSecurityPolicy is a mock for the corresponding method.
func (m *MockRegionBackendServices) SetSecurityPolicy(ctx context.Context, key *meta.Key, arg0 *computega.SecurityPolicyReference, options ...Option) error {
if m.SetSecurityPolicyHook != nil {
return m.SetSecurityPolicyHook(ctx, key, arg0, m)
}
return nil
}

// Update is a mock for the corresponding method.
func (m *MockRegionBackendServices) Update(ctx context.Context, key *meta.Key, arg0 *computega.BackendService, options ...Option) error {
if m.UpdateHook != nil {
Expand Down Expand Up @@ -8381,6 +8391,48 @@ func (g *GCERegionBackendServices) Patch(ctx context.Context, key *meta.Key, arg
return err
}

// SetSecurityPolicy is a method on GCERegionBackendServices.
func (g *GCERegionBackendServices) SetSecurityPolicy(ctx context.Context, key *meta.Key, arg0 *computega.SecurityPolicyReference, options ...Option) error {
opts := mergeOptions(options)
klog.V(5).Infof("GCERegionBackendServices.SetSecurityPolicy(%v, %v, %v, ...): called", ctx, key, opts)

if !key.Valid() {
klog.V(2).Infof("GCERegionBackendServices.SetSecurityPolicy(%v, %v, %v, ...): key is invalid (%#v)", ctx, key, opts, key)
return fmt.Errorf("invalid GCE key (%+v)", key)
}
projectID := getProjectID(ctx, g.s.ProjectRouter, opts, "ga", "RegionBackendServices")
ck := &CallContextKey{
ProjectID: projectID,
Operation: "SetSecurityPolicy",
Version: meta.Version("ga"),
Service: "RegionBackendServices",
}
klog.V(5).Infof("GCERegionBackendServices.SetSecurityPolicy(%v, %v, ...): projectID = %v, ck = %+v", ctx, key, projectID, ck)
callObserverStart(ctx, ck)
if err := g.s.RateLimiter.Accept(ctx, ck); err != nil {
klog.V(4).Infof("GCERegionBackendServices.SetSecurityPolicy(%v, %v, ...): RateLimiter error: %v", ctx, key, err)
return err
}
call := g.s.GA.RegionBackendServices.SetSecurityPolicy(projectID, key.Region, key.Name, arg0)
call.Context(ctx)
op, err := call.Do()

if err != nil {
callObserverEnd(ctx, ck, err)
g.s.RateLimiter.Observe(ctx, err, ck)

klog.V(4).Infof("GCERegionBackendServices.SetSecurityPolicy(%v, %v, ...) = %+v", ctx, key, err)
return err
}

err = g.s.WaitForCompletion(ctx, op)
callObserverEnd(ctx, ck, err)
g.s.RateLimiter.Observe(ctx, err, ck) // XXX

klog.V(4).Infof("GCERegionBackendServices.SetSecurityPolicy(%v, %v, ...) = %+v", ctx, key, err)
return err
}

// Update is a method on GCERegionBackendServices.
func (g *GCERegionBackendServices) Update(ctx context.Context, key *meta.Key, arg0 *computega.BackendService, options ...Option) error {
opts := mergeOptions(options)
Expand Down Expand Up @@ -8431,6 +8483,7 @@ type AlphaRegionBackendServices interface {
Delete(ctx context.Context, key *meta.Key, options ...Option) error
GetHealth(context.Context, *meta.Key, *computealpha.ResourceGroupReference, ...Option) (*computealpha.BackendServiceGroupHealth, error)
Patch(context.Context, *meta.Key, *computealpha.BackendService, ...Option) error
SetSecurityPolicy(context.Context, *meta.Key, *computealpha.SecurityPolicyReference, ...Option) error
Update(context.Context, *meta.Key, *computealpha.BackendService, ...Option) error
}

Expand Down Expand Up @@ -8467,13 +8520,14 @@ type MockAlphaRegionBackendServices struct {
// order to add your own logic. Return (true, _, _) to prevent the normal
// execution flow of the mock. Return (false, nil, nil) to continue with
// normal mock behavior/ after the hook function executes.
GetHook func(ctx context.Context, key *meta.Key, m *MockAlphaRegionBackendServices, options ...Option) (bool, *computealpha.BackendService, error)
ListHook func(ctx context.Context, region string, fl *filter.F, m *MockAlphaRegionBackendServices, options ...Option) (bool, []*computealpha.BackendService, error)
InsertHook func(ctx context.Context, key *meta.Key, obj *computealpha.BackendService, m *MockAlphaRegionBackendServices, options ...Option) (bool, error)
DeleteHook func(ctx context.Context, key *meta.Key, m *MockAlphaRegionBackendServices, options ...Option) (bool, error)
GetHealthHook func(context.Context, *meta.Key, *computealpha.ResourceGroupReference, *MockAlphaRegionBackendServices, ...Option) (*computealpha.BackendServiceGroupHealth, error)
PatchHook func(context.Context, *meta.Key, *computealpha.BackendService, *MockAlphaRegionBackendServices, ...Option) error
UpdateHook func(context.Context, *meta.Key, *computealpha.BackendService, *MockAlphaRegionBackendServices, ...Option) error
GetHook func(ctx context.Context, key *meta.Key, m *MockAlphaRegionBackendServices, options ...Option) (bool, *computealpha.BackendService, error)
ListHook func(ctx context.Context, region string, fl *filter.F, m *MockAlphaRegionBackendServices, options ...Option) (bool, []*computealpha.BackendService, error)
InsertHook func(ctx context.Context, key *meta.Key, obj *computealpha.BackendService, m *MockAlphaRegionBackendServices, options ...Option) (bool, error)
DeleteHook func(ctx context.Context, key *meta.Key, m *MockAlphaRegionBackendServices, options ...Option) (bool, error)
GetHealthHook func(context.Context, *meta.Key, *computealpha.ResourceGroupReference, *MockAlphaRegionBackendServices, ...Option) (*computealpha.BackendServiceGroupHealth, error)
PatchHook func(context.Context, *meta.Key, *computealpha.BackendService, *MockAlphaRegionBackendServices, ...Option) error
SetSecurityPolicyHook func(context.Context, *meta.Key, *computealpha.SecurityPolicyReference, *MockAlphaRegionBackendServices, ...Option) error
UpdateHook func(context.Context, *meta.Key, *computealpha.BackendService, *MockAlphaRegionBackendServices, ...Option) error

// X is extra state that can be used as part of the mock. Generated code
// will not use this field.
Expand Down Expand Up @@ -8639,6 +8693,14 @@ func (m *MockAlphaRegionBackendServices) Patch(ctx context.Context, key *meta.Ke
return nil
}

// SetSecurityPolicy is a mock for the corresponding method.
func (m *MockAlphaRegionBackendServices) SetSecurityPolicy(ctx context.Context, key *meta.Key, arg0 *computealpha.SecurityPolicyReference, options ...Option) error {
if m.SetSecurityPolicyHook != nil {
return m.SetSecurityPolicyHook(ctx, key, arg0, m)
}
return nil
}

// Update is a mock for the corresponding method.
func (m *MockAlphaRegionBackendServices) Update(ctx context.Context, key *meta.Key, arg0 *computealpha.BackendService, options ...Option) error {
if m.UpdateHook != nil {
Expand Down Expand Up @@ -8898,6 +8960,48 @@ func (g *GCEAlphaRegionBackendServices) Patch(ctx context.Context, key *meta.Key
return err
}

// SetSecurityPolicy is a method on GCEAlphaRegionBackendServices.
func (g *GCEAlphaRegionBackendServices) SetSecurityPolicy(ctx context.Context, key *meta.Key, arg0 *computealpha.SecurityPolicyReference, options ...Option) error {
opts := mergeOptions(options)
klog.V(5).Infof("GCEAlphaRegionBackendServices.SetSecurityPolicy(%v, %v, %v, ...): called", ctx, key, opts)

if !key.Valid() {
klog.V(2).Infof("GCEAlphaRegionBackendServices.SetSecurityPolicy(%v, %v, %v, ...): key is invalid (%#v)", ctx, key, opts, key)
return fmt.Errorf("invalid GCE key (%+v)", key)
}
projectID := getProjectID(ctx, g.s.ProjectRouter, opts, "alpha", "RegionBackendServices")
ck := &CallContextKey{
ProjectID: projectID,
Operation: "SetSecurityPolicy",
Version: meta.Version("alpha"),
Service: "RegionBackendServices",
}
klog.V(5).Infof("GCEAlphaRegionBackendServices.SetSecurityPolicy(%v, %v, ...): projectID = %v, ck = %+v", ctx, key, projectID, ck)
callObserverStart(ctx, ck)
if err := g.s.RateLimiter.Accept(ctx, ck); err != nil {
klog.V(4).Infof("GCEAlphaRegionBackendServices.SetSecurityPolicy(%v, %v, ...): RateLimiter error: %v", ctx, key, err)
return err
}
call := g.s.Alpha.RegionBackendServices.SetSecurityPolicy(projectID, key.Region, key.Name, arg0)
call.Context(ctx)
op, err := call.Do()

if err != nil {
callObserverEnd(ctx, ck, err)
g.s.RateLimiter.Observe(ctx, err, ck)

klog.V(4).Infof("GCEAlphaRegionBackendServices.SetSecurityPolicy(%v, %v, ...) = %+v", ctx, key, err)
return err
}

err = g.s.WaitForCompletion(ctx, op)
callObserverEnd(ctx, ck, err)
g.s.RateLimiter.Observe(ctx, err, ck) // XXX

klog.V(4).Infof("GCEAlphaRegionBackendServices.SetSecurityPolicy(%v, %v, ...) = %+v", ctx, key, err)
return err
}

// Update is a method on GCEAlphaRegionBackendServices.
func (g *GCEAlphaRegionBackendServices) Update(ctx context.Context, key *meta.Key, arg0 *computealpha.BackendService, options ...Option) error {
opts := mergeOptions(options)
Expand Down Expand Up @@ -8948,6 +9052,7 @@ type BetaRegionBackendServices interface {
Delete(ctx context.Context, key *meta.Key, options ...Option) error
GetHealth(context.Context, *meta.Key, *computebeta.ResourceGroupReference, ...Option) (*computebeta.BackendServiceGroupHealth, error)
Patch(context.Context, *meta.Key, *computebeta.BackendService, ...Option) error
SetSecurityPolicy(context.Context, *meta.Key, *computebeta.SecurityPolicyReference, ...Option) error
Update(context.Context, *meta.Key, *computebeta.BackendService, ...Option) error
}

Expand Down Expand Up @@ -8984,13 +9089,14 @@ type MockBetaRegionBackendServices struct {
// order to add your own logic. Return (true, _, _) to prevent the normal
// execution flow of the mock. Return (false, nil, nil) to continue with
// normal mock behavior/ after the hook function executes.
GetHook func(ctx context.Context, key *meta.Key, m *MockBetaRegionBackendServices, options ...Option) (bool, *computebeta.BackendService, error)
ListHook func(ctx context.Context, region string, fl *filter.F, m *MockBetaRegionBackendServices, options ...Option) (bool, []*computebeta.BackendService, error)
InsertHook func(ctx context.Context, key *meta.Key, obj *computebeta.BackendService, m *MockBetaRegionBackendServices, options ...Option) (bool, error)
DeleteHook func(ctx context.Context, key *meta.Key, m *MockBetaRegionBackendServices, options ...Option) (bool, error)
GetHealthHook func(context.Context, *meta.Key, *computebeta.ResourceGroupReference, *MockBetaRegionBackendServices, ...Option) (*computebeta.BackendServiceGroupHealth, error)
PatchHook func(context.Context, *meta.Key, *computebeta.BackendService, *MockBetaRegionBackendServices, ...Option) error
UpdateHook func(context.Context, *meta.Key, *computebeta.BackendService, *MockBetaRegionBackendServices, ...Option) error
GetHook func(ctx context.Context, key *meta.Key, m *MockBetaRegionBackendServices, options ...Option) (bool, *computebeta.BackendService, error)
ListHook func(ctx context.Context, region string, fl *filter.F, m *MockBetaRegionBackendServices, options ...Option) (bool, []*computebeta.BackendService, error)
InsertHook func(ctx context.Context, key *meta.Key, obj *computebeta.BackendService, m *MockBetaRegionBackendServices, options ...Option) (bool, error)
DeleteHook func(ctx context.Context, key *meta.Key, m *MockBetaRegionBackendServices, options ...Option) (bool, error)
GetHealthHook func(context.Context, *meta.Key, *computebeta.ResourceGroupReference, *MockBetaRegionBackendServices, ...Option) (*computebeta.BackendServiceGroupHealth, error)
PatchHook func(context.Context, *meta.Key, *computebeta.BackendService, *MockBetaRegionBackendServices, ...Option) error
SetSecurityPolicyHook func(context.Context, *meta.Key, *computebeta.SecurityPolicyReference, *MockBetaRegionBackendServices, ...Option) error
UpdateHook func(context.Context, *meta.Key, *computebeta.BackendService, *MockBetaRegionBackendServices, ...Option) error

// X is extra state that can be used as part of the mock. Generated code
// will not use this field.
Expand Down Expand Up @@ -9156,6 +9262,14 @@ func (m *MockBetaRegionBackendServices) Patch(ctx context.Context, key *meta.Key
return nil
}

// SetSecurityPolicy is a mock for the corresponding method.
func (m *MockBetaRegionBackendServices) SetSecurityPolicy(ctx context.Context, key *meta.Key, arg0 *computebeta.SecurityPolicyReference, options ...Option) error {
if m.SetSecurityPolicyHook != nil {
return m.SetSecurityPolicyHook(ctx, key, arg0, m)
}
return nil
}

// Update is a mock for the corresponding method.
func (m *MockBetaRegionBackendServices) Update(ctx context.Context, key *meta.Key, arg0 *computebeta.BackendService, options ...Option) error {
if m.UpdateHook != nil {
Expand Down Expand Up @@ -9415,6 +9529,48 @@ func (g *GCEBetaRegionBackendServices) Patch(ctx context.Context, key *meta.Key,
return err
}

// SetSecurityPolicy is a method on GCEBetaRegionBackendServices.
func (g *GCEBetaRegionBackendServices) SetSecurityPolicy(ctx context.Context, key *meta.Key, arg0 *computebeta.SecurityPolicyReference, options ...Option) error {
opts := mergeOptions(options)
klog.V(5).Infof("GCEBetaRegionBackendServices.SetSecurityPolicy(%v, %v, %v, ...): called", ctx, key, opts)

if !key.Valid() {
klog.V(2).Infof("GCEBetaRegionBackendServices.SetSecurityPolicy(%v, %v, %v, ...): key is invalid (%#v)", ctx, key, opts, key)
return fmt.Errorf("invalid GCE key (%+v)", key)
}
projectID := getProjectID(ctx, g.s.ProjectRouter, opts, "beta", "RegionBackendServices")
ck := &CallContextKey{
ProjectID: projectID,
Operation: "SetSecurityPolicy",
Version: meta.Version("beta"),
Service: "RegionBackendServices",
}
klog.V(5).Infof("GCEBetaRegionBackendServices.SetSecurityPolicy(%v, %v, ...): projectID = %v, ck = %+v", ctx, key, projectID, ck)
callObserverStart(ctx, ck)
if err := g.s.RateLimiter.Accept(ctx, ck); err != nil {
klog.V(4).Infof("GCEBetaRegionBackendServices.SetSecurityPolicy(%v, %v, ...): RateLimiter error: %v", ctx, key, err)
return err
}
call := g.s.Beta.RegionBackendServices.SetSecurityPolicy(projectID, key.Region, key.Name, arg0)
call.Context(ctx)
op, err := call.Do()

if err != nil {
callObserverEnd(ctx, ck, err)
g.s.RateLimiter.Observe(ctx, err, ck)

klog.V(4).Infof("GCEBetaRegionBackendServices.SetSecurityPolicy(%v, %v, ...) = %+v", ctx, key, err)
return err
}

err = g.s.WaitForCompletion(ctx, op)
callObserverEnd(ctx, ck, err)
g.s.RateLimiter.Observe(ctx, err, ck) // XXX

klog.V(4).Infof("GCEBetaRegionBackendServices.SetSecurityPolicy(%v, %v, ...) = %+v", ctx, key, err)
return err
}

// Update is a method on GCEBetaRegionBackendServices.
func (g *GCEBetaRegionBackendServices) Update(ctx context.Context, key *meta.Key, arg0 *computebeta.BackendService, options ...Option) error {
opts := mergeOptions(options)
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloud/meta/compute_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ var ComputeServices = []*ServiceInfo{
"GetHealth",
"Patch",
"Update",
"SetSecurityPolicy",
},
},
{
Expand All @@ -153,6 +154,7 @@ var ComputeServices = []*ServiceInfo{
"GetHealth",
"Patch",
"Update",
"SetSecurityPolicy",
},
},
{
Expand All @@ -166,6 +168,7 @@ var ComputeServices = []*ServiceInfo{
"GetHealth",
"Patch",
"Update",
"SetSecurityPolicy",
},
},
{
Expand Down

0 comments on commit 93f2a9a

Please sign in to comment.