Skip to content
Permalink
Browse files
feat!: use microgenerator (#94)
The bulk of the changes are to the handwritten code (`gogle/cloud/logging_v2/*.py`). Changes are listed in `UPGRADING.md`.

* `_gapic` uses the microgenerated surface
* Add support for parent resources that are not `project` (`folder`, `billingAccount`, `organization`) where appropriate for log entries and sinks.
* Use google-style docstrings
* Optional params can only be passed as kwargs
  • Loading branch information
busunkim96 committed Nov 19, 2020
1 parent c722d2d commit ff90fd2fb54c612fe6ab29708a2d5d984f60dea7
Showing with 26,566 additions and 15,029 deletions.
  1. +13 −0 .github/sync-repo-settings.yml
  2. +1 −1 .kokoro/docs/common.cfg
  3. +13 −37 .kokoro/release/common.cfg
  4. +6 −0 .kokoro/samples/python3.6/common.cfg
  5. +6 −0 .kokoro/samples/python3.7/common.cfg
  6. +6 −0 .kokoro/samples/python3.8/common.cfg
  7. +10 −5 .kokoro/trampoline.sh
  8. +87 −36 CODE_OF_CONDUCT.md
  9. +4 −4 README.rst
  10. +337 −0 UPGRADING.md
  11. +1 −0 docs/UPGRADING.md
  12. +2 −2 docs/_templates/layout.html
  13. +1 −1 docs/client.rst
  14. +1 −0 docs/conf.py
  15. +1 −1 docs/entries.rst
  16. +1 −1 docs/handlers-app-engine.rst
  17. +1 −1 docs/handlers-container-engine.rst
  18. +1 −1 docs/handlers.rst
  19. +11 −0 docs/index.rst
  20. +1 −1 docs/logger.rst
  21. +1 −1 docs/metric.rst
  22. +6 −0 docs/resource.rst
  23. +1 −1 docs/sink.rst
  24. +2 −2 docs/snippets.py
  25. +5 −5 docs/stdlib-usage.rst
  26. +1 −1 docs/transports-base.rst
  27. +1 −1 docs/transports-sync.rst
  28. +1 −1 docs/transports-thread.rst
  29. +1 −0 docs/v2.rst
  30. +40 −17 google/cloud/logging/__init__.py
  31. +0 −574 google/cloud/logging/_gapic.py
  32. +0 −540 google/cloud/logging/_http.py
  33. +0 −407 google/cloud/logging/client.py
  34. +0 −386 google/cloud/logging/logger.py
  35. +2 −0 google/cloud/logging/py.typed
  36. +0 −220 google/cloud/logging/sink.py
  37. +39 −21 google/cloud/logging_v2/__init__.py
  38. +562 −0 google/cloud/logging_v2/_gapic.py
  39. +38 −39 google/cloud/{logging → logging_v2}/_helpers.py
  40. +525 −0 google/cloud/logging_v2/_http.py
  41. +384 −0 google/cloud/logging_v2/client.py
  42. +51 −79 google/cloud/{logging → logging_v2}/entries.py
  43. 0 google/cloud/logging_v2/gapic/__init__.py
  44. +0 −1,442 google/cloud/logging_v2/gapic/config_service_v2_client.py
  45. +0 −93 google/cloud/logging_v2/gapic/config_service_v2_client_config.py
  46. +0 −215 google/cloud/logging_v2/gapic/enums.py
  47. +0 −806 google/cloud/logging_v2/gapic/logging_service_v2_client.py
  48. +0 −62 google/cloud/logging_v2/gapic/logging_service_v2_client_config.py
  49. +0 −650 google/cloud/logging_v2/gapic/metrics_service_v2_client.py
  50. +0 −48 google/cloud/logging_v2/gapic/metrics_service_v2_client_config.py
  51. 0 google/cloud/logging_v2/gapic/transports/__init__.py
  52. +0 −306 google/cloud/logging_v2/gapic/transports/config_service_v2_grpc_transport.py
  53. +0 −192 google/cloud/logging_v2/gapic/transports/logging_service_v2_grpc_transport.py
  54. +0 −181 google/cloud/logging_v2/gapic/transports/metrics_service_v2_grpc_transport.py
  55. +4 −4 google/cloud/{logging → logging_v2}/handlers/__init__.py
  56. +9 −9 google/cloud/{logging → logging_v2}/handlers/_helpers.py
  57. +24 −24 google/cloud/{logging → logging_v2}/handlers/app_engine.py
  58. +12 −12 google/cloud/{logging → logging_v2}/handlers/container_engine.py
  59. +37 −47 google/cloud/{logging → logging_v2}/handlers/handlers.py
  60. +1 −1 google/cloud/{logging → logging_v2}/handlers/middleware/__init__.py
  61. +6 −5 google/cloud/{logging → logging_v2}/handlers/middleware/request.py
  62. +3 −3 google/cloud/{logging → logging_v2}/handlers/transports/__init__.py
  63. +75 −107 google/cloud/{logging → logging_v2}/handlers/transports/background_thread.py
  64. +8 −13 google/cloud/{logging → logging_v2}/handlers/transports/base.py
  65. +12 −16 google/cloud/{logging → logging_v2}/handlers/transports/sync.py
  66. +382 −0 google/cloud/logging_v2/logger.py
  67. +60 −65 google/cloud/{logging → logging_v2}/metric.py
  68. 0 google/cloud/logging_v2/proto/__init__.py
  69. +47 −60 google/cloud/logging_v2/proto/log_entry.proto
  70. +0 −881 google/cloud/logging_v2/proto/log_entry_pb2.py
  71. +0 −2 google/cloud/logging_v2/proto/log_entry_pb2_grpc.py
  72. +52 −50 google/cloud/logging_v2/proto/logging.proto
  73. +361 −109 google/cloud/logging_v2/proto/logging_config.proto
  74. +0 −2,368 google/cloud/logging_v2/proto/logging_config_pb2.py
  75. +0 −259 google/cloud/logging_v2/proto/logging_config_pb2_grpc.py
  76. +21 −21 google/cloud/logging_v2/proto/logging_metrics.proto
  77. +0 −1,045 google/cloud/logging_v2/proto/logging_metrics_pb2.py
  78. +0 −111 google/cloud/logging_v2/proto/logging_metrics_pb2_grpc.py
  79. +0 −1,326 google/cloud/logging_v2/proto/logging_pb2.py
  80. +0 −127 google/cloud/logging_v2/proto/logging_pb2_grpc.py
  81. +2 −0 google/cloud/logging_v2/py.typed
  82. +12 −14 google/cloud/{logging → logging_v2}/resource.py
  83. +16 −0 google/cloud/logging_v2/services/__init__.py
  84. +24 −0 google/cloud/logging_v2/services/config_service_v2/__init__.py
  85. +1,531 −0 google/cloud/logging_v2/services/config_service_v2/async_client.py
  86. +1,692 −0 google/cloud/logging_v2/services/config_service_v2/client.py
  87. +404 −0 google/cloud/logging_v2/services/config_service_v2/pagers.py
  88. +36 −0 google/cloud/logging_v2/services/config_service_v2/transports/__init__.py
  89. +405 −0 google/cloud/logging_v2/services/config_service_v2/transports/base.py
  90. +675 −0 google/cloud/logging_v2/services/config_service_v2/transports/grpc.py
  91. +702 −0 google/cloud/logging_v2/services/config_service_v2/transports/grpc_asyncio.py
  92. +24 −0 google/cloud/logging_v2/services/logging_service_v2/__init__.py
  93. +702 −0 google/cloud/logging_v2/services/logging_service_v2/async_client.py
  94. +845 −0 google/cloud/logging_v2/services/logging_service_v2/client.py
  95. +412 −0 google/cloud/logging_v2/services/logging_service_v2/pagers.py
  96. +36 −0 google/cloud/logging_v2/services/logging_service_v2/transports/__init__.py
  97. +248 −0 google/cloud/logging_v2/services/logging_service_v2/transports/base.py
  98. +384 −0 google/cloud/logging_v2/services/logging_service_v2/transports/grpc.py
  99. +394 −0 google/cloud/logging_v2/services/logging_service_v2/transports/grpc_asyncio.py
  100. +24 −0 google/cloud/logging_v2/services/metrics_service_v2/__init__.py
  101. +627 −0 google/cloud/logging_v2/services/metrics_service_v2/async_client.py
  102. +780 −0 google/cloud/logging_v2/services/metrics_service_v2/client.py
  103. +148 −0 google/cloud/logging_v2/services/metrics_service_v2/pagers.py
  104. +36 −0 google/cloud/logging_v2/services/metrics_service_v2/transports/__init__.py
  105. +234 −0 google/cloud/logging_v2/services/metrics_service_v2/transports/base.py
  106. +366 −0 google/cloud/logging_v2/services/metrics_service_v2/transports/grpc.py
  107. +377 −0 google/cloud/logging_v2/services/metrics_service_v2/transports/grpc_asyncio.py
  108. +233 −0 google/cloud/logging_v2/sink.py
  109. +0 −72 google/cloud/logging_v2/types.py
  110. +116 −0 google/cloud/logging_v2/types/__init__.py
  111. +271 −0 google/cloud/logging_v2/types/log_entry.py
  112. +394 −0 google/cloud/logging_v2/types/logging.py
  113. +960 −0 google/cloud/logging_v2/types/logging_config.py
  114. +327 −0 google/cloud/logging_v2/types/logging_metrics.py
  115. +3 −0 mypy.ini
  116. +3 −1 noxfile.py
  117. +7 −22 samples/snippets/README.rst
  118. +3 −3 samples/snippets/README.rst.in
  119. +36 −43 samples/snippets/export.py
  120. +11 −13 samples/snippets/export_test.py
  121. +3 −3 samples/snippets/handler.py
  122. +1 −1 samples/snippets/handler_test.py
  123. +32 −15 samples/snippets/noxfile.py
  124. +4 −4 samples/snippets/quickstart.py
  125. +1 −1 samples/snippets/quickstart_test.py
  126. +30 −25 samples/snippets/snippets.py
  127. +2 −2 samples/snippets/snippets_test.py
  128. +14 −1 scripts/decrypt-secrets.sh
  129. +203 −0 scripts/fixup_logging_v2_keywords.py
  130. +3 −3 setup.py
  131. +6 −6 synth.metadata
  132. +32 −19 synth.py
  133. +2 −4 tests/system/gapic/v2/test_system_logging_service_v2_v2.py
  134. +28 −17 tests/system/test_system.py
  135. +1 −0 tests/unit/gapic/logging_v2/__init__.py
  136. +4,382 −0 tests/unit/gapic/logging_v2/test_config_service_v2.py
  137. +2,166 −0 tests/unit/gapic/logging_v2/test_logging_service_v2.py
  138. +2,189 −0 tests/unit/gapic/logging_v2/test_metrics_service_v2.py
  139. +0 −604 tests/unit/gapic/v2/test_config_service_v2_client_v2.py
  140. +0 −262 tests/unit/gapic/v2/test_logging_service_v2_client_v2.py
  141. +0 −288 tests/unit/gapic/v2/test_metrics_service_v2_client_v2.py
  142. +4 −4 tests/unit/handlers/middleware/test_request.py
  143. +8 −8 tests/unit/handlers/test__helpers.py
  144. +5 −5 tests/unit/handlers/test_app_engine.py
  145. +1 −1 tests/unit/handlers/test_container_engine.py
  146. +6 −6 tests/unit/handlers/test_handlers.py
  147. +39 −22 tests/unit/handlers/transports/test_background_thread.py
  148. +2 −2 tests/unit/handlers/transports/test_base.py
  149. +5 −5 tests/unit/handlers/transports/test_sync.py
  150. +259 −237 tests/unit/test__gapic.py
  151. +9 −9 tests/unit/test__helpers.py
  152. +68 −63 tests/unit/test__http.py
  153. +65 −62 tests/unit/test_client.py
  154. +17 −17 tests/unit/test_entries.py
  155. +58 −54 tests/unit/test_logger.py
  156. +29 −0 tests/unit/test_logging_shim.py
  157. +31 −22 tests/unit/test_metric.py
  158. +83 −43 tests/unit/test_sink.py
@@ -0,0 +1,13 @@
# https://github.com/googleapis/repo-automation-bots/tree/master/packages/sync-repo-settings
# Rules for master branch protection
branchProtectionRules:
# Identifies the protection rule pattern. Name of the branch to be protected.
# Defaults to `master`
- pattern: master
requiredStatusCheckContexts:
- 'Kokoro'
- 'cla/google'
- 'Samples - Lint'
- 'Samples - Python 3.6'
- 'Samples - Python 3.7'
- 'Samples - Python 3.8'
@@ -30,7 +30,7 @@ env_vars: {

env_vars: {
key: "V2_STAGING_BUCKET"
value: "docs-staging-v2-staging"
value: "docs-staging-v2"
}

# It will upload the docker image after successful builds.
@@ -23,42 +23,18 @@ env_vars: {
value: "github/python-logging/.kokoro/release.sh"
}

# Fetch the token needed for reporting release status to GitHub
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "yoshi-automation-github-key"
}
}
}

