Skip to content

Commit 49abb80

Browse files
committed
for test
1 parent c54b7ce commit 49abb80

25 files changed

+1530
-0
lines changed

src/fortest/HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. :changelog:
2+
3+
Release History
4+
===============
5+
6+
1.0.0b1
7+
++++++
8+
* Initial release.

src/fortest/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Azure CLI Carbon Extension #
2+
This is an extension to Azure CLI to manage Carbon resources.
3+
4+
## How to use ##
5+
Install this extension using the below CLI command
6+
```
7+
az extension add --name carbon
8+
```
9+
### Included Features
10+
11+
##### Get emission data available date range.
12+
```
13+
az carbon get-emission-data-available-date-range
14+
```
15+
16+
##### Get emission report - overall summary.
17+
18+
```
19+
az carbon get-emission-report --subscription-list [00000000-0000-0000-0000-000000000000] --date-range '{start:2024-04-01,end:2025-04-01}' --carbon-scope-list [Scope1,Scope2,Scope3] --overall-summary
20+
```
21+
22+
##### Get emission report - monthly summary
23+
24+
```
25+
az carbon get-emission-report --subscription-list [00000000-0000-0000-0000-000000000000] --date-range '{start:2024-04-01,end:2025-04-01}' --carbon-scope-list [Scope1,Scope2,Scope3] --monthly-summary
26+
```
27+
28+
##### Get emission report - item details
29+
30+
```
31+
az carbon get-emission-report --subscription-list [00000000-0000-0000-0000-000000000000] --date-range '{start:2025-04-01,end:2025-04-01}' --carbon-scope-list [Scope1,Scope2,Scope3] --item-details "{category-type:ResourceType,order-by:ItemName,page-size:10,sort-direction:desc}"
32+
```
33+
34+
##### Get emission report - top items summary
35+
36+
```
37+
az carbon get-emission-report --subscription-list [00000000-0000-0000-0000-000000000000] --date-range '{start:2025-04-01,end:2025-04-01}' --carbon-scope-list [Scope1,Scope2,Scope3] --top-items-summary "{category-type:ResourceType,top-items:5}"
38+
```
39+
40+
##### Get emission report - top items monthly summary
41+
42+
```
43+
az carbon get-emission-report --subscription-list [00000000-0000-0000-0000-000000000000] --date-range '{start:2024-04-01,end:2025-04-01}' --carbon-scope-list [Scope1,Scope2,Scope3] --top-items-monthly "{category-type:ResourceType,top-items:5}"
44+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
from azure.cli.core import AzCommandsLoader
9+
from azext_carbon._help import helps # pylint: disable=unused-import
10+
11+
12+
class CarbonCommandsLoader(AzCommandsLoader):
13+
14+
def __init__(self, cli_ctx=None):
15+
from azure.cli.core.commands import CliCommandType
16+
custom_command_type = CliCommandType(
17+
operations_tmpl='azext_carbon.custom#{}')
18+
super().__init__(cli_ctx=cli_ctx,
19+
custom_command_type=custom_command_type)
20+
21+
def load_command_table(self, args):
22+
from azext_carbon.commands import load_command_table
23+
from azure.cli.core.aaz import load_aaz_command_table
24+
try:
25+
from . import aaz
26+
except ImportError:
27+
aaz = None
28+
if aaz:
29+
load_aaz_command_table(
30+
loader=self,
31+
aaz_pkg_name=aaz.__name__,
32+
args=args
33+
)
34+
load_command_table(self, args)
35+
return self.command_table
36+
37+
def load_arguments(self, command):
38+
from azext_carbon._params import load_arguments
39+
load_arguments(self, command)
40+
41+
42+
COMMAND_LOADER_CLS = CarbonCommandsLoader

src/fortest/azext_carbon/_help.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: disable=line-too-long
9+
# pylint: disable=too-many-lines
10+
11+
from knack.help_files import helps # pylint: disable=unused-import
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: disable=too-many-lines
9+
# pylint: disable=too-many-statements
10+
11+
12+
def load_arguments(self, _): # pylint: disable=unused-argument
13+
pass
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command_group(
15+
"carbon",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Carbon
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from .__cmd_group import *
12+
from ._get_emission_data_available_date_range import *
13+
from ._get_emission_report import *
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command(
15+
"carbon get-emission-data-available-date-range",
16+
)
17+
class GetEmissionDataAvailableDateRange(AAZCommand):
18+
"""API for query carbon emission data available date range
19+
20+
:example: Query Carbon Emission Data Available Date Range
21+
az carbon get-emission-data-available-date-range
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2025-04-01",
26+
"resources": [
27+
["mgmt-plane", "/providers/microsoft.carbon/querycarbonemissiondataavailabledaterange", "2025-04-01"],
28+
]
29+
}
30+
31+
def _handler(self, command_args):
32+
super()._handler(command_args)
33+
self._execute_operations()
34+
return self._output()
35+
36+
def _execute_operations(self):
37+
self.pre_operations()
38+
self.CarbonServiceQueryCarbonEmissionDataAvailableDateRange(ctx=self.ctx)()
39+
self.post_operations()
40+
41+
@register_callback
42+
def pre_operations(self):
43+
pass
44+
45+
@register_callback
46+
def post_operations(self):
47+
pass
48+
49+
def _output(self, *args, **kwargs):
50+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
51+
return result
52+
53+
class CarbonServiceQueryCarbonEmissionDataAvailableDateRange(AAZHttpOperation):
54+
CLIENT_TYPE = "MgmtClient"
55+
56+
def __call__(self, *args, **kwargs):
57+
request = self.make_request()
58+
session = self.client.send_request(request=request, stream=False, **kwargs)
59+
if session.http_response.status_code in [200]:
60+
return self.on_200(session)
61+
62+
return self.on_error(session.http_response)
63+
64+
@property
65+
def url(self):
66+
return self.client.format_url(
67+
"/providers/Microsoft.Carbon/queryCarbonEmissionDataAvailableDateRange",
68+
**self.url_parameters
69+
)
70+
71+
@property
72+
def method(self):
73+
return "POST"
74+
75+
@property
76+
def error_format(self):
77+
return "MgmtErrorFormat"
78+
79+
@property
80+
def query_parameters(self):
81+
parameters = {
82+
**self.serialize_query_param(
83+
"api-version", "2025-04-01",
84+
required=True,
85+
),
86+
}
87+
return parameters
88+
89+
@property
90+
def header_parameters(self):
91+
parameters = {
92+
**self.serialize_header_param(
93+
"Accept", "application/json",
94+
),
95+
}
96+
return parameters
97+
98+
def on_200(self, session):
99+
data = self.deserialize_http_content(session)
100+
self.ctx.set_var(
101+
"instance",
102+
data,
103+
schema_builder=self._build_schema_on_200
104+
)
105+
106+
_schema_on_200 = None
107+
108+
@classmethod
109+
def _build_schema_on_200(cls):
110+
if cls._schema_on_200 is not None:
111+
return cls._schema_on_200
112+
113+
cls._schema_on_200 = AAZObjectType()
114+
115+
_schema_on_200 = cls._schema_on_200
116+
_schema_on_200.end_date = AAZStrType(
117+
serialized_name="endDate",
118+
flags={"required": True},
119+
)
120+
_schema_on_200.start_date = AAZStrType(
121+
serialized_name="startDate",
122+
flags={"required": True},
123+
)
124+
125+
return cls._schema_on_200
126+
127+
128+
class _GetEmissionDataAvailableDateRangeHelper:
129+
"""Helper class for GetEmissionDataAvailableDateRange"""
130+
131+
132+
__all__ = ["GetEmissionDataAvailableDateRange"]

0 commit comments

Comments
 (0)