Skip to content

Commit

Permalink
Send request options (#7934) (#5653)
Browse files Browse the repository at this point in the history
* Refactor SendRequest

* Refactor calls to SendRequest

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored May 17, 2023
1 parent 0e3aa21 commit a684b8f
Show file tree
Hide file tree
Showing 1,061 changed files with 19,489 additions and 2,522 deletions.
3 changes: 3 additions & 0 deletions .changelog/7934.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
7 changes: 6 additions & 1 deletion google-beta/access_context_manager_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ func (w *AccessContextManagerOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.AccessContextManagerBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", "", url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createAccessContextManagerWaiter(config *transport_tpg.Config, op map[string]interface{}, activity, userAgent string) (*AccessContextManagerOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/active_directory_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *ActiveDirectoryOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.ActiveDirectoryBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createActiveDirectoryWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ActiveDirectoryOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/alloydb_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ func (w *AlloydbOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.AlloydbBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createAlloydbWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*AlloydbOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/api_gateway_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *ApiGatewayOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.ApiGatewayBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createApiGatewayWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ApiGatewayOperationWaiter, error) {
Expand Down
7 changes: 6 additions & 1 deletion google-beta/apigee_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ func (w *ApigeeOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.ApigeeBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", "", url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createApigeeWaiter(config *transport_tpg.Config, op map[string]interface{}, activity, userAgent string) (*ApigeeOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/artifact_registry_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *ArtifactRegistryOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.ArtifactRegistryBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createArtifactRegistryWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ArtifactRegistryOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/beyondcorp_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *BeyondcorpOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.BeyondcorpBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createBeyondcorpWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*BeyondcorpOperationWaiter, error) {
Expand Down
64 changes: 57 additions & 7 deletions google-beta/bootstrap_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,14 @@ func BootstrapSharedTestADDomain(t *testing.T, testId string, networkName string

log.Printf("[DEBUG] Getting shared test active directory domain %q", adDomainName)
getURL := fmt.Sprintf("%s%s", config.ActiveDirectoryBasePath, adDomainName)
_, err := transport_tpg.SendRequestWithTimeout(config, "GET", project, getURL, config.UserAgent, nil, 4*time.Minute)
_, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: project,
RawURL: getURL,
UserAgent: config.UserAgent,
Timeout: 4 * time.Minute,
})
if err != nil && transport_tpg.IsGoogleApiErrorWithCode(err, 404) {
log.Printf("[DEBUG] AD domain %q not found, bootstrapping", sharedADDomain)
postURL := fmt.Sprintf("%sprojects/%s/locations/global/domains?domainName=%s", config.ActiveDirectoryBasePath, project, sharedADDomain)
Expand All @@ -242,15 +249,30 @@ func BootstrapSharedTestADDomain(t *testing.T, testId string, networkName string
"authorizedNetworks": []string{fmt.Sprintf("projects/%s/global/networks/%s", project, networkName)},
}

_, err := transport_tpg.SendRequestWithTimeout(config, "POST", project, postURL, config.UserAgent, domainObj, 60*time.Minute)
_, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "POST",
Project: project,
RawURL: postURL,
UserAgent: config.UserAgent,
Body: domainObj,
Timeout: 60 * time.Minute,
})
if err != nil {
t.Fatalf("Error bootstrapping shared active directory domain %q: %s", adDomainName, err)
}

log.Printf("[DEBUG] Waiting for active directory domain creation to finish")
}

_, err = transport_tpg.SendRequestWithTimeout(config, "GET", project, getURL, config.UserAgent, nil, 4*time.Minute)
_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: project,
RawURL: getURL,
UserAgent: config.UserAgent,
Timeout: 4 * time.Minute,
})

