Skip to content
Open
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
13 changes: 8 additions & 5 deletions mmv1/api/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ type Resource struct {
// organization variant, however most resources do not need it.
ApiVariantPatterns []string `yaml:"api_variant_patterns,omitempty"`

// ApiResourceField indicates what field on the API resource is managed by a resource.
// This is generally relevant for fine-grained resources. For example,
// google_compute_router_nat manages the `nat` field on the `Router` resource. Can be
// set to "." to indicate explicitly that the resource's fields aren't
// "nested", even if the resource uses NestedQuery. This is useful for resources that
// use "list" instead of "get" as the read endpoint.
ApiResourceField string `yaml:"api_resource_field,omitempty"`

// [Required] A description of the resource that's surfaced in provider
// documentation.
Description string
Expand Down Expand Up @@ -323,11 +331,6 @@ type Resource struct {
// The version name provided by the user through CI
TargetVersionName string `yaml:"-"`

// ApiResourceField indicates what field on the API resource is managed by a resource.
// This is generally relevant for fine-grained resources. For example,
// google_compute_router_nat manages the `nat` field on the `Router` resource.
ApiResourceField string `yaml:"api_resource_field,omitempty"`

ImportPath string `yaml:"-"`
SourceYamlFile string `yaml:"-"`

Expand Down
15 changes: 13 additions & 2 deletions mmv1/api/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,19 @@ func (t Type) Lineage() []string {
// include the field on the API resource that the fine-grained resource manages.
func (t Type) ApiLineage() []string {
if t.ParentMetadata == nil {
if !t.UrlParamOnly && t.ResourceMetadata.ApiResourceField != "" {
return []string{t.ResourceMetadata.ApiResourceField, t.ApiName}
// The special value "." indicates that the resource's shouldn't be considered "nested"
// even if it has NestedQuery set.
if !t.UrlParamOnly && t.ResourceMetadata.ApiResourceField != "." {
if t.ResourceMetadata.ApiResourceField != "" {
return []string{t.ResourceMetadata.ApiResourceField, t.ApiName}
} else if t.ResourceMetadata.NestedQuery != nil {
// Handle `items` as a special case since that's a common container field name for a list endpoint,
// not a fine-grained field name within a resource.
keys := t.ResourceMetadata.NestedQuery.Keys
if len(keys) > 1 || keys[0] != "items" {
return append(t.ResourceMetadata.NestedQuery.Keys, t.ApiName)
}
}
}
return []string{t.ApiName}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
mutex: '{{access_policy_id}}'
import_format:
- '{{access_level}}'
# no unique way to specify

Check warning on line 53 in mmv1/products/accesscontextmanager/AccessLevelCondition.yaml

View workflow job for this annotation

GitHub Actions / lint-yaml

53:2 [comments-indentation] comment not indented like content
exclude_import: true
timeouts:
insert_minutes: 20
Expand Down Expand Up @@ -255,3 +255,4 @@
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
1 change: 1 addition & 0 deletions mmv1/products/accesscontextmanager/EgressPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
1 change: 1 addition & 0 deletions mmv1/products/accesscontextmanager/IngressPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
- name: 'etag'
type: String
output: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
- name: 'etag'
type: String
output: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
- name: 'etag'
type: String
output: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
- name: 'etag'
type: String
output: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
- name: 'etag'
type: String
output: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ properties:
The name of the Access Policy this resource belongs to.
ignore_read: true
output: true
client_side: true
- name: 'etag'
type: String
output: true
Expand Down
8 changes: 8 additions & 0 deletions mmv1/products/bigqueryreservation/Reservation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ examples:
exclude_docs: true
vars:
name: my-reservation
- name: bigquery_reservation_reservation_group
primary_resource_id: reservation
vars:
name: my-reservation
res_group: my-res-group
parameters:
- name: location
type: String
Expand Down Expand Up @@ -248,3 +253,6 @@ properties:
- autoscale
required_with:
- scalingMode
- name: reservationGroup
type: String
description: 'The reservation group that this reservation belongs to. You can set this property when you create or update a reservation. Reservations do not need to belong to a reservation group. Format: projects/{project}/locations/{location}/reservationGroups/{reservation_group} or just {reservation_group}'
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
---
name: 'ReservationAssignment'
api_resource_type_kind: Assignment
api_resource_field: "."
description: |
The BigqueryReservation Assignment resource.
references:
Expand Down
1 change: 0 additions & 1 deletion mmv1/products/compute/RouterNat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
---
name: 'RouterNat'
api_resource_type_kind: Router
api_resource_field: 'nats'
description: |
A NAT service created in a router.

Expand Down
1 change: 1 addition & 0 deletions mmv1/products/datacatalog/Tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

---
name: 'Tag'
api_resource_field: "."
description: |
Tags are used to attach custom metadata to Data Catalog resources. Tags conform to the specifications within their tag template.

Expand Down Expand Up @@ -97,7 +98,7 @@
'force_delete': 'true'
oics_vars_overrides:
'force_delete': 'true'
# omitting doc as it is almost identical to the case of data_catalog_entry_tag_basic

Check warning on line 101 in mmv1/products/datacatalog/Tag.yaml

View workflow job for this annotation

GitHub Actions / lint-yaml

101:2 [comments-indentation] comment not indented like content
exclude_docs: true
parameters:
- name: 'parent'
Expand Down
1 change: 1 addition & 0 deletions mmv1/products/resourcemanager/Lien.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

---
name: 'Lien'
api_resource_field: "."
description:
A Lien represents an encumbrance on the actions that can be performed on a
resource.
Expand Down
1 change: 1 addition & 0 deletions mmv1/products/serviceusage/ConsumerQuotaOverride.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
---
name: ConsumerQuotaOverride
api_resource_type_kind: QuotaOverride
api_resource_field: "."
description: |
A consumer override is applied to the consumer on its own authority to limit its own quota usage.
Consumer overrides cannot be used to grant more quota than would be allowed by admin overrides,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_bigquery_reservation" "{{$.PrimaryResourceId}}" {
name = "{{index $.Vars "name"}}"
location = "us-west2"
slot_capacity = 0
edition = "STANDARD"
ignore_idle_slots = true
concurrency = 0
autoscale {
max_slots = 100
}
reservation_group = "{{index $.Vars "res_group"}}"
}
Loading