Skip to content

Commit 6543c44

Browse files
committed
Add vault API quickstart
1 parent 6982c27 commit 6543c44

File tree

3 files changed

+71
-7
lines changed

3 files changed

+71
-7
lines changed

tasks/quickstart/quickstart.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232

3333
# Call the Tasks API
3434
results = service.tasklists().list(maxResults=10).execute()
35-
items = results.get('items', [])
36-
if not items:
37-
print('No task lists found.')
38-
else:
39-
print('Task lists:')
40-
for item in items:
41-
print('{0} ({1})'.format(item['title'], item['id']))
35+
items = results.get('items', [])
36+
if not items:
37+
print('No task lists found.')
38+
else:
39+
print('Task lists:')
40+
for item in items:
41+
print('{0} ({1})'.format(item['title'], item['id']))
4242
# [END tasks_quickstart]

vault/quickstart/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Google Vault Python Quickstart
2+
3+
Complete the steps described in the [quickstart instructions](
4+
https://developers.google.com/vault/quickstart/python), and in about
5+
five minutes you'll have a simple Node.js command-line application that makes
6+
requests to the Google Vault API.
7+
8+
## Install
9+
10+
```
11+
pip install --upgrade google-api-python-client
12+
```
13+
14+
## Run
15+
16+
After following the quickstart setup instructions, run the sample:
17+
18+
```
19+
python quickstart.py
20+
```

vault/quickstart/quickstart.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

Comments
 (0)