|
| 1 | +# Copyright 2018 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# [START vault_quickstart] |
| 16 | +""" |
| 17 | +Shows basic usage of the Vault API. Outputs the names and IDs of the first |
| 18 | +10 matters in Vault. |
| 19 | +""" |
| 20 | +from __future__ import print_function |
| 21 | +from apiclient.discovery import build |
| 22 | +from httplib2 import Http |
| 23 | +from oauth2client import file, client, tools |
| 24 | + |
| 25 | +# Setup the Vault API |
| 26 | +SCOPES = 'https://www.googleapis.com/auth/ediscovery' |
| 27 | +store = file.Storage('credentials.json') |
| 28 | +creds = store.get() |
| 29 | +if not creds or creds.invalid: |
| 30 | + flow = client.flow_from_clientsecrets('client_secret.json', SCOPES) |
| 31 | + creds = tools.run_flow(flow, store) |
| 32 | +service = build('vault', 'v1', http=creds.authorize(Http())) |
| 33 | + |
| 34 | +# Call the Vault API |
| 35 | +results = service.matters().list(pageSize=10).execute() |
| 36 | +matters = results.get('matters', []) |
| 37 | + |
| 38 | +if not matters: |
| 39 | + print('No matters found.') |
| 40 | +else: |
| 41 | + print('Matters:') |
| 42 | + for matter in matters: |
| 43 | + print('{} ({})'.format(matter.get('name'), matter.get('id'))) |
| 44 | +# [END vault_quickstart] |
0 commit comments