if err != nil {
t.Fatalf("Error getting shared active directory domain %q: %s", adDomainName, err)
Expand Down Expand Up @@ -297,7 +319,15 @@ func BootstrapSharedTestNetwork(t *testing.T, testId string) string {
"autoCreateSubnetworks": false,
}

res, err := transport_tpg.SendRequestWithTimeout(config, "POST", project, url, config.UserAgent, netObj, 4*time.Minute)
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "POST",
Project: project,
RawURL: url,
UserAgent: config.UserAgent,
Body: netObj,
Timeout: 4 * time.Minute,
})
if err != nil {
t.Fatalf("Error bootstrapping shared test network %q: %s", networkName, err)
}
Expand Down Expand Up @@ -665,14 +695,28 @@ func BootstrapSharedCaPoolInLocation(t *testing.T, location string) string {

log.Printf("[DEBUG] Getting shared CA pool %q", poolName)
url := fmt.Sprintf("%sprojects/%s/locations/%s/caPools/%s", config.PrivatecaBasePath, project, location, poolName)
_, err := transport_tpg.SendRequest(config, "GET", project, url, config.UserAgent, nil)
_, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: project,
RawURL: url,
UserAgent: config.UserAgent,
})
if err != nil {
log.Printf("[DEBUG] CA pool %q not found, bootstrapping", poolName)
poolObj := map[string]interface{}{
"tier": "ENTERPRISE",
}
createUrl := fmt.Sprintf("%sprojects/%s/locations/%s/caPools?caPoolId=%s", config.PrivatecaBasePath, project, location, poolName)
res, err := transport_tpg.SendRequestWithTimeout(config, "POST", project, createUrl, config.UserAgent, poolObj, 4*time.Minute)
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "POST",
Project: project,
RawURL: createUrl,
UserAgent: config.UserAgent,
Body: poolObj,
Timeout: 4 * time.Minute,
})
if err != nil {
t.Fatalf("Error bootstrapping shared CA pool %q: %s", poolName, err)
}
Expand All @@ -685,7 +729,13 @@ func BootstrapSharedCaPoolInLocation(t *testing.T, location string) string {
if err != nil {
t.Errorf("Error getting shared CA pool %q: %s", poolName, err)
}
_, err = transport_tpg.SendRequest(config, "GET", project, url, config.UserAgent, nil)
_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: project,
RawURL: url,
UserAgent: config.UserAgent,
})
if err != nil {
t.Errorf("Error getting shared CA pool %q: %s", poolName, err)
}
Expand Down
8 changes: 7 additions & 1 deletion google-beta/certificate_manager_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ func (w *CertificateManagerOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.CertificateManagerBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createCertificateManagerWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*CertificateManagerOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/cloud_build_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *CloudBuildOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.CloudBuildBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createCloudBuildWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*CloudBuildOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/cloud_ids_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *CloudIdsOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.CloudIdsBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createCloudIdsWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*CloudIdsOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/cloud_run_v2_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *CloudRunV2OperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.CloudRunV2BasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createCloudRunV2Waiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*CloudRunV2OperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/cloudfunctions2_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *Cloudfunctions2OperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.Cloudfunctions2BasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createCloudfunctions2Waiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*Cloudfunctions2OperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/container_attached_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ func (w *ContainerAttachedOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("https://%s-gkemulticloud.googleapis.com/v1/%s", region, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createContainerAttachedWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ContainerAttachedOperationWaiter, error) {
Expand Down
8 changes: 7 additions & 1 deletion google-beta/data_fusion_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ func (w *DataFusionOperationWaiter) QueryOp() (interface{}, error) {
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.DataFusionBasePath, w.CommonOperationWaiter.Op.Name)

return transport_tpg.SendRequest(w.Config, "GET", w.Project, url, w.UserAgent, nil)
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: w.Config,
Method: "GET",
Project: w.Project,
RawURL: url,
UserAgent: w.UserAgent,
})
}

func createDataFusionWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*DataFusionOperationWaiter, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func dataSourceAccessApprovalFolderServiceAccountRead(d *schema.ResourceData, me
billingProject = bp
}

res, err := transport_tpg.SendRequest(config, "GET", billingProject, url, userAgent, nil)
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: userAgent,
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessApprovalFolderServiceAccount %q", d.Id()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func dataSourceAccessApprovalOrganizationServiceAccountRead(d *schema.ResourceDa
billingProject = bp
}

res, err := transport_tpg.SendRequest(config, "GET", billingProject, url, userAgent, nil)
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: userAgent,
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessApprovalOrganizationServiceAccount %q", d.Id()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func dataSourceAccessApprovalProjectServiceAccountRead(d *schema.ResourceData, m
billingProject = bp
}

res, err := transport_tpg.SendRequest(config, "GET", billingProject, url, userAgent, nil)
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: userAgent,
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessApprovalProjectServiceAccount %q", d.Id()))
}
Expand Down
16 changes: 14 additions & 2 deletions google-beta/data_source_alloydb_locations.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ func dataSourceAlloydbLocationsRead(d *schema.ResourceData, meta interface{}) er
if err != nil {
return fmt.Errorf("Error setting api endpoint")
}
res, err := transport_tpg.SendRequest(config, "GET", billingProject, url, userAgent, nil)
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: userAgent,
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Locations %q", d.Id()))
}
Expand Down Expand Up @@ -128,7 +134,13 @@ func dataSourceAlloydbLocationsRead(d *schema.ResourceData, meta interface{}) er
if err != nil {
return fmt.Errorf("Error setting api endpoint")
}
res, err = transport_tpg.SendRequest(config, "GET", billingProject, url, userAgent, nil)
res, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: userAgent,
})
if err != nil {
return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Locations %q", d.Id()))
}
Expand Down
Loading

0 comments on commit a684b8f

Please sign in to comment.