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 microgen (#33)
Browse files Browse the repository at this point in the history
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-containeranalysis/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕
  • Loading branch information
busunkim96 committed Aug 12, 2020
1 parent 4f3bcdd commit 6098905
Show file tree
Hide file tree
Showing 46 changed files with 3,918 additions and 1,544 deletions.
30 changes: 6 additions & 24 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Generated by synthtool. DO NOT EDIT!
[run]
branch = True

[report]
fail_under = 100
show_missing = True
omit = google/cloud/devtools/containeranalysis/__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
# 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
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ dependencies.
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/


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

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7.

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

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

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

The 2.0 release of the `google-cloud-containeranalysis` 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-containeranalysis/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-containeranalysis
```

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

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

**Before:**
```py
from google.cloud.devtools import containeranalysis_v1

client = containeranalysis_v1.ContainerAnalysisClient()
resource = "projects/[PROJECT_ID]/notes/[NOTE_ID]"
policy = client.get_iam_policy(resource)
```


**After:**
```py
from google.cloud.devtools import containeranalysis_v1

client = containeranalysis_v1.ContainerAnalysisClient()
request = {"resource": "projects/[PROJECT_ID]/notes/[NOTE_ID]"}
policy = client.get_iam_policy(request=request)
```

### More Details

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

**Before:**
```py
def get_iam_policy(
self,
resource,
options_=None,
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](https://github.com/googleapis/googleapis/blob/b77cacf1ed06e0301a39d6328b599e24102f04be/google/devtools/containeranalysis/v1/containeranalysis.proto#L67) specified by the API producer.


**After:**
```py
def get_iam_policy(
self,
request: iam_policy.GetIamPolicyRequest = None,
*,
resource: str = None,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy.Policy:
```

> **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.test_iam_permissions(
request={
"resource": resource,
"permissions": permissions,
}
)
```

```py
response = client.test_iam_permissions(
resource=resource,
permissions=permissions,
)
```

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

```py
response = client.test_iam_permissions(
request={
"resource": resource,
},
permissions=permissions
)
```



## Enums and Types


> **WARNING**: Breaking change
The submodule `types` has been removed.

**Before:**
```py
from google.cloud.devtools import containeranalysis_v1

audit_config = containeranalysis_v1.types.AuditConfigDelta()
```


**After:**
```py
from google.cloud.devtools import containeranalysis_v1

audit_config = containeranalysis_v1.AuditConfigDelta()
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
6 changes: 6 additions & 0 deletions docs/containeranalysis_v1/services.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Services for Google Cloud Devtools Containeranalysis v1 API
===========================================================

.. automodule:: google.cloud.devtools.containeranalysis_v1.services.container_analysis
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/containeranalysis_v1/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Types for Google Cloud Devtools Containeranalysis v1 API
========================================================

.. automodule:: google.cloud.devtools.containeranalysis_v1.types
:members:
6 changes: 0 additions & 6 deletions docs/gapic/v1/api.rst

This file was deleted.

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

This file was deleted.

16 changes: 13 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Api Reference
.. toctree::
:maxdepth: 2

gapic/v1/api
gapic/v1/types
containeranalysis_v1/services
containeranalysis_v1/types


Changelog
Expand All @@ -19,4 +19,14 @@ For all previous ``google-cloud-containeranalysis`` releases:
.. toctree::
:maxdepth: 2

changelog
changelog

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

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

.. toctree::
:maxdepth: 2

UPGRADING
100 changes: 0 additions & 100 deletions google/cloud/containeranalysis_v1/proto/containeranalysis.proto

This file was deleted.

28 changes: 28 additions & 0 deletions google/cloud/devtools/containeranalysis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-

# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from google.cloud.devtools.containeranalysis_v1.services.container_analysis.async_client import (
ContainerAnalysisAsyncClient,
)
from google.cloud.devtools.containeranalysis_v1.services.container_analysis.client import (
ContainerAnalysisClient,
)

__all__ = (
"ContainerAnalysisAsyncClient",
"ContainerAnalysisClient",
)
2 changes: 2 additions & 0 deletions google/cloud/devtools/containeranalysis/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-devtools-containeranalysis package uses inline types.
Loading

0 comments on commit 6098905

Please sign in to comment.