Skip to content

Commit fa7dd72

Browse files
authored
feat: add multimodal configuration api (#350)
1 parent d32bd02 commit fa7dd72

File tree

4 files changed

+121
-1
lines changed

4 files changed

+121
-1
lines changed

aliyun/log/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
from .metering_mode_response import GetLogStoreMeteringModeResponse, \
4949
GetMetricStoreMeteringModeResponse, \
5050
UpdateLogStoreMeteringModeResponse, UpdateMetricStoreMeteringModeResponse
51+
from .multimodal_config_response import GetLogStoreMultimodalConfigurationResponse, \
52+
PutLogStoreMultimodalConfigurationResponse
5153
from .object_response import PutObjectResponse, GetObjectResponse
5254

5355
from .store_view import StoreView, StoreViewStore

aliyun/log/logclient.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@
7676
from .metering_mode_response import GetLogStoreMeteringModeResponse, \
7777
GetMetricStoreMeteringModeResponse, UpdateLogStoreMeteringModeResponse, \
7878
UpdateMetricStoreMeteringModeResponse
79+
from .multimodal_config_response import GetLogStoreMultimodalConfigurationResponse, \
80+
PutLogStoreMultimodalConfigurationResponse
7981
from .object_response import PutObjectResponse, GetObjectResponse
8082
from .util import require_python3, object_name_encode
8183

@@ -1833,6 +1835,61 @@ def update_logstore_metering_mode(self, project_name, logstore_name, metering_mo
18331835
(resp, header) = self._send("PUT", project_name, body_str, resource, params, headers)
18341836
return UpdateLogStoreMeteringModeResponse(header, resp)
18351837

1838+
def get_logstore_multimodal_configuration(self, project_name, logstore_name):
1839+
""" Get the multimodal configuration of the logstore
1840+
Unsuccessful operation will cause an LogException.
1841+
1842+
:type project_name: string
1843+
:param project_name: the Project name
1844+
1845+
:type logstore_name: string
1846+
:param logstore_name: the logstore name
1847+
1848+
:return: GetLogStoreMultimodalConfigurationResponse
1849+
1850+
:raise: LogException
1851+
"""
1852+
params = {}
1853+
resource = "/logstores/" + logstore_name + "/multimodalconfiguration"
1854+
headers = {}
1855+
1856+
(resp, header) = self._send("GET", project_name, None, resource, params, headers)
1857+
return GetLogStoreMultimodalConfigurationResponse(resp, header)
1858+
1859+
def put_logstore_multimodal_configuration(self, project_name, logstore_name, status, anonymous_write=None):
1860+
""" Put the multimodal configuration of the logstore
1861+
Unsuccessful operation will cause an LogException.
1862+
1863+
:type project_name: string
1864+
:param project_name: the Project name
1865+
1866+
:type logstore_name: string
1867+
:param logstore_name: the logstore name
1868+
1869+
:type status: string
1870+
:param status: the status of multimodal configuration, required (e.g., "Enabled" or "Disabled")
1871+
1872+
:type anonymous_write: string
1873+
:param anonymous_write: the anonymous write setting, optional (e.g., "Enabled" or "Disabled")
1874+
1875+
:return: PutLogStoreMultimodalConfigurationResponse
1876+
1877+
:raise: LogException
1878+
"""
1879+
params = {}
1880+
resource = "/logstores/" + logstore_name + "/multimodalconfiguration"
1881+
headers = {"x-log-bodyrawsize": '0', "Content-Type": "application/json"}
1882+
body = {
1883+
"status": status
1884+
}
1885+
if anonymous_write is not None:
1886+
body["anonymousWrite"] = anonymous_write
1887+
1888+
body_str = six.b(json.dumps(body))
1889+
1890+
(resp, header) = self._send("PUT", project_name, body_str, resource, params, headers)
1891+
return PutLogStoreMultimodalConfigurationResponse(header, resp)
1892+
18361893
def get_metric_store_metering_mode(self, project_name, metric_store_name):
18371894
""" Get the metering mode of the metric store
18381895
Unsuccessful operation will cause an LogException.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
4+
# Copyright (C) Alibaba Cloud Computing
5+
# All rights reserved.
6+
7+
from .util import Util
8+
from .logresponse import LogResponse
9+
10+
11+
class GetLogStoreMultimodalConfigurationResponse(LogResponse):
12+
""" The response of the get_logstore_multimodal_configuration API from log.
13+
14+
:type header: dict
15+
:param header: GetLogStoreMultimodalConfigurationResponse HTTP response header
16+
17+
:type resp: dict
18+
:param resp: the HTTP response body
19+
"""
20+
21+
def __init__(self, resp, header):
22+
LogResponse.__init__(self, header, resp)
23+
self.status = Util.convert_unicode_to_str(resp["status"])
24+
self.anonymous_write = None
25+
if "anonymousWrite" in resp:
26+
self.anonymous_write = Util.convert_unicode_to_str(resp["anonymousWrite"])
27+
28+
def get_status(self):
29+
"""
30+
:return: string, the status of the multimodal configuration
31+
"""
32+
return self.status
33+
34+
def get_anonymous_write(self):
35+
"""
36+
:return: string, the anonymous write setting, or None if not set
37+
"""
38+
return self.anonymous_write
39+
40+
def log_print(self):
41+
print('GetLogStoreMultimodalConfigurationResponse')
42+
print('headers:', self.get_all_headers())
43+
print('status:', self.status)
44+
if self.anonymous_write is not None:
45+
print('anonymousWrite:', self.anonymous_write)
46+
47+
48+
class PutLogStoreMultimodalConfigurationResponse(LogResponse):
49+
""" The response of the put_logstore_multimodal_configuration API from log.
50+
51+
:type header: dict
52+
:param header: PutLogStoreMultimodalConfigurationResponse HTTP response header
53+
"""
54+
55+
def __init__(self, header, resp=''):
56+
LogResponse.__init__(self, header, resp)
57+
58+
def log_print(self):
59+
print('PutLogStoreMultimodalConfigurationResponse:')
60+
print('headers:', self.get_all_headers())
61+

aliyun/log/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.9.39'
1+
__version__ = '0.9.40'
22

33
import sys
44
OS_VERSION = str(sys.platform)

0 commit comments

Comments
 (0)