Skip to content

Commit 7fd96fe

Browse files
committed
[Monitor Ingestion] Add typespec generation files
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
1 parent 824cc36 commit 7fd96fe

24 files changed

+1432
-243
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
recursive-include tests *.py
2-
recursive-include samples *.py
31
include *.md
42
include LICENSE
3+
include azure/monitor/ingestion/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
56
include azure/__init__.py
67
include azure/monitor/__init__.py
7-
include azure/monitor/ingestion/py.typed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"apiVersion": "2023-01-01"
3+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"CrossLanguagePackageId": "LogsIngestion",
3+
"CrossLanguageDefinitionId": {}
4+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# 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.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88
# pylint: disable=wrong-import-position
@@ -13,6 +13,9 @@
1313
from ._patch import * # pylint: disable=unused-wildcard-import
1414

1515
from ._client import LogsIngestionClient # type: ignore
16+
from ._version import VERSION
17+
18+
__version__ = VERSION
1619

1720
try:
1821
from ._patch import __all__ as _patch_all

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/_client.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# 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.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

@@ -16,28 +16,30 @@
1616

1717
from ._configuration import LogsIngestionClientConfiguration
1818
from ._operations import LogsIngestionClientOperationsMixin
19-
from ._serialization import Deserializer, Serializer
19+
from ._utils.serialization import Deserializer, Serializer
2020

2121
if TYPE_CHECKING:
2222
from azure.core.credentials import TokenCredential
2323

2424

