-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new Apigee resource /v1/organizations/<apigee_org>/environments…
…/<apigee_env>/addonsConfig (#12616) Co-authored-by: Stephen Lewis (Burrows) <[email protected]>
- Loading branch information
1 parent
c1ae9f3
commit 716d7b6
Showing
5 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright 2024 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
--- | ||
name: 'EnvironmentAddonsConfig' | ||
api_resource_type_kind: AddonsConfig | ||
description: Enable/Disable add-ons for an Apigee environment. | ||
references: | ||
guides: | ||
'Enable Analytics Add-On': 'https://cloud.google.com/apigee/docs/api-platform/reference/manage-analytics-add-on' | ||
api: 'https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments.addonsConfig/setAddonEnablement' | ||
docs: | ||
base_url: '{{env_id}}' | ||
self_link: '{{env_id}}/addonsConfig' | ||
create_url: '{{env_id}}/addonsConfig:setAddonEnablement' | ||
update_url: '{{env_id}}/addonsConfig:setAddonEnablement' | ||
update_verb: 'POST' | ||
exclude_delete: true | ||
timeouts: | ||
insert_minutes: 5 | ||
update_minutes: 5 | ||
async: | ||
actions: ['create', 'update'] | ||
type: 'OpAsync' | ||
operation: | ||
base_url: '{{op_id}}' | ||
import_format: | ||
- '{{env_id}}' | ||
id_format: '{{env_id}}' | ||
custom_code: | ||
custom_import: 'templates/terraform/custom_import/apigee_env_addons.go.tmpl' | ||
decoder: 'templates/terraform/decoders/apigee_env_addons.go.tmpl' | ||
examples: | ||
- name: 'apigee_env_addons_analytics_test' | ||
primary_resource_id: 'apigee_org_addons' | ||
test_env_vars: | ||
org_id: 'ORG_ID' | ||
billing_account: 'BILLING_ACCT' | ||
exclude_docs: true | ||
- name: 'apigee_env_addons_enable_analytics' | ||
exclude_test: true | ||
parameters: | ||
- name: 'envId' | ||
type: String | ||
description: | | ||
The Apigee environment group associated with the Apigee environment, | ||
in the format `organizations/{{org_name}}/environments/{{env_name}}`. | ||
url_param_only: true | ||
required: true | ||
immutable: true | ||
properties: | ||
- name: 'analyticsEnabled' | ||
type: Boolean | ||
description: Flag to enable/disable Analytics. |
14 changes: 14 additions & 0 deletions
14
mmv1/templates/terraform/custom_import/apigee_env_addons.go.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
config := meta.(*transport_tpg.Config) | ||
|
||
// current import_formats cannot import fields with forward slashes in their value | ||
if err := tpgresource.ParseImportId([]string{"(?P<env_id>.+)"}, d, config); err != nil { | ||
return nil, err | ||
} | ||
|
||
id := d.Get("env_id").(string) | ||
nameParts := strings.Split(id, "/") | ||
if len(nameParts) != 4 { | ||
return nil, fmt.Errorf("env is expected to have shape organizations/{{"{{"}}org_id{{"}}"}}/environments/{{"{{"}}env{{"}}"}}, got %s instead", id) | ||
} | ||
d.SetId(id) | ||
return []*schema.ResourceData{d}, nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
res["analyticsEnabled"] = res["analyticsConfig"].(map[string]interface{})["enabled"] | ||
return res, nil |
70 changes: 70 additions & 0 deletions
70
mmv1/templates/terraform/examples/apigee_env_addons_analytics_test.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
resource "google_project" "project" { | ||
project_id = "tf-test-%{random_suffix}" | ||
name = "tf-test-%{random_suffix}" | ||
org_id = "{{index $.TestEnvVars "org_id"}}" | ||
billing_account = "{{index $.TestEnvVars "billing_account"}}" | ||
deletion_policy = "DELETE" | ||
} | ||
|
||
resource "google_project_service" "apigee" { | ||
project = google_project.project.project_id | ||
service = "apigee.googleapis.com" | ||
} | ||
|
||
resource "google_project_service" "compute" { | ||
project = google_project.project.project_id | ||
service = "compute.googleapis.com" | ||
depends_on = [google_project_service.servicenetworking ] | ||
} | ||
|
||
resource "google_project_service" "servicenetworking" { | ||
project = google_project.project.project_id | ||
service = "servicenetworking.googleapis.com" | ||
depends_on = [google_project_service.apigee] | ||
} | ||
|
||
resource "google_compute_network" "apigee_network" { | ||
name = "apigee-network" | ||
project = google_project.project.project_id | ||
depends_on = [google_project_service.compute] | ||
} | ||
|
||
resource "google_compute_global_address" "apigee_range" { | ||
name = "apigee-range" | ||
purpose = "VPC_PEERING" | ||
address_type = "INTERNAL" | ||
prefix_length = 16 | ||
network = google_compute_network.apigee_network.id | ||
project = google_project.project.project_id | ||
} | ||
|
||
resource "google_service_networking_connection" "apigee_vpc_connection" { | ||
network = google_compute_network.apigee_network.id | ||
service = "servicenetworking.googleapis.com" | ||
reserved_peering_ranges = [google_compute_global_address.apigee_range.name] | ||
depends_on = [google_project_service.servicenetworking] | ||
} | ||
|
||
resource "google_apigee_organization" "apigee_org" { | ||
analytics_region = "us-central1" | ||
project_id = google_project.project.project_id | ||
authorized_network = google_compute_network.apigee_network.id | ||
billing_type = "PAYG" | ||
depends_on = [ | ||
google_service_networking_connection.apigee_vpc_connection, | ||
google_project_service.apigee | ||
] | ||
} | ||
|
||
resource "google_apigee_environment" "{{$.PrimaryResourceId}}" { | ||
org_id = google_apigee_organization.apigee_org.id | ||
name = "tf-test%{random_suffix}" | ||
type = "COMPREHENSIVE" | ||
description = "Apigee Environment" | ||
display_name = "environment-1" | ||
} | ||
|
||
resource "google_apigee_environment_addons_config" "{{$.PrimaryResourceId}}" { | ||
env_id = google_apigee_environment.{{$.PrimaryResourceId}}.id | ||
analytics_enabled = true | ||
} |
19 changes: 19 additions & 0 deletions
19
mmv1/templates/terraform/examples/apigee_env_addons_enable_analytics.tf.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
resource "google_apigee_organization" "apigee_org" { | ||
analytics_region = "us-central1" | ||
project_id = google_project.project.project_id | ||
authorized_network = google_compute_network.apigee_network.id | ||
billing_type = "PAYG" | ||
} | ||
|
||
resource "google_apigee_environment" "{{$.PrimaryResourceId}}" { | ||
org_id = google_apigee_organization.apigee_org.id | ||
name = "tf-test%{random_suffix}" | ||
type = "COMPREHENSIVE" | ||
description = "Apigee Environment" | ||
display_name = "environment-1" | ||
} | ||
|
||
resource "google_apigee_environment_addons_config" "{{$.PrimaryResourceId}}" { | ||
env_id = google_apigee_environment.{{$.PrimaryResourceId}}.id | ||
analytics_enabled = true | ||
} |