1package enterpriseknowledgegraphservice 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 "context" 11 "encoding/json" 12 "github.com/Azure/go-autorest/autorest" 13 "github.com/Azure/go-autorest/autorest/to" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// The package's fully qualified name. 19const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice" 20 21// EnterpriseKnowledgeGraph enterpriseKnowledgeGraph resource definition 22type EnterpriseKnowledgeGraph struct { 23 autorest.Response `json:"-"` 24 // Properties - The set of properties specific to EnterpriseKnowledgeGraph resource 25 Properties *EnterpriseKnowledgeGraphProperties `json:"properties,omitempty"` 26 // ID - READ-ONLY; Specifies the resource ID. 27 ID *string `json:"id,omitempty"` 28 // Name - READ-ONLY; Specifies the name of the resource. 29 Name *string `json:"name,omitempty"` 30 // Type - READ-ONLY; Specifies the type of the resource. 31 Type *string `json:"type,omitempty"` 32 // Location - Specifies the location of the resource. 33 Location *string `json:"location,omitempty"` 34 // Tags - Contains resource tags defined as key/value pairs. 35 Tags map[string]*string `json:"tags"` 36 // Sku - Gets or sets the SKU of the resource. 37 Sku *Sku `json:"sku,omitempty"` 38} 39 40// MarshalJSON is the custom marshaler for EnterpriseKnowledgeGraph. 41func (ekg EnterpriseKnowledgeGraph) MarshalJSON() ([]byte, error) { 42 objectMap := make(map[string]interface{}) 43 if ekg.Properties != nil { 44 objectMap["properties"] = ekg.Properties 45 } 46 if ekg.Location != nil { 47 objectMap["location"] = ekg.Location 48 } 49 if ekg.Tags != nil { 50 objectMap["tags"] = ekg.Tags 51 } 52 if ekg.Sku != nil { 53 objectMap["sku"] = ekg.Sku 54 } 55 return json.Marshal(objectMap) 56} 57 58// EnterpriseKnowledgeGraphProperties the parameters to provide for the EnterpriseKnowledgeGraph. 59type EnterpriseKnowledgeGraphProperties struct { 60 // Description - The description of the EnterpriseKnowledgeGraph 61 Description *string `json:"description,omitempty"` 62 // Metadata - Specifies the metadata of the resource. 63 Metadata interface{} `json:"metadata,omitempty"` 64 // ProvisioningState - The state of EnterpriseKnowledgeGraph provisioning. Possible values include: 'Creating', 'Deleting', 'Failed', 'Succeeded' 65 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 66} 67 68// EnterpriseKnowledgeGraphResponseList the list of EnterpriseKnowledgeGraph service operation response. 69type EnterpriseKnowledgeGraphResponseList struct { 70 autorest.Response `json:"-"` 71 // NextLink - The link used to get the next page of EnterpriseKnowledgeGraph service resources. 72 NextLink *string `json:"nextLink,omitempty"` 73 // Value - READ-ONLY; Gets the list of EnterpriseKnowledgeGraph service results and their properties. 74 Value *[]EnterpriseKnowledgeGraph `json:"value,omitempty"` 75} 76 77// MarshalJSON is the custom marshaler for EnterpriseKnowledgeGraphResponseList. 78func (ekgrl EnterpriseKnowledgeGraphResponseList) MarshalJSON() ([]byte, error) { 79 objectMap := make(map[string]interface{}) 80 if ekgrl.NextLink != nil { 81 objectMap["nextLink"] = ekgrl.NextLink 82 } 83 return json.Marshal(objectMap) 84} 85 86// EnterpriseKnowledgeGraphResponseListIterator provides access to a complete listing of 87// EnterpriseKnowledgeGraph values. 88type EnterpriseKnowledgeGraphResponseListIterator struct { 89 i int 90 page EnterpriseKnowledgeGraphResponseListPage 91} 92 93// NextWithContext advances to the next value. If there was an error making 94// the request the iterator does not advance and the error is returned. 95func (iter *EnterpriseKnowledgeGraphResponseListIterator) NextWithContext(ctx context.Context) (err error) { 96 if tracing.IsEnabled() { 97 ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphResponseListIterator.NextWithContext") 98 defer func() { 99 sc := -1 100 if iter.Response().Response.Response != nil { 101 sc = iter.Response().Response.Response.StatusCode 102 } 103 tracing.EndSpan(ctx, sc, err) 104 }() 105 } 106 iter.i++ 107 if iter.i < len(iter.page.Values()) { 108 return nil 109 } 110 err = iter.page.NextWithContext(ctx) 111 if err != nil { 112 iter.i-- 113 return err 114 } 115 iter.i = 0 116 return nil 117} 118 119// Next advances to the next value. If there was an error making 120// the request the iterator does not advance and the error is returned. 121// Deprecated: Use NextWithContext() instead. 122func (iter *EnterpriseKnowledgeGraphResponseListIterator) Next() error { 123 return iter.NextWithContext(context.Background()) 124} 125 126// NotDone returns true if the enumeration should be started or is not yet complete. 127func (iter EnterpriseKnowledgeGraphResponseListIterator) NotDone() bool { 128 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 129} 130 131// Response returns the raw server response from the last page request. 132func (iter EnterpriseKnowledgeGraphResponseListIterator) Response() EnterpriseKnowledgeGraphResponseList { 133 return iter.page.Response() 134} 135 136// Value returns the current value or a zero-initialized value if the 137// iterator has advanced beyond the end of the collection. 138func (iter EnterpriseKnowledgeGraphResponseListIterator) Value() EnterpriseKnowledgeGraph { 139 if !iter.page.NotDone() { 140 return EnterpriseKnowledgeGraph{} 141 } 142 return iter.page.Values()[iter.i] 143} 144 145// Creates a new instance of the EnterpriseKnowledgeGraphResponseListIterator type. 146func NewEnterpriseKnowledgeGraphResponseListIterator(page EnterpriseKnowledgeGraphResponseListPage) EnterpriseKnowledgeGraphResponseListIterator { 147 return EnterpriseKnowledgeGraphResponseListIterator{page: page} 148} 149 150// IsEmpty returns true if the ListResult contains no values. 151func (ekgrl EnterpriseKnowledgeGraphResponseList) IsEmpty() bool { 152 return ekgrl.Value == nil || len(*ekgrl.Value) == 0 153} 154 155// hasNextLink returns true if the NextLink is not empty. 156func (ekgrl EnterpriseKnowledgeGraphResponseList) hasNextLink() bool { 157 return ekgrl.NextLink != nil && len(*ekgrl.NextLink) != 0 158} 159 160// enterpriseKnowledgeGraphResponseListPreparer prepares a request to retrieve the next set of results. 161// It returns nil if no more results exist. 162func (ekgrl EnterpriseKnowledgeGraphResponseList) enterpriseKnowledgeGraphResponseListPreparer(ctx context.Context) (*http.Request, error) { 163 if !ekgrl.hasNextLink() { 164 return nil, nil 165 } 166 return autorest.Prepare((&http.Request{}).WithContext(ctx), 167 autorest.AsJSON(), 168 autorest.AsGet(), 169 autorest.WithBaseURL(to.String(ekgrl.NextLink))) 170} 171 172// EnterpriseKnowledgeGraphResponseListPage contains a page of EnterpriseKnowledgeGraph values. 173type EnterpriseKnowledgeGraphResponseListPage struct { 174 fn func(context.Context, EnterpriseKnowledgeGraphResponseList) (EnterpriseKnowledgeGraphResponseList, error) 175 ekgrl EnterpriseKnowledgeGraphResponseList 176} 177 178// NextWithContext advances to the next page of values. If there was an error making 179// the request the page does not advance and the error is returned. 180func (page *EnterpriseKnowledgeGraphResponseListPage) NextWithContext(ctx context.Context) (err error) { 181 if tracing.IsEnabled() { 182 ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphResponseListPage.NextWithContext") 183 defer func() { 184 sc := -1 185 if page.Response().Response.Response != nil { 186 sc = page.Response().Response.Response.StatusCode 187 } 188 tracing.EndSpan(ctx, sc, err) 189 }() 190 } 191 for { 192 next, err := page.fn(ctx, page.ekgrl) 193 if err != nil { 194 return err 195 } 196 page.ekgrl = next 197 if !next.hasNextLink() || !next.IsEmpty() { 198 break 199 } 200 } 201 return nil 202} 203 204// Next advances to the next page of values. If there was an error making 205// the request the page does not advance and the error is returned. 206// Deprecated: Use NextWithContext() instead. 207func (page *EnterpriseKnowledgeGraphResponseListPage) Next() error { 208 return page.NextWithContext(context.Background()) 209} 210 211// NotDone returns true if the page enumeration should be started or is not yet complete. 212func (page EnterpriseKnowledgeGraphResponseListPage) NotDone() bool { 213 return !page.ekgrl.IsEmpty() 214} 215 216// Response returns the raw server response from the last page request. 217func (page EnterpriseKnowledgeGraphResponseListPage) Response() EnterpriseKnowledgeGraphResponseList { 218 return page.ekgrl 219} 220 221// Values returns the slice of values for the current page or nil if there are no values. 222func (page EnterpriseKnowledgeGraphResponseListPage) Values() []EnterpriseKnowledgeGraph { 223 if page.ekgrl.IsEmpty() { 224 return nil 225 } 226 return *page.ekgrl.Value 227} 228 229// Creates a new instance of the EnterpriseKnowledgeGraphResponseListPage type. 230func NewEnterpriseKnowledgeGraphResponseListPage(cur EnterpriseKnowledgeGraphResponseList, getNextPage func(context.Context, EnterpriseKnowledgeGraphResponseList) (EnterpriseKnowledgeGraphResponseList, error)) EnterpriseKnowledgeGraphResponseListPage { 231 return EnterpriseKnowledgeGraphResponseListPage{ 232 fn: getNextPage, 233 ekgrl: cur, 234 } 235} 236 237// Error enterpriseKnowledgeGraph Service error object. 238type Error struct { 239 // Error - The error body. 240 Error *ErrorBody `json:"error,omitempty"` 241} 242 243// ErrorBody enterpriseKnowledgeGraph Service error body. 244type ErrorBody struct { 245 // Code - error code 246 Code *string `json:"code,omitempty"` 247 // Message - error message 248 Message *string `json:"message,omitempty"` 249} 250 251// OperationDisplayInfo the operation supported by EnterpriseKnowledgeGraph Service Management. 252type OperationDisplayInfo struct { 253 // Description - The description of the operation. 254 Description *string `json:"description,omitempty"` 255 // Operation - The action that users can perform, based on their permission level. 256 Operation *string `json:"operation,omitempty"` 257 // Provider - Service provider: Microsoft EnterpriseKnowledgeGraph Service. 258 Provider *string `json:"provider,omitempty"` 259 // Resource - Resource on which the operation is performed. 260 Resource *string `json:"resource,omitempty"` 261} 262 263// OperationEntity the operations supported by EnterpriseKnowledgeGraph Service Management. 264type OperationEntity struct { 265 // Name - Operation name: {provider}/{resource}/{operation}. 266 Name *string `json:"name,omitempty"` 267 // Display - The operation supported by EnterpriseKnowledgeGraph Service Management. 268 Display *OperationDisplayInfo `json:"display,omitempty"` 269 // Origin - The origin of the operation. 270 Origin *string `json:"origin,omitempty"` 271 // Properties - Additional properties. 272 Properties interface{} `json:"properties,omitempty"` 273} 274 275// OperationEntityListResult the list of EnterpriseKnowledgeGraph service operation response. 276type OperationEntityListResult struct { 277 autorest.Response `json:"-"` 278 // NextLink - The link used to get the next page of operations. 279 NextLink *string `json:"nextLink,omitempty"` 280 // Value - The list of operations. 281 Value *[]OperationEntity `json:"value,omitempty"` 282} 283 284// OperationEntityListResultIterator provides access to a complete listing of OperationEntity values. 285type OperationEntityListResultIterator struct { 286 i int 287 page OperationEntityListResultPage 288} 289 290// NextWithContext advances to the next value. If there was an error making 291// the request the iterator does not advance and the error is returned. 292func (iter *OperationEntityListResultIterator) NextWithContext(ctx context.Context) (err error) { 293 if tracing.IsEnabled() { 294 ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultIterator.NextWithContext") 295 defer func() { 296 sc := -1 297 if iter.Response().Response.Response != nil { 298 sc = iter.Response().Response.Response.StatusCode 299 } 300 tracing.EndSpan(ctx, sc, err) 301 }() 302 } 303 iter.i++ 304 if iter.i < len(iter.page.Values()) { 305 return nil 306 } 307 err = iter.page.NextWithContext(ctx) 308 if err != nil { 309 iter.i-- 310 return err 311 } 312 iter.i = 0 313 return nil 314} 315 316// Next advances to the next value. If there was an error making 317// the request the iterator does not advance and the error is returned. 318// Deprecated: Use NextWithContext() instead. 319func (iter *OperationEntityListResultIterator) Next() error { 320 return iter.NextWithContext(context.Background()) 321} 322 323// NotDone returns true if the enumeration should be started or is not yet complete. 324func (iter OperationEntityListResultIterator) NotDone() bool { 325 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 326} 327 328// Response returns the raw server response from the last page request. 329func (iter OperationEntityListResultIterator) Response() OperationEntityListResult { 330 return iter.page.Response() 331} 332 333// Value returns the current value or a zero-initialized value if the 334// iterator has advanced beyond the end of the collection. 335func (iter OperationEntityListResultIterator) Value() OperationEntity { 336 if !iter.page.NotDone() { 337 return OperationEntity{} 338 } 339 return iter.page.Values()[iter.i] 340} 341 342// Creates a new instance of the OperationEntityListResultIterator type. 343func NewOperationEntityListResultIterator(page OperationEntityListResultPage) OperationEntityListResultIterator { 344 return OperationEntityListResultIterator{page: page} 345} 346 347// IsEmpty returns true if the ListResult contains no values. 348func (oelr OperationEntityListResult) IsEmpty() bool { 349 return oelr.Value == nil || len(*oelr.Value) == 0 350} 351 352// hasNextLink returns true if the NextLink is not empty. 353func (oelr OperationEntityListResult) hasNextLink() bool { 354 return oelr.NextLink != nil && len(*oelr.NextLink) != 0 355} 356 357// operationEntityListResultPreparer prepares a request to retrieve the next set of results. 358// It returns nil if no more results exist. 359func (oelr OperationEntityListResult) operationEntityListResultPreparer(ctx context.Context) (*http.Request, error) { 360 if !oelr.hasNextLink() { 361 return nil, nil 362 } 363 return autorest.Prepare((&http.Request{}).WithContext(ctx), 364 autorest.AsJSON(), 365 autorest.AsGet(), 366 autorest.WithBaseURL(to.String(oelr.NextLink))) 367} 368 369// OperationEntityListResultPage contains a page of OperationEntity values. 370type OperationEntityListResultPage struct { 371 fn func(context.Context, OperationEntityListResult) (OperationEntityListResult, error) 372 oelr OperationEntityListResult 373} 374 375// NextWithContext advances to the next page of values. If there was an error making 376// the request the page does not advance and the error is returned. 377func (page *OperationEntityListResultPage) NextWithContext(ctx context.Context) (err error) { 378 if tracing.IsEnabled() { 379 ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultPage.NextWithContext") 380 defer func() { 381 sc := -1 382 if page.Response().Response.Response != nil { 383 sc = page.Response().Response.Response.StatusCode 384 } 385 tracing.EndSpan(ctx, sc, err) 386 }() 387 } 388 for { 389 next, err := page.fn(ctx, page.oelr) 390 if err != nil { 391 return err 392 } 393 page.oelr = next 394 if !next.hasNextLink() || !next.IsEmpty() { 395 break 396 } 397 } 398 return nil 399} 400 401// Next advances to the next page of values. If there was an error making 402// the request the page does not advance and the error is returned. 403// Deprecated: Use NextWithContext() instead. 404func (page *OperationEntityListResultPage) Next() error { 405 return page.NextWithContext(context.Background()) 406} 407 408// NotDone returns true if the page enumeration should be started or is not yet complete. 409func (page OperationEntityListResultPage) NotDone() bool { 410 return !page.oelr.IsEmpty() 411} 412 413// Response returns the raw server response from the last page request. 414func (page OperationEntityListResultPage) Response() OperationEntityListResult { 415 return page.oelr 416} 417 418// Values returns the slice of values for the current page or nil if there are no values. 419func (page OperationEntityListResultPage) Values() []OperationEntity { 420 if page.oelr.IsEmpty() { 421 return nil 422 } 423 return *page.oelr.Value 424} 425 426// Creates a new instance of the OperationEntityListResultPage type. 427func NewOperationEntityListResultPage(cur OperationEntityListResult, getNextPage func(context.Context, OperationEntityListResult) (OperationEntityListResult, error)) OperationEntityListResultPage { 428 return OperationEntityListResultPage{ 429 fn: getNextPage, 430 oelr: cur, 431 } 432} 433 434// Resource azure resource 435type Resource struct { 436 // ID - READ-ONLY; Specifies the resource ID. 437 ID *string `json:"id,omitempty"` 438 // Name - READ-ONLY; Specifies the name of the resource. 439 Name *string `json:"name,omitempty"` 440 // Type - READ-ONLY; Specifies the type of the resource. 441 Type *string `json:"type,omitempty"` 442 // Location - Specifies the location of the resource. 443 Location *string `json:"location,omitempty"` 444 // Tags - Contains resource tags defined as key/value pairs. 445 Tags map[string]*string `json:"tags"` 446 // Sku - Gets or sets the SKU of the resource. 447 Sku *Sku `json:"sku,omitempty"` 448} 449 450// MarshalJSON is the custom marshaler for Resource. 451func (r Resource) MarshalJSON() ([]byte, error) { 452 objectMap := make(map[string]interface{}) 453 if r.Location != nil { 454 objectMap["location"] = r.Location 455 } 456 if r.Tags != nil { 457 objectMap["tags"] = r.Tags 458 } 459 if r.Sku != nil { 460 objectMap["sku"] = r.Sku 461 } 462 return json.Marshal(objectMap) 463} 464 465// Sku the SKU of the EnterpriseKnowledgeGraph service account. 466type Sku struct { 467 // Name - The sku name. Possible values include: 'F0', 'S1' 468 Name SkuName `json:"name,omitempty"` 469} 470