Skip to content

Commit

Permalink
Automated DCL import.
Browse files Browse the repository at this point in the history
  - 03396622cff58701f899e348430c521c199cfc6c Automatic import from cloud_mmv2_dcl_20220518_1531_RC00 by DCL Team <[email protected]>

GitOrigin-RevId: 03396622cff58701f899e348430c521c199cfc6c
  • Loading branch information
DCL Team authored and copybara-github committed May 18, 2022
1 parent c41cf75 commit 8cbeb84
Show file tree
Hide file tree
Showing 249 changed files with 3,222 additions and 3,403 deletions.
4 changes: 4 additions & 0 deletions dcl/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ func SendRequest(ctx context.Context, c *Config, verb, url string, body *bytes.B
}
}

if body == nil {
// A nil value indicates an empty request body.
body = &bytes.Buffer{}
}
bodyBytes := body.Bytes()
req, err := http.NewRequestWithContext(ctx, verb, u, bytes.NewReader(bodyBytes))
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -191,20 +190,20 @@ func (op *deleteEnvironmentGroupAttachmentOperation) do(ctx context.Context, r *
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetEnvironmentGroupAttachment(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetEnvironmentGroupAttachment(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
27 changes: 13 additions & 14 deletions services/google/apigee/alpha/environment_group_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -271,20 +270,20 @@ func (op *deleteEnvironmentGroupOperation) do(ctx context.Context, r *Environmen
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetEnvironmentGroup(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetEnvironmentGroup(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
27 changes: 13 additions & 14 deletions services/google/apigee/alpha/environment_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -231,20 +230,20 @@ func (op *deleteEnvironmentOperation) do(ctx context.Context, r *Environment, c
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetEnvironment(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetEnvironment(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
27 changes: 13 additions & 14 deletions services/google/apigee/alpha/instance_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -194,20 +193,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetInstance(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetInstance(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
27 changes: 13 additions & 14 deletions services/google/apigee/alpha/organization_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -276,20 +275,20 @@ func (op *deleteOrganizationOperation) do(ctx context.Context, r *Organization,
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetOrganization(ctx, r)
if !dcl.IsNotFoundOrCode(err, 403) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetOrganization(ctx, r)
if dcl.IsNotFoundOrCode(err, 403) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -191,20 +190,20 @@ func (op *deleteEnvironmentGroupAttachmentOperation) do(ctx context.Context, r *
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetEnvironmentGroupAttachment(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetEnvironmentGroupAttachment(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
27 changes: 13 additions & 14 deletions services/google/apigee/beta/environment_group_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -271,20 +270,20 @@ func (op *deleteEnvironmentGroupOperation) do(ctx context.Context, r *Environmen
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetEnvironmentGroup(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetEnvironmentGroup(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
27 changes: 13 additions & 14 deletions services/google/apigee/beta/environment_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -231,20 +230,20 @@ func (op *deleteEnvironmentOperation) do(ctx context.Context, r *Environment, c
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetEnvironment(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetEnvironment(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
27 changes: 13 additions & 14 deletions services/google/apigee/beta/instance_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"io/ioutil"
"strings"
"time"

"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl"
"github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations"
Expand Down Expand Up @@ -194,20 +193,20 @@ func (op *deleteInstanceOperation) do(ctx context.Context, r *Instance, c *Clien
return err
}

// we saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// this is the reason we are adding retry to handle that case.
maxRetry := 10
for i := 1; i <= maxRetry; i++ {
_, err = c.GetInstance(ctx, r)
if !dcl.IsNotFound(err) {
if i == maxRetry {
return dcl.NotDeletedError{ExistingResource: r}
}
time.Sleep(1000 * time.Millisecond)
} else {
break
// We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration.
// This is the reason we are adding retry to handle that case.
retriesRemaining := 10
dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) {
_, err := c.GetInstance(ctx, r)
if dcl.IsNotFound(err) {
return nil, nil
}
}
if retriesRemaining > 0 {
retriesRemaining--
return &dcl.RetryDetails{}, dcl.OperationNotDone{}
}
return nil, dcl.NotDeletedError{ExistingResource: r}
}, c.Config.RetryProvider)
return nil
}

Expand Down
Loading

0 comments on commit 8cbeb84

Please sign in to comment.