Skip to content

Commit

Permalink
feat: add v2 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
busunkim96 committed Mar 1, 2021
1 parent 4d84b7d commit 8aaa847
Show file tree
Hide file tree
Showing 44 changed files with 7,347 additions and 239 deletions.
18 changes: 18 additions & 0 deletions .coveragerc
@@ -0,0 +1,18 @@
[run]
branch = True

[report]
fail_under = 100
show_missing = True
omit =
google/cloud/orgpolicy/__init__.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
15 changes: 15 additions & 0 deletions .github/header-checker-lint.yml
@@ -0,0 +1,15 @@
{"allowedCopyrightHolders": ["Google LLC"],
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
"sourceFileExtensions": [
"ts",
"js",
"java",
"sh",
"Dockerfile",
"yaml",
"py",
"html",
"txt"
]
}
8 changes: 5 additions & 3 deletions .gitignore
Expand Up @@ -10,6 +10,7 @@
dist
build
eggs
.eggs
parts
bin
var
Expand Down Expand Up @@ -45,17 +46,18 @@ pip-log.txt
# Built documentation
docs/_build
bigquery/docs/generated
docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
*sponge_log.xml

# System test environment variables.
system_tests/local_test_setup

# Make sure a generated file isn't accidentally committed.
pylintrc
pylintrc.test

# Exclude python-asset which is copied for testing
python-asset/
26 changes: 20 additions & 6 deletions .kokoro/build.sh
Expand Up @@ -15,7 +15,11 @@

set -eo pipefail

cd github/python-org-policy
if [[ -z "${PROJECT_ROOT:-}" ]]; then
PROJECT_ROOT="github/python-org-policy"
fi

cd "${PROJECT_ROOT}"

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1
Expand All @@ -30,16 +34,26 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")

# Remove old nox
python3.6 -m pip uninstall --yes --quiet nox-automation
python3 -m pip uninstall --yes --quiet nox-automation

# Install nox
python3.6 -m pip install --upgrade --quiet nox
python3.6 -m nox --version
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
python3.6 -m nox -s "${NOX_SESSION:-}"
python3 -m nox -s ${NOX_SESSION:-}
else
python3.6 -m nox
python3 -m nox
fi
11 changes: 11 additions & 0 deletions .kokoro/docs/docs-presubmit.cfg
Expand Up @@ -15,3 +15,14 @@ env_vars: {
key: "TRAMPOLINE_IMAGE_UPLOAD"
value: "false"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-org-policy/.kokoro/build.sh"
}

