or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

alerts.mdbenefits.mddimensions.mdexports.mdindex.mdprice-sheet.mdquery-forecast.mdreports.mdscheduled-actions.mdviews.md

views.mddocs/

0

# Views Management

1

2

Manage and organize cost analysis views for consistent reporting and sharing across teams. Create, update, and delete custom views with specific filters, groupings, and configurations for standardized cost analysis workflows.

3

4

## Capabilities

5

6

### View Management Operations

7

8

Create, retrieve, update, and delete cost management views with custom configurations for team sharing and consistent analysis.

9

10

```python { .api }

11

def list() -> ViewListResult:

12

"""

13

List all shared views accessible to the current user.

14

15

Returns:

16

ViewListResult: Collection of shared views

17

"""

18

19

def get(view_name: str) -> View:

20

"""

21

Get a specific shared view by name.

22

23

Args:

24

view_name (str): Name of the view to retrieve

25

26

Returns:

27

View: View configuration and properties

28

"""

29

30

def create_or_update(view_name: str, parameters: View) -> View:

31

"""

32

Create or update a shared view.

33

34

Args:

35

view_name (str): Name for the view

36

parameters (View): View configuration details

37

38

Returns:

39

View: Created or updated view

40

"""

41

42

def delete(view_name: str) -> None:

43

"""

44

Delete a shared view.

45

46

Args:

47

view_name (str): Name of the view to delete

48

"""

49

```

50

51

### Scoped View Operations

52

53

Manage views within specific scopes like subscriptions or resource groups for targeted cost analysis.

54

55

```python { .api }

56

def list_by_scope(scope: str) -> ViewListResult:

57

"""

58

List views for a specific scope.

59

60

Args:

61

scope (str): The scope to list views for

62

63

Returns:

64

ViewListResult: Collection of scoped views

65

"""

66

67

def get_by_scope(scope: str, view_name: str) -> View:

68

"""

69

Get a specific view within a scope.

70

71

Args:

72

scope (str): The scope containing the view

73

view_name (str): Name of the view

74

75

Returns:

76

View: Scoped view configuration

77

"""

78

79

def create_or_update_by_scope(scope: str, view_name: str, parameters: View) -> View:

80

"""

81

Create or update a view within a specific scope.

82

83

Args:

84

scope (str): The scope for the view

85

view_name (str): Name for the view

86

parameters (View): View configuration

87

88

Returns:

89

View: Created or updated scoped view

90

"""

91

92

def delete_by_scope(scope: str, view_name: str) -> None:

93

"""

94

Delete a view within a specific scope.

95

96

Args:

97

scope (str): The scope containing the view

98

view_name (str): Name of the view to delete

99

"""

100

```

101

102

## Usage Examples

103

104

### Create a Standard Cost Analysis View

105

106

```python

107

from azure.mgmt.costmanagement.models import (

108

View,

109

ReportConfigDefinition,

110

ReportConfigDataset,

111

ReportConfigAggregation,

112

ReportConfigGrouping,

113

ReportConfigTimePeriod,

114

ChartType,

115

TimeframeType,

116

GranularityType

117

)

118

119

# Create view for monthly costs by resource group

120

view_config = View()

121

view_config.display_name = "Monthly Costs by Resource Group"

122

view_config.chart = ChartType.STACKED_COLUMN

123

view_config.accumulated = "true"

124

view_config.metric = "ActualCost"

125

view_config.kpis = [

126

{

127

"type": "Forecast",

128

"enabled": True

129

},

130

{

131

"type": "Budget",

132

"enabled": True,

133

"id": "/subscriptions/{sub-id}/providers/Microsoft.Consumption/budgets/monthly-budget"

134

}

135

]

136

137

# Configure dataset

138

dataset = ReportConfigDataset(

139

granularity=GranularityType.MONTHLY,

140

aggregation={

141

"totalCost": ReportConfigAggregation(name="Cost", function="Sum")

142

},

143

grouping=[

144

ReportConfigGrouping(type="Dimension", name="ResourceGroup")

145

]

146

)

147

148

view_config.query = ReportConfigDefinition(

149

type="ActualCost",

150

timeframe=TimeframeType.THE_LAST_MONTH,

151

dataset=dataset

152

)

153

154

# Create the view

155

created_view = client.views.create_or_update(

156

view_name="monthly-rg-costs",

157

parameters=view_config

158

)

159

160

print(f"Created view: {created_view.display_name}")

161

```

162

163

### List and Browse Available Views

164

165

