codecraftai-restclient-google 1.2.0__tar.gz → 1.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (13) hide show
  1. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/LICENSE.md +30 -21
  2. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/PKG-INFO +4 -4
  3. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/pyproject.toml +5 -26
  4. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/googleobject.py +56 -0
  5. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/googletransport.py +19 -4
  6. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/storageclient.py +14 -3
  7. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/README.rst +0 -0
  8. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/__init__.py +0 -0
  9. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/computeclient.py +0 -0
  10. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/dnsclient.py +0 -0
  11. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/googleapierror.py +0 -0
  12. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/googletokenprovider.py +0 -0
  13. {codecraftai_restclient_google-1.2.0 → codecraftai_restclient_google-1.3.0}/source/packages/ccai/restclient/google/tpuclient.py +0 -0
@@ -1,5 +1,5 @@
1
1
  # Code Craft AI - Source Available License
2
- Version 1.0, October 2026
2
+ Version 1.1, November 2026
3
3
 
4
4
  Copyright (C) 2026, Code Craft AI LLC
5
5
 
@@ -7,12 +7,12 @@ Everyone is permitted to copy and distribute verbatim copies of *This License* d
7
7
 
8
8
  *This License* covers the Python Automation Kit, the full suite of software published by *Licensor* that consists of every `codecraftai-*` package, every `pychestrate` package, and the `pychestrate` server.
9
9
 
10
- *The Software* is source available. Its source code is published so that anyone can read it, learn from it, and use it, but *This License* is not an open source license. *The Software* is free to use for *Non-Commercial Use*. *Commercial Use* is permitted in exchange for a *Usage Fee* that is based on a reasonable estimation of the income derived from *The Software*, as described in section 5. When a company migrates a product or service to *The Software* from another code base, the *Profit* from that product or service is not counted toward the *Usage Fee* for two years, as described in section 5.4. For assurance of costs, a company can disclose its usage and estimated returns to *Licensor* and negotiate a fixed license cost, as described in section 5.10.
10
+ *The Software* is source available. Its source code is published so that anyone can read it, learn from it, and use it, but *This License* is not an open source license. *The Software* is free to use for *Non-Commercial Use*. *Commercial Use* is permitted in exchange for a *Usage Fee* that is based on a reasonable estimation of the income derived from *The Software*, as described in section 5. That estimation starts from *Gross Income*, not net profit, so spending on research and development or other operating expenses does not reduce it. When a company migrates a product or service to *The Software* from another code base, the *Gross Income* from that product or service is not counted toward the *Usage Fee* for two years, as described in section 5.4. For assurance of costs, a company can disclose its usage and estimated returns to *Licensor* and negotiate a fixed license cost, as described in section 5.10.
11
11
 
12
12
  ## 1. Definitions
13
13
 
14
14
  ### 1.1 *This License* or *The License*
15
- **This License** or **The License** refers to version 1.0 of the Code Craft AI - Source Available License.
15
+ **This License** or **The License** refers to version 1.1 of the Code Craft AI - Source Available License.
16
16
 
17
17
  ### 1.2 Licensor
18
18
  **Licensor** refers to Code Craft AI LLC.
@@ -42,14 +42,14 @@ Everyone is permitted to copy and distribute verbatim copies of *This License* d
42
42
  ### 1.9 Fiscal Year
43
43
  **Fiscal Year** means the annual accounting period that *You* use for financial reporting.
44
44
 
45
- ### 1.10 Profit
46
- **Profit** means the net profit that *You* earn from the *Commercial Activity* during a *Fiscal Year*, determined under the accounting principles that *You* regularly use for financial reporting.
45
+ ### 1.10 Gross Income
46
+ **Gross Income** means, for each product or service in connection with which *You* make *Commercial Use* of *The Software*, the gross profit that *You* earn from that product or service during a *Fiscal Year*: the revenue from that product or service, less its cost of goods sold or cost of revenue, determined under the accounting principles that *You* regularly use for financial reporting. *Gross Income* is calculated before operating expenses, such as research and development, sales and marketing, and general and administrative expenses, and before interest and taxes. *Gross Income* is measured for the products and services that *The Software* is used for, not for *Your* business as a whole.
47
47
 
