Skip to content

Commit

Permalink
Add output to identifiers, check for project as well as projectsId (G…
Browse files Browse the repository at this point in the history
…oogleCloudPlatform#10081)

* Add output to identifiers, check for project as well as projectsId

* Correct identifier behavior

* Rubocop
  • Loading branch information
slevenick authored and Charles Leon committed Mar 11, 2024
1 parent f967f83 commit 9fba2e2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mmv1/openapi_generate/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def run
def write_object(name, obj, type, url_param)
field = nil
case name
when 'projectsId'
when 'projectsId', 'project'
# projectsId and project are omitted in MMv1 as they are inferred from
# the presence of {{project}} in the URL
return field
when 'locationsId'
name = 'location'
Expand Down Expand Up @@ -126,6 +128,12 @@ def write_object(name, obj, type, url_param)
field.instance_variable_set(:@output, obj.read_only)
end

# x-google-identifier fields are described by AIP 203 and are represented
# as output only in Terraform.
if obj.instance_variable_get(:@raw_schema)['x-google-identifier']
field.instance_variable_set(:@output, true)
end

if (obj.respond_to?(:write_only) && obj.write_only) \
|| obj.instance_variable_get(:@raw_schema)['x-google-immutable']
field.instance_variable_set(:@immutable, true)
Expand Down Expand Up @@ -155,8 +163,8 @@ def parse_openapi(spec_path, resource_path, resource_name)
parameters = []
path.post.parameters.each do |param|
parameter_object = write_object(param.name, param, param.schema.type, true)
# Ignore standard requestId field
next if param.name == 'requestId'
# Ignore standard requestId and validateOnly params
next if param.name == 'requestId' || param.name == 'validateOnly'
next if parameter_object.nil?

# All parameters are immutable
Expand Down

0 comments on commit 9fba2e2

Please sign in to comment.