Skip to content

Commit c1d1f0d

Browse files
author
Jon Wayne Parrott
authored
Generate readmes for most service samples [(googleapis#599)](GoogleCloudPlatform/python-docs-samples#599)
1 parent 958a4f9 commit c1d1f0d

File tree

3 files changed

+189
-36
lines changed

3 files changed

+189
-36
lines changed

samples/snippets/README.md

-36
This file was deleted.

samples/snippets/README.rst

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
.. This file is automatically generated. Do not edit this file directly.
2+
3+
Stackdriver Logging Python Samples
4+
===============================================================================
5+
6+
This directory contains samples for Stackdriver Logging. `Stackdriver Logging`_ allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud Platform and Amazon Web Services.
7+
8+
9+
10+
11+
.. _Stackdriver Logging: https://cloud.google.com/logging/docs
12+
13+
Setup
14+
-------------------------------------------------------------------------------
15+
16+
17+
Authentication
18+
++++++++++++++
19+
20+
Authentication is typically done through `Application Default Credentials`_,
21+
which means you do not have to change the code to authenticate as long as
22+
your environment has credentials. You have a few options for setting up
23+
authentication:
24+
25+
#. When running locally, use the `Google Cloud SDK`_
26+
27+
.. code-block:: bash
28+
29+
gcloud beta auth application-default login
30+
31+
32+
#. When running on App Engine or Compute Engine, credentials are already
33+
set-up. However, you may need to configure your Compute Engine instance
34+
with `additional scopes`_.
35+
36+
#. You can create a `Service Account key file`_. This file can be used to
37+
authenticate to Google Cloud Platform services from any environment. To use
38+
the file, set the ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable to
39+
the path to the key file, for example:
40+
41+
.. code-block:: bash
42+
43+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
44+
45+
.. _Application Default Credentials: https://cloud.google.com/docs/authentication#getting_credentials_for_server-centric_flow
46+
.. _additional scopes: https://cloud.google.com/compute/docs/authentication#using
47+
.. _Service Account key file: https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount
48+
49+
Install Dependencies
50+
++++++++++++++++++++
51+
52+
#. Install `pip`_ and `virtualenv`_ if you do not already have them.
53+
54+
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
55+
56+
.. code-block:: bash
57+
58+
$ virtualenv env
59+
$ source env/bin/activate
60+
61+
#. Install the dependencies needed to run the samples.
62+
63+
.. code-block:: bash
64+
65+
$ pip install -r requirements.txt
66+
67+
.. _pip: https://pip.pypa.io/
68+
.. _virtualenv: https://virtualenv.pypa.io/
69+
70+
Samples
71+
-------------------------------------------------------------------------------
72+
73+
Quickstart
74+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
75+
76+
77+
78+
To run this sample:
79+
80+
.. code-block:: bash
81+
82+
$ python quickstart.py
83+
84+
85+
Snippets
86+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
87+
88+
89+
90+
To run this sample:
91+
92+
.. code-block:: bash
93+
94+
$ python snippets.py
95+
96+
usage: snippets.py [-h] logger_name {list,write,delete} ...
97+
98+
This application demonstrates how to perform basic operations on logs and
99+
log entries with Stackdriver Logging.
100+
101+
For more information, see the README.md under /logging and the
102+
documentation at https://cloud.google.com/logging/docs.
103+
104+
positional arguments:
105+
logger_name Logger name
106+
{list,write,delete}
107+
list Lists the most recent entries for a given logger.
108+
write Writes log entries to the given logger.
109+
delete Deletes a logger and all its entries. Note that a
110+
deletion can take several minutes to take effect.
111+
112+
optional arguments:
113+
-h, --help show this help message and exit
114+
115+
116+
Export
117+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118+
119+
120+
121+
To run this sample:
122+
123+
.. code-block:: bash
124+
125+
$ python export.py
126+
127+
usage: export.py [-h] {list,create,update,delete} ...
128+
129+
positional arguments:
130+
{list,create,update,delete}
131+
list Lists all sinks.
132+
create Lists all sinks.
133+
update Changes a sink's filter. The filter determines which
134+
logs this sink matches and will be exported to the
135+
destination. For example a filter of 'severity>=INFO'
136+
will send all logs that have a severity of INFO or
137+
greater to the destination. See https://cloud.google.c
138+
om/logging/docs/view/advanced_filters for more filter
139+
information.
140+
delete Deletes a sink.
141+
142+
optional arguments:
143+
-h, --help show this help message and exit
144+
145+
146+
147+
148+
The client library
149+
-------------------------------------------------------------------------------
150+
151+
This sample uses the `Google Cloud Client Library for Python`_.
152+
You can read the documentation for more details on API usage and use GitHub
153+
to `browse the source`_ and `report issues`_.
154+
155+
.. Google Cloud Client Library for Python:
156+
https://googlecloudplatform.github.io/google-cloud-python/
157+
.. browse the source:
158+
https://github.com/GoogleCloudPlatform/google-cloud-python
159+
.. report issues:
160+
https://github.com/GoogleCloudPlatform/google-cloud-python/issues
161+
162+
163+
.. _Google Cloud SDK: https://cloud.google.com/sdk/

samples/snippets/README.rst.in

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This file is used to generate README.rst
2+
3+
product:
4+
name: Stackdriver Logging
5+
short_name: Stackdriver Logging
6+
url: https://cloud.google.com/logging/docs
7+
description: >
8+
`Stackdriver Logging`_ allows you to store, search, analyze, monitor,
9+
and alert on log data and events from Google Cloud Platform and Amazon
10+
Web Services.
11+
12+
setup:
13+
- auth
14+
- install_deps
15+
16+
samples:
17+
- name: Quickstart
18+
file: quickstart.py
19+
- name: Snippets
20+
file: snippets.py
21+
show_help: true
22+
- name: Export
23+
file: export.py
24+
show_help: true
25+
26+
cloud_client_library: true

0 commit comments

Comments
 (0)