# Only run this nox session.
env_vars: {
key: "NOX_SESSION"
value: "docs docfx"
}
6 changes: 4 additions & 2 deletions .repo-metadata.json
@@ -1,10 +1,12 @@
{
"name": "orgpolicy",
"name_pretty": "Organization Policy",
"product_documentation": "https://cloud.google.com/resource-manager/docs/organization-policy/overview",
"client_documentation": "https://googleapis.dev/python/orgpolicy/latest",
"issue_tracker": "https://github.com/googleapis/python-orgpolicy/issues",
"issue_tracker": "",
"release_level": "beta",
"language": "python",
"repo": "googleapis/python-org-policy",
"distribution_name": "google-cloud-org-policy"
"distribution_name": "google-cloud-org-policy",
"api_id": "orgpolicy.googleapis.com"
}
1 change: 1 addition & 0 deletions .trampolinerc
Expand Up @@ -24,6 +24,7 @@ required_envvars+=(
pass_down_envvars+=(
"STAGING_BUCKET"
"V2_STAGING_BUCKET"
"NOX_SESSION"
)

# Prevent unintentional override on the default image.
Expand Down
22 changes: 18 additions & 4 deletions CONTRIBUTING.rst
Expand Up @@ -70,9 +70,14 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::

$ nox -s unit-2.7
$ nox -s unit-3.7
$ nox -s unit-3.8
$ ...

- Args to pytest can be passed through the nox command separated by a `--`. For
example, to run a single test::

$ nox -s unit-3.8 -- -k <name of test>

.. note::

The unit tests and system tests are described in the
Expand All @@ -93,8 +98,12 @@ On Debian/Ubuntu::
************
Coding Style
************
- We use the automatic code formatter ``black``. You can run it using
the nox session ``blacken``. This will eliminate many lint errors. Run via::

$ nox -s blacken

- PEP8 compliance, with exceptions defined in the linter configuration.
- PEP8 compliance is required, with exceptions defined in the linter configuration.
If you have ``nox`` installed, you can test that you have not introduced
any non-compliant code via::

Expand Down Expand Up @@ -133,13 +142,18 @@ Running System Tests

- To run system tests, you can execute::

$ nox -s system-3.7
# Run all system tests
$ nox -s system-3.8
$ nox -s system-2.7

# Run a single system test
$ nox -s system-3.8 -- -k <name of test>


.. note::

System tests are only configured to run under Python 2.7 and
Python 3.7. For expediency, we do not run them in older versions
Python 3.8. For expediency, we do not run them in older versions
of Python 3.

This alone will not run the tests. You'll need to change some local
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Expand Up @@ -16,10 +16,10 @@

# Generated by synthtool. DO NOT EDIT!
include README.rst LICENSE
recursive-include google *.json *.proto
recursive-include google *.json *.proto py.typed
recursive-include tests *
global-exclude *.py[co]
global-exclude __pycache__

# Exclude scripts for samples readmegen
prune scripts/readme-gen
prune scripts/readme-gen
1 change: 0 additions & 1 deletion README.md

This file was deleted.

83 changes: 83 additions & 0 deletions README.rst
@@ -0,0 +1,83 @@
Python Client for Organization Policy
=================================================

|beta| |pypi| |versions|

`Organization Policy`_: The Organization Policy API allows users to configure governance rules on their GCP
resources across the Cloud Resource Hierarchy.

- `Client Library Documentation`_
- `Product Documentation`_

.. |beta| image:: https://img.shields.io/badge/support-beta-orange.svg
:target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#beta-support
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-org-policy.svg
:target: https://pypi.org/project/google-cloud-org-policy/
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-org-policy.svg
:target: https://pypi.org/project/google-cloud-org-policy/
.. _Organization Policy: https://cloud.google.com/resource-manager/docs/organization-policy/overview
.. _Client Library Documentation: https://googleapis.dev/python/orgpolicy/latest
.. _Product Documentation: https://cloud.google.com/resource-manager/docs/organization-policy/overview

Quick Start
-----------

In order to use this library, you first need to go through the following steps:

1. `Select or create a Cloud Platform project.`_
2. `Enable billing for your project.`_
3. `Enable the Organization Policy API.`_
4. `Setup Authentication.`_

.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
.. _Enable the Organization Policy API.: https://cloud.google.com/resource-manager/docs/organization-policy/overview
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html

Installation
~~~~~~~~~~~~

Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
create isolated Python environments. The basic problem it addresses is one of
dependencies and versions, and indirectly permissions.

With `virtualenv`_, it's possible to install this library without needing system
install permissions, and without clashing with the installed system
dependencies.

.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/


Mac/Linux
^^^^^^^^^

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-org-policy
Windows
^^^^^^^

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-org-policy
Next Steps
~~~~~~~~~~

- Read the `Client Library Documentation`_ for Organization Policy
to see other available methods on the client.
- Read the `Organization Policy Product documentation`_ to learn
more about the product and see How-to Guides.
- View this `README`_ to see the full list of Cloud
APIs that we cover.

.. _Organization Policy Product documentation: https://cloud.google.com/resource-manager/docs/organization-policy/overview
.. _README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst
1 change: 0 additions & 1 deletion docs/README.md

This file was deleted.

1 change: 1 addition & 0 deletions docs/README.rst
6 changes: 1 addition & 5 deletions docs/conf.py
Expand Up @@ -347,13 +347,9 @@
intersphinx_mapping = {
"python": ("https://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
"google.api_core": (
"https://googleapis.dev/python/google-api-core/latest/",
None,
),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"grpc": ("https://grpc.github.io/grpc/python/", None),
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),

}


Expand Down
15 changes: 10 additions & 5 deletions docs/index.rst
@@ -1,18 +1,23 @@
.. include:: README.md

.. include:: README.rst

.. include:: multiprocessing.rst

API Reference
-------------
.. toctree::
:maxdepth: 2

v1
orgpolicy_v2/services
orgpolicy_v2/types

.. include:: multiprocessing.rst

Changelog
---------

For a list of all ``google-cloud-org-policy`` releases:

.. toctree::
:maxdepth: 2
:maxdepth: 2

changelog
changelog
11 changes: 11 additions & 0 deletions docs/orgpolicy_v2/org_policy.rst
@@ -0,0 +1,11 @@
OrgPolicy
---------------------------

.. automodule:: google.cloud.orgpolicy_v2.services.org_policy
:members:
:inherited-members:


.. automodule:: google.cloud.orgpolicy_v2.services.org_policy.pagers
:members:
:inherited-members:
6 changes: 6 additions & 0 deletions docs/orgpolicy_v2/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Orgpolicy v2 API
==========================================
.. toctree::
:maxdepth: 2

org_policy
7 changes: 7 additions & 0 deletions docs/orgpolicy_v2/types.rst
@@ -0,0 +1,7 @@
Types for Google Cloud Orgpolicy v2 API
=======================================

.. automodule:: google.cloud.orgpolicy_v2.types
:members:
:undoc-members:
:show-inheritance:
6 changes: 0 additions & 6 deletions docs/v1.rst

This file was deleted.

0 comments on commit 8aaa847

Please sign in to comment.