Skip to content

Add API hub product, with resource ApiHubInstance #9080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/12499.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_apihub_api_hub_instance`
```
1 change: 1 addition & 0 deletions google-beta/fwmodels/provider_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type ProviderModel struct {
AlloydbCustomEndpoint types.String `tfsdk:"alloydb_custom_endpoint"`
ApiGatewayCustomEndpoint types.String `tfsdk:"api_gateway_custom_endpoint"`
ApigeeCustomEndpoint types.String `tfsdk:"apigee_custom_endpoint"`
ApihubCustomEndpoint types.String `tfsdk:"apihub_custom_endpoint"`
AppEngineCustomEndpoint types.String `tfsdk:"app_engine_custom_endpoint"`
ApphubCustomEndpoint types.String `tfsdk:"apphub_custom_endpoint"`
ArtifactRegistryCustomEndpoint types.String `tfsdk:"artifact_registry_custom_endpoint"`
Expand Down
6 changes: 6 additions & 0 deletions google-beta/fwprovider/framework_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
transport_tpg.CustomEndpointValidator(),
},
},
"apihub_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
transport_tpg.CustomEndpointValidator(),
},
},
"app_engine_custom_endpoint": &schema.StringAttribute{
Optional: true,
Validators: []validator.String{
Expand Down
6 changes: 6 additions & 0 deletions google-beta/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ func Provider() *schema.Provider {
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"apihub_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
},
"app_engine_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1081,6 +1086,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.AlloydbBasePath = d.Get("alloydb_custom_endpoint").(string)
config.ApiGatewayBasePath = d.Get("api_gateway_custom_endpoint").(string)
config.ApigeeBasePath = d.Get("apigee_custom_endpoint").(string)
config.ApihubBasePath = d.Get("apihub_custom_endpoint").(string)
config.AppEngineBasePath = d.Get("app_engine_custom_endpoint").(string)
config.ApphubBasePath = d.Get("apphub_custom_endpoint").(string)
config.ArtifactRegistryBasePath = d.Get("artifact_registry_custom_endpoint").(string)
Expand Down
6 changes: 4 additions & 2 deletions google-beta/provider/provider_mmv1_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/alloydb"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/apigateway"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/apigee"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/apihub"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/appengine"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/apphub"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/artifactregistry"
Expand Down Expand Up @@ -517,9 +518,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
}

// Resources
// Generated resources: 588
// Generated resources: 589
// Generated IAM resources: 294
// Total generated resources: 882
// Total generated resources: 883
var generatedResources = map[string]*schema.Resource{
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
Expand Down Expand Up @@ -584,6 +585,7 @@ var generatedResources = map[string]*schema.Resource{
"google_apigee_organization": apigee.ResourceApigeeOrganization(),
"google_apigee_sync_authorization": apigee.ResourceApigeeSyncAuthorization(),
"google_apigee_target_server": apigee.ResourceApigeeTargetServer(),
"google_apihub_api_hub_instance": apihub.ResourceApihubApiHubInstance(),
"google_app_engine_application_url_dispatch_rules": appengine.ResourceAppEngineApplicationUrlDispatchRules(),
"google_app_engine_domain_mapping": appengine.ResourceAppEngineDomainMapping(),
"google_app_engine_firewall_rule": appengine.ResourceAppEngineFirewallRule(),
Expand Down
92 changes: 92 additions & 0 deletions google-beta/services/apihub/apihub_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package apihub

import (
"encoding/json"
"errors"
"fmt"
"time"

"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
)

type ApihubOperationWaiter struct {
Config *transport_tpg.Config
UserAgent string
Project string
tpgresource.CommonOperationWaiter
}

func (w *ApihubOperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("%s%s", w.Config.ApihubBasePath, w.CommonOperationWaiter.Op.Name)

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

func createApihubWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ApihubOperationWaiter, error) {
w := &ApihubOperationWaiter{
Config: config,
UserAgent: userAgent,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return nil, err
}
return w, nil
}

// nolint: deadcode,unused
func ApihubOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
w, err := createApihubWaiter(config, op, project, activity, userAgent)
if err != nil {
return err
}
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
return err
}
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
if len(rawResponse) == 0 {
return errors.New("`resource` not set in operation response")
}
return json.Unmarshal(rawResponse, response)
}

func ApihubOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w, err := createApihubWaiter(config, op, project, activity, userAgent)
if err != nil {
// If w is nil, the op was synchronous.
return err
}
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
}
Loading
Loading