```python

166

# List all shared views

167

shared_views = client.views.list()

168

169

print(f"Shared views ({len(shared_views.value)}):")

170

for view in shared_views.value:

171

print(f" Name: {view.name}")

172

print(f" Display Name: {view.display_name}")

173

print(f" Chart Type: {view.chart}")

174

print(f" Metric: {view.metric}")

175

print(f" Timeframe: {view.query.timeframe}")

176

print(" ---")

177

178

# List views for specific subscription

179

scope = "/subscriptions/{subscription-id}"

180

scoped_views = client.views.list_by_scope(scope)

181

182

print(f"\nSubscription views ({len(scoped_views.value)}):")

183

for view in scoped_views.value:

184

print(f" {view.name}: {view.display_name}")

185

```

186

187

### Update Existing View

188

189

```python

190

# Get existing view

191

existing_view = client.views.get("monthly-rg-costs")

192

193

# Update display name and chart type

194

existing_view.display_name = "Updated Monthly Resource Group Costs"

195

existing_view.chart = ChartType.LINE

196

197

# Add additional grouping

198

if existing_view.query.dataset.grouping:

199

existing_view.query.dataset.grouping.append(

200

ReportConfigGrouping(type="Dimension", name="ServiceName")

201

)

202

203

# Update the view

204

updated_view = client.views.create_or_update(

205

view_name="monthly-rg-costs",

206

parameters=existing_view

207

)

208

209

print(f"Updated view: {updated_view.display_name}")

210

```

211

212

### Create Service-Specific View

213

214

```python

215

from azure.mgmt.costmanagement.models import ReportConfigFilter, ReportConfigComparisonExpression

216

217

# Create view filtered for specific services

218

service_filter = ReportConfigFilter(

219

and_=[

220

ReportConfigComparisonExpression(

221

name="ServiceName",

222

operator="In",

223

values=["Virtual Machines", "Storage", "Azure SQL Database"]

224

)

225

]

226

)

227

228

service_dataset = ReportConfigDataset(

229

granularity=GranularityType.DAILY,

230

aggregation={

231

"totalCost": ReportConfigAggregation(name="Cost", function="Sum")

232

},

233

grouping=[

234

ReportConfigGrouping(type="Dimension", name="ServiceName")

235

],

236

filter=service_filter

237

)

238

239

service_view = View()

240

service_view.display_name = "Core Services Daily Costs"

241

service_view.chart = ChartType.AREA

242

service_view.accumulated = "false"

243

service_view.metric = "ActualCost"

244

service_view.query = ReportConfigDefinition(

245

type="ActualCost",

246

timeframe=TimeframeType.THE_LAST_WEEK,

247

dataset=service_dataset

248

)

249

250

created_service_view = client.views.create_or_update(

251

view_name="core-services-daily",

252

parameters=service_view

253

)

254

```

255

256

## Data Models

257

258

```python { .api }

259

class View:

260

id: str

261

name: str

262

type: str

263

display_name: str

264

scope: str

265

created_on: str

266

modified_on: str

267

chart: ChartType

268

accumulated: str

269

metric: str

270

kpis: List[KpiProperties]

271

pivots: List[PivotProperties]

272

query: ReportConfigDefinition

273

274

class ViewListResult:

275

value: List[View]

276

next_link: str

277

278

class ReportConfigDefinition:

279

type: str

280

timeframe: TimeframeType

281

time_period: ReportConfigTimePeriod

282

dataset: ReportConfigDataset

283

284

class ReportConfigDataset:

285

granularity: GranularityType

286

configuration: ReportConfigDatasetConfiguration

287

aggregation: Dict[str, ReportConfigAggregation]

288

grouping: List[ReportConfigGrouping]

289

sorting: List[ReportConfigSorting]

290

filter: ReportConfigFilter

291

292

class KpiProperties:

293

type: str

294

enabled: bool

295

id: str

296

297

class PivotProperties:

298

type: str

299

name: str

300

```

301

302

## View Enumerations

303

304

```python { .api }

305

class ChartType(str, Enum):

306

AREA = "Area"

307

LINE = "Line"

308

STACKED_COLUMN = "StackedColumn"

309

GROUPED_COLUMN = "GroupedColumn"

310

TABLE = "Table"

311

312

class KpiType(str, Enum):

313

FORECAST = "Forecast"

314

BUDGET = "Budget"

315

316

class PivotType(str, Enum):

317

DIMENSION = "Dimension"

318

```

319

320

This module provides comprehensive view management capabilities for creating standardized, shareable cost analysis configurations that ensure consistent reporting across teams and projects.