Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Re-writing the sample.
Browse files Browse the repository at this point in the history
* Changing auth to usable auth piggybacking on gcloud credentials.
* Providing succinct examples for listing, insterting, and deleting instances.
* Following current convention of main() and run() functions.
* Adding markers for direct inclusion into cloud docs.
  • Loading branch information
Jon Parrott committed Mar 27, 2015
1 parent 87efa4b commit f266f79
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 701 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
indent_size = 4
38 changes: 0 additions & 38 deletions CONTRIB.md

This file was deleted.

35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# How to become a contributor and submit your own code

## Contributor License Agreements

We'd love to accept your sample apps and patches! Before we can take them, we
have to jump a couple of legal hurdles.

Please fill out either the individual or corporate Contributor License Agreement
(CLA).

* If you are an individual writing original source code and you're sure you
own the intellectual property, then you'll need to sign an [individual CLA]
(https://developers.google.com/open-source/cla/individual).
* If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a [corporate CLA]
(https://developers.google.com/open-source/cla/corporate).

Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it. Once we receive it, we'll be able to
accept your pull requests.

## Contributing A Patch

1. Submit an issue describing your proposed change to the repo in question.
1. The repo owner will respond to your issue promptly.
1. If your proposed change is accepted, and you haven't already done so, sign a
Contributor License Agreement (see details above).
1. Fork the desired repo, develop and test your code changes.
1. Ensure that your code adheres to the existing style in the sample to which
you are contributing. Refer to the
[Google Cloud Platform Samples Style Guide]
(https://github.com/GoogleCloudPlatform/Template/wiki/style.html) for the
recommended coding standards for this organization.
1. Ensure that your code has an appropriate set of unit tests which all pass.
1. Submit a pull request.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2015 Google, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
81 changes: 40 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
# Getting Started with Compute Engine and the Google Python Client Library

Google Compute Engine features a RESTful API that allows developers to
run virtual machines in the cloud. This sample python command-line application
demonstrates how to access the Compute Engine API using the Google Python API
Client Library. For more information about the library, read the
[Getting Started: Google Python Client Library documentation][1].
[Google Compute Engine](https://cloud.google.com/compute/) features a [RESTful API](https://cloud.google.com/compute/docs/api/getting-started)
that allows developers to run virtual machines in the cloud. This sample python command-line application demonstrates how to access the Compute Engine API using the
[Google Python API Client Library](https://developers.google.com/api-client-library/python/).

To run the demo:

- Update the variables in the settings.json file.
- <your-project-id>: your Compute Engine [project ID][2].
- Update the client_secrets.json file with your client id and secret found in
the [Google APIs Console][3].
- Run the sample using the command:
## Pre-requisites

1. Create a project on the [Google Developers Console](https://console.developers.google.com) and [enable billing](https://console.developers.google.com/project/_/settings).
2. Install the [Google Cloud SDK](https://cloud.google.com/sdk/)

```bash
curl https://sdk.cloud.google.com | bash
gcloud auth login
gcloud config set project your-project-id
```
3. Install dependencies using [pip](https://pypi.python.org/pypi/pip)

```bash
pip install -r requirements.txt
```

## Running the sample

```bash
python main.py
```

The sample will:
1. Create an instance with a start up script and metadata.
2. Print out the URL where the modified image will be written.
3. Waits for input from the user and then delete the instance.

Demo steps:
The start up script executes these steps on the instance:
1. Installs Image Magick on the machine.
2. Downloads the image from the URL provided in the metadata.
3. Adds the text provided in the metadata to the image.
4. Copies the edited image to Cloud Storage.

- Create an instance with a start up script and metadata.
- Print out the URL where the modified image will be written.
- The start up script executes these steps on the instance:
- Installs Image Magick on the machine.
- Downloads the image from the URL provided in the metadata.
- Adds the text provided in the metadata to the image.
- Copies the edited image to Cloud Storage.
- After recieving input from the user, shut down the instance.

## Products
- [Google Compute Engine][4]
- [Google Cloud Storage][5]
- [Google Compute Engine](https://developers.google.com/compute)
- [Google Cloud Storage](https://developers.google.com/storage)

## Language
- [Python][6]

## Dependencies
- [Google APIs Client Library for Python][7]
- [python-gflags][8]
- [httplib2][9]
## Contributing changes

Python dependencies can be installed via pip:
```
pip install -r requirements.txt
```
* See [CONTRIBUTING.md](CONTRIBUTING.md)


## Licensing

[1]: https://developers.google.com/compute/docs/api/python_guide
[2]: https://developers.google.com/compute/docs/overview#concepts
[3]: https://code.google.com/apis/console
[4]: https://developers.google.com/compute
[5]: https://developers.google.com/storage
[6]: https://python.org
[7]: http://code.google.com/p/google-api-python-client/
[8]: https://code.google.com/p/python-gflags/
[9]: https://code.google.com/p/httplib2/
* See [LICENSE](LICENSE)
9 changes: 0 additions & 9 deletions client_secrets.json

This file was deleted.

Loading

0 comments on commit f266f79

Please sign in to comment.