added my business api

This commit is contained in:
lordie
2020-02-06 19:46:34 -03:00
committed by Sebastian Thiel
parent 80bf4495f7
commit d5519b9dfe
14 changed files with 37842 additions and 222 deletions

View File

@@ -4,406 +4,408 @@
api:
list:
abusiveexperiencereport:
- v1
- v1
acceleratedmobilepageurl:
- v1
- v1
accessapproval:
- v1beta1
- v1beta1
accesscontextmanager:
- v1
- v1beta
- v1
- v1beta
adexchangebuyer:
- v1.3
- v1.4
- v1.3
- v1.4
adexchangebuyer2:
- v2beta1
- v2beta1
adexchangeseller:
- v2.0
- v2.0
adexperiencereport:
- v1
- v1
admin:
- directory_v1
- reports_v1
- directory_v1
- reports_v1
adsense:
- v1.4
- v1.4
adsensehost:
- v4.1
- v4.1
alertcenter:
- v1beta1
- v1beta1
analytics:
- v3
- v3
analyticsreporting:
- v4
- v4
androiddeviceprovisioning:
- v1
- v1
androidenterprise:
- v1
- v1
androidmanagement:
- v1
- v1
androidpublisher:
- v2
- v3
- v2
- v3
appengine:
- v1
- v1beta4
- v1beta5
- v1
- v1beta4
- v1beta5
appsactivity:
- v1
- v1
appstate:
- v1
- v1
audit:
- v1
- v1
autoscaler:
- v1beta2
- v1beta2
bigquery:
- v2
- v2
bigquerydatatransfer:
- v1
- v1
bigtableadmin:
- v2
- v2
binaryauthorization:
- v1beta1
- v1beta1
blogger:
- v3
- v3
books:
- v1
- v1
calendar:
- v3
- v3
chat:
- v1
- v1
civicinfo:
- v2
- v2
classroom:
- v1
- v1
cloudasset:
- v1
- v1beta1
- v1
- v1beta1
cloudbilling:
- v1
- v1
cloudbuild:
- v1
- v1
clouddebugger:
- v2
- v2
clouderrorreporting:
- v1beta1
- v1beta1
cloudfunctions:
- v1
- v1
cloudidentity:
- v1
- v1
cloudiot:
- v1
- v1
cloudkms:
- v1
- v1beta1
- v1
- v1beta1
cloudlatencytest:
- v2
- v2
cloudmonitoring:
- v2beta2
- v2beta2
cloudprivatecatalog:
- v1beta1
- v1beta1
cloudprivatecatalogproducer:
- v1beta1
- v1beta1
cloudprofiler:
- v2
- v2
cloudresourcemanager:
- v1
- v1beta1
- v2
- v1
- v1beta1
- v2
cloudscheduler:
- v1
- v1beta1
- v1
- v1beta1
cloudsearch:
- v1
- v1
cloudshell:
- v1
- v1
cloudtasks:
- v2
- v2beta2
- v2beta3
- v2
- v2beta2
- v2beta3
cloudtrace:
- v1
- v2
- v1
- v2
clouduseraccounts:
- vm_beta
- vm_beta
commentanalyzer:
- v1alpha1
- v1alpha1
composer:
- v1
- v1
compute:
- v1
- v1
consumersurveys:
- v2
- v2
container:
- v1
- v1
containeranalysis:
- v1beta1
- v1beta1
content:
- v2
- v2sandbox
- v2
- v2sandbox
coordinate:
- v1
- v1
customsearch:
- v1
- v1
dataflow:
- v1b4
- v1b4
datafusion:
- v1beta1
- v1beta1
dataproc:
- v1
- v1
datastore:
- v1
- v1beta3
- v1
- v1beta3
deploymentmanager:
- v2
- v2beta2
- v2
- v2beta2
dfareporting:
- v2.8
- v3.0
- v3.2
- v3.3
- v2.8
- v3.0
- v3.2
- v3.3
dialogflow:
- v2
- v2beta1
- v2
- v2beta1
digitalassetlinks:
- v1
- v1
discovery:
- v1
- v1
dlp:
- v2
- v2beta1
- v2
- v2beta1
dns:
- v1
- v1
doubleclickbidmanager:
- v1
- v1
doubleclicksearch:
- v2
- v2
drive:
- v2
- v3
- v2
- v3
driveactivity:
- v2
- v2
factchecktools:
- v1alpha1
- v1alpha1
fcm:
- v1
- v1
file:
- v1
- v1beta1
- v1
- v1beta1
firebase:
- v1beta1
- v1beta1
firebasedynamiclinks:
- v1
- v1
firebasehosting:
- v1beta1
- v1beta1
firebaseremoteconfig:
- v1
- v1
firebaserules:
- v1
- v1
firestore:
- v1
- v1beta1
- v1
- v1beta1
fitness:
- v1
- v1
freebase:
- v1sandbox
- v1sandbox
fusiontables:
- v2
- v2
games:
- v1
- v1
gamesconfiguration:
- v1configuration
- v1configuration
gamesmanagement:
- v1management
- v1management
gan:
- v1beta1
- v1beta1
genomics:
- v1
- v1
gmail:
- v1
- v1
groupsmigration:
- v1
- v1
groupssettings:
- v1
- v1
healthcare:
- v1beta1
- v1beta1
iam:
- v1
- v1
iamcredentials:
- v1
- v1
iap:
- v1
- v1beta1
- v1
- v1beta1
identitytoolkit:
- v3
- v3
indexing:
- v3
- v3
jobs:
- v3
- v3
kgsearch:
- v1
- v1
language:
- v1
- v1beta1
- v1
- v1beta1
libraryagent:
- v1
- v1
licensing:
- v1
- v1
logging:
- v2
- v2beta1
- v2
- v2beta1
manager:
- v1beta2
- v1beta2
manufacturers:
- v1
- v1
mapsengine:
- v1
- v1
mirror:
- v1
- v1
ml:
- v1
- v1
monitoring:
- v3
- v3
mybusiness:
- v4
oauth2:
- v2
- v2
osconfig:
- v1alpha2
- v1alpha2
oslogin:
- v1
- v1beta
- v1
- v1beta
pagespeedonline:
- v2
- v4
- v5
- v2
- v4
- v5
partners:
- v2
- v2
people:
- v1
- v1
photoslibrary:
- v1
- v1
playcustomapp:
- v1
- v1
playmoviespartner:
- v1
- v1
plus:
- v1
- v1
plusdomains:
- v1
- v1
poly:
- v1
- v1
prediction:
- v1.6
- v1.6
proximitybeacon:
- v1beta1
- v1beta1
pubsub:
- v1
- v1beta2
- v1
- v1beta2
qpxexpress:
- v1
- v1
redis:
- v1
- v1
remotebuildexecution:
- v2
- v2
replicapool:
- v1beta2
- v1beta2
replicapoolupdater:
- v1beta1
- v1beta1
reseller:
- v1sandbox
- v1sandbox
resourceviews:
- v1beta2
- v1beta2
run:
- v1
- v1
runtimeconfig:
- v1
- v1beta1
- v1
- v1beta1
safebrowsing:
- v4
- v4
script:
- v1
- v1
searchconsole:
- v1
- v1
securitycenter:
- v1
- v1
servicebroker:
- v1
- v1
serviceconsumermanagement:
- v1
- v1
servicecontrol:
- v1
- v1
servicemanagement:
- v1
- v1
servicenetworking:
- v1
- v1beta
- v1
- v1beta
serviceregistry:
- alpha
- alpha
serviceusage:
- v1
- v1
serviceuser:
- v1
- v1
sheets:
- v4
- v4
siteverification:
- v1
- v1
slides:
- v1
- v1
sourcerepo:
- v1
- v1
spanner:
- v1
- v1
spectrum:
- v1explorer
- v1explorer
speech:
- v1
- v1beta1
- v1
- v1beta1
sqladmin:
- v1beta4
- v1beta4
storage:
- v1
- v1
storagetransfer:
- v1
- v1
streetviewpublish:
- v1
- v1
surveys:
- v2
- v2
tagmanager:
- v1
- v2
- v1
- v2
taskqueue:
- v1beta2
- v1beta2
tasks:
- v1
- v1
testing:
- v1
- v1
texttospeech:
- v1
- v1
toolresults:
- v1beta3
- v1beta3
tpu:
- v1
- v1alpha1
- v1
- v1alpha1
translate:
- v2
- v2
urlshortener:
- v1
- v1
vault:
- v1
- v1
videointelligence:
- v1
- v1beta1
- v1
- v1beta1
vision:
- v1
- v1
webfonts:
- v1
- v1
webmasters:
- v3
- v3
websecurityscanner:
- v1
- v1beta
- v1
- v1beta
youtube:
- v3
- v3
youtubeanalytics:
- v1
- v2
- v1
- v2
youtubereporting:
- v1
- v1

