Skip to content

Commit 3ab5c22

Browse files
committed
chore: small fixes
1 parent 3ecbbb2 commit 3ab5c22

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

.idea/magic-module-skaffolder.iml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/magic_module_skaffolder/api_descriptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ def is_resource_ref(self) -> re.Match:
7575

7676
@property
7777
def is_output_only(self) -> bool:
78-
return "[output only]" in self.get("description", "").lower()
78+
description = self.get("description", "").lower()
79+
return description.startswith("output only") or "[output only]" in description
7980

8081
@property
8182
def is_input_only(self) -> bool:

src/magic_module_skaffolder/skaffolder.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
1+
import sys
22
import logging
33
import re
44
from pathlib import Path
@@ -100,6 +100,8 @@ def create_magic_module_field(
100100
name and "timestamp" in name.lower()
101101
):
102102
result["type"] = "Api::Type::Time"
103+
elif name == "etag":
104+
result["type"] = "Api::Type::Fingerprint"
103105
elif type_definition.is_resource_ref:
104106
# see https://googlecloudplatform.github.io/magic-modules/docs/how-to/add-mmv1-resource/#resourceref
105107
resource_reference = type_definition.is_resource_ref.group(1)
@@ -200,7 +202,7 @@ def add_self_link():
200202
def add_update_verb():
201203
patch_method = resource_definition.methods.get("patch")
202204
if patch_method:
203-
result["update_verb"] = "PATCH"
205+
result["update_verb"] = ":PATCH"
204206
if "updateMask" in patch_method.parameters:
205207
result["update_mask"] = True
206208

@@ -220,7 +222,7 @@ def add_create_link():
220222
"_", " "
221223
)
222224
for name, value in method.parameters.items():
223-
if not value.get("required"):
225+
if not value.is_required:
224226
continue
225227

226228
if name == id_name:
@@ -236,7 +238,6 @@ def add_create_link():
236238
query_parameters[name] = "{{name}}"
237239
elif name == "parent":
238240
parameter = self.create_magic_module_field(api, "location", value)
239-
parameter["default"] = "global"
240241
parameter["url_param_only"] = True
241242
parameter["description"] = f"the location of the {readable_name}."
242243
if value.get("location") == "query":
@@ -256,7 +257,7 @@ def add_create_link():
256257
parameters.append(parameter)
257258

258259
if query_parameters:
259-
result["create_link"] = (
260+
result["create_url"] = (
260261
result["base_url"]
261262
+ "/?"
262263
+ "&".join(
@@ -410,4 +411,4 @@ def update(resource_file: str, inplace: bool):
410411
with open(resource_file, "w") as file:
411412
yaml.dump(existing, file)
412413
else:
413-
yaml.dump(existing, os.stdout)
414+
yaml.dump(existing, sys.stdout)

0 commit comments

Comments
 (0)