Skip to content
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

Add output to identifiers, check for project as well as projectsId #10081

Merged
merged 3 commits into from
Feb 28, 2024
Merged
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
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
Loading