Skip to content

Commit

Permalink
Merge pull request #14 from GoogleCloudPlatform/main
Browse files Browse the repository at this point in the history
merging latest
  • Loading branch information
niharika-98 authored Aug 29, 2024
2 parents 0ecca06 + b7538e9 commit 0c109e7
Show file tree
Hide file tree
Showing 164 changed files with 3,900 additions and 953 deletions.
6 changes: 6 additions & 0 deletions mmv1/api/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ func (r *Resource) UnmarshalYAML(n *yaml.Node) error {
r.CollectionUrlKey = google.Camelize(google.Plural(r.Name), "lower")
}

if len(r.VirtualFields) > 0 {
for _, f := range r.VirtualFields {
f.ClientSide = true
}
}

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions mmv1/api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ def validate
type: Array,
default: []

@virtual_fields&.each { |field| field.client_side = true }

check :custom_code, type: Provider::Terraform::CustomCode,
default: Provider::Terraform::CustomCode.new
check :sweeper, type: Provider::Terraform::Sweeper, default: Provider::Terraform::Sweeper.new
Expand Down
14 changes: 14 additions & 0 deletions mmv1/api/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type Type struct {
// behavior.
Immutable bool

// Indicates that this field is client-side only (aka virtual.)
ClientSide bool `yaml:"client_side"`

// url_param_only will not send the field in the resource body and will
// not attempt to read the field from the API response.
// NOTE - this doesn't work for nested fields
Expand Down Expand Up @@ -1100,6 +1103,12 @@ func propertyWithImmutable(immutable bool) func(*Type) {
}
}

func propertyWithClientSide(clientSide bool) func(*Type) {
return func(p *Type) {
p.ClientSide = clientSide
}
}

