Skip to content
This repository was archived by the owner on Mar 15, 2025. It is now read-only.

Commit 8aaa847

Browse files
authored
feat: add v2 (#21)
1 parent 4d84b7d commit 8aaa847

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+7347
-239
lines changed

.coveragerc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
fail_under = 100
6+
show_missing = True
7+
omit =
8+
google/cloud/orgpolicy/__init__.py
9+
exclude_lines =
10+
# Re-enable the standard pragma
11+
pragma: NO COVER
12+
# Ignore debug-only repr
13+
def __repr__
14+
# Ignore pkg_resources exceptions.
15+
# This is added at the module level as a safeguard for if someone
16+
# generates the code and tries to run it without pip installing. This
17+
# makes it virtually impossible to test properly.
18+
except pkg_resources.DistributionNotFound

.github/header-checker-lint.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{"allowedCopyrightHolders": ["Google LLC"],
2+
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
3+
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
4+
"sourceFileExtensions": [
5+
"ts",
6+
"js",
7+
"java",
8+
"sh",
9+
"Dockerfile",
10+
"yaml",
11+
"py",
12+
"html",
13+
"txt"
14+
]
15+
}

.gitignore

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
dist
1111
build
1212
eggs
13+
.eggs
1314
parts
1415
bin
1516
var
@@ -45,17 +46,18 @@ pip-log.txt
4546
# Built documentation
4647
docs/_build
4748
bigquery/docs/generated
49+
docs.metadata
4850

4951
# Virtual environment
5052
env/
53+
54+
# Test logs
5155
coverage.xml
56+
*sponge_log.xml
5257

5358
# System test environment variables.
5459
system_tests/local_test_setup
5560

5661
# Make sure a generated file isn't accidentally committed.
5762
pylintrc
5863
pylintrc.test
59-
60-
# Exclude python-asset which is copied for testing
61-
python-asset/

.kokoro/build.sh

+20-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515

1616
set -eo pipefail
1717

18-
cd github/python-org-policy
18+
if [[ -z "${PROJECT_ROOT:-}" ]]; then
19+
PROJECT_ROOT="github/python-org-policy"
20+
fi
21+
22+
cd "${PROJECT_ROOT}"
1923

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

3236
# Remove old nox
33-
python3.6 -m pip uninstall --yes --quiet nox-automation
37+
python3 -m pip uninstall --yes --quiet nox-automation
3438

3539
# Install nox
36-
python3.6 -m pip install --upgrade --quiet nox
37-
python3.6 -m nox --version
40+
python3 -m pip install --upgrade --quiet nox
41+
python3 -m nox --version
42+
43+
# If this is a continuous build, send the test log to the FlakyBot.
44+
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
45+
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
46+
cleanup() {
47+
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
48+
$KOKORO_GFILE_DIR/linux_amd64/flakybot
49+
}
50+
trap cleanup EXIT HUP
51+
fi
3852

3953
# If NOX_SESSION is set, it only runs the specified session,
4054
# otherwise run all the sessions.
4155
if [[ -n "${NOX_SESSION:-}" ]]; then
42-
python3.6 -m nox -s "${NOX_SESSION:-}"
56+
python3 -m nox -s ${NOX_SESSION:-}
4357
else
44-
python3.6 -m nox
58+
python3 -m nox
4559
fi

.kokoro/docs/docs-presubmit.cfg

+11
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,14 @@ env_vars: {
1515
key: "TRAMPOLINE_IMAGE_UPLOAD"
1616
value: "false"
1717
}
18+
19+
env_vars: {
20+
key: "TRAMPOLINE_BUILD_FILE"
21+
value: "github/python-org-policy/.kokoro/build.sh"
22+
}
23+
24+
# Only run this nox session.
25+
env_vars: {
26+
key: "NOX_SESSION"
27+
value: "docs docfx"
28+
}

.repo-metadata.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"name": "orgpolicy",
33
"name_pretty": "Organization Policy",
4+
"product_documentation": "https://cloud.google.com/resource-manager/docs/organization-policy/overview",
45
"client_documentation": "https://googleapis.dev/python/orgpolicy/latest",
5-
"issue_tracker": "https://github.com/googleapis/python-orgpolicy/issues",
6+
"issue_tracker": "",
67
"release_level": "beta",
78
"language": "python",
89
"repo": "googleapis/python-org-policy",
9-
"distribution_name": "google-cloud-org-policy"
10+
"distribution_name": "google-cloud-org-policy",
11+
"api_id": "orgpolicy.googleapis.com"
1012
}

