2
2
# --------------------------------------------------------------------------
3
3
# Copyright (c) Microsoft Corporation. All rights reserved.
4
4
# Licensed under the MIT License. See License.txt in the project root for license information.
5
- # Code generated by Microsoft (R) AutoRest Code Generator.
5
+ # Code generated by Microsoft (R) Python Code Generator.
6
6
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
# --------------------------------------------------------------------------
8
+ from collections .abc import MutableMapping
8
9
from io import IOBase
9
- import sys
10
+ import json
10
11
from typing import Any , Callable , Dict , IO , List , Optional , TypeVar , Union , overload
11
12
13
+ from azure .core import PipelineClient
12
14
from azure .core .exceptions import (
13
15
ClientAuthenticationError ,
14
16
HttpResponseError ,
22
24
from azure .core .tracing .decorator import distributed_trace
23
25
from azure .core .utils import case_insensitive_dict
24
26
25
- from .._serialization import Serializer
26
- from .._vendor import LogsIngestionClientMixinABC
27
+ from .._configuration import LogsIngestionClientConfiguration
28
+ from .._utils .model_base import SdkJSONEncoder
29
+ from .._utils .serialization import Serializer
30
+ from .._utils .utils import ClientMixinABC
27
31
28
- if sys .version_info >= (3 , 9 ):
29
- from collections .abc import MutableMapping
30
- else :
31
- from typing import MutableMapping # type: ignore
32
- JSON = MutableMapping [str , Any ] # pylint: disable=unsubscriptable-object
33
32
T = TypeVar ("T" )
34
33
ClsType = Optional [Callable [[PipelineResponse [HttpRequest , HttpResponse ], T , Dict [str , Any ]], Any ]]
35
34
38
37
39
38
40
39
def build_logs_ingestion_upload_request (
41
- rule_id : str , stream : str , * , content_encoding : Optional [str ] = None , ** kwargs : Any
40
+ rule_id : str , stream_name : str , * , content_encoding : Optional [str ] = None , ** kwargs : Any
42
41
) -> HttpRequest :
43
42
_headers = case_insensitive_dict (kwargs .pop ("headers" , {}) or {})
44
43
_params = case_insensitive_dict (kwargs .pop ("params" , {}) or {})
@@ -51,7 +50,7 @@ def build_logs_ingestion_upload_request(
51
50
_url = "/dataCollectionRules/{ruleId}/streams/{stream}"
52
51
path_format_arguments = {
53
52
"ruleId" : _SERIALIZER .url ("rule_id" , rule_id , "str" ),
54
- "stream" : _SERIALIZER .url ("stream " , stream , "str" ),
53
+ "stream" : _SERIALIZER .url ("stream_name " , stream_name , "str" ),
55
54
}
56
55
57
56
_url : str = _url .format (** path_format_arguments ) # type: ignore
@@ -69,14 +68,16 @@ def build_logs_ingestion_upload_request(
69
68
return HttpRequest (method = "POST" , url = _url , params = _params , headers = _headers , ** kwargs )
70
69
71
70
72
- class LogsIngestionClientOperationsMixin (LogsIngestionClientMixinABC ):
71
+ class LogsIngestionClientOperationsMixin (
72
+ ClientMixinABC [PipelineClient [HttpRequest , HttpResponse ], LogsIngestionClientConfiguration ]
73
+ ):
73
74
74
75
@overload
75
76
def _upload (
76
77
self ,
77
78
rule_id : str ,
78
- stream : str ,
79
- body : List [JSON ],
79
+ stream_name : str ,
80
+ body : List [Dict [ str , Any ] ],
80
81
* ,
81
82
content_encoding : Optional [str ] = None ,
82
83
content_type : str = "application/json" ,
@@ -86,7 +87,7 @@ def _upload(
86
87
def _upload (
87
88
self ,
88
89
rule_id : str ,
89
- stream : str ,
90
+ stream_name : str ,
90
91
body : IO [bytes ],
91
92
* ,
92
93
content_encoding : Optional [str ] = None ,
@@ -98,24 +99,26 @@ def _upload(
98
99
def _upload ( # pylint: disable=inconsistent-return-statements
99
100
self ,
100
101
rule_id : str ,
101
- stream : str ,
102
- body : Union [List [JSON ], IO [bytes ]],
102
+ stream_name : str ,
103
+ body : Union [List [Dict [ str , Any ] ], IO [bytes ]],
103
104
* ,
104
105
content_encoding : Optional [str ] = None ,
105
106
** kwargs : Any
106
107
) -> None :
107
108
"""Ingestion API used to directly ingest data using Data Collection Rules.
108
109
109
- See error response code and error response message for more detail .
110
+ Ingestion API used to directly ingest data using Data Collection Rules .
110
111
111
- :param rule_id: The immutable Id of the Data Collection Rule resource. Required.
112
+ :param rule_id: The immutable ID of the Data Collection Rule resource. Required.
112
113
:type rule_id: str
113
- :param stream: The streamDeclaration name as defined in the Data Collection Rule. Required.
114
- :type stream: str
115
- :param body: An array of objects matching the schema defined by the provided stream. Is either
116
- a [JSON] type or a IO[bytes] type. Required.
117
- :type body: list[JSON] or IO[bytes]
118
- :keyword content_encoding: gzip. Default value is None.
114
+ :param stream_name: The streamDeclaration name as defined in the Data Collection Rule.
115
+ Required.
116
+ :type stream_name: str
117
+ :param body: The array of objects matching the schema defined by the provided stream. Is either
118
+ a [{str: Any}] type or a IO[bytes] type. Required.
119
+ :type body: list[dict[str, any]] or IO[bytes]
120
+ :keyword content_encoding: The content encoding of the request body which is always 'gzip'.
121
+ Default value is None.
119
122
:paramtype content_encoding: str
120
123
:return: None
121
124
:rtype: None
@@ -136,20 +139,18 @@ def _upload( # pylint: disable=inconsistent-return-statements
136
139
cls : ClsType [None ] = kwargs .pop ("cls" , None )
137
140
138
141
content_type = content_type or "application/json"
139
- _json = None
140
142
_content = None
141
143
if isinstance (body , (IOBase , bytes )):
142
144
_content = body
143
145
else :
144
- _json = body
146
+ _content = json . dumps ( body , cls = SdkJSONEncoder , exclude_readonly = True ) # type: ignore
145
147
146
148
_request = build_logs_ingestion_upload_request (
147
149
rule_id = rule_id ,
148
- stream = stream ,
150
+ stream_name = stream_name ,
149
151
content_encoding = content_encoding ,
150
152
content_type = content_type ,
151
153
api_version = self ._config .api_version ,
152
- json = _json ,
153
154
content = _content ,
154
155
headers = _headers ,
155
156
params = _params ,
0 commit comments