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

Commit

Permalink
feat: migrate to use microgenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Jul 13, 2020
1 parent 01ea98e commit 446cc42
Show file tree
Hide file tree
Showing 51 changed files with 4,287 additions and 3,077 deletions.
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
*/site-packages/*.py
google/cloud/billing/budgets/__init__.py
11 changes: 10 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Python Client for Cloud Billing Budget API
=====================================================

|beta| |pypi| |versions|
|beta| |pypi| |versions|

`Cloud Billing Budget API`_: The Cloud Billing Budget API stores Cloud Billing budgets, which define a
budget plan and the rules to execute as spend is tracked against that
Expand Down Expand Up @@ -48,6 +48,15 @@ dependencies.

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

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

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

The last version of this library compatible with Python 2.7 is google-cloud-billing-budgets==0.4.0.

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

The 1.0 release of the `google-cloud-billing-budgets` 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-billingbudgets/issues).

## Supported Python Versions

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


## Namespace Change

> **WARNING**: Breaking change
The 1.0.0 release changes namespace from `google.cloud.billing_budgets` to `google.cloud.billing.budgets`.

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

client = billing_budgets.BudgetServiceClient()
```


**After:**
```py
from google.cloud.billing import budgets

client = budgets.BudgetServiceClient()
```


## 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-billing-budgets
```

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

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

**Before:**
```py
budget = client.get_budget(name="billingAccounts/account/budgets/budget")
```


**After:**
```py
budget = client.get_budget(request = {'name': "billingAccounts/account/budgets/budget"})
```

### More Details

In `google-cloud-billing-budgets<1.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.

**Before:**
```py
def create_budget(
self,
parent,
budget,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
```

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


**After:**
```py
def create_budget(
self,
request: budget_service.CreateBudgetRequest = None,
*,
retry: retries.Retry = gapic_v1.method.DEFAULT,
timeout: float = None,
metadata: Sequence[Tuple[str, str]] = (),
) -> budget_model.Budget:
```


## Enums and Types


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

**Before:**
```py

from google.cloud import billing_budgets

filter = billing_budgets.enums.Filter.CreditTypesTreatment.INCLUDE_ALL_CREDITS
budget = billing_budgets.types.Budget()
```


**After:**
```py
from google.cloud.billing import budgets

filter = budgets.Filter.CreditTypesTreatment.INCLUDE_ALL_CREDITS
budget = budgets.Budget()
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
6 changes: 6 additions & 0 deletions docs/budgets_v1beta1/services.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Services for Google Cloud Billing Budgets v1beta1 API
=====================================================

.. automodule:: google.cloud.billing.budgets_v1beta1.services.budget_service
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/budgets_v1beta1/types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Types for Google Cloud Billing Budgets v1beta1 API
==================================================

.. automodule:: google.cloud.billing.budgets_v1beta1.types
:members:
6 changes: 0 additions & 6 deletions docs/gapic/v1beta1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1beta1/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 @@ -7,8 +7,18 @@ Api Reference
.. toctree::
:maxdepth: 2

gapic/v1beta1/api
gapic/v1beta1/types
budgets_v1beta1/services
budgets_v1beta1/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
60 changes: 60 additions & 0 deletions google/cloud/billing/budgets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- 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.billing.budgets_v1beta1.services.budget_service.async_client import (
BudgetServiceAsyncClient,
)
from google.cloud.billing.budgets_v1beta1.services.budget_service.client import (
BudgetServiceClient,
)
from google.cloud.billing.budgets_v1beta1.types.budget_model import AllUpdatesRule
from google.cloud.billing.budgets_v1beta1.types.budget_model import Budget
from google.cloud.billing.budgets_v1beta1.types.budget_model import BudgetAmount
from google.cloud.billing.budgets_v1beta1.types.budget_model import Filter
from google.cloud.billing.budgets_v1beta1.types.budget_model import LastPeriodAmount
from google.cloud.billing.budgets_v1beta1.types.budget_model import ThresholdRule
from google.cloud.billing.budgets_v1beta1.types.budget_service import (
CreateBudgetRequest,
)
from google.cloud.billing.budgets_v1beta1.types.budget_service import (
DeleteBudgetRequest,
)
from google.cloud.billing.budgets_v1beta1.types.budget_service import GetBudgetRequest
from google.cloud.billing.budgets_v1beta1.types.budget_service import ListBudgetsRequest
from google.cloud.billing.budgets_v1beta1.types.budget_service import (
ListBudgetsResponse,
)
from google.cloud.billing.budgets_v1beta1.types.budget_service import (
UpdateBudgetRequest,
)

__all__ = (
"AllUpdatesRule",
"Budget",
"BudgetAmount",
"BudgetServiceAsyncClient",
"BudgetServiceClient",
"CreateBudgetRequest",
"DeleteBudgetRequest",
"Filter",
"GetBudgetRequest",
"LastPeriodAmount",
"ListBudgetsRequest",
"ListBudgetsResponse",
"ThresholdRule",
"UpdateBudgetRequest",
)
2 changes: 2 additions & 0 deletions google/cloud/billing/budgets/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-billing-budgets package uses inline types.
47 changes: 47 additions & 0 deletions google/cloud/billing/budgets_v1beta1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- 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 .services.budget_service import BudgetServiceClient
from .types.budget_model import AllUpdatesRule
from .types.budget_model import Budget
from .types.budget_model import BudgetAmount
from .types.budget_model import Filter
from .types.budget_model import LastPeriodAmount
from .types.budget_model import ThresholdRule
from .types.budget_service import CreateBudgetRequest
from .types.budget_service import DeleteBudgetRequest
from .types.budget_service import GetBudgetRequest
from .types.budget_service import ListBudgetsRequest
from .types.budget_service import ListBudgetsResponse
from .types.budget_service import UpdateBudgetRequest


__all__ = (
"AllUpdatesRule",
"Budget",
"BudgetAmount",
"CreateBudgetRequest",
"DeleteBudgetRequest",
"Filter",
"GetBudgetRequest",
"LastPeriodAmount",
"ListBudgetsRequest",
"ListBudgetsResponse",
"ThresholdRule",
"UpdateBudgetRequest",
"BudgetServiceClient",
)
2 changes: 2 additions & 0 deletions google/cloud/billing/budgets_v1beta1/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-billing-budgets package uses inline types.
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# -*- 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
# 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.

try:
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil

__path__ = pkgutil.extend_path(__path__, __name__)
#
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# -*- 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
# 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.
#

try:
import pkg_resources

pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
from .client import BudgetServiceClient
from .async_client import BudgetServiceAsyncClient

__path__ = pkgutil.extend_path(__path__, __name__)
__all__ = (
"BudgetServiceClient",
"BudgetServiceAsyncClient",
)
Loading

0 comments on commit 446cc42

Please sign in to comment.