48
48
  ### 1.11 Contribution Estimate
49
- **Contribution Estimate** means *Your* reasonable, good faith estimate of the portion of the *Profit* that *The Software* contributed to, expressed as a number from 0 to 1.
49
+ **Contribution Estimate** means *Your* reasonable, good faith estimate of the portion of the *Gross Income* that *The Software* contributed to, expressed as a number from 0 to 1.
50
50
 
51
51
  ### 1.12 Derived Income
52
- **Derived Income** means the portion of the *Profit* for a *Fiscal Year* that is derived from *The Software*, calculated as described in section 5.2.
52
+ **Derived Income** means the portion of the *Gross Income* for a *Fiscal Year* that is derived from *The Software*, calculated as described in section 5.2.
53
53
 
54
54
  ### 1.13 Usage Fee
55
55
  **Usage Fee** means the yearly fee for *Commercial Use* that is set by the table in section 5.3.
@@ -58,7 +58,7 @@ Everyone is permitted to copy and distribute verbatim copies of *This License* d
58
58
  **Migration** means moving the work for one of *Your* products or services from a code base other than *The Software*, such as another framework, another library, or *Your* own code, to *The Software*.
59
59
 
60
60
  ### 1.15 Migration Period
61
- **Migration Period** means the two (2) year period, described in section 5.4, during which the *Profit* from a product or service that *You* are migrating to *The Software* is not counted.
61
+ **Migration Period** means the two (2) year period, described in section 5.4, during which the *Gross Income* from a product or service that *You* are migrating to *The Software* is not counted.
62
62
 
63
63
  ## 2. License Grant
64
64
 
@@ -96,11 +96,11 @@ For each *Fiscal Year* in which *You* make *Commercial Use* of *The Software*, *
96
96
  ### 5.2 Derived Income
97
97
  The *Derived Income* for a *Fiscal Year* is calculated as follows:
98
98
 
99
- (Contribution Estimate) * (Profit) = (Derived Income)
99
+ (Contribution Estimate) * (Gross Income) = (Derived Income)
100
100
 
101
- If *You* make *Commercial Use* of *The Software* for more than one product or service, calculate the *Derived Income* for each product or service using its own *Contribution Estimate* and *Profit*, and add the results together. The *Profit* from a product or service that is in its *Migration Period* is not counted, as described in section 5.4.
101
+ If *You* make *Commercial Use* of *The Software* for more than one product or service, calculate the *Derived Income* for each product or service using its own *Contribution Estimate* and *Gross Income*, and add the results together. The *Gross Income* from a product or service that is in its *Migration Period* is not counted, as described in section 5.4.
102
102
 
103
- If the *Profit* from a product or service for a *Fiscal Year* is zero or less, then the *Derived Income* from that product or service for that *Fiscal Year* is zero.
103
+ If the *Gross Income* from a product or service for a *Fiscal Year* is zero or less, then the *Derived Income* from that product or service for that *Fiscal Year* is zero.
104
104
 
105
105
  ### 5.3 Usage Fee
106
106
  The *Usage Fee* for a *Fiscal Year* is set by the *Derived Income* for that *Fiscal Year*, as shown in the following table.
@@ -113,56 +113,65 @@ The *Usage Fee* for a *Fiscal Year* is set by the *Derived Income* for that *Fis
113
113
  | More than 100,000,000, up to and including 1,000,000,000 | 250,000 |
114
114
  | More than 1,000,000,000 | 500,000 |
115
115
 
116
- All amounts in this section 5 are in United States dollars. If *You* report *Profit* in a different currency, convert the *Derived Income* to United States dollars using the average exchange rate for the *Fiscal Year*.
116
+ All amounts in this section 5 are in United States dollars. If *You* report *Gross Income* in a different currency, convert the *Derived Income* to United States dollars using the average exchange rate for the *Fiscal Year*.
117
117
 