# Fetch PyPI password
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "google_cloud_pypi_password"
}
}
}

# Fetch magictoken to use with Magic Github Proxy
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "releasetool-magictoken"
}
}
# Fetch PyPI password
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "google_cloud_pypi_password"
}
}
}

# Fetch api key to use with Magic Github Proxy
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "magic-github-proxy-api-key"
}
}
}
# Tokens needed to report release status back to GitHub
env_vars: {
key: "SECRET_MANAGER_KEYS"
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
}
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.6"
}

# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py36"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-logging/.kokoro/test-samples.sh"
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.7"
}

# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py37"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-logging/.kokoro/test-samples.sh"
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.8"
}

# Declare build specific Cloud project.
env_vars: {
key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
value: "python-docs-samples-tests-py38"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-logging/.kokoro/test-samples.sh"
@@ -15,9 +15,14 @@

set -eo pipefail

python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" || ret_code=$?
# Always run the cleanup script, regardless of the success of bouncing into
# the container.
function cleanup() {
chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
echo "cleanup";
}
trap cleanup EXIT

chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
${KOKORO_GFILE_DIR}/trampoline_cleanup.sh || true

exit ${ret_code}
$(dirname $0)/populate-secrets.sh # Secret Manager secrets.
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"
@@ -1,44 +1,95 @@
<!-- # Generated by synthtool. DO NOT EDIT! !-->
# Contributor Code of Conduct
# Code of Conduct

As contributors and maintainers of this project,
and in the interest of fostering an open and welcoming community,
we pledge to respect all people who contribute through reporting issues,
posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.
## Our Pledge

We are committed to making participation in this project
a harassment-free experience for everyone,
regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information,
such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct.
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct.
By adopting this Code of Conduct,
project maintainers commit themselves to fairly and consistently
applying these principles to every aspect of managing this project.
Project maintainers who do not follow or enforce the Code of Conduct
may be permanently removed from the project team.

This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by opening an issue
or contacting one or more of the project maintainers.

This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

This Code of Conduct also applies outside the project spaces when the Project
Steward has a reasonable belief that an individual's behavior may have a
negative impact on the project or its community.

## Conflict Resolution

We do not believe that all conflict is bad; healthy debate and disagreement
often yield positive results. However, it is never okay to be disrespectful or
to engage in behavior that violates the project’s code of conduct.

If you see someone violating the code of conduct, you are encouraged to address
the behavior directly with those involved. Many issues can be resolved quickly
and easily, and this gives people more control over the outcome of their
dispute. If you are unable to resolve the matter for any reason, or if the
behavior is threatening or harassing, report it. We are dedicated to providing
an environment where participants feel welcome and safe.


Reports should be directed to *googleapis-stewards@google.com*, the
Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to
receive and address reported violations of the code of conduct. They will then
work with a committee consisting of representatives from the Open Source
Programs Office and the Google Open Source Strategy team. If for any reason you
are uncomfortable reaching out to the Project Steward, please email
opensource@google.com.

We will investigate every complaint, but you may not receive a direct response.
We will use our discretion in determining when and how to follow up on reported
incidents, which may range from not taking action to permanent expulsion from
the project and project-sponsored spaces. We will notify the accused of the
report and provide them an opportunity to discuss it before any action is taken.
The identity of the reporter will be omitted from the details of the report
supplied to the accused. In potentially harmful situations, such as ongoing
harassment or threats to anyone's safety, we may take action without notice.

## Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
@@ -50,11 +50,11 @@ dependencies.

Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.5
Python >= 3.6

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. Python 2.7 support was removed on January 1, 2020.
Unsupported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. The last version of the library compatible with Python 2.7 is `google-cloud-logging==1.15.1`.


Mac/Linux

0 comments on commit ff90fd2

Please sign in to comment.