File diff suppressed because it is too large Load Diff

View File

@@ -43,6 +43,9 @@ api:
# returned by google APIs, but can't be fetched
- osconfig
manually_added:
- name: mybusiness
version: v4
discovery_rest_url: https://developers.google.com/my-business/samples/mybusiness_google_rest_v4p5.json
- name: photoslibrary
version: v1
discovery_rest_url: https://photoslibrary.googleapis.com/$discovery/rest?version=v1

View File

@@ -0,0 +1,45 @@
# DO NOT EDIT !
# This file was generated automatically from 'src/mako/Cargo.toml.mako'
# DO NOT EDIT !
[package]
name = "google-mybusiness4-cli"
version = "1.0.12+0"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
description = "A complete library to interact with My Business (protocol v4)"
repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/mybusiness4-cli"
homepage = "https://developers.google.com/my-business/"
documentation = "http://byron.github.io/google-apis-rs/google_mybusiness4_cli"
license = "MIT"
keywords = ["mybusiness", "google", "cli"]
autobins = false
[[bin]]
name = "mybusiness4"
path = "src/main.rs"
[dev-dependencies]
hyper-rustls = "^0.6"
[dependencies]
hyper = "^ 0.10"
mime = "^ 0.2.0"
serde = "^ 1.0"
serde_json = "^ 1.0"
serde_derive = "^ 1.0"
yup-oauth2 = { version = "^ 1.0", default-features = false }
strsim = "^0.5"
hyper-rustls = "^0.6"
yup-hyper-mock = "^2.0"
clap = "^2.0"
[features]
default = ["openssl"]
openssl = ["yup-oauth2/default"]
rustls = ["yup-oauth2/no-openssl"]
[dependencies.google-mybusiness4]
path = "../mybusiness4"
version = "1.0.12+0"

View File