118
118
  ### 5.4 Migration Allowance
119
- When *You* migrate a product or service to *The Software*, the *Profit* from that product or service is not counted when calculating the *Derived Income* during its *Migration Period* (the **Migration Allowance**).
119
+ When *You* migrate a product or service to *The Software*, the *Gross Income* from that product or service is not counted when calculating the *Derived Income* during its *Migration Period* (the **Migration Allowance**).
120
120
 
121
121
  The *Migration Period* for a product or service begins on the date that *You* first make *Commercial Use* of *The Software* for that product or service as part of its *Migration*, and ends two (2) years after that date.
122
122
 
123
123
  The *Migration Allowance* applies to each product or service separately, and *You* may use it for every product or service that *You* migrate. Each product or service has only one *Migration Period*.
124
124
 
125
- If a *Fiscal Year* is only partly within the *Migration Period* of a product or service, the *Profit* from that product or service for that *Fiscal Year* is reduced in proportion to the number of days of that *Fiscal Year* that fall within its *Migration Period*.
125
+ If a *Fiscal Year* is only partly within the *Migration Period* of a product or service, the *Gross Income* from that product or service for that *Fiscal Year* is reduced in proportion to the number of days of that *Fiscal Year* that fall within its *Migration Period*.
126
126
 
127
- For example, a company tests product A with *The Software* and pays a *Usage Fee* based on the *Profit* from product A. On March 1, 2027, the company begins moving the testing of product B from a different test framework to *The Software*. The company does not count the *Profit* from product B in its *Derived Income* from March 1, 2027 until March 1, 2029. Starting March 1, 2029, the *Profit* from product B is counted. If the company later migrates product C, the *Profit* from product C is not counted for two years from the start of its own *Migration*.
127
+ For example, a company tests product A with *The Software* and pays a *Usage Fee* based on the *Gross Income* from product A. On March 1, 2027, the company begins moving the testing of product B from a different test framework to *The Software*. The company does not count the *Gross Income* from product B in its *Derived Income* from March 1, 2027 until March 1, 2029. Starting March 1, 2029, the *Gross Income* from product B is counted. If the company later migrates product C, the *Gross Income* from product C is not counted for two years from the start of its own *Migration*.
128
128
 
129
129
  ### 5.5 Contribution Estimate
130
130
  *You* are responsible for making the *Contribution Estimate*. A *Contribution Estimate* must be reasonable and made in good faith. The *Contribution Estimate* for a product or service covers all of the *Components* that *You* *Use* for that product or service. When making the *Contribution Estimate*, *You* should consider how important *The Software* is to the *Commercial Activity*, how much of the *Commercial Activity* depends on *The Software*, and the effort and cost that *You* would otherwise need to spend to accomplish what *The Software* accomplishes for *You*.
131
131
 
132
132
  The following table is a guide for making the *Contribution Estimate*. When *Your* *Commercial Use* of *The Software* matches an entry in the table, the *Contribution Estimate* in that entry is a reasonable *Contribution Estimate*. When *Your* *Commercial Use* does not match an entry in the table, make the *Contribution Estimate* by comparing *Your* *Commercial Use* with the entries in the table. When more than one entry matches the same *Commercial Activity*, use the entry with the highest *Contribution Estimate*.
133
133
 
134
+ Many products are not software, such as devices, machines, vehicles, and other physical goods, and software accounts for only part of what such a product is worth. For a product or service that is not software, *You* may reduce the *Contribution Estimate* in proportion to the share of the value of the shipped product that its software reasonably accounts for. To do so, multiply the *Contribution Estimate* from the table by that share, expressed as a number from 0 to 1. *You* must keep records that reasonably support that share, as described in section 5.8.
135
+
134
136
  | Commercial Use of *The Software* | Contribution Estimate |
135
137
  |----------------------------------|-----------------------|
136
138
  | Quality Assurance (QA) and Continuous Integration (CI): *The Software* is used to test or validate the products or services of the *Commercial Activity*, or to run their build and test pipelines | 0.3 |
