Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
feat!: move to use microgen (#54)
Browse files Browse the repository at this point in the history
* feat!: move to use microgen

* update

* Update google/cloud/monitoring_v3/query.py

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>

* Update google/cloud/monitoring_v3/query.py

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
  • Loading branch information
arithmetic1728 and busunkim96 committed Oct 6, 2020
1 parent b8ad0de commit d25e49f
Show file tree
Hide file tree
Showing 170 changed files with 44,463 additions and 27,967 deletions.
14 changes: 6 additions & 8 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ omit =
[report]
fail_under = 100
show_missing = True
omit = google/cloud/monitoring/__init__.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore abstract methods
raise NotImplementedError
omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
google/cloud/__init__.py
# 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
12 changes: 6 additions & 6 deletions .kokoro/samples/python3.6/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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-monitoring/.kokoro/test-samples.sh"
Expand All @@ -24,12 +30,6 @@ env_vars: {
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

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

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

Expand Down
12 changes: 6 additions & 6 deletions .kokoro/samples/python3.7/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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-monitoring/.kokoro/test-samples.sh"
Expand All @@ -24,12 +30,6 @@ env_vars: {
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

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

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

Expand Down
12 changes: 6 additions & 6 deletions .kokoro/samples/python3.8/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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-monitoring/.kokoro/test-samples.sh"
Expand All @@ -24,12 +30,6 @@ env_vars: {
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

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

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

Expand Down
10 changes: 6 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ dependencies.

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

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
Unsupported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7.

The last version of this library compatible with Python 2.7 is google-cloud-monitoring==1.1.0.


Mac/Linux
Expand Down
159 changes: 159 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# 2.0.0 Migration Guide

The 2.0 release of the `google-cloud-monitoring` client is a significant upgrade based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-python), and includes substantial interface changes. Existing code written for earlier versions of this library will likely require updates to use this version. This document describes the changes that have been made, and what you need to do to update your usage.

If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-monitoring/issues).

## Supported Python Versions

> **WARNING**: Breaking change
The 2.0.0 release requires Python 3.6+.


## Method Calls

> **WARNING**: Breaking change
Methods expect request objects. We provide a script that will convert most common use cases.

* Install the library

```py
python3 -m pip install google-cloud-monitoring
```

* The script `fixup_monitoring_v3_keywords.py` is shipped with the library. It expects
an input directory (with the code to convert) and an empty destination directory.

```sh
$ fixup_monitoring_v3_keywords.py --input-directory .samples/ --output-directory samples/
```

**Before:**
```py
from google.cloud import monitoring_v3

client = monitoring_v3.MetricServiceClient()

metric_descriptor = client.get_metric_descriptor("name")
```


**After:**
```py
from google.cloud import monitoring_v3

client = monitoring_v3.MetricServiceClient()

metric_descriptor = client.get_metric_descriptor(request={"name": "name"})
```

### More Details

In `google-cloud-monitoring<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.

**Before:**
```py
def create_metric_descriptor(
self,
name,
metric_descriptor,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
```

In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.

Some methods have additional keyword only parameters. The available parameters depend on the `google.api.method_signature` annotation specified by the API producer.


**After:**
```py
def create_metric_descriptor(
self,
request: metric_service.CreateMetricDescriptorRequest = None,
*,
name: str = None,
metric_descriptor: ga_metric.MetricDescriptor = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> ga_metric.MetricDescriptor:
```

> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
> Passing both will result in an error.

Both of these calls are valid:

```py
response = client.create_metric_descriptor(
request={
"name": name,
"metric_descriptor": metric_descriptor
}
)
```

```py
response = client.create_metric_descriptor(
name=name,
metric_descriptor=metric_descriptor
)
```

This call is invalid because it mixes `request` with a keyword argument `metric_descriptor`. Executing this code
will result in an error.

```py
response = client.create_metric_descriptor(
request={
"name": name,
},
metric_descriptor=metric_descriptor
)
```



## Enums and Types


> **WARNING**: Breaking change
The submodules `enums` and `types` have been removed.

**Before:**
```py
from google.cloud import monitoring_v3

launch_stage = monitoring_v3.enums.LaunchStage.ALPHA
policy = monitoring_v3.types.AlertPolicy(name="name")
```


**After:**
```py
from google.cloud import monitoring_v3

launch_stage = monitoring_v3.LaunchStage.ALPHA
policy = monitoring_v3.AlertPolicy(name="name")
```

## Project Path Helper Method

`project_path` method is renamed `common_project_path`.

**Before:**
```py
project_path = client.project_path("project_id")
```

**After:**
```py
project_path = client.common_project_path("project_id")
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
6 changes: 0 additions & 6 deletions docs/gapic/v3/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v3/types.rst

This file was deleted.

14 changes: 12 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ Api Reference
:maxdepth: 2

query.rst
gapic/v3/api
gapic/v3/types
monitoring_v3/services
monitoring_v3/types

Migration Guide
---------------

See the guide below for instructions on migrating to the 2.x release of this library.

.. toctree::
:maxdepth: 2

UPGRADING

Changelog
---------
Expand Down
21 changes: 21 additions & 0 deletions docs/monitoring_v3/services.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Services for Google Cloud Monitoring v3 API
===========================================

.. automodule:: google.cloud.monitoring_v3.services.alert_policy_service
:members:
:inherited-members:
.. automodule:: google.cloud.monitoring_v3.services.group_service
:members:
:inherited-members:
.. automodule:: google.cloud.monitoring_v3.services.metric_service
:members:
:inherited-members:
.. automodule:: google.cloud.monitoring_v3.services.notification_channel_service
:members:
:inherited-members:
.. automodule:: google.cloud.monitoring_v3.services.service_monitoring_service
:members:
:inherited-members:
.. automodule:: google.cloud.monitoring_v3.services.uptime_check_service
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/monitoring_v3/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Types for Google Cloud Monitoring v3 API
========================================

.. automodule:: google.cloud.monitoring_v3.types
:members:
39 changes: 0 additions & 39 deletions google/cloud/monitoring.py

This file was deleted.

Loading

0 comments on commit d25e49f

Please sign in to comment.