mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-06 03:22:42 +01:00
fix(CLI): verified download works
* implement custom scopes - previously they could be set, but were ignored during the API call * api-overrides are not yaml files for convenience. Existing ones were updated as needed. Fixes #75
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"no_auth": 1
|
||||
}
|
||||
1
etc/api/discovery/v1/discovery-api_overrides.yaml
Normal file
1
etc/api/discovery/v1/discovery-api_overrides.yaml
Normal file
@@ -0,0 +1 @@
|
||||
no_auth: 1
|
||||
@@ -11,7 +11,7 @@
|
||||
DELEGATE_PROPERTY_NAME, struct_type_bounds_s, scope_url_to_variant,
|
||||
re_find_replacements, ADD_PARAM_FN, ADD_PARAM_MEDIA_EXAMPLE, upload_action_fn, METHODS_RESOURCE,
|
||||
method_name_to_variant, unique_type_name, size_to_bytes, method_default_scope,
|
||||
is_repeated_property, setter_fn_name)
|
||||
is_repeated_property, setter_fn_name, ADD_SCOPE_FN)
|
||||
|
||||
def get_parts(part_prop):
|
||||
if not part_prop:
|
||||
@@ -173,7 +173,7 @@ ${self._setter_fn(resource, method, m, p, part_prop, ThisType, c)}\
|
||||
/// Usually there is more than one suitable scope to authorize an operation, some of which may
|
||||
/// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
|
||||
/// sufficient, a read-write scope will do as well.
|
||||
pub fn add_scope<T>(mut self, scope: T) -> ${ThisType}
|
||||
pub fn ${ADD_SCOPE_FN}<T>(mut self, scope: T) -> ${ThisType}
|
||||
where T: AsRef<str> {
|
||||
self.${api.properties.scopes}.insert(scope.as_ref().to_string(), ());
|
||||
self
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<%namespace name="util" file="../../lib/util.mako"/>\
|
||||
<%!
|
||||
from util import (hub_type, mangle_ident, indent_all_but_first_by, activity_rust_type, setter_fn_name, ADD_PARAM_FN,
|
||||
upload_action_fn, is_schema_with_optionals, schema_markers, indent_by)
|
||||
upload_action_fn, is_schema_with_optionals, schema_markers, indent_by, method_default_scope,
|
||||
ADD_SCOPE_FN)
|
||||
from cli import (mangle_subcommand, new_method_context, PARAM_FLAG, STRUCT_FLAG, UPLOAD_FLAG, OUTPUT_FLAG, VALUE_ARG,
|
||||
CONFIG_DIR, SCOPE_FLAG, is_request_value_property, FIELD_SEP, docopt_mode, FILE_ARG, MIME_ARG, OUT_ARG,
|
||||
cmd_ident, call_method_ident, arg_ident, POD_TYPES, flag_ident, ident, JSON_TYPE_VALUE_MAP,
|
||||
@@ -284,6 +285,12 @@ if dry_run {
|
||||
None
|
||||
} else {
|
||||
assert!(err.issues.len() == 0);
|
||||
% if method_default_scope(mc.m):
|
||||
<% scope_opt = SOPT + flag_ident('scope') %>\
|
||||
if ${scope_opt}.len() > 0 {
|
||||
call = call.${ADD_SCOPE_FN}(&${scope_opt});
|
||||
}
|
||||
% endif
|
||||
## Make the call, handle uploads, handle downloads (also media downloads|json decoding)
|
||||
## TODO: unify error handling
|
||||
% if handle_output:
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
api_meta_dir = os.path.dirname(api_json)
|
||||
api_crate_publish_file = api_meta_dir + '/crates/' + util.crate_version(cargo.build_version +
|
||||
make.aggregated_target_suffix, json.load(open(api_json, 'r')).get('revision', '00000000'))
|
||||
api_json_overrides = api_meta_dir + '/' + an + '-api_overrides.json'
|
||||
api_json_overrides = api_meta_dir + '/' + an + '-api_overrides.yaml'
|
||||
type_specific_json = '$(API_DIR)/type-' + make.id + '.yaml'
|
||||
api_json_inputs = api_json + ' $(API_SHARED_INFO) ' + type_specific_json
|
||||
if os.path.isfile(api_json_overrides):
|
||||
|
||||
@@ -54,6 +54,7 @@ DEL_METHOD = 'delete'
|
||||
METHODS_RESOURCE = 'methods'
|
||||
|
||||
ADD_PARAM_FN = 'param'
|
||||
ADD_SCOPE_FN = 'add_scope'
|
||||
ADD_PARAM_MEDIA_EXAMPLE = "." + ADD_PARAM_FN + '("alt", "media")'
|
||||
|
||||
SPACES_PER_TAB = 4
|
||||
|
||||
Reference in New Issue
Block a user