137
139
  | Products Completely Based on *The Software*: the products or services of the *Commercial Activity* are built completely on *The Software* | 0.5 |
138
140
 
139
141
  ### 5.6 Examples
140
- A company earns 1,000,000,000 in *Profit* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
142
+ A company earns 1,000,000,000 in *Gross Income* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
141
143
 
142
144
  0.3 * 1,000,000,000 = 300,000,000
143
145
 
144
146
  The *Derived Income* of 300,000,000 is more than 100,000,000 and not more than 1,000,000,000, so the *Usage Fee* for that *Fiscal Year* is 250,000.
145
147
 
146
- A company earns 4,000,000 in *Profit* from a product during a *Fiscal Year*. The product is built completely on *The Software*, so the *Contribution Estimate* is 0.5.
148
+ A company earns 4,000,000 in *Gross Income* from a product during a *Fiscal Year*. The product is built completely on *The Software*, so the *Contribution Estimate* is 0.5.
147
149
 
148
150
  0.5 * 4,000,000 = 2,000,000
149
151
 
150
152
  The *Derived Income* of 2,000,000 is more than 1,000,000 and not more than 10,000,000, so the *Usage Fee* for that *Fiscal Year* is 50,000.
151
153
 
152
- A company earns 3,000,000 in *Profit* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
154
+ A company earns 3,000,000 in *Gross Income* from a product line during a *Fiscal Year*. The company uses *The Software* for the QA and CI of that product line, so the *Contribution Estimate* is 0.3.
153
155
 
154
156
  0.3 * 3,000,000 = 900,000
155
157
 
156
158
  The *Derived Income* of 900,000 is 1,000,000 or less, so there is no *Usage Fee* for that *Fiscal Year*.
157
159
 
160
+ A company earns 50,000,000 in *Gross Income* from a line of medical devices during a *Fiscal Year*. The company uses *The Software* for the QA and CI of the devices, so the *Contribution Estimate* from the table is 0.3. The devices are not software, and the company reasonably estimates that their software accounts for one fifth (0.2) of the value of each shipped device, so the company reduces the *Contribution Estimate* to 0.06.
161
+
162
+ 0.3 * 0.2 = 0.06
163
+ 0.06 * 50,000,000 = 3,000,000
164
+
165
+ The *Derived Income* of 3,000,000 is more than 1,000,000 and not more than 10,000,000, so the *Usage Fee* for that *Fiscal Year* is 50,000. Without the reduction, the *Derived Income* would be 15,000,000 and the *Usage Fee* would be 100,000.
166
+
158
167
  ### 5.7 Reporting and Payment
159
- Within one hundred twenty (120) days after the end of each *Fiscal Year* for which a *Usage Fee* is owed, *You* must pay the *Usage Fee* to *Licensor* and provide *Licensor* with a written statement that shows the *Profit*, the *Contribution Estimate*, the reasoning used to make the *Contribution Estimate*, the *Derived Income*, and the *Usage Fee*. *Usage Fees* are payable in United States dollars. If any *Profit* is not counted under section 5.4, the statement must also identify each product or service that is in a *Migration Period* and show the dates of its *Migration Period*. No statement is required for a *Fiscal Year* in which no *Usage Fee* is owed.
168
+ Within one hundred twenty (120) days after the end of each *Fiscal Year* for which a *Usage Fee* is owed, *You* must pay the *Usage Fee* to *Licensor* and provide *Licensor* with a written statement that shows the *Gross Income*, the *Contribution Estimate*, the reasoning used to make the *Contribution Estimate*, the *Derived Income*, and the *Usage Fee*. *Usage Fees* are payable in United States dollars. If any *Gross Income* is not counted under section 5.4, the statement must also identify each product or service that is in a *Migration Period* and show the dates of its *Migration Period*. No statement is required for a *Fiscal Year* in which no *Usage Fee* is owed.
160
169
 
161
170
  ### 5.8 Records and Review
