1package resourcegraph 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "encoding/json" 11 "github.com/Azure/go-autorest/autorest" 12) 13 14// The package's fully qualified name. 15const fqdn = "github.com/Azure/azure-sdk-for-go/services/resourcegraph/mgmt/2019-04-01/resourcegraph" 16 17// Column query result column descriptor. 18type Column struct { 19 // Name - Column name. 20 Name *string `json:"name,omitempty"` 21 // Type - Column data type. Possible values include: 'String', 'Integer', 'Number', 'Boolean', 'Object' 22 Type ColumnDataType `json:"type,omitempty"` 23} 24 25// Error error details. 26type Error struct { 27 // Code - Error code identifying the specific error. 28 Code *string `json:"code,omitempty"` 29 // Message - A human readable error message. 30 Message *string `json:"message,omitempty"` 31 // Details - Error details 32 Details *[]ErrorDetails `json:"details,omitempty"` 33} 34 35// ErrorDetails ... 36type ErrorDetails struct { 37 // AdditionalProperties - Unmatched properties from the message are deserialized this collection 38 AdditionalProperties map[string]interface{} `json:""` 39 // Code - Error code identifying the specific error. 40 Code *string `json:"code,omitempty"` 41 // Message - A human readable error message. 42 Message *string `json:"message,omitempty"` 43} 44 45// MarshalJSON is the custom marshaler for ErrorDetails. 46func (ed ErrorDetails) MarshalJSON() ([]byte, error) { 47 objectMap := make(map[string]interface{}) 48 if ed.Code != nil { 49 objectMap["code"] = ed.Code 50 } 51 if ed.Message != nil { 52 objectMap["message"] = ed.Message 53 } 54 for k, v := range ed.AdditionalProperties { 55 objectMap[k] = v 56 } 57 return json.Marshal(objectMap) 58} 59 60// UnmarshalJSON is the custom unmarshaler for ErrorDetails struct. 61func (ed *ErrorDetails) UnmarshalJSON(body []byte) error { 62 var m map[string]*json.RawMessage 63 err := json.Unmarshal(body, &m) 64 if err != nil { 65 return err 66 } 67 for k, v := range m { 68 switch k { 69 default: 70 if v != nil { 71 var additionalProperties interface{} 72 err = json.Unmarshal(*v, &additionalProperties) 73 if err != nil { 74 return err 75 } 76 if ed.AdditionalProperties == nil { 77 ed.AdditionalProperties = make(map[string]interface{}) 78 } 79 ed.AdditionalProperties[k] = additionalProperties 80 } 81 case "code": 82 if v != nil { 83 var code string 84 err = json.Unmarshal(*v, &code) 85 if err != nil { 86 return err 87 } 88 ed.Code = &code 89 } 90 case "message": 91 if v != nil { 92 var message string 93 err = json.Unmarshal(*v, &message) 94 if err != nil { 95 return err 96 } 97 ed.Message = &message 98 } 99 } 100 } 101 102 return nil 103} 104 105// ErrorResponse an error response from the API. 106type ErrorResponse struct { 107 // Error - Error information. 108 Error *Error `json:"error,omitempty"` 109} 110 111// BasicFacet a facet containing additional statistics on the response of a query. Can be either FacetResult or 112// FacetError. 113type BasicFacet interface { 114 AsFacetResult() (*FacetResult, bool) 115 AsFacetError() (*FacetError, bool) 116 AsFacet() (*Facet, bool) 117} 118 119// Facet a facet containing additional statistics on the response of a query. Can be either FacetResult or 120// FacetError. 121type Facet struct { 122 // Expression - Facet expression, same as in the corresponding facet request. 123 Expression *string `json:"expression,omitempty"` 124 // ResultType - Possible values include: 'ResultTypeFacet', 'ResultTypeFacetResult', 'ResultTypeFacetError' 125 ResultType ResultType `json:"resultType,omitempty"` 126} 127 128func unmarshalBasicFacet(body []byte) (BasicFacet, error) { 129 var m map[string]interface{} 130 err := json.Unmarshal(body, &m) 131 if err != nil { 132 return nil, err 133 } 134 135 switch m["resultType"] { 136 case string(ResultTypeFacetResult): 137 var fr FacetResult 138 err := json.Unmarshal(body, &fr) 139 return fr, err 140 case string(ResultTypeFacetError): 141 var fe FacetError 142 err := json.Unmarshal(body, &fe) 143 return fe, err 144 default: 145 var f Facet 146 err := json.Unmarshal(body, &f) 147 return f, err 148 } 149} 150func unmarshalBasicFacetArray(body []byte) ([]BasicFacet, error) { 151 var rawMessages []*json.RawMessage 152 err := json.Unmarshal(body, &rawMessages) 153 if err != nil { 154 return nil, err 155 } 156 157 fArray := make([]BasicFacet, len(rawMessages)) 158 159 for index, rawMessage := range rawMessages { 160 f, err := unmarshalBasicFacet(*rawMessage) 161 if err != nil { 162 return nil, err 163 } 164 fArray[index] = f 165 } 166 return fArray, nil 167} 168 169// MarshalJSON is the custom marshaler for Facet. 170func (f Facet) MarshalJSON() ([]byte, error) { 171 f.ResultType = ResultTypeFacet 172 objectMap := make(map[string]interface{}) 173 if f.Expression != nil { 174 objectMap["expression"] = f.Expression 175 } 176 if f.ResultType != "" { 177 objectMap["resultType"] = f.ResultType 178 } 179 return json.Marshal(objectMap) 180} 181 182// AsFacetResult is the BasicFacet implementation for Facet. 183func (f Facet) AsFacetResult() (*FacetResult, bool) { 184 return nil, false 185} 186 187// AsFacetError is the BasicFacet implementation for Facet. 188func (f Facet) AsFacetError() (*FacetError, bool) { 189 return nil, false 190} 191 192// AsFacet is the BasicFacet implementation for Facet. 193func (f Facet) AsFacet() (*Facet, bool) { 194 return &f, true 195} 196 197// AsBasicFacet is the BasicFacet implementation for Facet. 198func (f Facet) AsBasicFacet() (BasicFacet, bool) { 199 return &f, true 200} 201 202// FacetError a facet whose execution resulted in an error. 203type FacetError struct { 204 // Errors - An array containing detected facet errors with details. 205 Errors *[]ErrorDetails `json:"errors,omitempty"` 206 // Expression - Facet expression, same as in the corresponding facet request. 207 Expression *string `json:"expression,omitempty"` 208 // ResultType - Possible values include: 'ResultTypeFacet', 'ResultTypeFacetResult', 'ResultTypeFacetError' 209 ResultType ResultType `json:"resultType,omitempty"` 210} 211 212// MarshalJSON is the custom marshaler for FacetError. 213func (fe FacetError) MarshalJSON() ([]byte, error) { 214 fe.ResultType = ResultTypeFacetError 215 objectMap := make(map[string]interface{}) 216 if fe.Errors != nil { 217 objectMap["errors"] = fe.Errors 218 } 219 if fe.Expression != nil { 220 objectMap["expression"] = fe.Expression 221 } 222 if fe.ResultType != "" { 223 objectMap["resultType"] = fe.ResultType 224 } 225 return json.Marshal(objectMap) 226} 227 228// AsFacetResult is the BasicFacet implementation for FacetError. 229func (fe FacetError) AsFacetResult() (*FacetResult, bool) { 230 return nil, false 231} 232 233// AsFacetError is the BasicFacet implementation for FacetError. 234func (fe FacetError) AsFacetError() (*FacetError, bool) { 235 return &fe, true 236} 237 238// AsFacet is the BasicFacet implementation for FacetError. 239func (fe FacetError) AsFacet() (*Facet, bool) { 240 return nil, false 241} 242 243// AsBasicFacet is the BasicFacet implementation for FacetError. 244func (fe FacetError) AsBasicFacet() (BasicFacet, bool) { 245 return &fe, true 246} 247 248// FacetRequest a request to compute additional statistics (facets) over the query results. 249type FacetRequest struct { 250 // Expression - The column or list of columns to summarize by 251 Expression *string `json:"expression,omitempty"` 252 // Options - The options for facet evaluation 253 Options *FacetRequestOptions `json:"options,omitempty"` 254} 255 256// FacetRequestOptions the options for facet evaluation 257type FacetRequestOptions struct { 258 // SortBy - The column name or query expression to sort on. Defaults to count if not present. 259 SortBy *string `json:"sortBy,omitempty"` 260 // SortOrder - The sorting order by the selected column (count by default). Possible values include: 'Asc', 'Desc' 261 SortOrder FacetSortOrder `json:"sortOrder,omitempty"` 262 // Filter - Specifies the filter condition for the 'where' clause which will be run on main query's result, just before the actual faceting. 263 Filter *string `json:"filter,omitempty"` 264 // Top - The maximum number of facet rows that should be returned. 265 Top *int32 `json:"$top,omitempty"` 266} 267 268// FacetResult successfully executed facet containing additional statistics on the response of a query. 269type FacetResult struct { 270 // TotalRecords - Number of total records in the facet results. 271 TotalRecords *int64 `json:"totalRecords,omitempty"` 272 // Count - Number of records returned in the facet response. 273 Count *int32 `json:"count,omitempty"` 274 // Data - A table containing the desired facets. Only present if the facet is valid. 275 Data interface{} `json:"data,omitempty"` 276 // Expression - Facet expression, same as in the corresponding facet request. 277 Expression *string `json:"expression,omitempty"` 278 // ResultType - Possible values include: 'ResultTypeFacet', 'ResultTypeFacetResult', 'ResultTypeFacetError' 279 ResultType ResultType `json:"resultType,omitempty"` 280} 281 282// MarshalJSON is the custom marshaler for FacetResult. 283func (fr FacetResult) MarshalJSON() ([]byte, error) { 284 fr.ResultType = ResultTypeFacetResult 285 objectMap := make(map[string]interface{}) 286 if fr.TotalRecords != nil { 287 objectMap["totalRecords"] = fr.TotalRecords 288 } 289 if fr.Count != nil { 290 objectMap["count"] = fr.Count 291 } 292 if fr.Data != nil { 293 objectMap["data"] = fr.Data 294 } 295 if fr.Expression != nil { 296 objectMap["expression"] = fr.Expression 297 } 298 if fr.ResultType != "" { 299 objectMap["resultType"] = fr.ResultType 300 } 301 return json.Marshal(objectMap) 302} 303 304// AsFacetResult is the BasicFacet implementation for FacetResult. 305func (fr FacetResult) AsFacetResult() (*FacetResult, bool) { 306 return &fr, true 307} 308 309// AsFacetError is the BasicFacet implementation for FacetResult. 310func (fr FacetResult) AsFacetError() (*FacetError, bool) { 311 return nil, false 312} 313 314// AsFacet is the BasicFacet implementation for FacetResult. 315func (fr FacetResult) AsFacet() (*Facet, bool) { 316 return nil, false 317} 318 319// AsBasicFacet is the BasicFacet implementation for FacetResult. 320func (fr FacetResult) AsBasicFacet() (BasicFacet, bool) { 321 return &fr, true 322} 323 324// Operation resource Graph REST API operation definition. 325type Operation struct { 326 // Name - Operation name: {provider}/{resource}/{operation} 327 Name *string `json:"name,omitempty"` 328 // Display - Display metadata associated with the operation. 329 Display *OperationDisplay `json:"display,omitempty"` 330 // Origin - The origin of operations. 331 Origin *string `json:"origin,omitempty"` 332} 333 334// OperationDisplay display metadata associated with the operation. 335type OperationDisplay struct { 336 // Provider - Service provider: Microsoft Resource Graph. 337 Provider *string `json:"provider,omitempty"` 338 // Resource - Resource on which the operation is performed etc. 339 Resource *string `json:"resource,omitempty"` 340 // Operation - Type of operation: get, read, delete, etc. 341 Operation *string `json:"operation,omitempty"` 342 // Description - Description for the operation. 343 Description *string `json:"description,omitempty"` 344} 345 346// OperationListResult result of the request to list Resource Graph operations. It contains a list of 347// operations and a URL link to get the next set of results. 348type OperationListResult struct { 349 autorest.Response `json:"-"` 350 // Value - List of Resource Graph operations supported by the Resource Graph resource provider. 351 Value *[]Operation `json:"value,omitempty"` 352} 353 354// QueryRequest describes a query to be executed. 355type QueryRequest struct { 356 // Subscriptions - Azure subscriptions against which to execute the query. 357 Subscriptions *[]string `json:"subscriptions,omitempty"` 358 // Query - The resources query. 359 Query *string `json:"query,omitempty"` 360 // Options - The query evaluation options 361 Options *QueryRequestOptions `json:"options,omitempty"` 362 // Facets - An array of facet requests to be computed against the query result. 363 Facets *[]FacetRequest `json:"facets,omitempty"` 364} 365 366// QueryRequestOptions the options for query evaluation 367type QueryRequestOptions struct { 368 // SkipToken - Continuation token for pagination, capturing the next page size and offset, as well as the context of the query. 369 SkipToken *string `json:"$skipToken,omitempty"` 370 // Top - The maximum number of rows that the query should return. Overrides the page size when ```$skipToken``` property is present. 371 Top *int32 `json:"$top,omitempty"` 372 // Skip - The number of rows to skip from the beginning of the results. Overrides the next page offset when ```$skipToken``` property is present. 373 Skip *int32 `json:"$skip,omitempty"` 374 // ResultFormat - Defines in which format query result returned. Possible values include: 'ResultFormatTable', 'ResultFormatObjectArray' 375 ResultFormat ResultFormat `json:"resultFormat,omitempty"` 376} 377 378// QueryResponse query result. 379type QueryResponse struct { 380 autorest.Response `json:"-"` 381 // TotalRecords - Number of total records matching the query. 382 TotalRecords *int64 `json:"totalRecords,omitempty"` 383 // Count - Number of records returned in the current response. In the case of paging, this is the number of records in the current page. 384 Count *int64 `json:"count,omitempty"` 385 // ResultTruncated - Indicates whether the query results are truncated. Possible values include: 'True', 'False' 386 ResultTruncated ResultTruncated `json:"resultTruncated,omitempty"` 387 // SkipToken - When present, the value can be passed to a subsequent query call (together with the same query and subscriptions used in the current request) to retrieve the next page of data. 388 SkipToken *string `json:"$skipToken,omitempty"` 389 // Data - Query output in tabular format. 390 Data interface{} `json:"data,omitempty"` 391 // Facets - Query facets. 392 Facets *[]BasicFacet `json:"facets,omitempty"` 393} 394 395// UnmarshalJSON is the custom unmarshaler for QueryResponse struct. 396func (qr *QueryResponse) UnmarshalJSON(body []byte) error { 397 var m map[string]*json.RawMessage 398 err := json.Unmarshal(body, &m) 399 if err != nil { 400 return err 401 } 402 for k, v := range m { 403 switch k { 404 case "totalRecords": 405 if v != nil { 406 var totalRecords int64 407 err = json.Unmarshal(*v, &totalRecords) 408 if err != nil { 409 return err 410 } 411 qr.TotalRecords = &totalRecords 412 } 413 case "count": 414 if v != nil { 415 var count int64 416 err = json.Unmarshal(*v, &count) 417 if err != nil { 418 return err 419 } 420 qr.Count = &count 421 } 422 case "resultTruncated": 423 if v != nil { 424 var resultTruncated ResultTruncated 425 err = json.Unmarshal(*v, &resultTruncated) 426 if err != nil { 427 return err 428 } 429 qr.ResultTruncated = resultTruncated 430 } 431 case "$skipToken": 432 if v != nil { 433 var skipToken string 434 err = json.Unmarshal(*v, &skipToken) 435 if err != nil { 436 return err 437 } 438 qr.SkipToken = &skipToken 439 } 440 case "data": 441 if v != nil { 442 var data interface{} 443 err = json.Unmarshal(*v, &data) 444 if err != nil { 445 return err 446 } 447 qr.Data = data 448 } 449 case "facets": 450 if v != nil { 451 facets, err := unmarshalBasicFacetArray(*v) 452 if err != nil { 453 return err 454 } 455 qr.Facets = &facets 456 } 457 } 458 } 459 460 return nil 461} 462 463// Table query output in tabular format. 464type Table struct { 465 // Columns - Query result column descriptors. 466 Columns *[]Column `json:"columns,omitempty"` 467 // Rows - Query result rows. 468 Rows *[][]interface{} `json:"rows,omitempty"` 469} 470