Skip to content

Commit dd953ec

Browse files
feat: Supported project-level-budgets in Public Budget API V1 (#11597)
- [ ] Regenerate this pull request now. Added `scope` for project scope filter in `ListBudgetsRequest`. When this field is set to a project's resource name, the budgets returned are tracking the costs for the given project. feat: Added `enable_project_level_recipients` for project owner budget emails Setting this field to true will enable email notification to project owners for project-level budgets. PiperOrigin-RevId: 559152052 Source-Link: https://togithub.com/googleapis/googleapis/commit/113867b53b015c1f951e0e4e515756f221abc0a2 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/017d177f51469d150417b7b6a45d99d9963f7813 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmctYnVkZ2V0cy8uT3dsQm90LnlhbWwiLCJoIjoiMDE3ZDE3N2Y1MTQ2OWQxNTA0MTdiN2I2YTQ1ZDk5ZDk5NjNmNzgxMyJ9 BEGIN_NESTED_COMMIT feat: Supported project-level-budgets in Public Budget API V1Beta Added `scope` for project scope filter in `ListBudgetsRequest`. When this field is set to a project's resource name, the budgets returned are tracking the costs for the given project. feat: Added `enable_project_level_recipients` for project owner budget emails Setting this field to true will enable email notification to project owners for project-level budgets. PiperOrigin-RevId: 559151636 Source-Link: https://togithub.com/googleapis/googleapis/commit/138b0f1265518d46c9f65403fe6ddd163f2757af Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/41c0ba899f76cbbfacddeccf7c769747acafe26d Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWJpbGxpbmctYnVkZ2V0cy8uT3dsQm90LnlhbWwiLCJoIjoiNDFjMGJhODk5Zjc2Y2JiZmFjZGRlY2NmN2M3Njk3NDdhY2FmZTI2ZCJ9 END_NESTED_COMMIT
1 parent aaa652e commit dd953ec

File tree

14 files changed

+94
-27
lines changed

14 files changed

+94
-27
lines changed

packages/google-cloud-billing-budgets/.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2020 Google LLC
3+
# Copyright 2023 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

packages/google-cloud-billing-budgets/CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ We support:
236236

237237
Supported versions can be found in our ``noxfile.py`` `config`_.
238238

239-
.. _config: https://github.com/googleapis/google-cloud-python/blob/main/noxfile.py
239+
.. _config: https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-billing-budgets/noxfile.py
240240

241241

242242
**********

packages/google-cloud-billing-budgets/MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2020 Google LLC
3+
# Copyright 2023 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

packages/google-cloud-billing-budgets/README.rst

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,24 @@ In order to use this library, you first need to go through the following steps:
3636
Installation
3737
~~~~~~~~~~~~
3838

39-
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
40-
create isolated Python environments. The basic problem it addresses is one of
41-
dependencies and versions, and indirectly permissions.
39+
Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
40+
creates isolated Python environments. These isolated environments can have separate
41+
versions of Python packages, which allows you to isolate one project's dependencies
42+
from the dependencies of other projects.
4243

43-
With `virtualenv`_, it's possible to install this library without needing system
44+
With `venv`_, it's possible to install this library without needing system
4445
install permissions, and without clashing with the installed system
4546
dependencies.
4647

47-
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
48+
.. _`venv`: https://docs.python.org/3/library/venv.html
4849

4950

5051
Code samples and snippets
5152
~~~~~~~~~~~~~~~~~~~~~~~~~
5253

53-
Code samples and snippets live in the `samples/` folder.
54+
Code samples and snippets live in the `samples/`_ folder.
55+
56+
.. _samples/: https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-billing-budgets/samples
5457

5558

5659
Supported Python Versions
@@ -77,21 +80,19 @@ Mac/Linux
7780

7881
.. code-block:: console
7982
80-
pip install virtualenv
81-
virtualenv <your-env>
83+
python3 -m venv <your-env>
8284
source <your-env>/bin/activate
83-
<your-env>/bin/pip install google-cloud-billing-budgets
85+
pip install google-cloud-billing-budgets
8486
8587
8688
Windows
8789
^^^^^^^
8890

8991
.. code-block:: console
9092
91-
pip install virtualenv
92-
virtualenv <your-env>
93-
<your-env>\Scripts\activate
94-
<your-env>\Scripts\pip.exe install google-cloud-billing-budgets
93+
py -m venv <your-env>
94+
.\<your-env>\Scripts\activate
95+
pip install google-cloud-billing-budgets
9596
9697
Next Steps
9798
~~~~~~~~~~

packages/google-cloud-billing-budgets/docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright 2021 Google LLC
2+
# Copyright 2023 Google LLC
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.

packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/types/budget_model.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,14 @@ class NotificationsRule(proto.Message):
335335
Default notifications are sent to those with
336336
Billing Account Administrator and Billing
337337
Account User IAM roles for the target account.
338+
enable_project_level_recipients (bool):
339+
Optional. When set to true, and when the budget has a single
340+
project configured, notifications will be sent to project
341+
level recipients of that project. This field will be ignored
342+
if the budget has multiple or no project configured.
343+
344+
Currently, project level recipients are the users with
345+
``Owner`` role on a cloud project.
338346
"""
339347

340348
pubsub_topic: str = proto.Field(
@@ -353,6 +361,10 @@ class NotificationsRule(proto.Message):
353361
proto.BOOL,
354362
number=4,
355363
)
364+
enable_project_level_recipients: bool = proto.Field(
365+
proto.BOOL,
366+
number=5,
367+
)
356368

357369

358370
class Filter(proto.Message):
@@ -378,9 +390,11 @@ class Filter(proto.Message):
378390
``folders/{folderId}`` or
379391
``organizations/{organizationId}``, specifying that usage
380392
from only this set of folders and organizations should be
381-
included in the budget. If omitted, the report includes all
382-
usage for all organizations, regardless of which
383-
organization the usage occurred on.
393+
included in the budget. If omitted, the budget includes all
394+
usage that the billing account pays for. If the folder or
395+
organization contains projects that are paid for by a
396+
different Cloud Billing account, the budget *doesn't* apply
397+
to those projects.
384398
credit_types (MutableSequence[str]):
385399
Optional. If
386400
[Filter.credit_types_treatment][google.cloud.billing.budgets.v1.Filter.credit_types_treatment]

packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/types/budget_service.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ class ListBudgetsRequest(proto.Message):
110110
Required. Name of billing account to list budgets under.
111111
Values are of the form
112112
``billingAccounts/{billingAccountId}``.
113+
scope (str):
114+
Optional. Set the scope of the budgets to be
115+
returned, in the format of the resource name.
116+
The scope of a budget is the cost that it
117+
tracks, such as costs for a single project, or
118+
the costs for all projects in a folder. Only
119+
project scope (in the format of
120+
"projects/project-id" or "projects/123") is
121+
supported in this field. When this field is set
122+
to a project's resource name, the budgets
123+
returned are tracking the costs for that
124+
project.
113125
page_size (int):
114126
Optional. The maximum number of budgets to
115127
return per page. The default and maximum value
@@ -125,6 +137,10 @@ class ListBudgetsRequest(proto.Message):
125137
proto.STRING,
126138
number=1,
127139
)
140+
scope: str = proto.Field(
141+
proto.STRING,
142+
number=4,
143+
)
128144
page_size: int = proto.Field(
129145
proto.INT32,
130146
number=2,

packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/types/budget_model.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,14 @@ class AllUpdatesRule(proto.Message):
305305
Default notifications are sent to those with
306306
Billing Account Administrator and Billing
307307
Account User IAM roles for the target account.
308+
enable_project_level_recipients (bool):
309+
Optional. When set to true, and when the budget has a single
310+
project configured, notifications will be sent to project
311+
level recipients of that project. This field will be ignored
312+
if the budget has multiple or no project configured.
313+
314+
Currently, project level recipients are the users with
315+
``Owner`` role on a cloud project.
308316
"""
309317

310318
pubsub_topic: str = proto.Field(
@@ -323,6 +331,10 @@ class AllUpdatesRule(proto.Message):
323331
proto.BOOL,
324332
number=4,
325333
)
334+
enable_project_level_recipients: bool = proto.Field(
335+
proto.BOOL,
336+
number=5,
337+
)
326338

327339

328340
class Filter(proto.Message):
@@ -348,9 +360,11 @@ class Filter(proto.Message):
348360
``folders/{folderId}`` or
349361
``organizations/{organizationId}``, specifying that usage
350362
from only this set of folders and organizations should be
351-
included in the budget. If omitted, the report includes all
352-
usage for all organizations, regardless of which
353-
organization the usage occurred on.
363+
included in the budget. If omitted, the budget includes all
364+
usage that the billing account pays for. If the folder or
365+
organization contains projects that are paid for by a
366+
different Cloud Billing account, the budget *doesn't* apply
367+
to those projects.
354368
credit_types (MutableSequence[str]):
355369
Optional. If
356370
[Filter.credit_types_treatment][google.cloud.billing.budgets.v1beta1.Filter.credit_types_treatment]

packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/types/budget_service.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ class ListBudgetsRequest(proto.Message):
110110
Required. Name of billing account to list budgets under.
111111
Values are of the form
112112
``billingAccounts/{billingAccountId}``.
113+
scope (str):
114+
Optional. Set the scope of the budgets to be
115+
returned, in the format of the resource name.
116+
The scope of a budget is the cost that it
117+
tracks, such as costs for a single project, or
118+
the costs for all projects in a folder. Only
119+
project scope (in the format of
120+
"projects/project-id" or "projects/123") is
121+
supported in this field. When this field is set
122+
to a project's resource name, the budgets
123+
returned are tracking the costs for that
124+
project.
113125
page_size (int):
114126
Optional. The maximum number of budgets to
115127
return per page. The default and maximum value
@@ -125,6 +137,10 @@ class ListBudgetsRequest(proto.Message):
125137
proto.STRING,
126138
number=1,
127139
)
140+
scope: str = proto.Field(
141+
proto.STRING,
142+
number=4,
143+
)
128144
page_size: int = proto.Field(
129145
proto.INT32,
130146
number=2,

packages/google-cloud-billing-budgets/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2018 Google LLC
3+
# Copyright 2023 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)