-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Added new Apigee resource /v1/organizations/<apigee_org>/environments/<apigee_env>/addonsConfig #12616
base: main
Are you sure you want to change the base?
Added new Apigee resource /v1/organizations/<apigee_org>/environments/<apigee_env>/addonsConfig #12616
Changes from all commits
83e825b
2990972
4852161
3a51da1
eeec741
1af8c49
e04d9e5
9cd2f45
2c5817b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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' | ||||||||
'Enable ApiSecurity Add-On': 'https://cloud.google.com/apigee/docs/api-platform/reference/manage-security-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 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would you think about sending a POST request to unset AddonEnablement on delete? This would match the behavior of AddonsConfig.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not possible with this api because Delete operation test sends null object as input to api. AddonsConfig api allows null object as input but this api doesn't allow.
|
||||||||
timeouts: | ||||||||
insert_minutes: 5 | ||||||||
update_minutes: 5 | ||||||||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just want to double-check that this is desired; we usually only lengthen the timeouts, not shorten them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5 minute timeout is ok. This api usually takes < 1 minute. |
||||||||
async: | ||||||||
actions: ['create', 'update'] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (if delete support is added)
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as previous comment on supporting delete |
||||||||
type: 'OpAsync' | ||||||||
operation: | ||||||||
base_url: '{{op_id}}' | ||||||||
import_format: | ||||||||
- '{{env_id}}/addonsConfig' | ||||||||
custom_code: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (if delete support is added) you'll also need a test_check_destroy similar to AddonsConfig
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as previous comment on supporting delete |
||||||||
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 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There needs to be at least one docs example; you could add a doc-only example similar to AddonsConfig: magic-modules/mmv1/products/apigee/AddonsConfig.yaml Lines 45 to 46 in 55ec241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||
- 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. |
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>.+)/addonsConfig"}, d, config); err != nil { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
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 |
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 |
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 | ||
} |
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 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need addonsConfig, since it's not a "real" resource - leaving it off better matches the AddonsConfig resource behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remove '/addonsConfig' from self_link Get resource fails and I get error like "inplace update not happened. expected analytics_enabled True found False"