@@ -0,0 +1,30 @@
<!---
DO NOT EDIT !
This file was generated automatically from 'src/mako/LICENSE.md.mako'
DO NOT EDIT !
-->
The MIT License (MIT)
=====================
Copyright © `2015-2020` `Sebastian Thiel`
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,184 @@
<!---
DO NOT EDIT !
This file was generated automatically from 'src/mako/cli/README.md.mako'
DO NOT EDIT !
-->
The `mybusiness4` command-line interface *(CLI)* allows to use most features of the *Google My Business* service from the comfort of your terminal.
By default all output is printed to standard out, but flags can be set to direct it into a file independent of your shell's
capabilities. Errors will be printed to standard error, and cause the program's exit code to be non-zero.
If data-structures are requested, these will be returned as pretty-printed JSON, to be useful as input to other tools.
Everything else about the *My Business* API can be found at the
[official documentation site](https://developers.google.com/my-business/).
# Installation and Source Code
Install the command-line interface with cargo using:
```bash
cargo install google-mybusiness4-cli
```
Find the source code [on github](https://github.com/Byron/google-apis-rs/tree/master/gen/mybusiness4-cli).
# Usage
This documentation was generated from the *My Business* API at revision *0*. The CLI is at version *1.0.12*.
```bash
mybusiness4 [options]
accounts
admins-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
admins-delete <name> [-p <v>]... [-o <out>]
admins-list <parent> [-p <v>]... [-o <out>]
admins-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
create (-r <kv>)... [-p <v>]... [-o <out>]
delete-notifications <name> [-p <v>]... [-o <out>]
generate-account-number <name> (-r <kv>)... [-p <v>]... [-o <out>]
get <name> [-p <v>]... [-o <out>]
get-notifications <name> [-p <v>]... [-o <out>]
invitations-accept <name> (-r <kv>)... [-p <v>]... [-o <out>]
invitations-decline <name> (-r <kv>)... [-p <v>]... [-o <out>]
invitations-list <parent> [-p <v>]... [-o <out>]
list [-p <v>]... [-o <out>]
list-recommend-google-locations <name> [-p <v>]... [-o <out>]
locations-admins-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-admins-delete <name> [-p <v>]... [-o <out>]
locations-admins-list <parent> [-p <v>]... [-o <out>]
locations-admins-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-associate <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-batch-get <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-batch-get-reviews <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-clear-association <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-delete <name> [-p <v>]... [-o <out>]
locations-fetch-verification-options <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-find-matches <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-followers-get-metadata <name> [-p <v>]... [-o <out>]
locations-get <name> [-p <v>]... [-o <out>]
locations-get-google-updated <name> [-p <v>]... [-o <out>]
locations-list <parent> [-p <v>]... [-o <out>]
locations-local-posts-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-local-posts-delete <name> [-p <v>]... [-o <out>]
locations-local-posts-get <name> [-p <v>]... [-o <out>]
locations-local-posts-list <parent> [-p <v>]... [-o <out>]
locations-local-posts-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-local-posts-report-insights <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-media-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-media-customers-get <name> [-p <v>]... [-o <out>]
locations-media-customers-list <parent> [-p <v>]... [-o <out>]
locations-media-delete <name> [-p <v>]... [-o <out>]
locations-media-get <name> [-p <v>]... [-o <out>]
locations-media-list <parent> [-p <v>]... [-o <out>]
locations-media-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-media-start-upload <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-questions-answers-delete <parent> [-p <v>]... [-o <out>]
locations-questions-answers-list <parent> [-p <v>]... [-o <out>]
locations-questions-answers-upsert <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-questions-create <parent> (-r <kv>)... [-p <v>]... [-o <out>]
locations-questions-delete <name> [-p <v>]... [-o <out>]
locations-questions-list <parent> [-p <v>]... [-o <out>]
locations-questions-patch <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-report-insights <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-reviews-delete-reply <name> [-p <v>]... [-o <out>]
locations-reviews-get <name> [-p <v>]... [-o <out>]
locations-reviews-list <parent> [-p <v>]... [-o <out>]
locations-reviews-update-reply <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-transfer <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-verifications-complete <name> (-r <kv>)... [-p <v>]... [-o <out>]
locations-verifications-list <parent> [-p <v>]... [-o <out>]
locations-verify <name> (-r <kv>)... [-p <v>]... [-o <out>]
update <name> (-r <kv>)... [-p <v>]... [-o <out>]
update-notifications <name> (-r <kv>)... [-p <v>]... [-o <out>]
attributes
list [-p <v>]... [-o <out>]
categories
list [-p <v>]... [-o <out>]
chains
get <name> [-p <v>]... [-o <out>]
search [-p <v>]... [-o <out>]
google-locations
report <name> (-r <kv>)... [-p <v>]... [-o <out>]
search (-r <kv>)... [-p <v>]... [-o <out>]
verification-tokens
generate (-r <kv>)... [-p <v>]... [-o <out>]
mybusiness4 --help
Configuration:
--config-dir <folder>
A directory into which we will store our persistent data. Defaults to
a user-writable directory that we will create during the first invocation.
[default: ~/.google-service-cli]
--debug
Output all server communication to standard error. `tx` and `rx` are placed
into the same stream.
--debug-auth
Output all communication related to authentication to standard error. `tx`
and `rx` are placed into the same stream.
```
# Configuration
The program will store all persistent data in the `~/.google-service-cli` directory in *JSON* files prefixed with `mybusiness4-`. You can change the directory used to store configuration with the `--config-dir` flag on a per-invocation basis.
More information about the various kinds of persistent data are given in the following paragraphs.
# Authentication
Most APIs require a user to authenticate any request. If this is the case, the [scope][scopes] determines the
set of permissions granted. The granularity of these is usually no more than *read-only* or *full-access*.
If not set, the system will automatically select the smallest feasible scope, e.g. when invoking a
method that is read-only, it will ask only for a read-only scope.
You may use the `--scope` flag to specify a scope directly.
All applicable scopes are documented in the respective method's CLI documentation.
The first time a scope is used, the user is asked for permission. Follow the instructions given
by the CLI to grant permissions, or to decline.
If a scope was authenticated by the user, the respective information will be stored as *JSON* in the configuration
directory, e.g. `~/.google-service-cli/mybusiness4-token-<scope-hash>.json`. No manual management of these tokens
is necessary.
To revoke granted authentication, please refer to the [official documentation][revoke-access].
# Application Secrets
In order to allow any application to use Google services, it will need to be registered using the
[Google Developer Console][google-dev-console]. APIs the application may use are then enabled for it
one by one. Most APIs can be used for free and have a daily quota.
To allow more comfortable usage of the CLI without forcing anyone to register an own application, the CLI
comes with a default application secret that is configured accordingly. This also means that heavy usage
all around the world may deplete the daily quota.
You can workaround this limitation by putting your own secrets file at this location:
`~/.google-service-cli/mybusiness4-secret.json`, assuming that the required *mybusiness* API
was enabled for it. Such a secret file can be downloaded in the *Google Developer Console* at
*APIs & auth -> Credentials -> Download JSON* and used as is.
Learn more about how to setup Google projects and enable APIs using the [official documentation][google-project-new].
# Debugging
Even though the CLI does its best to provide usable error messages, sometimes it might be desirable to know
what exactly led to a particular issue. This is done by allowing all client-server communication to be
output to standard error *as-is*.
The `--debug` flag will print all client-server communication to standard error, whereas the `--debug-auth` flag
will cause all communication related to authentication to standard error.
If the `--debug` flag is set, error-results will be debug-printed, possibly yielding more information about the
issue at hand.
You may consider redirecting standard error into a file for ease of use, e.g. `mybusiness4 --debug <resource> <method> [options] 2>debug.txt`.
[scopes]: https://developers.google.com/+/api/oauth#scopes
[revoke-access]: http://webapps.stackexchange.com/a/30849
[google-dev-console]: https://console.developers.google.com/
[google-project-new]: https://developers.google.com/console/help/new/

View File

@@ -0,0 +1,86 @@
site_name: My Business v1.0.12+0
site_url: http://byron.github.io/google-apis-rs/google-mybusiness4-cli
site_description: A complete library to interact with My Business (protocol v4)
repo_url: https://github.com/Byron/google-apis-rs/tree/master/gen/mybusiness4-cli
docs_dir: docs
site_dir: build_html
pages:
- ['index.md', 'Home']
- ['accounts_admins-create.md', 'Accounts', 'Admins Create']
- ['accounts_admins-delete.md', 'Accounts', 'Admins Delete']
- ['accounts_admins-list.md', 'Accounts', 'Admins List']
- ['accounts_admins-patch.md', 'Accounts', 'Admins Patch']
- ['accounts_create.md', 'Accounts', 'Create']
- ['accounts_delete-notifications.md', 'Accounts', 'Delete Notifications']
- ['accounts_generate-account-number.md', 'Accounts', 'Generate Account Number']
- ['accounts_get.md', 'Accounts', 'Get']
- ['accounts_get-notifications.md', 'Accounts', 'Get Notifications']
- ['accounts_invitations-accept.md', 'Accounts', 'Invitations Accept']
- ['accounts_invitations-decline.md', 'Accounts', 'Invitations Decline']
- ['accounts_invitations-list.md', 'Accounts', 'Invitations List']
- ['accounts_list.md', 'Accounts', 'List']
- ['accounts_list-recommend-google-locations.md', 'Accounts', 'List Recommend Google Locations']
- ['accounts_locations-admins-create.md', 'Accounts', 'Locations Admins Create']
- ['accounts_locations-admins-delete.md', 'Accounts', 'Locations Admins Delete']
- ['accounts_locations-admins-list.md', 'Accounts', 'Locations Admins List']
- ['accounts_locations-admins-patch.md', 'Accounts', 'Locations Admins Patch']
- ['accounts_locations-associate.md', 'Accounts', 'Locations Associate']
- ['accounts_locations-batch-get.md', 'Accounts', 'Locations Batch Get']
- ['accounts_locations-batch-get-reviews.md', 'Accounts', 'Locations Batch Get Reviews']
- ['accounts_locations-clear-association.md', 'Accounts', 'Locations Clear Association']
- ['accounts_locations-create.md', 'Accounts', 'Locations Create']
- ['accounts_locations-delete.md', 'Accounts', 'Locations Delete']
- ['accounts_locations-fetch-verification-options.md', 'Accounts', 'Locations Fetch Verification Options']
- ['accounts_locations-find-matches.md', 'Accounts', 'Locations Find Matches']
- ['accounts_locations-followers-get-metadata.md', 'Accounts', 'Locations Followers Get Metadata']
- ['accounts_locations-get.md', 'Accounts', 'Locations Get']
- ['accounts_locations-get-google-updated.md', 'Accounts', 'Locations Get Google Updated']
- ['accounts_locations-list.md', 'Accounts', 'Locations List']
- ['accounts_locations-local-posts-create.md', 'Accounts', 'Locations Local Posts Create']
- ['accounts_locations-local-posts-delete.md', 'Accounts', 'Locations Local Posts Delete']
- ['accounts_locations-local-posts-get.md', 'Accounts', 'Locations Local Posts Get']
- ['accounts_locations-local-posts-list.md', 'Accounts', 'Locations Local Posts List']
- ['accounts_locations-local-posts-patch.md', 'Accounts', 'Locations Local Posts Patch']
- ['accounts_locations-local-posts-report-insights.md', 'Accounts', 'Locations Local Posts Report Insights']
- ['accounts_locations-media-create.md', 'Accounts', 'Locations Media Create']
- ['accounts_locations-media-customers-get.md', 'Accounts', 'Locations Media Customers Get']
- ['accounts_locations-media-customers-list.md', 'Accounts', 'Locations Media Customers List']
- ['accounts_locations-media-delete.md', 'Accounts', 'Locations Media Delete']
- ['accounts_locations-media-get.md', 'Accounts', 'Locations Media Get']
- ['accounts_locations-media-list.md', 'Accounts', 'Locations Media List']
- ['accounts_locations-media-patch.md', 'Accounts', 'Locations Media Patch']
- ['accounts_locations-media-start-upload.md', 'Accounts', 'Locations Media Start Upload']
- ['accounts_locations-patch.md', 'Accounts', 'Locations Patch']
- ['accounts_locations-questions-answers-delete.md', 'Accounts', 'Locations Questions Answers Delete']
- ['accounts_locations-questions-answers-list.md', 'Accounts', 'Locations Questions Answers List']
- ['accounts_locations-questions-answers-upsert.md', 'Accounts', 'Locations Questions Answers Upsert']
- ['accounts_locations-questions-create.md', 'Accounts', 'Locations Questions Create']
- ['accounts_locations-questions-delete.md', 'Accounts', 'Locations Questions Delete']
- ['accounts_locations-questions-list.md', 'Accounts', 'Locations Questions List']
- ['accounts_locations-questions-patch.md', 'Accounts', 'Locations Questions Patch']
- ['accounts_locations-report-insights.md', 'Accounts', 'Locations Report Insights']
- ['accounts_locations-reviews-delete-reply.md', 'Accounts', 'Locations Reviews Delete Reply']
- ['accounts_locations-reviews-get.md', 'Accounts', 'Locations Reviews Get']
- ['accounts_locations-reviews-list.md', 'Accounts', 'Locations Reviews List']
- ['accounts_locations-reviews-update-reply.md', 'Accounts', 'Locations Reviews Update Reply']
- ['accounts_locations-transfer.md', 'Accounts', 'Locations Transfer']
- ['accounts_locations-verifications-complete.md', 'Accounts', 'Locations Verifications Complete']
- ['accounts_locations-verifications-list.md', 'Accounts', 'Locations Verifications List']
- ['accounts_locations-verify.md', 'Accounts', 'Locations Verify']
- ['accounts_update.md', 'Accounts', 'Update']
- ['accounts_update-notifications.md', 'Accounts', 'Update Notifications']
- ['attributes_list.md', 'Attributes', 'List']
- ['categories_list.md', 'Categories', 'List']
- ['chains_get.md', 'Chains', 'Get']
- ['chains_search.md', 'Chains', 'Search']
- ['google-locations_report.md', 'Google Locations', 'Report']
- ['google-locations_search.md', 'Google Locations', 'Search']
- ['verification-tokens_generate.md', 'Verification Tokens', 'Generate']
theme: readthedocs
copyright: Copyright &copy; 2015-2020, `Sebastian Thiel`

View File

@@ -0,0 +1,811 @@
// COPY OF 'src/rust/cli/cmn.rs'
// DO NOT EDIT
use oauth2::{ApplicationSecret, ConsoleApplicationSecret, TokenStorage, Token};
use serde_json as json;
use serde_json::value::Value;
use mime::Mime;
use clap::{App, SubCommand};
use strsim;
use std::fs;
use std::env;
use std::io;
use std::error::Error as StdError;
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::string::ToString;
use std::io::{Write, Read, stdout};
use std::default::Default;
const FIELD_SEP: char = '.';
pub enum ComplexType {
Pod,
Vec,
Map,
}
// Null,
// Bool(bool),
// I64(i64),
// U64(u64),
// F64(f64),
// String(String),
pub enum JsonType {
Boolean,
Int,
Uint,
Float,
String,
}
pub struct JsonTypeInfo {
pub jtype: JsonType,
pub ctype: ComplexType,
}
// Based on @erickt user comment. Thanks for the idea !
// Remove all keys whose values are null from given value (changed in place)
pub fn remove_json_null_values(value: &mut Value) {
match *value {
Value::Object(ref mut map) => {
let mut for_removal = Vec::new();
for (key, mut value) in map.iter_mut() {
if value.is_null() {
for_removal.push(key.clone());
} else {
remove_json_null_values(&mut value);
}
}
for key in &for_removal {
map.remove(key);
}
}
json::value::Value::Array(ref mut arr) => {
let mut i = 0;
while i < arr.len() {
if arr[i].is_null() {
arr.remove(i);
} else {
remove_json_null_values(&mut arr[i]);
i += 1;
}
}
}
_ => {}
}
}
fn did_you_mean<'a>(v: &str, possible_values: &[&'a str]) -> Option<&'a str> {
let mut candidate: Option<(f64, &str)> = None;
for pv in possible_values {
let confidence = strsim::jaro_winkler(v, pv);
if confidence > 0.8 &&
(candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) {
candidate = Some((confidence, pv));
}
}
match candidate {
None => None,
Some((_, candidate)) => Some(candidate),
}
}
pub enum CallType {
Upload(UploadProtocol),
Standard,
}
arg_enum!{
pub enum UploadProtocol {
Simple,
Resumable
}
}
impl AsRef<str> for UploadProtocol {
fn as_ref(&self) -> &str {
match *self {
UploadProtocol::Simple => "simple",
UploadProtocol::Resumable => "resumable",
}
}
}
impl AsRef<str> for CallType {
fn as_ref(&self) -> &str {
match *self {
CallType::Upload(ref proto) => proto.as_ref(),
CallType::Standard => "standard-request",
}
}
}
#[derive(Clone, Default)]
pub struct FieldCursor(Vec<String>);
impl ToString for FieldCursor {
fn to_string(&self) -> String {
self.0.join(".")
}
}
impl From<&'static str> for FieldCursor {
fn from(value: &'static str) -> FieldCursor {
let mut res = FieldCursor::default();
res.set(value).unwrap();
res
}
}
fn assure_entry<'a, 'b>(m: &'a mut json::Map<String, Value>, k: &'b String) -> &'a mut Value {
if m.contains_key(k) {
return m.get_mut(k).expect("value to exist");
}
m.insert(k.to_owned(), Value::Object(Default::default()));
m.get_mut(k).expect("value to exist")
}
impl FieldCursor {
pub fn set(&mut self, value: &str) -> Result<(), CLIError> {
if value.len() == 0 {
return Err(CLIError::Field(FieldError::Empty));
}
let mut first_is_field_sep = false;
let mut char_count: usize = 0;
let mut last_c = FIELD_SEP;
let mut num_conscutive_field_seps = 0;
let mut field = String::new();
let mut fields = self.0.clone();
let push_field = |fs: &mut Vec<String>, f: &mut String| {
if f.len() > 0 {
fs.push(f.clone());
f.truncate(0);
}
};
for (cid, c) in value.chars().enumerate() {
char_count += 1;
if c == FIELD_SEP {
if cid == 0 {
first_is_field_sep = true;
}
num_conscutive_field_seps += 1;
if cid > 0 && last_c == FIELD_SEP {
if fields.pop().is_none() {
return Err(CLIError::Field(FieldError::PopOnEmpty(value.to_string())));
}
} else {
push_field(&mut fields, &mut field);
}
} else {
num_conscutive_field_seps = 0;
if cid == 1 {
if first_is_field_sep {
fields.truncate(0);
}
}
field.push(c);
}
last_c = c;
}
push_field(&mut fields, &mut field);
if char_count == 1 && first_is_field_sep {
fields.truncate(0);
}
if char_count > 1 && num_conscutive_field_seps == 1 {
return Err(CLIError::Field(FieldError::TrailingFieldSep(value.to_string())));
}
self.0 = fields;
Ok(())
}
pub fn did_you_mean(value: &str, possible_values: &[&str]) -> Option<String> {
if value.len() == 0 {
return None;
}
let mut last_c = FIELD_SEP;
let mut field = String::new();
let mut output = String::new();
let push_field = |fs: &mut String, f: &mut String| {
if f.len() > 0 {
fs.push_str(match did_you_mean(&f, possible_values) {
Some(candidate) => candidate,
None => &f,
});
f.truncate(0);
}
};
for (cid, c) in value.chars().enumerate() {
if c == FIELD_SEP {
if last_c != FIELD_SEP {
push_field(&mut output, &mut field);
}
output.push(c);
} else {
field.push(c);
}
last_c = c;
}
push_field(&mut output, &mut field);
if &output == value {
None
} else {
Some(output)
}
}
pub fn set_json_value(&self,
mut object: &mut Value,
value: &str,
type_info: JsonTypeInfo,
err: &mut InvalidOptionsError,
orig_cursor: &FieldCursor) {
assert!(self.0.len() > 0);
for field in &self.0[..self.0.len() - 1] {
let tmp = object;
object = match *tmp {
Value::Object(ref mut mapping) => {
assure_entry(mapping, &field)
}
_ => panic!("We don't expect non-object Values here ..."),
};
}
match *object {
Value::Object(ref mut mapping) => {
let field = &self.0[self.0.len() - 1];
let to_jval = |value: &str,
jtype: JsonType,
err: &mut InvalidOptionsError|
-> Value {
match jtype {
JsonType::Boolean =>
Value::Bool(arg_from_str(value, err, &field, "boolean")),
JsonType::Int =>
Value::Number(json::Number::from_f64(arg_from_str(value,
err,
&field,
"int"))
.expect("valid f64")),
JsonType::Uint =>
Value::Number(json::Number::from_f64(arg_from_str(value,
err,
&field,
"uint"))
.expect("valid f64")),
JsonType::Float =>
Value::Number(json::Number::from_f64(arg_from_str(value,
err,
&field,
"float"))
.expect("valid f64")),
JsonType::String => Value::String(value.to_owned()),
}
};
match type_info.ctype {
ComplexType::Pod => {
if mapping.insert(field.to_owned(), to_jval(value, type_info.jtype, err))
.is_some() {
err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string())));
}
}
ComplexType::Vec => {
match *assure_entry(mapping, field) {
Value::Array(ref mut values) =>
values.push(to_jval(value, type_info.jtype, err)),
_ => unreachable!(),
}
}
ComplexType::Map => {
let (key, value) = parse_kv_arg(value, err, true);
let jval = to_jval(value.unwrap_or(""), type_info.jtype, err);
match *assure_entry(mapping, &field) {
Value::Object(ref mut value_map) => {
if value_map.insert(key.to_owned(), jval).is_some() {
err.issues.push(CLIError::Field(FieldError::Duplicate(orig_cursor.to_string())));
}
}
_ => unreachable!(),
}
}
}
}
_ => unreachable!(),
}
}
pub fn num_fields(&self) -> usize {
self.0.len()
}
}
pub fn parse_kv_arg<'a>(kv: &'a str,
err: &mut InvalidOptionsError,
for_hashmap: bool)
-> (&'a str, Option<&'a str>) {
let mut add_err = || {
err.issues.push(CLIError::InvalidKeyValueSyntax(kv.to_string(), for_hashmap))
};
match kv.find('=') {
None => {
add_err();
return (kv, None);
}
Some(pos) => {
let key = &kv[..pos];
if kv.len() <= pos + 1 {
add_err();
return (key, Some(""));
}
(key, Some(&kv[pos + 1..]))
}
}
}
pub fn calltype_from_str(name: &str,
valid_protocols: Vec<String>,
err: &mut InvalidOptionsError)
-> CallType {
CallType::Upload(match UploadProtocol::from_str(name) {
Ok(up) => up,
Err(msg) => {
err.issues.push(CLIError::InvalidUploadProtocol(name.to_string(), valid_protocols));
UploadProtocol::Simple
}
})
}
pub fn input_file_from_opts(file_path: &str, err: &mut InvalidOptionsError) -> Option<fs::File> {
match fs::File::open(file_path) {
Ok(f) => Some(f),
Err(io_err) => {
err.issues.push(CLIError::Input(InputError::Io((file_path.to_string(), io_err))));
None
}
}
}
pub fn input_mime_from_opts(mime: &str, err: &mut InvalidOptionsError) -> Option<Mime> {
match mime.parse() {
Ok(m) => Some(m),
Err(_) => {
err.issues.push(CLIError::Input(InputError::Mime(mime.to_string())));
None
}
}
}
pub fn writer_from_opts(arg: Option<&str>) -> Result<Box<dyn Write>, io::Error> {
let f = arg.unwrap_or("-");
match f {
"-" => Ok(Box::new(stdout())),
_ => match fs::OpenOptions::new().create(true).truncate(true).write(true).open(f) {
Ok(f) => Ok(Box::new(f)),
Err(io_err) => Err(io_err),
},
}
}
pub fn arg_from_str<'a, T>(arg: &str,
err: &mut InvalidOptionsError,
arg_name: &'a str,
arg_type: &'a str)
-> T
where T: FromStr + Default,
<T as FromStr>::Err: fmt::Display
{
match FromStr::from_str(arg) {
Err(perr) => {
err.issues.push(CLIError::ParseError(arg_name.to_owned(),
arg_type.to_owned(),
arg.to_string(),
format!("{}", perr)));
Default::default()
}
Ok(v) => v,
}
}
pub struct JsonTokenStorage {
pub program_name: &'static str,
pub db_dir: String,
}
impl JsonTokenStorage {
fn path(&self, scope_hash: u64) -> PathBuf {
Path::new(&self.db_dir).join(&format!("{}-token-{}.json", self.program_name, scope_hash))
}
}
#[derive(Debug)]
pub enum TokenStorageError {
Json(json::Error),
Io(io::Error),
}
impl fmt::Display for TokenStorageError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
TokenStorageError::Json(ref err) => writeln!(f, "Could not serialize secrets: {}", err),
TokenStorageError::Io(ref err) => writeln!(f, "Failed to write secret token: {}", err),
}
}
}
impl StdError for TokenStorageError {
fn description(&self) -> &str {
"Failure when getting or setting the token storage"
}
}
impl TokenStorage for JsonTokenStorage {
type Error = TokenStorageError;
// NOTE: logging might be interesting, currently we swallow all errors
fn set(&mut self,
scope_hash: u64,
_: &Vec<&str>,
token: Option<Token>)
-> Result<(), TokenStorageError> {
match token {
None => {
match fs::remove_file(self.path(scope_hash)) {
Err(err) => match err.kind() {
io::ErrorKind::NotFound => Ok(()),
_ => Err(TokenStorageError::Io(err)),
},
Ok(_) => Ok(()),
}
}
Some(token) => {
match fs::OpenOptions::new().create(true).write(true).truncate(true).open(&self.path(scope_hash)) {
Ok(mut f) => {
match json::to_writer_pretty(&mut f, &token) {
Ok(_) => Ok(()),
Err(serde_err) => Err(TokenStorageError::Json(serde_err)),
}
}
Err(io_err) => Err(TokenStorageError::Io(io_err)),
}
}
}
}
fn get(&self, scope_hash: u64, _: &Vec<&str>) -> Result<Option<Token>, TokenStorageError> {
match fs::File::open(&self.path(scope_hash)) {
Ok(f) => {
match json::de::from_reader(f) {
Ok(token) => Ok(Some(token)),
Err(err) => Err(TokenStorageError::Json(err)),
}
}
Err(io_err) => {
match io_err.kind() {
io::ErrorKind::NotFound => Ok(None),
_ => Err(TokenStorageError::Io(io_err)),
}
}
}
}
}
#[derive(Debug)]
pub enum ApplicationSecretError {
DecoderError((String, json::Error)),
FormatError(String),
}
impl fmt::Display for ApplicationSecretError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
ApplicationSecretError::DecoderError((ref path, ref err)) =>
writeln!(f,
"Could not decode file at '{}' with error: {}.",
path,
err),
ApplicationSecretError::FormatError(ref path) =>
writeln!(f,
"'installed' field is unset in secret file at '{}'.",
path),
}
}
}
#[derive(Debug)]
pub enum ConfigurationError {
DirectoryCreationFailed((String, io::Error)),
DirectoryUnset,
HomeExpansionFailed(String),
Secret(ApplicationSecretError),
Io((String, io::Error)),
}
impl fmt::Display for ConfigurationError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
ConfigurationError::DirectoryCreationFailed((ref dir, ref err)) =>
writeln!(f,
"Directory '{}' could not be created with error: {}.",
dir,
err),
ConfigurationError::DirectoryUnset => writeln!(f, "--config-dir was unset or empty."),
ConfigurationError::HomeExpansionFailed(ref dir) =>
writeln!(f,
"Couldn't find HOME directory of current user, failed to expand '{}'.",
dir),
ConfigurationError::Secret(ref err) => writeln!(f, "Secret -> {}", err),
ConfigurationError::Io((ref path, ref err)) =>
writeln!(f,
"IO operation failed on path '{}' with error: {}.",
path,
err),
}
}
}
#[derive(Debug)]
pub enum InputError {
Io((String, io::Error)),
Mime(String),
}
impl fmt::Display for InputError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
InputError::Io((ref file_path, ref io_err)) =>
writeln!(f,
"Failed to open '{}' for reading with error: {}.",
file_path,
io_err),
InputError::Mime(ref mime) => writeln!(f, "'{}' is not a known mime-type.", mime),
}
}
}
#[derive(Debug)]
pub enum FieldError {
PopOnEmpty(String),
TrailingFieldSep(String),
Unknown(String, Option<String>, Option<String>),
Duplicate(String),
Empty,
}
impl fmt::Display for FieldError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
FieldError::PopOnEmpty(ref field) =>
writeln!(f, "'{}': Cannot move up on empty field cursor.", field),
FieldError::TrailingFieldSep(ref field) =>
writeln!(f,
"'{}': Single field separator may not be last character.",
field),
FieldError::Unknown(ref field, ref suggestion, ref value) => {
let suffix = match *suggestion {
Some(ref s) => {
let kv = match *value {
Some(ref v) => format!("{}={}", s, v),
None => s.clone(),
};
format!(" Did you mean '{}' ?", kv)
}
None => String::new(),
};
writeln!(f, "Field '{}' does not exist.{}", field, suffix)
}
FieldError::Duplicate(ref cursor) =>
writeln!(f, "Value at '{}' was already set", cursor),
FieldError::Empty => writeln!(f, "Field names must not be empty."),
}
}
}
#[derive(Debug)]
pub enum CLIError {
Configuration(ConfigurationError),
ParseError(String, String, String, String),
UnknownParameter(String, Vec<&'static str>),
InvalidUploadProtocol(String, Vec<String>),
InvalidKeyValueSyntax(String, bool),
Input(InputError),
Field(FieldError),
MissingCommandError,
MissingMethodError(String),
}
impl fmt::Display for CLIError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
CLIError::Configuration(ref err) => write!(f, "Configuration -> {}", err),
CLIError::Input(ref err) => write!(f, "Input -> {}", err),
CLIError::Field(ref err) => write!(f, "Field -> {}", err),
CLIError::InvalidUploadProtocol(ref proto_name, ref valid_names) =>
writeln!(f,
"'{}' is not a valid upload protocol. Choose from one of {}.",
proto_name,
valid_names.join(", ")),
CLIError::ParseError(ref arg_name, ref type_name, ref value, ref err_desc) =>
writeln!(f,
"Failed to parse argument '{}' with value '{}' as {} with error: {}.",
arg_name,
value,
type_name,
err_desc),
CLIError::UnknownParameter(ref param_name, ref possible_values) => {
let suffix = match did_you_mean(param_name, &possible_values) {
Some(v) => format!(" Did you mean '{}' ?", v),
None => String::new(),
};
write!(f, "Parameter '{}' is unknown.{}\n", param_name, suffix)
}
CLIError::InvalidKeyValueSyntax(ref kv, is_hashmap) => {
let hashmap_info = if is_hashmap {
"hashmap "
} else {
""
};
writeln!(f,
"'{}' does not match {}pattern <key>=<value>.",
kv,
hashmap_info)
}
CLIError::MissingCommandError => writeln!(f, "Please specify the main sub-command."),
CLIError::MissingMethodError(ref cmd) =>
writeln!(f,
"Please specify the method to call on the '{}' command.",
cmd),
}
}
}
#[derive(Debug)]
pub struct InvalidOptionsError {
pub issues: Vec<CLIError>,
pub exit_code: i32,
}
impl fmt::Display for InvalidOptionsError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
for issue in &self.issues {
issue.fmt(f)?;
}
Ok(())
}
}
impl InvalidOptionsError {
pub fn single(err: CLIError, exit_code: i32) -> InvalidOptionsError {
InvalidOptionsError {
issues: vec![err],
exit_code: exit_code,
}
}
pub fn new() -> InvalidOptionsError {
InvalidOptionsError {
issues: Vec::new(),
exit_code: 1,
}
}
}
pub fn assure_config_dir_exists(dir: &str) -> Result<String, CLIError> {
let trdir = dir.trim();
if trdir.len() == 0 {
return Err(CLIError::Configuration(ConfigurationError::DirectoryUnset));
}
let expanded_config_dir = if trdir.as_bytes()[0] == b'~' {
match env::var("HOME").ok().or(env::var("UserProfile").ok()) {
None => return Err(CLIError::Configuration(ConfigurationError::HomeExpansionFailed(trdir.to_string()))),
Some(mut user) => {
user.push_str(&trdir[1..]);
user
}
}
} else {
trdir.to_string()
};
if let Err(err) = fs::create_dir(&expanded_config_dir) {
if err.kind() != io::ErrorKind::AlreadyExists {
return Err(CLIError::Configuration(
ConfigurationError::DirectoryCreationFailed((expanded_config_dir, err))));
}
}
Ok(expanded_config_dir)
}
pub fn application_secret_from_directory(dir: &str,
secret_basename: &str,
json_console_secret: &str)
-> Result<ApplicationSecret, CLIError> {
let secret_path = Path::new(dir).join(secret_basename);
let secret_str = || secret_path.as_path().to_str().unwrap().to_string();
let secret_io_error = |io_err: io::Error| {
Err(CLIError::Configuration(ConfigurationError::Io((secret_str(), io_err))))
};
for _ in 0..2 {
match fs::File::open(&secret_path) {
Err(mut err) => {
if err.kind() == io::ErrorKind::NotFound {
// Write our built-in one - user may adjust the written file at will
err = match fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(true)
.open(&secret_path) {
Err(cfe) => cfe,
Ok(mut f) => {
// Assure we convert 'ugly' json string into pretty one
let console_secret: ConsoleApplicationSecret =
json::from_str(json_console_secret).unwrap();
match json::to_writer_pretty(&mut f, &console_secret) {
Err(serde_err) =>
panic!("Unexpected serde error: {:#?}", serde_err),
Ok(_) => continue,
}
}
};
// fall through to IO error handling
}
return secret_io_error(err);
}
Ok(f) => {
match json::de::from_reader::<_, ConsoleApplicationSecret>(f) {
Err(json_err) =>
return Err(CLIError::Configuration(
ConfigurationError::Secret(
ApplicationSecretError::DecoderError(
(secret_str(), json_err)
)))),
Ok(console_secret) => match console_secret.installed {
Some(secret) => return Ok(secret),
None => return Err(
CLIError::Configuration(
ConfigurationError::Secret(
ApplicationSecretError::FormatError(secret_str())
))),
},
}
}
}
}
unreachable!();
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
# DO NOT EDIT !
# This file was generated automatically from 'src/mako/Cargo.toml.mako'
# DO NOT EDIT !
[package]
name = "google-mybusiness4"
version = "1.0.12+0"
authors = ["Sebastian Thiel <byronimo@gmail.com>"]
description = "A complete library to interact with My Business (protocol v4)"
repository = "https://github.com/Byron/google-apis-rs/tree/master/gen/mybusiness4"
homepage = "https://developers.google.com/my-business/"
documentation = "https://docs.rs/google-mybusiness4/1.0.12+0"
license = "MIT"
keywords = ["mybusiness", "google", "protocol", "web", "api"]
autobins = false
[dev-dependencies]
hyper-rustls = "^0.6"
[dependencies]
hyper = "^ 0.10"
mime = "^ 0.2.0"
serde = "^ 1.0"
serde_json = "^ 1.0"
serde_derive = "^ 1.0"
yup-oauth2 = { version = "^ 1.0", default-features = false }
url = "= 1.7"
[features]
default = ["openssl"]
openssl = ["yup-oauth2/default"]
rustls = ["yup-oauth2/no-openssl"]

View File

@@ -0,0 +1,30 @@
<!---
DO NOT EDIT !
This file was generated automatically from 'src/mako/LICENSE.md.mako'
DO NOT EDIT !
-->
The MIT License (MIT)
=====================
Copyright © `2015-2020` `Sebastian Thiel`
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

259
gen/mybusiness4/README.md Normal file

File diff suppressed because one or more lines are too long

764
gen/mybusiness4/src/cmn.rs Normal file
View File

@@ -0,0 +1,764 @@
// COPY OF 'src/rust/api/cmn.rs'
// DO NOT EDIT
use std::io::{self, Read, Seek, Cursor, Write, SeekFrom};
use std;
use std::fmt::{self, Display};
use std::str::FromStr;
use std::error;
use std::thread::sleep;
use std::time::Duration;
use mime::{Mime, TopLevel, SubLevel, Attr, Value};
use oauth2::{TokenType, Retry, self};
use hyper;
use hyper::header::{ContentType, ContentLength, Headers, UserAgent, Authorization, Header,
HeaderFormat, Bearer};
use hyper::http::h1::LINE_ENDING;
use hyper::method::Method;
use hyper::status::StatusCode;
use serde_json as json;
/// Identifies the Hub. There is only one per library, this trait is supposed
/// to make intended use more explicit.
/// The hub allows to access all resource methods more easily.
pub trait Hub {}
/// Identifies types for building methods of a particular resource type
pub trait MethodsBuilder {}
/// Identifies types which represent builders for a particular resource method
pub trait CallBuilder {}
/// Identifies types which can be inserted and deleted.
/// Types with this trait are most commonly used by clients of this API.
pub trait Resource {}
/// Identifies types which are used in API responses.
pub trait ResponseResult {}
/// Identifies types which are used in API requests.
pub trait RequestValue {}
/// Identifies types which are not actually used by the API
/// This might be a bug within the google API schema.
pub trait UnusedType {}
/// Identifies types which are only used as part of other types, which
/// usually are carrying the `Resource` trait.
pub trait Part {}
/// Identifies types which are only used by other types internally.
/// They have no special meaning, this trait just marks them for completeness.
pub trait NestedType {}
/// A utility to specify reader types which provide seeking capabilities too
pub trait ReadSeek: Seek + Read {}
impl<T: Seek + Read> ReadSeek for T {}
/// A trait for all types that can convert themselves into a *parts* string
pub trait ToParts {
fn to_parts(&self) -> String;
}
/// A utility type which can decode a server response that indicates error
#[derive(Deserialize)]
pub struct JsonServerError {
pub error: String,
pub error_description: Option<String>
}
/// A utility to represent detailed errors we might see in case there are BadRequests.
/// The latter happen if the sent parameters or request structures are unsound
#[derive(Deserialize, Serialize, Debug)]
pub struct ErrorResponse {
pub error: ServerError,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct ServerError {
pub errors: Vec<ServerMessage>,
pub code: u16,
pub message: String,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct ServerMessage {
pub domain: String,
pub reason: String,
pub message: String,
#[serde(rename="locationType")]
pub location_type: Option<String>,
pub location: Option<String>
}
#[derive(Copy, Clone)]
pub struct DummyNetworkStream;
impl Read for DummyNetworkStream {
fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
Ok(0)
}
}
impl Write for DummyNetworkStream {
fn write(&mut self, _: &[u8]) -> io::Result<usize> {
Ok(0)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
impl hyper::net::NetworkStream for DummyNetworkStream {
fn peer_addr(&mut self) -> io::Result<std::net::SocketAddr> {
Ok("127.0.0.1:1337".parse().unwrap())
}
fn set_read_timeout(&self, _dur: Option<Duration>) -> io::Result<()> {
Ok(())
}
fn set_write_timeout(&self, _dur: Option<Duration>) -> io::Result<()> {
Ok(())
}
}
/// A trait specifying functionality to help controlling any request performed by the API.
/// The trait has a conservative default implementation.
///
/// It contains methods to deal with all common issues, as well with the ones related to
/// uploading media
pub trait Delegate {
/// Called at the beginning of any API request. The delegate should store the method
/// information if he is interesting in knowing more context when further calls to it
/// are made.
/// The matching `finished()` call will always be made, no matter whether or not the API
/// request was successful. That way, the delegate may easily maintain a clean state
/// between various API calls.
fn begin(&mut self, MethodInfo) {}
/// Called whenever there is an [HttpError](http://hyperium.github.io/hyper/hyper/error/enum.HttpError.html), usually if there are network problems.
///
/// If you choose to retry after a duration, the duration should be chosen using the
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
///
/// Return retry information.
fn http_error(&mut self, &hyper::Error) -> Retry {
Retry::Abort
}
/// Called whenever there is the need for your applications API key after
/// the official authenticator implementation didn't provide one, for some reason.
/// If this method returns None as well, the underlying operation will fail
fn api_key(&mut self) -> Option<String> {
None
}
/// Called whenever the Authenticator didn't yield a token. The delegate
/// may attempt to provide one, or just take it as a general information about the
/// impending failure.
/// The given Error provides information about why the token couldn't be acquired in the
/// first place
fn token(&mut self, err: &dyn error::Error) -> Option<oauth2::Token> {
let _ = err;
None
}
/// Called during resumable uploads to provide a URL for the impending upload.
/// It was saved after a previous call to `store_upload_url(...)`, and if not None,
/// will be used instead of asking the server for a new upload URL.
/// This is useful in case a previous resumable upload was aborted/canceled, but should now
/// be resumed.
/// The returned URL will be used exactly once - if it fails again and the delegate allows
/// to retry, we will ask the server for a new upload URL.
fn upload_url(&mut self) -> Option<String> {
None
}
/// Called after we have retrieved a new upload URL for a resumable upload to store it
/// in case we fail or cancel. That way, we can attempt to resume the upload later,
/// see `upload_url()`.
/// It will also be called with None after a successful upload, which allows the delegate
/// to forget the URL. That way, we will not attempt to resume an upload that has already
/// finished.
fn store_upload_url(&mut self, url: Option<&str>) {
let _ = url;
}
/// Called whenever a server response could not be decoded from json.
/// It's for informational purposes only, the caller will return with an error
/// accordingly.
///
/// # Arguments
///
/// * `json_encoded_value` - The json-encoded value which failed to decode.
/// * `json_decode_error` - The decoder error
fn response_json_decode_error(&mut self, json_encoded_value: &str, json_decode_error: &json::Error) {
let _ = json_encoded_value;
let _ = json_decode_error;
}
/// Called whenever the http request returns with a non-success status code.
/// This can involve authentication issues, or anything else that very much
/// depends on the used API method.
/// The delegate should check the status, header and decoded json error to decide
/// whether to retry or not. In the latter case, the underlying call will fail.
///
/// If you choose to retry after a duration, the duration should be chosen using the
/// [exponential backoff algorithm](http://en.wikipedia.org/wiki/Exponential_backoff).
fn http_failure(&mut self, _: &hyper::client::Response, Option<JsonServerError>, _: Option<ServerError>) -> Retry {
Retry::Abort
}
/// Called prior to sending the main request of the given method. It can be used to time
/// the call or to print progress information.
/// It's also useful as you can be sure that a request will definitely be made.
fn pre_request(&mut self) { }
/// Return the size of each chunk of a resumable upload.
/// Must be a power of two, with 1<<18 being the smallest allowed chunk size.
/// Will be called once before starting any resumable upload.
fn chunk_size(&mut self) -> u64 {
1 << 23
}
/// Called before the given chunk is uploaded to the server.
/// If true is returned, the upload will be interrupted.
/// However, it may be resumable if you stored the upload URL in a previous call
/// to `store_upload_url()`
fn cancel_chunk_upload(&mut self, chunk: &ContentRange) -> bool {
let _ = chunk;
false
}
/// Called before the API request method returns, in every case. It can be used to clean up
/// internal state between calls to the API.
/// This call always has a matching call to `begin(...)`.
///
/// # Arguments
///
/// * `is_success` - a true value indicates the operation was successful. If false, you should
/// discard all values stored during `store_upload_url`.
fn finished(&mut self, is_success: bool) {
let _ = is_success;
}
}
/// A delegate with a conservative default implementation, which is used if no other delegate is
/// set.
#[derive(Default)]
pub struct DefaultDelegate;
impl Delegate for DefaultDelegate {}
#[derive(Debug)]
pub enum Error {
/// The http connection failed
HttpError(hyper::Error),
/// An attempt was made to upload a resource with size stored in field `.0`
/// even though the maximum upload size is what is stored in field `.1`.
UploadSizeLimitExceeded(u64, u64),
/// Represents information about a request that was not understood by the server.
/// Details are included.
BadRequest(ErrorResponse),
/// We needed an API key for authentication, but didn't obtain one.
/// Neither through the authenticator, nor through the Delegate.
MissingAPIKey,
/// We required a Token, but didn't get one from the Authenticator
MissingToken(Box<dyn error::Error>),
/// The delgate instructed to cancel the operation
Cancelled,
/// An additional, free form field clashed with one of the built-in optional ones
FieldClash(&'static str),
/// Shows that we failed to decode the server response.
/// This can happen if the protocol changes in conjunction with strict json decoding.
JsonDecodeError(String, json::Error),
/// Indicates an HTTP repsonse with a non-success status code
Failure(hyper::client::Response),
}
impl Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Error::HttpError(ref err) => err.fmt(f),
Error::UploadSizeLimitExceeded(ref resource_size, ref max_size) =>
writeln!(f, "The media size {} exceeds the maximum allowed upload size of {}"
, resource_size, max_size),
Error::MissingAPIKey => {
(writeln!(f, "The application's API key was not found in the configuration")).ok();
writeln!(f, "It is used as there are no Scopes defined for this method.")
},
Error::BadRequest(ref err) => {
writeln!(f, "Bad Request ({}): {}", err.error.code, err.error.message)?;
for err in err.error.errors.iter() {
writeln!(f, " {}: {}, {}{}",
err.domain,
err.message,
err.reason,
match &err.location {
&Some(ref loc) => format!("@{}", loc),
&None => String::new(),
})?;
}
Ok(())
},
Error::MissingToken(ref err) =>
writeln!(f, "Token retrieval failed with error: {}", err),
Error::Cancelled =>
writeln!(f, "Operation cancelled by delegate"),
Error::FieldClash(field) =>
writeln!(f, "The custom parameter '{}' is already provided natively by the CallBuilder.", field),
Error::JsonDecodeError(ref json_str, ref err)
=> writeln!(f, "{}: {}", err, json_str),
Error::Failure(ref response) =>
writeln!(f, "Http status indicates failure: {:?}", response),
}
}
}
impl error::Error for Error {
fn description(&self) -> &str {
match *self {
Error::HttpError(ref err) => err.description(),
Error::JsonDecodeError(_, ref err) => err.description(),
_ => "NO DESCRIPTION POSSIBLE - use `Display.fmt()` instead"
}
}
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
Error::HttpError(ref err) => err.source(),
Error::JsonDecodeError(_, ref err) => err.source(),
_ => None
}
}
}
/// A universal result type used as return for all calls.
pub type Result<T> = std::result::Result<T, Error>;
/// Contains information about an API request.
pub struct MethodInfo {
pub id: &'static str,
pub http_method: Method,
}
const BOUNDARY: &'static str = "MDuXWGyeE33QFXGchb2VFWc4Z7945d";
/// Provides a `Read` interface that converts multiple parts into the protocol
/// identified by [RFC2387](https://tools.ietf.org/html/rfc2387).
/// **Note**: This implementation is just as rich as it needs to be to perform uploads
/// to google APIs, and might not be a fully-featured implementation.
#[derive(Default)]
pub struct MultiPartReader<'a> {
raw_parts: Vec<(Headers, &'a mut dyn Read)>,
current_part: Option<(Cursor<Vec<u8>>, &'a mut dyn Read)>,
last_part_boundary: Option<Cursor<Vec<u8>>>,
}
impl<'a> MultiPartReader<'a> {
/// Reserve memory for exactly the given amount of parts
pub fn reserve_exact(&mut self, cap: usize) {
self.raw_parts.reserve_exact(cap);
}
/// Add a new part to the queue of parts to be read on the first `read` call.
///
/// # Arguments
///
/// `headers` - identifying the body of the part. It's similar to the header
/// in an ordinary single-part call, and should thus contain the
/// same information.
/// `reader` - a reader providing the part's body
/// `size` - the amount of bytes provided by the reader. It will be put onto the header as
/// content-size.
/// `mime` - It will be put onto the content type
pub fn add_part(&mut self, reader: &'a mut dyn Read, size: u64, mime_type: Mime) -> &mut MultiPartReader<'a> {
let mut headers = Headers::new();
headers.set(ContentType(mime_type));
headers.set(ContentLength(size));
self.raw_parts.push((headers, reader));
self
}
/// Returns the mime-type representing our multi-part message.
/// Use it with the ContentType header.
pub fn mime_type(&self) -> Mime {
Mime(
TopLevel::Multipart,
SubLevel::Ext("Related".to_string()),
vec![(Attr::Ext("boundary".to_string()), Value::Ext(BOUNDARY.to_string()))],
)
}
/// Returns true if we are totally used
fn is_depleted(&self) -> bool {
self.raw_parts.len() == 0 && self.current_part.is_none() && self.last_part_boundary.is_none()
}
/// Returns true if we are handling our last part
fn is_last_part(&self) -> bool {
self.raw_parts.len() == 0 && self.current_part.is_some()
}
}
impl<'a> Read for MultiPartReader<'a> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match (self.raw_parts.len(),
self.current_part.is_none(),
self.last_part_boundary.is_none()) {
(_, _, false) => {
let br = self.last_part_boundary.as_mut().unwrap().read(buf).unwrap_or(0);
if br < buf.len() {
self.last_part_boundary = None;
}
return Ok(br)
},
(0, true, true) => return Ok(0),
(n, true, _) if n > 0 => {
let (headers, reader) = self.raw_parts.remove(0);
let mut c = Cursor::new(Vec::<u8>::new());
(write!(&mut c, "{}--{}{}{}{}", LINE_ENDING, BOUNDARY, LINE_ENDING,
headers, LINE_ENDING)).unwrap();
c.seek(SeekFrom::Start(0)).unwrap();
self.current_part = Some((c, reader));
}
_ => {},
}
// read headers as long as possible
let (hb, rr) = {
let &mut (ref mut c, ref mut reader) = self.current_part.as_mut().unwrap();
let b = c.read(buf).unwrap_or(0);
(b, reader.read(&mut buf[b..]))
};
match rr {
Ok(bytes_read) => {
if hb < buf.len() && bytes_read == 0 {
if self.is_last_part() {
// before clearing the last part, we will add the boundary that
// will be written last
self.last_part_boundary = Some(Cursor::new(
format!("{}--{}--", LINE_ENDING, BOUNDARY).into_bytes()))
}
// We are depleted - this can trigger the next part to come in
self.current_part = None;
}
let mut total_bytes_read = hb + bytes_read;
while total_bytes_read < buf.len() && !self.is_depleted() {
match self.read(&mut buf[total_bytes_read ..]) {
Ok(br) => total_bytes_read += br,
Err(err) => return Err(err),
}
}
Ok(total_bytes_read)
}
Err(err) => {
// fail permanently
self.current_part = None;
self.last_part_boundary = None;
self.raw_parts.clear();
Err(err)
}
}
}
}
/// The `X-Upload-Content-Type` header.
///
/// Generated via rustc --pretty expanded -Z unstable-options, and manually
/// processed to be more readable.
#[derive(PartialEq, Debug, Clone)]
pub struct XUploadContentType(pub Mime);
impl ::std::ops::Deref for XUploadContentType {
type Target = Mime;
fn deref<'a>(&'a self) -> &'a Mime { &self.0 }
}
impl ::std::ops::DerefMut for XUploadContentType {
fn deref_mut<'a>(&'a mut self) -> &'a mut Mime { &mut self.0 }
}
impl Header for XUploadContentType {
fn header_name() -> &'static str { "X-Upload-Content-Type" }
fn parse_header(raw: &[Vec<u8>]) -> hyper::error::Result<Self> {
hyper::header::parsing::from_one_raw_str(raw).map(XUploadContentType)
}
}
impl HeaderFormat for XUploadContentType {
fn fmt_header(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(&**self, f)
}
}
impl Display for XUploadContentType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
#[derive(Clone, PartialEq, Debug)]
pub struct Chunk {
pub first: u64,
pub last: u64
}
impl fmt::Display for Chunk {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
(write!(fmt, "{}-{}", self.first, self.last)).ok();
Ok(())
}
}
impl FromStr for Chunk {
type Err = &'static str;
/// NOTE: only implements `%i-%i`, not `*`
fn from_str(s: &str) -> std::result::Result<Chunk, &'static str> {
let parts: Vec<&str> = s.split('-').collect();
if parts.len() != 2 {
return Err("Expected two parts: %i-%i")
}
Ok(
Chunk {
first: match FromStr::from_str(parts[0]) {
Ok(d) => d,
_ => return Err("Couldn't parse 'first' as digit")
},
last: match FromStr::from_str(parts[1]) {
Ok(d) => d,
_ => return Err("Couldn't parse 'last' as digit")
}
}
)
}
}
/// Implements the Content-Range header, for serialization only
#[derive(Clone, PartialEq, Debug)]
pub struct ContentRange {
pub range: Option<Chunk>,
pub total_length: u64,
}
impl Header for ContentRange {
fn header_name() -> &'static str {
"Content-Range"
}
/// We are not parsable, as parsing is done by the `Range` header
fn parse_header(_: &[Vec<u8>]) -> hyper::error::Result<Self> {
Err(hyper::error::Error::Method)
}
}
impl HeaderFormat for ContentRange {
fn fmt_header(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.write_str("bytes ")?;
match self.range {
Some(ref c) => c.fmt(fmt)?,
None => fmt.write_str("*")?
}
(write!(fmt, "/{}", self.total_length)).ok();
Ok(())
}
}
#[derive(Clone, PartialEq, Debug)]
pub struct RangeResponseHeader(pub Chunk);
impl Header for RangeResponseHeader {
fn header_name() -> &'static str {
"Range"
}
fn parse_header(raw: &[Vec<u8>]) -> hyper::error::Result<Self> {
if raw.len() > 0 {
let v = &raw[0];
if let Ok(s) = std::str::from_utf8(v) {
const PREFIX: &'static str = "bytes ";
if s.starts_with(PREFIX) {
if let Ok(c) = <Chunk as FromStr>::from_str(&s[PREFIX.len()..]) {
return Ok(RangeResponseHeader(c))
}
}
}
}
Err(hyper::error::Error::Method)
}
}
impl HeaderFormat for RangeResponseHeader {
/// No implmentation necessary, we just need to parse
fn fmt_header(&self, _: &mut fmt::Formatter) -> fmt::Result {
Err(fmt::Error)
}
}
/// A utility type to perform a resumable upload from start to end.
pub struct ResumableUploadHelper<'a, A: 'a> {
pub client: &'a mut hyper::client::Client,
pub delegate: &'a mut dyn Delegate,
pub start_at: Option<u64>,
pub auth: &'a mut A,
pub user_agent: &'a str,
pub auth_header: Authorization<Bearer>,
pub url: &'a str,
pub reader: &'a mut dyn ReadSeek,
pub media_type: Mime,
pub content_length: u64
}
impl<'a, A> ResumableUploadHelper<'a, A>
where A: oauth2::GetToken {
fn query_transfer_status(&mut self) -> std::result::Result<u64, hyper::Result<hyper::client::Response>> {
loop {
match self.client.post(self.url)
.header(UserAgent(self.user_agent.to_string()))
.header(ContentRange { range: None, total_length: self.content_length })
.header(self.auth_header.clone())
.send() {
Ok(r) => {
// 308 = resume-incomplete == PermanentRedirect
let headers = r.headers.clone();
let h: &RangeResponseHeader = match headers.get() {
Some(hh) if r.status == StatusCode::PermanentRedirect => hh,
None|Some(_) => {
if let Retry::After(d) = self.delegate.http_failure(&r, None, None) {
sleep(d);
continue;
}
return Err(Ok(r))
}
};
return Ok(h.0.last)
}
Err(err) => {
if let Retry::After(d) = self.delegate.http_error(&err) {
sleep(d);
continue;
}
return Err(Err(err))
}
}
}
}
/// returns None if operation was cancelled by delegate, or the HttpResult.
/// It can be that we return the result just because we didn't understand the status code -
/// caller should check for status himself before assuming it's OK to use
pub fn upload(&mut self) -> Option<hyper::Result<hyper::client::Response>> {
let mut start = match self.start_at {
Some(s) => s,
None => match self.query_transfer_status() {
Ok(s) => s,
Err(result) => return Some(result)
}
};
const MIN_CHUNK_SIZE: u64 = 1 << 18;
let chunk_size = match self.delegate.chunk_size() {
cs if cs > MIN_CHUNK_SIZE => cs,
_ => MIN_CHUNK_SIZE
};
self.reader.seek(SeekFrom::Start(start)).unwrap();
loop {
let request_size = match self.content_length - start {
rs if rs > chunk_size => chunk_size,
rs => rs
};
let mut section_reader = self.reader.take(request_size);
let range_header = ContentRange {
range: Some(Chunk {first: start, last: start + request_size - 1}),
total_length: self.content_length
};
start += request_size;
if self.delegate.cancel_chunk_upload(&range_header) {
return None
}
let res = self.client.post(self.url)
.header(range_header)
.header(ContentType(self.media_type.clone()))
.header(UserAgent(self.user_agent.to_string()))
.body(&mut section_reader)
.send();
match res {
Ok(mut res) => {
if res.status == StatusCode::PermanentRedirect {
continue
}
if !res.status.is_success() {
let mut json_err = String::new();
res.read_to_string(&mut json_err).unwrap();
if let Retry::After(d) = self.delegate.http_failure(&res,
json::from_str(&json_err).ok(),
json::from_str(&json_err).ok()) {
sleep(d);
continue;
}
}
return Some(Ok(res))
},
Err(err) => {
if let Retry::After(d) = self.delegate.http_error(&err) {
sleep(d);
continue;
}
return Some(Err(err))
}
}
}
}
}
// Copy of src/rust/cli/cmn.rs
// TODO(ST): Allow sharing common code between program types
pub fn remove_json_null_values(value: &mut json::value::Value) {
match *value {
json::value::Value::Object(ref mut map) => {
let mut for_removal = Vec::new();
for (key, mut value) in map.iter_mut() {
if value.is_null() {
for_removal.push(key.clone());
} else {
remove_json_null_values(&mut value);
}
}
for key in &for_removal {
map.remove(key);
}
}
json::value::Value::Array(ref mut arr) => {
let mut i = 0;
while i < arr.len() {
if arr[i].is_null() {
arr.remove(i);
} else {
remove_json_null_values(&mut arr[i]);
i += 1;
}
}
}
_ => {}
}
}

22461
gen/mybusiness4/src/lib.rs Normal file

File diff suppressed because it is too large Load Diff