|
| 1 | +# 1.0.0 Migration Guide |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-billingbudgets/issues). |
| 6 | + |
| 7 | +## Supported Python Versions |
| 8 | + |
| 9 | +> **WARNING**: Breaking change |
| 10 | +
|
| 11 | +The 1.0.0 release requires Python 3.6+. |
| 12 | + |
| 13 | + |
| 14 | +## Namespace Change |
| 15 | + |
| 16 | +> **WARNING**: Breaking change |
| 17 | +
|
| 18 | +The 1.0.0 release changes namespace from `google.cloud.billing_budgets` to `google.cloud.billing.budgets`. |
| 19 | + |
| 20 | +**Before:** |
| 21 | +```py |
| 22 | +from google.cloud import billing_budgets |
| 23 | + |
| 24 | +client = billing_budgets.BudgetServiceClient() |
| 25 | +``` |
| 26 | + |
| 27 | + |
| 28 | +**After:** |
| 29 | +```py |
| 30 | +from google.cloud.billing import budgets |
| 31 | + |
| 32 | +client = budgets.BudgetServiceClient() |
| 33 | +``` |
| 34 | + |
| 35 | + |
| 36 | +## Method Calls |
| 37 | + |
| 38 | +> **WARNING**: Breaking change |
| 39 | +
|
| 40 | +Methods expect request objects. We provide a script that will convert most common use cases. |
| 41 | + |
| 42 | +* Install the library |
| 43 | + |
| 44 | +```py |
| 45 | +python3 -m pip install google-cloud-billing-budgets |
| 46 | +``` |
| 47 | + |
| 48 | +* The script `fixup_budgets_v1beta1_keywords.py` is shipped with the library. It expects |
| 49 | +an input directory (with the code to convert) and an empty destination directory. |
| 50 | + |
| 51 | +```sh |
| 52 | +$ fixup_budgets_v1beta1_keywords.py --input-directory .samples/ --output-directory samples/ |
| 53 | +``` |
| 54 | + |
| 55 | +**Before:** |
| 56 | +```py |
| 57 | +budget = client.get_budget(name="billingAccounts/account/budgets/budget") |
| 58 | +``` |
| 59 | + |
| 60 | + |
| 61 | +**After:** |
| 62 | +```py |
| 63 | +budget = client.get_budget(request = {'name': "billingAccounts/account/budgets/budget"}) |
| 64 | +``` |
| 65 | + |
| 66 | +### More Details |
| 67 | + |
| 68 | +In `google-cloud-billing-budgets<1.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters. |
| 69 | + |
| 70 | +**Before:** |
| 71 | +```py |
| 72 | + def create_budget( |
| 73 | + self, |
| 74 | + parent, |
| 75 | + budget, |
| 76 | + retry=google.api_core.gapic_v1.method.DEFAULT, |
| 77 | + timeout=google.api_core.gapic_v1.method.DEFAULT, |
| 78 | + metadata=None, |
| 79 | + ): |
| 80 | +``` |
| 81 | + |
| 82 | +In the 1.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional. |
| 83 | + |
| 84 | + |
| 85 | +**After:** |
| 86 | +```py |
| 87 | + def create_budget( |
| 88 | + self, |
| 89 | + request: budget_service.CreateBudgetRequest = None, |
| 90 | + *, |
| 91 | + retry: retries.Retry = gapic_v1.method.DEFAULT, |
| 92 | + timeout: float = None, |
| 93 | + metadata: Sequence[Tuple[str, str]] = (), |
| 94 | + ) -> budget_model.Budget: |
| 95 | +``` |
| 96 | + |
| 97 | + |
| 98 | +## Enums and Types |
| 99 | + |
| 100 | + |
| 101 | +> **WARNING**: Breaking change |
| 102 | +
|
| 103 | +The submodules `enums` and `types` have been removed. |
| 104 | + |
| 105 | +**Before:** |
| 106 | +```py |
| 107 | + |
| 108 | +from google.cloud import billing_budgets |
| 109 | + |
| 110 | +filter = billing_budgets.enums.Filter.CreditTypesTreatment.INCLUDE_ALL_CREDITS |
| 111 | +budget = billing_budgets.types.Budget() |
| 112 | +``` |
| 113 | + |
| 114 | + |
| 115 | +**After:** |
| 116 | +```py |
| 117 | +from google.cloud.billing import budgets |
| 118 | + |
| 119 | +filter = budgets.Filter.CreditTypesTreatment.INCLUDE_ALL_CREDITS |
| 120 | +budget = budgets.Budget() |
| 121 | +``` |
0 commit comments