Skip to content

Commit 34670f7

Browse files
author
SDKAuto
committed
CodeGen from PR 3537 in test-repo-billy/azure-rest-api-specs
Merge 6296b8e5c14516850f6b39a7fee10b2f0db170a5 into 6c6e1713f03acaf37e5c89652b023dd2c9eae16e
1 parent b2b0c35 commit 34670f7

33 files changed

+773
-1059
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
include *.md
22
include LICENSE
33
include azure/ai/vision/imageanalysis/py.typed
4-
recursive-include tests *.py *.md sample.jpg
5-
recursive-include samples *.py *.md sample.jpg run_all_samples.cmd run_all_samples.ps1
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
66
include azure/__init__.py
77
include azure/ai/__init__.py
88
include azure/ai/vision/__init__.py
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"commit": "bef35d01d2572ba131d7f2d4cd8d6313ec649525",
3-
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4-
"typespec_src": "specification/cognitiveservices/Vision.ImageAnalysis",
5-
"@azure-tools/typespec-python": "0.15.0"
2+
"commit": "c29452397f8d29456182b951987a765d1ae01bb1",
3+
"repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs",
4+
"typespec_src": "specification/ai/ImageAnalysis",
5+
"@azure-tools/typespec-python": "0.31.1"
66
}

sdk/vision/azure-ai-vision-imageanalysis/azure/ai/vision/imageanalysis/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._patch import ImageAnalysisClient
9+
from ._client import ImageAnalysisClient
1010
from ._version import VERSION
1111

1212
__version__ = VERSION
1313

14-
14+
try:
15+
from ._patch import __all__ as _patch_all
16+
from ._patch import * # pylint: disable=unused-wildcard-import
17+
except ImportError:
18+
_patch_all = []
1519
from ._patch import patch_sdk as _patch_sdk
1620

1721
__all__ = [
1822
"ImageAnalysisClient",
1923
]
20-
24+
__all__.extend([p for p in _patch_all if p not in __all__])
2125

2226
_patch_sdk()

sdk/vision/azure-ai-vision-imageanalysis/azure/ai/vision/imageanalysis/_model_base.py

Lines changed: 308 additions & 38 deletions
Large diffs are not rendered by default.

sdk/vision/azure-ai-vision-imageanalysis/azure/ai/vision/imageanalysis/_operations/_operations.py