2525
class LogsIngestionClient(LogsIngestionClientOperationsMixin):
26-
"""Azure Monitor Data Collection Python Client.
26+
"""Azure Monitor data collection client.
2727
28-
:param endpoint: The Data Collection Endpoint for the Data Collection Rule, for example
29-
https://dce-name.eastus-2.ingest.monitor.azure.com. Required.
28+
:param endpoint: The Data Collection Endpoint for the Data Collection Rule. For example,
29+
`https://dce-name.eastus-2.ingest.monitor.azure.com
30+
<https://dce-name.eastus-2.ingest.monitor.azure.com>`_. Required.
3031
:type endpoint: str
31-
:param credential: Credential needed for the client to connect to Azure. Required.
32+
:param credential: Credential used to authenticate requests to the service. Required.
3233
:type credential: ~azure.core.credentials.TokenCredential
33-
:keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this
34-
default value may result in unsupported behavior.
34+
:keyword api_version: The API version to use for this operation. Default value is "2023-01-01".
35+
Note that overriding this default value may result in unsupported behavior.
3536
:paramtype api_version: str
3637
"""
3738

3839
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
3940
_endpoint = "{endpoint}"
4041
self._config = LogsIngestionClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
42+
4143
_policies = kwargs.pop("policies", None)
4244
if _policies is None:
4345
_policies = [

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/_configuration.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,34 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# 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.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

99
from typing import Any, TYPE_CHECKING
1010

1111
from azure.core.pipeline import policies
1212

13+
from ._version import VERSION
14+
1315
if TYPE_CHECKING:
1416
from azure.core.credentials import TokenCredential
1517

16-
VERSION = "unknown"
17-
1818

1919
class LogsIngestionClientConfiguration: # pylint: disable=too-many-instance-attributes
2020
"""Configuration for LogsIngestionClient.
2121
2222
Note that all parameters used to create this instance are saved as instance
2323
attributes.
2424
25-
:param endpoint: The Data Collection Endpoint for the Data Collection Rule, for example
26-
https://dce-name.eastus-2.ingest.monitor.azure.com. Required.
25+
:param endpoint: The Data Collection Endpoint for the Data Collection Rule. For example,
26+
`https://dce-name.eastus-2.ingest.monitor.azure.com
27+
<https://dce-name.eastus-2.ingest.monitor.azure.com>`_. Required.
2728
:type endpoint: str
28-
:param credential: Credential needed for the client to connect to Azure. Required.
29+
:param credential: Credential used to authenticate requests to the service. Required.
2930
:type credential: ~azure.core.credentials.TokenCredential
30-
:keyword api_version: Api Version. Default value is "2023-01-01". Note that overriding this
31-
default value may result in unsupported behavior.
31+
:keyword api_version: The API version to use for this operation. Default value is "2023-01-01".
32+
Note that overriding this default value may result in unsupported behavior.
3233
:paramtype api_version: str
3334
"""
3435

@@ -43,7 +44,7 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any)
4344
self.endpoint = endpoint
4445
self.credential = credential
4546
self.api_version = api_version
46-
self.credential_scopes = kwargs.pop("credential_scopes", ["https://monitor.azure.com//.default"])
47+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://monitor.azure.com/.default"])
4748
kwargs.setdefault("sdk_moniker", "monitor-ingestion/{}".format(VERSION))
4849
self.polling_interval = kwargs.get("polling_interval", 30)
4950
self._configure(**kwargs)

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/_operations/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# 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.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88
# pylint: disable=wrong-import-position

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/_operations/_operations.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
# --------------------------------------------------------------------------
33
# Copyright (c) Microsoft Corporation. All rights reserved.
44
# 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.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
from collections.abc import MutableMapping
89
from io import IOBase
9-
import sys
10+
import json
1011
from typing import Any, Callable, Dict, IO, List, Optional, TypeVar, Union, overload
1112

13+
from azure.core import PipelineClient
1214
from azure.core.exceptions import (
1315
ClientAuthenticationError,
1416
HttpResponseError,
@@ -22,14 +24,11 @@
2224
from azure.core.tracing.decorator import distributed_trace
2325
from azure.core.utils import case_insensitive_dict
2426

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
2731

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
3332
T = TypeVar("T")
3433
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]]
3534

@@ -38,7 +37,7 @@
3837

3938

4039
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
4241
) -> HttpRequest:
4342
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
4443
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
@@ -51,7 +50,7 @@ def build_logs_ingestion_upload_request(
5150
_url = "/dataCollectionRules/{ruleId}/streams/{stream}"
5251
path_format_arguments = {
5352
"ruleId": _SERIALIZER.url("rule_id", rule_id, "str"),
54-
"stream": _SERIALIZER.url("stream", stream, "str"),
53+
"stream": _SERIALIZER.url("stream_name", stream_name, "str"),
5554
}
5655

5756
_url: str = _url.format(**path_format_arguments) # type: ignore
@@ -69,14 +68,16 @@ def build_logs_ingestion_upload_request(
6968
return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs)
7069

7170

72-
class LogsIngestionClientOperationsMixin(LogsIngestionClientMixinABC):
71+
class LogsIngestionClientOperationsMixin(
72+
ClientMixinABC[PipelineClient[HttpRequest, HttpResponse], LogsIngestionClientConfiguration]
73+
):
7374

7475
@overload
7576
def _upload(
7677
self,
7778
rule_id: str,
78-
stream: str,
79-
body: List[JSON],
79+
stream_name: str,
80+
body: List[Dict[str, Any]],
8081
*,
8182
content_encoding: Optional[str] = None,
8283
content_type: str = "application/json",
@@ -86,7 +87,7 @@ def _upload(
8687
def _upload(
8788
self,
8889
rule_id: str,
89-
stream: str,
90+
stream_name: str,
9091
body: IO[bytes],
9192
*,
9293
content_encoding: Optional[str] = None,
@@ -98,24 +99,26 @@ def _upload(
9899
def _upload( # pylint: disable=inconsistent-return-statements
99100
self,
100101
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]],
103104
*,
104105
content_encoding: Optional[str] = None,
105106
**kwargs: Any
106107
) -> None:
107108
"""Ingestion API used to directly ingest data using Data Collection Rules.
108109
109-
See error response code and error response message for more detail.
110+
Ingestion API used to directly ingest data using Data Collection Rules.
110111
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.
112113
: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.
119122
:paramtype content_encoding: str
120123
:return: None
121124
:rtype: None
@@ -136,20 +139,18 @@ def _upload( # pylint: disable=inconsistent-return-statements
136139
cls: ClsType[None] = kwargs.pop("cls", None)
137140

138141
content_type = content_type or "application/json"
139-
_json = None
140142
_content = None
141143
if isinstance(body, (IOBase, bytes)):
142144
_content = body
143145
else:
144-
_json = body
146+
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
145147

146148
_request = build_logs_ingestion_upload_request(
147149
rule_id=rule_id,
148-
stream=stream,
150+
stream_name=stream_name,
149151
content_encoding=content_encoding,
150152
content_type=content_type,
151153
api_version=self._config.api_version,
152-
json=_json,
153154
content=_content,
154155
headers=_headers,
155156
params=_params,

0 commit comments

Comments
 (0)