162
- *You* must keep records that reasonably support each *Contribution Estimate*, each *Profit* figure, and the dates of any *Migration Period* for at least three (3) years after the end of the *Fiscal Year* that they apply to. No more than once in any twelve (12) month period, *Licensor* may ask in writing for the records that support a statement, and *You* must provide them within sixty (60) days of the request. *Licensor* will treat those records as confidential.
171
+ *You* must keep records that reasonably support each *Contribution Estimate*, including any share used to reduce it under section 5.5, each *Gross Income* figure, and the dates of any *Migration Period* for at least three (3) years after the end of the *Fiscal Year* that they apply to. No more than once in any twelve (12) month period, *Licensor* may ask in writing for the records that support a statement, and *You* must provide them within sixty (60) days of the request. *Licensor* will treat those records as confidential.
163
172
 
164
173
  ### 5.9 Disputes About the Usage Fee
165
- If *Licensor* believes that a *Contribution Estimate*, a *Profit* figure, or the dates of a *Migration Period* are not reasonable, *Licensor* will notify *You* in writing and explain why. *You* and *Licensor* will then negotiate in good faith for at least sixty (60) days to agree on a reasonable *Usage Fee*. If *You* and *Licensor* cannot agree, either party may resolve the dispute as described in section 8.
174
+ If *Licensor* believes that a *Contribution Estimate*, a *Gross Income* figure, or the dates of a *Migration Period* are not reasonable, *Licensor* will notify *You* in writing and explain why. *You* and *Licensor* will then negotiate in good faith for at least sixty (60) days to agree on a reasonable *Usage Fee*. If *You* and *Licensor* cannot agree, either party may resolve the dispute as described in section 8.
166
175
 
167
176
  ### 5.10 Fixed License Cost
168
177
  For assurance of costs, *You* may disclose to *Licensor* how *You* *Use* *The Software* and the returns that *You* estimate *You* will derive from it, and negotiate a fixed license cost with *Licensor*. A fixed license cost, and any other terms that *You* and *Licensor* agree to, must be set out in a writing signed by both *You* and *Licensor* (a **Fixed License Agreement**).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codecraftai-restclient-google
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: Code Craft AI - Google Cloud REST client
5
5
  License-Expression: LicenseRef-CodeCraftAI-Source-Available
6
6
  License-File: LICENSE.md
@@ -10,9 +10,9 @@ Author-email: myron.walker@gmail.com
10
10
  Requires-Python: >=3.10,<4.0
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Operating System :: POSIX
13
- Requires-Dist: codecraftai-credentials (<2.0.0)
14
- Requires-Dist: codecraftai-foundations (<2.0.0)
15
- Requires-Dist: codecraftai-restclient-base (<2.0.0)
13
+ Requires-Dist: codecraftai-credentials (>=1.0.0,<2.0.0)
14
+ Requires-Dist: codecraftai-foundations (>=1.0.0,<2.0.0)
15
+ Requires-Dist: codecraftai-restclient-base (>=1.0.0,<2.0.0)
16
16
  Requires-Dist: cryptography (>=45.0.5,<51.0.0)
17
17
  Requires-Dist: requests (>=2.32.4,<3.0.0)
18
18
  Project-URL: Issues, https://github.com/code-craft-ai-company/codecraftai-restclient-google/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "codecraftai-restclient-google"
3
- version = "1.2.0"
3
+ version = "1.3.0"
4
4
  description = "Code Craft AI - Google Cloud REST client"
5
5
  readme = "README.rst"
6
6
  license = "LicenseRef-CodeCraftAI-Source-Available"
@@ -21,9 +21,9 @@ requires-python = ">=3.10,<4.0"
21
21
  dependencies = [
22
22
  "requests>=2.32.4,<3.0.0",
23
23
  "cryptography>=45.0.5,<51.0.0",
24
- "codecraftai-foundations<2.0.0",
25
- "codecraftai-credentials<2.0.0",
26
- "codecraftai-restclient-base<2.0.0",
24
+ "codecraftai-foundations>=1.0.0,<2.0.0",
25
+ "codecraftai-credentials>=1.0.0,<2.0.0",
26
+ "codecraftai-restclient-base>=1.0.0,<2.0.0",
27
27
  ]