func propertyWithIgnoreWrite(ignoreWrite bool) func(*Type) {
return func(p *Type) {
p.IgnoreWrite = ignoreWrite
Expand Down Expand Up @@ -1347,6 +1356,11 @@ func (t *Type) IsForceNew() bool {
return true
}

// Client-side fields don't inherit immutability
if t.ClientSide {
return t.Immutable
}

parent := t.Parent()
return (!t.Output || t.IsA("KeyValueEffectiveLabels")) &&
(t.Immutable ||
Expand Down
4 changes: 4 additions & 0 deletions mmv1/api/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ module Fields
# behavior.
attr_accessor :immutable

# Indicates that this field is client-side only (aka virtual.)
attr_accessor :client_side

# url_param_only will not send the field in the resource body and will
# not attempt to read the field from the API response.
# NOTE - this doesn't work for nested fields
Expand Down Expand Up @@ -228,6 +231,7 @@ def validate
check :url_param_only, type: :boolean
check :read_query_params, type: ::String
check :immutable, type: :boolean
check :client_side, type: :boolean

raise 'Property cannot be output and required at the same time.' \
if @output && @required
Expand Down
38 changes: 33 additions & 5 deletions mmv1/products/alloydb/Cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,14 @@ custom_code: !ruby/object:Provider::Terraform::CustomCode
pre_update: templates/terraform/pre_update/alloydb_cluster.go.erb
pre_delete: templates/terraform/pre_delete/alloydb_cluster.go.erb
virtual_fields:
- !ruby/object:Api::Type::Enum
- !ruby/object:Api::Type::String
name: 'deletion_policy'
description: |
Policy to determine if the cluster should be deleted forcefully.
Deleting a cluster forcefully, deletes the cluster and all its associated instances within the cluster.
Deleting a Secondary cluster with a secondary instance REQUIRES setting deletion_policy = "FORCE" otherwise an error is returned. This is needed as there is no support to delete just the secondary instance, and the only way to delete secondary instance is to delete the associated secondary cluster forcefully which also deletes the secondary instance.
values:
- :DEFAULT
- :FORCE
default_value: :DEFAULT
Possible values: DEFAULT, FORCE
default_value: DEFAULT
parameters:
- !ruby/object:Api::Type::String
name: 'clusterId'
Expand Down Expand Up @@ -559,3 +557,33 @@ properties:
name: nanos
description: |
Fractions of seconds in nanoseconds. Currently, only the value 0 is supported.
- !ruby/object:Api::Type::Enum
name: 'subscriptionType'
values:
- :TRIAL
- :STANDARD
default_from_api: true
description: |
The subscrition type of cluster.
- !ruby/object:Api::Type::NestedObject
name: 'trialMetadata'
description: |
Contains information and all metadata related to TRIAL clusters.
output: true
properties:
- !ruby/object:Api::Type::String
name: startTime
description: |
Start time of the trial cluster.
- !ruby/object:Api::Type::String
name: endTime
description: |
End time of the trial cluster.
- !ruby/object:Api::Type::String
name: upgradeTime
description: |
Upgrade time of the trial cluster to standard cluster.
- !ruby/object:Api::Type::String
name: graceEndTime
description: |
Grace end time of the trial cluster.
3 changes: 2 additions & 1 deletion mmv1/products/alloydb/go_Cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ virtual_fields:
Policy to determine if the cluster should be deleted forcefully.
Deleting a cluster forcefully, deletes the cluster and all its associated instances within the cluster.
Deleting a Secondary cluster with a secondary instance REQUIRES setting deletion_policy = "FORCE" otherwise an error is returned. This is needed as there is no support to delete just the secondary instance, and the only way to delete secondary instance is to delete the associated secondary cluster forcefully which also deletes the secondary instance.
type: Enum
Possible values: DEFAULT, FORCE
type: String
default_value: "DEFAULT"
parameters:
- name: 'clusterId'
Expand Down
2 changes: 2 additions & 0 deletions mmv1/products/bigquery/DatasetAccess.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ properties:
- view
- dataset
- routine
custom_expand: 'templates/terraform/custom_expand/string_to_lower_case.go.erb'
diff_suppress_func: resourceBigQueryDatasetAccessIamMemberDiffSuppress
- !ruby/object:Api::Type::String
name: 'groupByEmail'
Expand All @@ -138,6 +139,7 @@ properties:
- view
- dataset
- routine
custom_expand: 'templates/terraform/custom_expand/string_to_lower_case.go.erb'
diff_suppress_func: resourceBigQueryDatasetAccessIamMemberDiffSuppress
- !ruby/object:Api::Type::String
name: 'domain'
Expand Down
19 changes: 19 additions & 0 deletions mmv1/products/bigquerydatatransfer/Config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ examples:
vars:
display_name: 'my-query'
dataset_id: 'my_dataset'
- !ruby/object:Provider::Terraform::Examples
name: 'bigquerydatatransfer_config_cmek'
skip_test: true
primary_resource_id: 'query_config_cmek'
vars:
dataset_id: 'example_dataset'
key_name: 'example-key'
keyring_name: 'example-keyring'
- !ruby/object:Provider::Terraform::Examples
skip_test: true
name: 'bigquerydatatransfer_config_salesforce'
primary_resource_id: 'salesforce_config'
vars:
display_name: 'my-salesforce-config'
dataset_id: 'my_dataset'

parameters:
- !ruby/object:Api::Type::String
name: 'location'
Expand Down Expand Up @@ -172,6 +181,16 @@ properties:
reingests data for [today-10, today-1], rather than ingesting data for
just [today-1]. Only valid if the data source supports the feature.
Set the value to 0 to use the default value.
- !ruby/object:Api::Type::NestedObject
name: 'encryptionConfiguration'
description: |
Represents the encryption configuration for a transfer.
properties:
- !ruby/object:Api::Type::String
name: 'kmsKeyName'
required: true
description: |
The name of the KMS key used for encrypting BigQuery data.
- !ruby/object:Api::Type::Boolean
name: 'disabled'
description: |
Expand Down
174 changes: 174 additions & 0 deletions mmv1/products/cloudtasks/Queue.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ examples:
- 'app_engine_routing_override.0.instance'
vars:
name: 'instance-name'
- !ruby/object:Provider::Terraform::Examples
name: 'cloud_tasks_queue_http_target_oidc'
primary_resource_id: 'http_target_oidc'
vars:
name: 'cloud-tasks-queue-http-target-oidc'
- !ruby/object:Provider::Terraform::Examples
name: 'cloud_tasks_queue_http_target_oauth'
primary_resource_id: 'http_target_oauth'
vars:
name: 'cloud-tasks-queue-http-target-oauth'
parameters:
- !ruby/object:Api::Type::String
name: 'location'
Expand Down Expand Up @@ -195,3 +205,167 @@ properties:
Specifies the fraction of operations to write to Stackdriver Logging.
This field may contain any value between 0.0 and 1.0, inclusive. 0.0 is the
default and means that no operations are logged.
- !ruby/object:Api::Type::NestedObject
name: 'httpTarget'
description: Modifies HTTP target for HTTP tasks.
properties:
- !ruby/object:Api::Type::Enum
name: 'httpMethod'
description: |
The HTTP method to use for the request.
When specified, it overrides HttpRequest for the task.
Note that if the value is set to GET the body of the task will be ignored at execution time.
values:
- HTTP_METHOD_UNSPECIFIED
- POST
- GET
- HEAD
- PUT
- DELETE
- PATCH
- OPTIONS
default_from_api: true
- !ruby/object:Api::Type::NestedObject
name: 'uriOverride'
description: |
URI override.
When specified, overrides the execution URI for all the tasks in the queue.
properties:
- !ruby/object:Api::Type::Enum
name: 'scheme'
description: |
Scheme override.
When specified, the task URI scheme is replaced by the provided value (HTTP or HTTPS).
values:
- 'HTTP'
- 'HTTPS'
default_from_api: true
- !ruby/object:Api::Type::String
name: 'host'
description: |
Host override.
When specified, replaces the host part of the task URL.
For example, if the task URL is "https://www.google.com", and host value
is set to "example.net", the overridden URI will be changed to "https://example.net".
Host value cannot be an empty string (INVALID_ARGUMENT).
- !ruby/object:Api::Type::String
name: 'port'
description: |
Port override.
When specified, replaces the port part of the task URI.
For instance, for a URI http://www.google.com/foo and port=123, the overridden URI becomes http://www.google.com:123/foo.
Note that the port value must be a positive integer.
Setting the port to 0 (Zero) clears the URI port.
- !ruby/object:Api::Type::NestedObject
name: 'pathOverride'
description: |
URI path.
When specified, replaces the existing path of the task URL.
Setting the path value to an empty string clears the URI path segment.
properties:
- !ruby/object:Api::Type::String
name: 'path'
description: The URI path (e.g., /users/1234). Default is an empty string.
default_from_api: true
- !ruby/object:Api::Type::NestedObject
name: 'queryOverride'
description: |
URI query.
When specified, replaces the query part of the task URI. Setting the query value to an empty string clears the URI query segment.
properties:
- !ruby/object:Api::Type::String
name: 'queryParams'
description: The query parameters (e.g., qparam1=123&qparam2=456). Default is an empty string.
default_from_api: true
- !ruby/object:Api::Type::Enum
name: 'uriOverrideEnforceMode'
description: |
URI Override Enforce Mode
When specified, determines the Target UriOverride mode. If not specified, it defaults to ALWAYS.
values:
- ALWAYS
- IF_NOT_EXISTS
default_from_api: true
- !ruby/object:Api::Type::Array
name: 'headerOverrides'
description: |
HTTP target headers.
This map contains the header field names and values.
Headers will be set when running the CreateTask and/or BufferTask.
These headers represent a subset of the headers that will be configured for the task's HTTP request.
Some HTTP request headers will be ignored or replaced.
Headers which can have multiple values (according to RFC2616) can be specified using comma-separated values.
The size of the headers must be less than 80KB. Queue-level headers to override headers of all the tasks in the queue.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::NestedObject
name: 'header'
description: |
Header embodying a key and a value.
required: true
properties:
- !ruby/object:Api::Type::String
name: 'key'
required: true
description: The Key of the header.
- !ruby/object:Api::Type::String
name: 'value'
required: true
description: The Value of the header.
- !ruby/object:Api::Type::NestedObject
name: 'oauthToken'
description: |
If specified, an OAuth token is generated and attached as the Authorization header in the HTTP request.
This type of authorization should generally be used only when calling Google APIs hosted on *.googleapis.com.
Note that both the service account email and the scope MUST be specified when using the queue-level authorization override.
conflicts:
- 'oidcToken'
properties:
- !ruby/object:Api::Type::String
name: 'serviceAccountEmail'
description: |
Service account email to be used for generating OAuth token.
The service account must be within the same project as the queue.
The caller must have iam.serviceAccounts.actAs permission for the service account.
required: true
- !ruby/object:Api::Type::String
name: 'scope'
description: |
OAuth scope to be used for generating OAuth access token.
If not specified, "https://www.googleapis.com/auth/cloud-platform" will be used.
default_from_api: true
- !ruby/object:Api::Type::NestedObject
name: 'oidcToken'
description: |
If specified, an OIDC token is generated and attached as an Authorization header in the HTTP request.
This type of authorization can be used for many scenarios, including calling Cloud Run, or endpoints where you intend to validate the token yourself.
Note that both the service account email and the audience MUST be specified when using the queue-level authorization override.
conflicts:
- 'oauthToken'
properties:
- !ruby/object:Api::Type::String
name: 'serviceAccountEmail'
description: |
Service account email to be used for generating OIDC token.
The service account must be within the same project as the queue.
The caller must have iam.serviceAccounts.actAs permission for the service account.
required: true
- !ruby/object:Api::Type::String
name: 'audience'
description: |
Audience to be used when generating OIDC token. If not specified, the URI specified in target will be used.
default_from_api: true
4 changes: 2 additions & 2 deletions mmv1/products/compute/Firewall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ properties:
either an integer or a range. If not specified, this rule
applies to connections through any port.
Example inputs include: ["22"], ["80","443"], and
Example inputs include: [22], [80, 443], and
["12345-12349"].
- !ruby/object:Api::Type::Time
name: 'creationTimestamp'
Expand Down Expand Up @@ -160,7 +160,7 @@ properties:
either an integer or a range. If not specified, this rule
applies to connections through any port.
Example inputs include: ["22"], ["80","443"], and
Example inputs include: [22], [80, 443], and
["12345-12349"].
- !ruby/object:Api::Type::String
name: 'description'
Expand Down
Loading

0 comments on commit 0c109e7

Please sign in to comment.