.trampolinerc

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ required_envvars+=(
2424
pass_down_envvars+=(
2525
"STAGING_BUCKET"
2626
"V2_STAGING_BUCKET"
27+
"NOX_SESSION"
2728
)
2829

2930
# Prevent unintentional override on the default image.

CONTRIBUTING.rst

+18-4
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
7070
- To test your changes, run unit tests with ``nox``::
7171

7272
$ nox -s unit-2.7
73-
$ nox -s unit-3.7
73+
$ nox -s unit-3.8
7474
$ ...
7575

76+
- Args to pytest can be passed through the nox command separated by a `--`. For
77+
example, to run a single test::
78+
79+
$ nox -s unit-3.8 -- -k <name of test>
80+
7681
.. note::
7782

7883
The unit tests and system tests are described in the
@@ -93,8 +98,12 @@ On Debian/Ubuntu::
9398
************
9499
Coding Style
95100
************
101+
- We use the automatic code formatter ``black``. You can run it using
102+
the nox session ``blacken``. This will eliminate many lint errors. Run via::
103+
104+
$ nox -s blacken
96105

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

@@ -133,13 +142,18 @@ Running System Tests
133142

134143
- To run system tests, you can execute::
135144

136-
$ nox -s system-3.7
145+
# Run all system tests
146+
$ nox -s system-3.8
137147
$ nox -s system-2.7
138148

149+
# Run a single system test
150+
$ nox -s system-3.8 -- -k <name of test>
151+
152+
139153
.. note::
140154

141155
System tests are only configured to run under Python 2.7 and
142-
Python 3.7. For expediency, we do not run them in older versions
156+
Python 3.8. For expediency, we do not run them in older versions
143157
of Python 3.
144158

145159
This alone will not run the tests. You'll need to change some local

MANIFEST.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
# Generated by synthtool. DO NOT EDIT!
1818
include README.rst LICENSE
19-
recursive-include google *.json *.proto
19+
recursive-include google *.json *.proto py.typed
2020
recursive-include tests *
2121
global-exclude *.py[co]
2222
global-exclude __pycache__
2323

2424
# Exclude scripts for samples readmegen
25-
prune scripts/readme-gen
25+
prune scripts/readme-gen

README.md

-1
This file was deleted.

README.rst

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Python Client for Organization Policy
2+
=================================================
3+
4+
|beta| |pypi| |versions|
5+
6+
`Organization Policy`_: The Organization Policy API allows users to configure governance rules on their GCP
7+
resources across the Cloud Resource Hierarchy.
8+
9+
- `Client Library Documentation`_
10+
- `Product Documentation`_
11+
12+
.. |beta| image:: https://img.shields.io/badge/support-beta-orange.svg
13+
:target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#beta-support
14+
.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-org-policy.svg
15+
:target: https://pypi.org/project/google-cloud-org-policy/
16+
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-org-policy.svg
17+
:target: https://pypi.org/project/google-cloud-org-policy/
18+
.. _Organization Policy: https://cloud.google.com/resource-manager/docs/organization-policy/overview
19+
.. _Client Library Documentation: https://googleapis.dev/python/orgpolicy/latest
20+
.. _Product Documentation: https://cloud.google.com/resource-manager/docs/organization-policy/overview
21+
22+
Quick Start
23+
-----------
24+
25+
In order to use this library, you first need to go through the following steps:
26+
27+
1. `Select or create a Cloud Platform project.`_
28+
2. `Enable billing for your project.`_
29+
3. `Enable the Organization Policy API.`_
30+
4. `Setup Authentication.`_
31+
32+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
33+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
34+
.. _Enable the Organization Policy API.: https://cloud.google.com/resource-manager/docs/organization-policy/overview
35+
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
36+
37+
Installation
38+
~~~~~~~~~~~~
39+
40+
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
41+
create isolated Python environments. The basic problem it addresses is one of
42+
dependencies and versions, and indirectly permissions.
43+
44+
With `virtualenv`_, it's possible to install this library without needing system
45+
install permissions, and without clashing with the installed system
46+
dependencies.
47+
48+
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
49+
50+
51+
Mac/Linux
52+
^^^^^^^^^
53+
54+
.. code-block:: console
55+
56+
pip install virtualenv
57+
virtualenv <your-env>
58+
source <your-env>/bin/activate
59+
<your-env>/bin/pip install google-cloud-org-policy
60+
61+
62+
Windows
63+
^^^^^^^
64+
65+
.. code-block:: console
66+
67+
pip install virtualenv
68+
virtualenv <your-env>
69+
<your-env>\Scripts\activate
70+
<your-env>\Scripts\pip.exe install google-cloud-org-policy
71+
72+
Next Steps
73+
~~~~~~~~~~
74+
75+
- Read the `Client Library Documentation`_ for Organization Policy
76+
to see other available methods on the client.
77+
- Read the `Organization Policy Product documentation`_ to learn
78+
more about the product and see How-to Guides.
79+
- View this `README`_ to see the full list of Cloud
80+
APIs that we cover.
81+
82+
.. _Organization Policy Product documentation: https://cloud.google.com/resource-manager/docs/organization-policy/overview
83+
.. _README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst

docs/README.md

-1
This file was deleted.

docs/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.rst

docs/conf.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,9 @@
347347
intersphinx_mapping = {
348348
"python": ("https://python.readthedocs.org/en/latest/", None),
349349
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
350-
"google.api_core": (
351-
"https://googleapis.dev/python/google-api-core/latest/",
352-
None,
353-
),
350+
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
354351
"grpc": ("https://grpc.github.io/grpc/python/", None),
355352
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
356-
357353
}
358354

359355

docs/index.rst

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
.. include:: README.md
21

2+
.. include:: README.rst
3+
4+
.. include:: multiprocessing.rst
5+
6+
API Reference
7+
-------------
38
.. toctree::
49
:maxdepth: 2
510

6-
v1
11+
orgpolicy_v2/services
12+
orgpolicy_v2/types
713

8-
.. include:: multiprocessing.rst
914

1015
Changelog
1116
---------
1217

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

1520
.. toctree::
16-
:maxdepth: 2
21+
:maxdepth: 2
1722

18-
changelog
23+
changelog

docs/orgpolicy_v2/org_policy.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
OrgPolicy
2+
---------------------------
3+
4+
.. automodule:: google.cloud.orgpolicy_v2.services.org_policy
5+
:members:
6+
:inherited-members:
7+
8+
9+
.. automodule:: google.cloud.orgpolicy_v2.services.org_policy.pagers
10+
:members:
11+
:inherited-members:

docs/orgpolicy_v2/services.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Orgpolicy v2 API
2+
==========================================
3+
.. toctree::
4+
:maxdepth: 2
5+
6+
org_policy

docs/orgpolicy_v2/types.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Types for Google Cloud Orgpolicy v2 API
2+
=======================================
3+
4+
.. automodule:: google.cloud.orgpolicy_v2.types
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:

docs/v1.rst

-6
This file was deleted.

0 commit comments

Comments
 (0)