28
28
 
29
29
  [project.urls]
@@ -32,34 +32,13 @@ Issues = "https://github.com/code-craft-ai-company/codecraftai-restclient-google
32
32
 
33
33
  [dependency-groups]
34
34
  dev = [
35
- "codecraftai-testbase<2.0.0",
35
+ "codecraftai-testbase>=1.0.0,<2.0.0",
36
36
  "requests-mock>=1.11.0",
37
37
  ]
38
38
 
39
39
  [tool.poetry]
40
40
  packages = [{include="ccai", from="source/packages"}]
41
41
 
42
- [tool.poetry.dependencies]
43
- codecraftai-foundations = {source = "codecraftai"}
44
- codecraftai-credentials = {source = "codecraftai"}
45
- codecraftai-restclient-base = {source = "codecraftai"}
46
-
47
- [tool.poetry.group.dev.dependencies]
48
- codecraftai-testbase = {source = "codecraftai"}
49
-
50
- [[tool.poetry.source]]
51
- name = "codecraftai"
52
- url = "https://code-craft.ai/licensed-repository/simple/"
53
- priority = "supplemental"
54
-
55
- [[tool.uv.index]]
56
- # Same licensed index as [[tool.poetry.source]]. Listed before PyPI so that
57
- # codecraftai-* packages (direct and transitive) resolve from it; everything
58
- # else falls through to PyPI. Credentials: UV_INDEX_CODECRAFTAI_USERNAME /
59
- # UV_INDEX_CODECRAFTAI_PASSWORD, or `uv auth login`.
60
- name = "codecraftai"
61
- url = "https://code-craft.ai/licensed-repository/simple/"
62
-
63
42
  [tool.ruff.lint]
64
43
  # Deliberately narrow. This gate exists for one reason: a bare `except:`
65
44
  # swallows ConfigurationError and SemanticError, which derive from
@@ -164,6 +164,40 @@ def wrap_value(value: Any) -> Any:
164
164
  return rtnval
165
165
 
166
166
 
167
+ class RepeatedItemsField(list):
168
+ """
169
+ The value of a message's ``items`` field.
170
+
171
+ ``items`` is both a repeated field of the Compute API (list bodies,
172
+ ``metadata.items``) and a ``dict`` method, and normal attribute lookup
173
+ would always find the method. This list answers the field, and when
174
+ CALLED still behaves as ``dict.items()`` of the owning message, so
175
+ ``for entry in metadata.items`` and ``message.items()`` both work, as
176
+ do the ``json``, ``copy`` and ``pickle`` machinery that call
177
+ ``items()`` on a ``dict`` subclass.
178
+ """
179
+
180
+ def __init__(self, values: Any, *, owner: dict) -> None:
181
+ """
182
+ Construct a RepeatedItemsField.
183
+
184
+ :param values: The field's entries.
185
+ :param owner: The message the field belongs to.
186
+ """
187
+ super().__init__(values)
188
+ self._owner = owner
189
+ return
190
+
191
+ def __call__(self) -> Any:
192
+ """
193
+ Behave as the owning message's ``dict.items()``.
194
+
195
+ :returns: The owning message's items view.
196
+ """
197
+ rtnval = dict.items(self._owner)
198
+ return rtnval
199
+
200
+
167
201
  class ProtoObject(dict):
168
202
  """
169
203
  A ``dict`` of Google Cloud JSON presented as a protobuf message.
@@ -172,6 +206,28 @@ class ProtoObject(dict):
172
206
  with its typed zero value rather than ``None``.
173
207
  """
174
208
 
