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