Skip to content

Commit c70ae52

Browse files
Add API hub product, with resource ApiHubInstance (#12499) (#20948)
[upstream:cba2ae39fed4fdf693cbc70ea3e12f91f7a3d060] Signed-off-by: Modular Magician <[email protected]>
1 parent de55c0f commit c70ae52

File tree

13 files changed

+917
-2
lines changed

13 files changed

+917
-2
lines changed

.changelog/12499.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_apihub_api_hub_instance`
3+
```

.teamcity/components/inputs/services_beta.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ var ServicesListBeta = mapOf(
4646
"displayName" to "Apigee",
4747
"path" to "./google-beta/services/apigee"
4848
),
49+
"apihub" to mapOf(
50+
"name" to "apihub",
51+
"displayName" to "Apihub",
52+
"path" to "./google-beta/services/apihub"
53+
),
4954
"apikeys" to mapOf(
5055
"name" to "apikeys",
5156
"displayName" to "Apikeys",

.teamcity/components/inputs/services_ga.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ var ServicesListGa = mapOf(
4646
"displayName" to "Apigee",
4747
"path" to "./google/services/apigee"
4848
),
49+
"apihub" to mapOf(
50+
"name" to "apihub",
51+
"displayName" to "Apihub",
52+
"path" to "./google/services/apihub"
53+
),
4954
"apikeys" to mapOf(
5055
"name" to "apikeys",
5156
"displayName" to "Apikeys",

google/fwmodels/provider_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type ProviderModel struct {
3535
ActiveDirectoryCustomEndpoint types.String `tfsdk:"active_directory_custom_endpoint"`
3636
AlloydbCustomEndpoint types.String `tfsdk:"alloydb_custom_endpoint"`
3737
ApigeeCustomEndpoint types.String `tfsdk:"apigee_custom_endpoint"`
38+
ApihubCustomEndpoint types.String `tfsdk:"apihub_custom_endpoint"`
3839
AppEngineCustomEndpoint types.String `tfsdk:"app_engine_custom_endpoint"`
3940
ApphubCustomEndpoint types.String `tfsdk:"apphub_custom_endpoint"`
4041
ArtifactRegistryCustomEndpoint types.String `tfsdk:"artifact_registry_custom_endpoint"`

google/fwprovider/framework_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
190190
transport_tpg.CustomEndpointValidator(),
191191
},
192192
},
193+
"apihub_custom_endpoint": &schema.StringAttribute{
194+
Optional: true,
195+
Validators: []validator.String{
196+
transport_tpg.CustomEndpointValidator(),
197+
},
198+
},
193199
"app_engine_custom_endpoint": &schema.StringAttribute{
194200
Optional: true,
195201
Validators: []validator.String{

google/provider/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ func Provider() *schema.Provider {
173173
Optional: true,
174174
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
175175
},
176+
"apihub_custom_endpoint": {
177+
Type: schema.TypeString,
178+
Optional: true,
179+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
180+
},
176181
"app_engine_custom_endpoint": {
177182
Type: schema.TypeString,
178183
Optional: true,
@@ -1004,6 +1009,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
10041009
config.ActiveDirectoryBasePath = d.Get("active_directory_custom_endpoint").(string)
10051010
config.AlloydbBasePath = d.Get("alloydb_custom_endpoint").(string)
10061011
config.ApigeeBasePath = d.Get("apigee_custom_endpoint").(string)
1012+
config.ApihubBasePath = d.Get("apihub_custom_endpoint").(string)
10071013
config.AppEngineBasePath = d.Get("app_engine_custom_endpoint").(string)
10081014
config.ApphubBasePath = d.Get("apphub_custom_endpoint").(string)
10091015
config.ArtifactRegistryBasePath = d.Get("artifact_registry_custom_endpoint").(string)

google/provider/provider_mmv1_resources.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/hashicorp/terraform-provider-google/google/services/activedirectory"
1010
"github.com/hashicorp/terraform-provider-google/google/services/alloydb"
1111
"github.com/hashicorp/terraform-provider-google/google/services/apigee"
12+
"github.com/hashicorp/terraform-provider-google/google/services/apihub"
1213
"github.com/hashicorp/terraform-provider-google/google/services/appengine"
1314
"github.com/hashicorp/terraform-provider-google/google/services/apphub"
1415
"github.com/hashicorp/terraform-provider-google/google/services/artifactregistry"
@@ -467,9 +468,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
467468
}
468469

469470
// Resources
470-
// Generated resources: 510
471+
// Generated resources: 511
471472
// Generated IAM resources: 264
472-
// Total generated resources: 774
473+
// Total generated resources: 775
473474
var generatedResources = map[string]*schema.Resource{
474475
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
475476
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -521,6 +522,7 @@ var generatedResources = map[string]*schema.Resource{
521522
"google_apigee_organization": apigee.ResourceApigeeOrganization(),
522523
"google_apigee_sync_authorization": apigee.ResourceApigeeSyncAuthorization(),
523524
"google_apigee_target_server": apigee.ResourceApigeeTargetServer(),
525+
"google_apihub_api_hub_instance": apihub.ResourceApihubApiHubInstance(),
524526
"google_app_engine_application_url_dispatch_rules": appengine.ResourceAppEngineApplicationUrlDispatchRules(),
525527
"google_app_engine_domain_mapping": appengine.ResourceAppEngineDomainMapping(),
526528
"google_app_engine_firewall_rule": appengine.ResourceAppEngineFirewallRule(),
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package apihub
19+
20+
import (
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"time"
25+
26+
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
27+
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
28+
)
29+
30+
type ApihubOperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
Project string
34+
tpgresource.CommonOperationWaiter
35+
}
36+
37+
func (w *ApihubOperationWaiter) QueryOp() (interface{}, error) {
38+
if w == nil {
39+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
40+
}
41+
// Returns the proper get.
42+
url := fmt.Sprintf("%s%s", w.Config.ApihubBasePath, w.CommonOperationWaiter.Op.Name)
43+
44+
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
45+
Config: w.Config,
46+
Method: "GET",
47+
Project: w.Project,
48+
RawURL: url,
49+
UserAgent: w.UserAgent,
50+
})
51+
}
52+
53+
func createApihubWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ApihubOperationWaiter, error) {
54+
w := &ApihubOperationWaiter{
55+
Config: config,
56+
UserAgent: userAgent,
57+
Project: project,
58+
}
59+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
60+
return nil, err
61+
}
62+
return w, nil
63+
}
64+
65+
// nolint: deadcode,unused
66+
func ApihubOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
67+
w, err := createApihubWaiter(config, op, project, activity, userAgent)
68+
if err != nil {
69+
return err
70+
}
71+
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
72+
return err
73+
}
74+
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
75+
if len(rawResponse) == 0 {
76+
return errors.New("`resource` not set in operation response")
77+
}
78+
return json.Unmarshal(rawResponse, response)
79+
}
80+
81+
func ApihubOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
82+
if val, ok := op["name"]; !ok || val == "" {
83+
// This was a synchronous call - there is no operation to wait for.
84+
return nil
85+
}
86+
w, err := createApihubWaiter(config, op, project, activity, userAgent)
87+
if err != nil {
88+
// If w is nil, the op was synchronous.
89+
return err
90+
}
91+
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
92+
}

0 commit comments

Comments
 (0)