Lines changed: 12 additions & 235 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
ResourceExistsError,
1818
ResourceNotFoundError,
1919
ResourceNotModifiedError,
20+
StreamClosedError,
21+
StreamConsumedError,
2022
map_error,
2123
)
2224
from azure.core.pipeline import PipelineResponse
@@ -173,121 +175,8 @@ def _analyze_from_image_data(
173175
:return: ImageAnalysisResult. The ImageAnalysisResult is compatible with MutableMapping
174176
:rtype: ~azure.ai.vision.imageanalysis.models.ImageAnalysisResult
175177
:raises ~azure.core.exceptions.HttpResponseError:
176-
177-
Example:
178-
.. code-block:: python
179-
180-
# response body for status code(s): 200
181-
response == {
182-
"metadata": {
183-
"height": 0,
184-
"width": 0
185-
},
186-
"modelVersion": "str",
187-
"captionResult": {
188-
"confidence": 0.0,
189-
"text": "str"
190-
},
191-
"denseCaptionsResult": {
192-
"values": [
193-
{
194-
"boundingBox": {
195-
"h": 0,
196-
"w": 0,
197-
"x": 0,
198-
"y": 0
199-
},
200-
"confidence": 0.0,
201-
"text": "str"
202-
}
203-
]
204-
},
205-
"objectsResult": {
206-
"values": [
207-
{
208-
"boundingBox": {
209-
"h": 0,
210-
"w": 0,
211-
"x": 0,
212-
"y": 0
213-
},
214-
"tags": [
215-
{
216-
"confidence": 0.0,
217-
"name": "str"
218-
}
219-
]
220-
}
221-
]
222-
},
223-
"peopleResult": {
224-
"values": [
225-
{
226-
"boundingBox": {
227-
"h": 0,
228-
"w": 0,
229-
"x": 0,
230-
"y": 0
231-
},
232-
"confidence": 0.0
233-
}
234-
]
235-
},
236-
"readResult": {
237-
"blocks": [
238-
{
239-
"lines": [
240-
{
241-
"boundingPolygon": [
242-
{
243-
"x": 0,
244-
"y": 0
245-
}
246-
],
247-
"text": "str",
248-
"words": [
249-
{
250-
"boundingPolygon": [
251-
{
252-
"x":
253-
0,
254-
"y":
255-
0
256-
}
257-
],
258-
"confidence": 0.0,
259-
"text": "str"
260-
}
261-
]
262-
}
263-
]
264-
}
265-
]
266-
},
267-
"smartCropsResult": {
268-
"values": [
269-
{
270-
"aspectRatio": 0.0,
271-
"boundingBox": {
272-
"h": 0,
273-
"w": 0,
274-
"x": 0,
275-
"y": 0
276-
}
277-
}
278-
]
279-
},
280-
"tagsResult": {
281-
"values": [
282-
{
283-
"confidence": 0.0,
284-
"name": "str"
285-
}
286-
]
287-
}
288-
}
289178
"""
290-
error_map: MutableMapping[int, Type[HttpResponseError]] = {
179+
error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object
291180
401: ClientAuthenticationError,
292181
404: ResourceNotFoundError,
293182
409: ResourceExistsError,
@@ -329,7 +218,10 @@ def _analyze_from_image_data(
329218

330219
if response.status_code not in [200]:
331220
if _stream:
332-
response.read() # Load the body in memory and close the socket
221+
try:
222+
response.read() # Load the body in memory and close the socket
223+
except (StreamConsumedError, StreamClosedError):
224+
pass
333225
map_error(status_code=response.status_code, response=response, error_map=error_map)
334226
raise HttpResponseError(response=response)
335227

@@ -433,126 +325,8 @@ def _analyze_from_url(
433325
:return: ImageAnalysisResult. The ImageAnalysisResult is compatible with MutableMapping
434326
:rtype: ~azure.ai.vision.imageanalysis.models.ImageAnalysisResult
435327
:raises ~azure.core.exceptions.HttpResponseError:
436-
437-
Example:
438-
.. code-block:: python
439-
440-
# JSON input template you can fill out and use as your body input.
441-
image_url = {
442-
"url": "str"
443-
}
444-
445-
# response body for status code(s): 200
446-
response == {
447-
"metadata": {
448-
"height": 0,
449-
"width": 0
450-
},
451-
"modelVersion": "str",
452-
"captionResult": {
453-
"confidence": 0.0,
454-
"text": "str"
455-
},
456-
"denseCaptionsResult": {
457-
"values": [
458-
{
459-
"boundingBox": {
460-
"h": 0,
461-
"w": 0,
462-
"x": 0,
463-
"y": 0
464-
},
465-
"confidence": 0.0,
466-
"text": "str"
467-
}
468-
]
469-
},
470-
"objectsResult": {
471-
"values": [
472-
{
473-
"boundingBox": {
474-
"h": 0,
475-
"w": 0,
476-
"x": 0,
477-
"y": 0
478-
},
479-
"tags": [
480-
{
481-
"confidence": 0.0,
482-
"name": "str"
483-
}
484-
]
485-
}
486-
]
487-
},
488-
"peopleResult": {
489-
"values": [
490-
{
491-
"boundingBox": {
492-
"h": 0,
493-
"w": 0,
494-
"x": 0,
495-
"y": 0
496-
},
497-
"confidence": 0.0
498-
}
499-
]
500-
},
501-
"readResult": {
502-
"blocks": [
503-
{
504-
"lines": [
505-
{
506-
"boundingPolygon": [
507-
{
508-
"x": 0,
509-
"y": 0
510-
}
511-
],
512-
"text": "str",
513-
"words": [
514-
{
515-
"boundingPolygon": [
516-
{
517-
"x":
518-
0,
519-
"y":
520-
0
521-
}
522-
],
523-
"confidence": 0.0,
524-
"text": "str"
525-
}
526-
]
527-
}
528-
]
529-
}
530-
]
531-
},
532-
"smartCropsResult": {
533-
"values": [
534-
{
535-
"aspectRatio": 0.0,
536-
"boundingBox": {
537-
"h": 0,
538-
"w": 0,
539-
"x": 0,
540-
"y": 0
541-
}
542-
}
543-
]
544-
},
545-
"tagsResult": {
546-
"values": [
547-
{
548-
"confidence": 0.0,
549-
"name": "str"
550-
}
551-
]
552-
}
553-
}
554328
"""
555-
error_map: MutableMapping[int, Type[HttpResponseError]] = {
329+
error_map: MutableMapping[int, Type[HttpResponseError]] = { # pylint: disable=unsubscriptable-object
556330
401: ClientAuthenticationError,
557331
404: ResourceNotFoundError,
558332
409: ResourceExistsError,
@@ -599,7 +373,10 @@ def _analyze_from_url(
599373

600374
if response.status_code not in [200]:
601375
if _stream:
602-
response.read() # Load the body in memory and close the socket
376+
try:
377+
response.read() # Load the body in memory and close the socket
378+
except (StreamConsumedError, StreamClosedError):
379+
pass
603380
map_error(status_code=response.status_code, response=response, error_map=error_map)
604381
raise HttpResponseError(response=response)
605382

sdk/vision/azure-ai-vision-imageanalysis/azure/ai/vision/imageanalysis/_operations/_patch.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# coding=utf-8
2-
# --------------------------------------------------------------------------
3-
# Copyright (c) Microsoft Corporation. All rights reserved.
4-
# Licensed under the MIT License. See License.txt in the project root for license information.
5-
# --------------------------------------------------------------------------
1+
# ------------------------------------
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
# ------------------------------------
5+
"""Customize generated code here.
6+
7+
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
8+
"""
69
from typing import List
710

811
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level

0 commit comments

Comments
 (0)