209
+ def __getattribute__(self, name: str) -> Any:
210
+ """
211
+ Resolve attribute access, letting the ``items`` field shadow the
212
+ ``dict`` method it collides with.
213
+
214
+ :param name: The attribute name.
215
+
216
+ :returns: For ``items``, a :class:`RepeatedItemsField` holding the
217
+ field's entries (empty when unset) that is also callable as
218
+ ``dict.items()``; otherwise normal attribute resolution.
219
+ """
220
+ if name == "items":
221
+ if dict.__contains__(self, "items") is False:
222
+ rtnval = RepeatedItemsField([], owner=self)
223
+ return rtnval
224
+ value = coerce_value(name, dict.__getitem__(self, "items"))
225
+ if isinstance(value, list) is True:
226
+ rtnval = RepeatedItemsField(value, owner=self)
227
+ return rtnval
228
+ rtnval = object.__getattribute__(self, name)
229
+ return rtnval
230
+
175
231
  def __getattr__(self, name: str) -> Any:
176
232
  """
177
233
  Resolve a field by attribute access.
@@ -70,7 +70,8 @@ class GoogleTransport:
70
70
  :returns: The decoded response, empty when there is no body.
71
71
 
72
72
  :raises: :class:`NotFound` on 404, otherwise
73
- :class:`GoogleApiError` on a non-success status.
73
+ :class:`GoogleApiError` on a non-success status or on a
74
+ success response whose body is not JSON.
74
75
  """
75
76
  query: Dict[str, Any] = {}
76
77
  if params is not None:
@@ -124,9 +125,23 @@ class GoogleTransport:
124
125
 
125
126
  try:
126
127
  decoded = response.json()
127
- except Exception:
128
- rtnval = ProtoObject()
129
- return rtnval
128
+ except ValueError as xcpt:
129
+ # A success status with a body that is not JSON (an intercepting
130
+ # proxy's page, a truncated body) must not read as an empty
131
+ # answer: a listing would come back as "no resources".
132
+ excerpt = text.strip()[:200]
133
+
134
+ err_msg_lines = ["The Google Cloud API answered with a body that "
135
+ "is not JSON."]
136
+ err_msg_lines.append("METHOD: {}".format(method))
137
+ err_msg_lines.append("URL: {}".format(url))
138
+ err_msg_lines.append("STATUS: {}".format(status))
139
+ err_msg_lines.append("BODY: {}".format(excerpt))
140
+ err_msg = os.linesep.join(err_msg_lines)
141
+
142
+ raise GoogleApiError(err_msg, status=status,
143
+ reason="non-JSON success body",
144
+ body=text) from xcpt
130
145
 
131
146
  wrapped = wrap_value(decoded)
132
147
  if isinstance(wrapped, ProtoObject) is True:
@@ -233,13 +233,19 @@ class StorageClient:
233
233
 
234
234
  def _delete_objects(self, *, bucket_name: str) -> None:
235
235
  """
236
- Delete every object in a bucket.
236
+ Delete every object in a bucket, every generation of it.
237
+
238
+ In a versioned bucket a delete by name only turns the live
239
+ version noncurrent, and noncurrent versions appear only in a
240
+ versioned listing; the bucket would stay non-empty and its delete
241
+ would fail. So the listing asks for every version and each one is
242
+ deleted by its generation.
237
243
 
238
244
  :param bucket_name: The bucket name.
239
245
 
240
246
  :returns: ``None``
241
247
  """
242
- params: Dict[str, Any] = {}
248
+ params: Dict[str, Any] = {"versions": "true"}
243
249
 
244
250
  while True:
245
251
  payload = self._transport.request(
@@ -252,10 +258,15 @@ class StorageClient:
252
258
  name = entry.get("name", None)
253
259
  if name is None:
254
260
  continue
261
+ delete_params: Dict[str, Any] = {}
262
+ generation = entry.get("generation", None)
263
+ if generation is not None:
264
+ delete_params["generation"] = str(generation)
255
265
  self._transport.request(
256
266
  method="DELETE",
257
267
  url="{}/b/{}/o/{}".format(self._endpoint, bucket_name,
258
- _quote(str(name))))
268
+ _quote(str(name))),
269
+ params=delete_params)
259
270
 
260
271
  token = payload.get("nextPageToken", None)
261
272
  if token is None or len(str(token)) == 0: