mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-23 15:49:49 +01:00
Add support for Spanner
This commit is contained in:
@@ -27,7 +27,6 @@ api:
|
||||
# Has a struct field called 'async', which is now reserved
|
||||
- homegraph
|
||||
- gkehub
|
||||
- spanner
|
||||
- firebaserules
|
||||
- servicemanagement
|
||||
# defines its own `Option` type
|
||||
|
||||
@@ -70,7 +70,7 @@ RUST_TYPE_RND_MAP = {
|
||||
f"{CHRONO_PATH}::Duration": lambda: f"chrono::Duration::seconds({randint(0, 9999999)})",
|
||||
CHRONO_DATE: chrono_date,
|
||||
CHRONO_DATETIME: lambda: CHRONO_UTC_NOW,
|
||||
"FieldMask": lambda: f"FieldMask(vec![{choice(WORDS)}])",
|
||||
"FieldMask": lambda: "FieldMask::new::<&str>(&[])",
|
||||
}
|
||||
|
||||
JSON_TO_RUST_DEFAULT = {
|
||||
|
||||
@@ -1059,7 +1059,9 @@ def mb_additional_type_params(m):
|
||||
|
||||
# return type name for a method on the given resource
|
||||
def mb_type(r, m):
|
||||
return "%s%sCall" % (singular(canonical_type_name(r)), dot_sep_to_canonical_type_name(m))
|
||||
resource = singular(canonical_type_name(r))
|
||||
method = dot_sep_to_canonical_type_name(m)
|
||||
return unique(f"{r}: {m}", f"{resource}{method}Call")
|
||||
|
||||
|
||||
# canonicalName = util.canonical_name()
|
||||
@@ -1158,10 +1160,12 @@ def method_name_to_variant(name):
|
||||
# given a rust type-name (no optional, as from to_rust_type), you will get a suitable random default value
|
||||
# as string suitable to be passed as reference (or copy, where applicable)
|
||||
def rnd_arg_val_for_type(tn):
|
||||
try:
|
||||
return str(RUST_TYPE_RND_MAP[tn]())
|
||||
except KeyError:
|
||||
return '&Default::default()'
|
||||
segments = tn.split("::")
|
||||
for index in range(len(segments)):
|
||||
name = "::".join(segments[index:])
|
||||
if name in RUST_TYPE_RND_MAP:
|
||||
return str(RUST_TYPE_RND_MAP[name]())
|
||||
return "&Default::default()"
|
||||
|
||||
|
||||
# Converts a size to the respective integer
|
||||
@@ -1190,5 +1194,21 @@ def string_impl(p):
|
||||
"string": lambda x: x
|
||||
}.get(p.get("format", p["type"]), lambda x: f"{x}.to_string()")
|
||||
|
||||
|
||||
def unique(
|
||||
original: str,
|
||||
desired: str,
|
||||
attempts: int = 0,
|
||||
assigned: dict[str, str] = {},
|
||||
) -> str:
|
||||
if original in assigned:
|
||||
return assigned[original]
|
||||
candidate = desired + ("" if attempts == 0 else str(attempts))
|
||||
if candidate not in assigned.values():
|
||||
assigned[original] = candidate
|
||||
return candidate
|
||||
return unique(original, desired, attempts + 1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise AssertionError('For import only')
|
||||
|
||||
Reference in New Issue
Block a user