github.com/newrelic/newrelic-client-go@v1.1.0/pkg/apiaccess/types.go (about) 1 // Code generated by tutone: DO NOT EDIT 2 package apiaccess 3 4 import ( 5 "encoding/json" 6 "fmt" 7 8 "github.com/newrelic/newrelic-client-go/pkg/accounts" 9 "github.com/newrelic/newrelic-client-go/pkg/users" 10 ) 11 12 // APIAccessIngestKeyErrorType - The type of error. 13 type APIAccessIngestKeyErrorType string 14 15 var APIAccessIngestKeyErrorTypeTypes = struct { 16 // Occurs when the user issuing the mutation does not have sufficient permissions to perform the action for a key. 17 FORBIDDEN APIAccessIngestKeyErrorType 18 // Occurs when the action taken on a key did not successfully pass validation. 19 INVALID APIAccessIngestKeyErrorType 20 // Occurs when the requested key `id` was not found. 21 NOT_FOUND APIAccessIngestKeyErrorType 22 }{ 23 // Occurs when the user issuing the mutation does not have sufficient permissions to perform the action for a key. 24 FORBIDDEN: "FORBIDDEN", 25 // Occurs when the action taken on a key did not successfully pass validation. 26 INVALID: "INVALID", 27 // Occurs when the requested key `id` was not found. 28 NOT_FOUND: "NOT_FOUND", 29 } 30 31 // APIAccessIngestKeyType - The type of ingest key, which dictates what types of agents can use it to report. 32 type APIAccessIngestKeyType string 33 34 var APIAccessIngestKeyTypeTypes = struct { 35 // Ingest keys of type `BROWSER` mean browser agents will use them to report data to New Relic. 36 BROWSER APIAccessIngestKeyType 37 // For ingest keys of type `LICENSE`: APM and Infrastructure agents use the key to report data to New Relic. 38 LICENSE APIAccessIngestKeyType 39 }{ 40 // Ingest keys of type `BROWSER` mean browser agents will use them to report data to New Relic. 41 BROWSER: "BROWSER", 42 // For ingest keys of type `LICENSE`: APM and Infrastructure agents use the key to report data to New Relic. 43 LICENSE: "LICENSE", 44 } 45 46 // APIAccessKeyType - The type of key. 47 type APIAccessKeyType string 48 49 var APIAccessKeyTypeTypes = struct { 50 // An ingest key is used by New Relic agents to authenticate with New Relic and send data to the assigned account. 51 INGEST APIAccessKeyType 52 // A user key is used by New Relic users to authenticate with New Relic and to interact with the New Relic GraphQL API . 53 USER APIAccessKeyType 54 }{ 55 // An ingest key is used by New Relic agents to authenticate with New Relic and send data to the assigned account. 56 INGEST: "INGEST", 57 // A user key is used by New Relic users to authenticate with New Relic and to interact with the New Relic GraphQL API . 58 USER: "USER", 59 } 60 61 // APIAccessUserKeyErrorType - The type of error. 62 type APIAccessUserKeyErrorType string 63 64 var APIAccessUserKeyErrorTypeTypes = struct { 65 // Occurs when the user issuing the mutation does not have sufficient permissions to perform the action for a key. 66 FORBIDDEN APIAccessUserKeyErrorType 67 // Occurs when the action taken on a key did not successfully pass validation. 68 INVALID APIAccessUserKeyErrorType 69 // Occurs when the requested key `id` was not found. 70 NOT_FOUND APIAccessUserKeyErrorType 71 }{ 72 // Occurs when the user issuing the mutation does not have sufficient permissions to perform the action for a key. 73 FORBIDDEN: "FORBIDDEN", 74 // Occurs when the action taken on a key did not successfully pass validation. 75 INVALID: "INVALID", 76 // Occurs when the requested key `id` was not found. 77 NOT_FOUND: "NOT_FOUND", 78 } 79 80 // APIAccessActorStitchedFields - 81 type APIAccessActorStitchedFields struct { 82 // Fetch a single key by ID and type. 83 Key APIAccessKeyInterface `json:"key,omitempty"` 84 // A list of keys scoped to the current actor and filter arguments. You can read more about managing keys on [this documentation page](https://docs.newrelic.com/docs/apis/nerdgraph/examples/use-nerdgraph-manage-license-keys-personal-api-keys). 85 KeySearch APIAccessKeySearchResult `json:"keySearch,omitempty"` 86 } 87 88 // special 89 func (x *APIAccessActorStitchedFields) UnmarshalJSON(b []byte) error { 90 var objMap map[string]*json.RawMessage 91 err := json.Unmarshal(b, &objMap) 92 if err != nil { 93 return err 94 } 95 96 for k, v := range objMap { 97 if v == nil { 98 continue 99 } 100 101 switch k { 102 case "key": 103 if v == nil { 104 continue 105 } 106 xxx, err := UnmarshalAPIAccessKeyInterface(*v) 107 if err != nil { 108 return err 109 } 110 111 if xxx != nil { 112 x.Key = *xxx 113 } 114 case "keySearch": 115 err = json.Unmarshal(*v, &x.KeySearch) 116 if err != nil { 117 return err 118 } 119 } 120 } 121 122 return nil 123 } 124 125 // APIAccessCreateIngestKeyInput - The input for any ingest keys you want to create. Each ingest key must have a type that communicates what kind of data it is for. You can optionally add a name or notes to your key, which can be updated later. 126 type APIAccessCreateIngestKeyInput struct { 127 // The account ID indicating which account you want to make the key for. This cannot be updated once created. 128 AccountID int `json:"accountId"` 129 // The type of ingest key you want to create. This cannot be updated once created. 130 IngestType APIAccessIngestKeyType `json:"ingestType"` 131 // The name of the key. This can be updated later. 132 Name string `json:"name,omitempty"` 133 // Any notes about this ingest key. This can be updated later. 134 Notes string `json:"notes,omitempty"` 135 } 136 137 // APIAccessCreateInput - The input object to create one or more keys. 138 type APIAccessCreateInput struct { 139 // Ingest keys are used by agents to report data about your applications to New Relic. Each ingest key input entered here must have a type that communicates what kind of data it is for. You can optionally add a name or notes to your key, which can be updated later. 140 Ingest []APIAccessCreateIngestKeyInput `json:"ingest,omitempty"` 141 // Create user keys. You can optionally add a name or notes to your key, which can be updated later. 142 User []APIAccessCreateUserKeyInput `json:"user,omitempty"` 143 } 144 145 // APIAccessCreateKeyResponse - The response of the create keys mutation. 146 type APIAccessCreateKeyResponse struct { 147 // Lists all successfully created keys. 148 CreatedKeys []APIAccessKeyInterface `json:"createdKeys,omitempty"` 149 // Lists all errors for keys that could not be created. Each error maps to a single key input. 150 Errors []APIAccessKeyErrorInterface `json:"errors,omitempty"` 151 } 152 153 // special 154 func (x *APIAccessCreateKeyResponse) UnmarshalJSON(b []byte) error { 155 var objMap map[string]*json.RawMessage 156 err := json.Unmarshal(b, &objMap) 157 if err != nil { 158 return err 159 } 160 161 for k, v := range objMap { 162 if v == nil { 163 continue 164 } 165 166 switch k { 167 case "createdKeys": 168 if v == nil { 169 continue 170 } 171 var rawMessageCreatedKeys []*json.RawMessage 172 err = json.Unmarshal(*v, &rawMessageCreatedKeys) 173 if err != nil { 174 return err 175 } 176 177 for _, m := range rawMessageCreatedKeys { 178 xxx, err := UnmarshalAPIAccessKeyInterface(*m) 179 if err != nil { 180 return err 181 } 182 183 if xxx != nil { 184 x.CreatedKeys = append(x.CreatedKeys, *xxx) 185 } 186 } 187 case "errors": 188 if v == nil { 189 continue 190 } 191 var rawMessageErrors []*json.RawMessage 192 err = json.Unmarshal(*v, &rawMessageErrors) 193 if err != nil { 194 return err 195 } 196 197 for _, m := range rawMessageErrors { 198 xxx, err := UnmarshalAPIAccessKeyErrorInterface(*m) 199 if err != nil { 200 return err 201 } 202 203 if xxx != nil { 204 x.Errors = append(x.Errors, *xxx) 205 } 206 } 207 } 208 } 209 210 return nil 211 } 212 213 // APIAccessCreateUserKeyInput - The input for any ingest keys you want to create. Each ingest key must have a type that communicates what kind of data it is for. You can optionally add a name or notes to your key, which can be updated later. 214 type APIAccessCreateUserKeyInput struct { 215 // The account ID indicating which account you want to make the key for. This cannot be updated once created. 216 AccountID int `json:"accountId"` 217 // The name of the key. This can be updated later. 218 Name string `json:"name,omitempty"` 219 // Any notes about this ingest key. This can be updated later. 220 Notes string `json:"notes,omitempty"` 221 // The user ID indicating which user you want to make the key for. This cannot be updated once created. 222 UserID int `json:"userId"` 223 } 224 225 // APIAccessDeleteInput - The input to delete keys. 226 type APIAccessDeleteInput struct { 227 // A list of the ingest key `id`s that you want to delete. 228 IngestKeyIDs []string `json:"ingestKeyIds,omitempty"` 229 // A list of the user key `id`s that you want to delete. 230 UserKeyIDs []string `json:"userKeyIds,omitempty"` 231 } 232 233 // APIAccessDeleteKeyResponse - The response of the key delete mutation. 234 type APIAccessDeleteKeyResponse struct { 235 // The `id`s of the successfully deleted ingest keys and any errors that occurred when deleting keys. 236 DeletedKeys []APIAccessDeletedKey `json:"deletedKeys,omitempty"` 237 // Lists all errors for keys that could not be deleted. Each error maps to a single key input. 238 Errors []APIAccessKeyErrorInterface `json:"errors,omitempty"` 239 } 240 241 // special 242 func (x *APIAccessDeleteKeyResponse) UnmarshalJSON(b []byte) error { 243 var objMap map[string]*json.RawMessage 244 err := json.Unmarshal(b, &objMap) 245 if err != nil { 246 return err 247 } 248 249 for k, v := range objMap { 250 if v == nil { 251 continue 252 } 253 254 switch k { 255 case "deletedKeys": 256 err = json.Unmarshal(*v, &x.DeletedKeys) 257 if err != nil { 258 return err 259 } 260 case "errors": 261 if v == nil { 262 continue 263 } 264 var rawMessageErrors []*json.RawMessage 265 err = json.Unmarshal(*v, &rawMessageErrors) 266 if err != nil { 267 return err 268 } 269 270 for _, m := range rawMessageErrors { 271 xxx, err := UnmarshalAPIAccessKeyErrorInterface(*m) 272 if err != nil { 273 return err 274 } 275 276 if xxx != nil { 277 x.Errors = append(x.Errors, *xxx) 278 } 279 } 280 } 281 } 282 283 return nil 284 } 285 286 // APIAccessDeletedKey - The deleted key response of the key delete mutation. 287 type APIAccessDeletedKey struct { 288 // The `id` of the deleted key. 289 ID string `json:"id,omitempty"` 290 } 291 292 // APIAccessIngestKey - An ingest key. 293 type APIAccessIngestKey struct { 294 // The account this key is in. 295 Account accounts.AccountReference `json:"account,omitempty"` 296 // The account attached to the ingest key. Agents using this key will report to the account the key belongs to. 297 AccountID int `json:"accountId,omitempty"` 298 // The UNIX epoch when the key was created, in seconds. 299 CreatedAt EpochSeconds `json:"createdAt,omitempty"` 300 // The ID of the ingest key. This can be used to identify a key without revealing the key itself (used to update and delete). 301 ID string `json:"id,omitempty"` 302 // The type of ingest key, which dictates what types of agents can use it to report. 303 IngestType APIAccessIngestKeyType `json:"ingestType,omitempty"` 304 // The keystring of the key. 305 Key string `json:"key,omitempty"` 306 // The name of the key. 307 Name string `json:"name,omitempty"` 308 // Any notes can be attached to an key. 309 Notes string `json:"notes,omitempty"` 310 // The type of key, indicating what New Relic APIs it can be used to access. 311 Type APIAccessKeyType `json:"type,omitempty"` 312 } 313 314 func (x *APIAccessIngestKey) ImplementsAPIAccessKey() {} 315 316 // APIAccessIngestKeyError - An ingest key error. Each error maps to a single key input. 317 type APIAccessIngestKeyError struct { 318 // The account ID of the key. 319 AccountID int `json:"accountId,omitempty"` 320 // The error type of the error. 321 ErrorType APIAccessIngestKeyErrorType `json:"errorType,omitempty"` 322 // The `id` of the key being updated. 323 ID string `json:"id,omitempty"` 324 // The ingest type of the key. 325 IngestType APIAccessIngestKeyType `json:"ingestType,omitempty"` 326 // A message about why the key creation failed. 327 Message string `json:"message,omitempty"` 328 // The type of the key. 329 Type APIAccessKeyType `json:"type,omitempty"` 330 } 331 332 func (x *APIAccessIngestKeyError) ImplementsAPIAccessKeyError() {} 333 334 // APIAccessKey - A key for accessing New Relic APIs. 335 type APIAccessKey struct { 336 // The UNIX epoch when the key was created, in seconds. 337 CreatedAt EpochSeconds `json:"createdAt,omitempty"` 338 // The ID of the key. This can be used to identify a key without revealing the key itself (used to update and delete). 339 ID string `json:"id,omitempty"` 340 // The keystring of the key. 341 Key string `json:"key,omitempty"` 342 // The name of the key. This can be used a short identifier for easy reference. 343 Name string `json:"name,omitempty"` 344 // Any notes can be attached to a key. This is intended for more a more detailed description of the key use if desired. 345 Notes string `json:"notes,omitempty"` 346 // The type of key, indicating what New Relic APIs it can be used to access. 347 Type APIAccessKeyType `json:"type,omitempty"` 348 } 349 350 func (x *APIAccessKey) ImplementsAPIAccessKey() {} 351 352 // APIAccessKeyError - A key error. Each error maps to a single key input. 353 type APIAccessKeyError struct { 354 // A message about why the key creation failed. 355 Message string `json:"message,omitempty"` 356 // The type of the key. 357 Type APIAccessKeyType `json:"type,omitempty"` 358 } 359 360 func (x *APIAccessKeyError) ImplementsAPIAccessKeyError() {} 361 362 // APIAccessKeySearchQuery - Parameters by which to filter the search. 363 type APIAccessKeySearchQuery struct { 364 // Criteria by which to narrow the scope of keys to be returned. 365 Scope APIAccessKeySearchScope `json:"scope,omitempty"` 366 // A list of key types to be included in the search. If no types are provided, all types will be returned by default. 367 Types []APIAccessKeyType `json:"types"` 368 } 369 370 // APIAccessKeySearchResult - A list of all keys scoped to the current actor. 371 type APIAccessKeySearchResult struct { 372 // The total number of keys found in scope, irrespective of pagination. 373 Count int `json:"count,omitempty"` 374 // A list of all keys scoped to the current actor. 375 Keys []APIAccessKeyInterface `json:"keys,omitempty"` 376 // The next cursor, used for pagination. If a cursor is present, it means more keys can be fetched. 377 NextCursor string `json:"nextCursor,omitempty"` 378 } 379 380 // special 381 func (x *APIAccessKeySearchResult) UnmarshalJSON(b []byte) error { 382 var objMap map[string]*json.RawMessage 383 err := json.Unmarshal(b, &objMap) 384 if err != nil { 385 return err 386 } 387 388 for k, v := range objMap { 389 if v == nil { 390 continue 391 } 392 393 switch k { 394 case "count": 395 err = json.Unmarshal(*v, &x.Count) 396 if err != nil { 397 return err 398 } 399 case "keys": 400 if v == nil { 401 continue 402 } 403 var rawMessageKeys []*json.RawMessage 404 err = json.Unmarshal(*v, &rawMessageKeys) 405 if err != nil { 406 return err 407 } 408 409 for _, m := range rawMessageKeys { 410 xxx, err := UnmarshalAPIAccessKeyInterface(*m) 411 if err != nil { 412 return err 413 } 414 415 if xxx != nil { 416 x.Keys = append(x.Keys, *xxx) 417 } 418 } 419 case "nextCursor": 420 err = json.Unmarshal(*v, &x.NextCursor) 421 if err != nil { 422 return err 423 } 424 } 425 } 426 427 return nil 428 } 429 430 // APIAccessKeySearchScope - The scope of keys to be returned. Note that some filters only apply to certain key types. 431 type APIAccessKeySearchScope struct { 432 // A list of key account IDs. 433 AccountIDs []int `json:"accountIds,omitempty"` 434 // The ingest type of the key. Only applies to ingest keys, and does not affect user key filtering. 435 IngestTypes []APIAccessIngestKeyType `json:"ingestTypes,omitempty"` 436 // A list of key user ids. Only applies to user keys, and does not affect ingest key filtering. 437 UserIDs []int `json:"userIds,omitempty"` 438 } 439 440 // APIAccessUpdateIngestKeyInput - The `id` and data to update one or more keys. 441 type APIAccessUpdateIngestKeyInput struct { 442 // The `id` of the key you want to update. 443 KeyID string `json:"keyId"` 444 // The name you want to assign to the key. 445 Name string `json:"name,omitempty"` 446 // The notes you want to assign to the key. 447 Notes string `json:"notes,omitempty"` 448 } 449 450 // APIAccessUpdateInput - The `id` and data to update one or more keys. 451 type APIAccessUpdateInput struct { 452 // A list of the configurations of each ingest key you want to update. 453 Ingest []APIAccessUpdateIngestKeyInput `json:"ingest,omitempty"` 454 // A list of the configurations of each user key you want to update. 455 User []APIAccessUpdateUserKeyInput `json:"user,omitempty"` 456 } 457 458 // APIAccessUpdateKeyResponse - The response of the update keys mutation. 459 type APIAccessUpdateKeyResponse struct { 460 // Lists all errors for keys that could not be updated. Each error maps to a single key input. 461 Errors []APIAccessKeyErrorInterface `json:"errors,omitempty"` 462 // Lists all successfully updated keys. 463 UpdatedKeys []APIAccessKeyInterface `json:"updatedKeys,omitempty"` 464 } 465 466 // special 467 func (x *APIAccessUpdateKeyResponse) UnmarshalJSON(b []byte) error { 468 var objMap map[string]*json.RawMessage 469 err := json.Unmarshal(b, &objMap) 470 if err != nil { 471 return err 472 } 473 474 for k, v := range objMap { 475 if v == nil { 476 continue 477 } 478 479 switch k { 480 case "errors": 481 if v == nil { 482 continue 483 } 484 var rawMessageErrors []*json.RawMessage 485 err = json.Unmarshal(*v, &rawMessageErrors) 486 if err != nil { 487 return err 488 } 489 490 for _, m := range rawMessageErrors { 491 xxx, err := UnmarshalAPIAccessKeyErrorInterface(*m) 492 if err != nil { 493 return err 494 } 495 496 if xxx != nil { 497 x.Errors = append(x.Errors, *xxx) 498 } 499 } 500 case "updatedKeys": 501 if v == nil { 502 continue 503 } 504 var rawMessageUpdatedKeys []*json.RawMessage 505 err = json.Unmarshal(*v, &rawMessageUpdatedKeys) 506 if err != nil { 507 return err 508 } 509 510 for _, m := range rawMessageUpdatedKeys { 511 xxx, err := UnmarshalAPIAccessKeyInterface(*m) 512 if err != nil { 513 return err 514 } 515 516 if xxx != nil { 517 x.UpdatedKeys = append(x.UpdatedKeys, *xxx) 518 } 519 } 520 } 521 } 522 523 return nil 524 } 525 526 // APIAccessUpdateUserKeyInput - The `id` and data to update one or more keys. 527 type APIAccessUpdateUserKeyInput struct { 528 // The `id` of the key you want to update. 529 KeyID string `json:"keyId"` 530 // The name you want to assign to the key. 531 Name string `json:"name,omitempty"` 532 // The notes you want to assign to the key. 533 Notes string `json:"notes,omitempty"` 534 } 535 536 // APIAccessUserKey - A user key. 537 type APIAccessUserKey struct { 538 // The account this key is in. 539 Account accounts.AccountReference `json:"account,omitempty"` 540 // The account ID of the key. 541 AccountID int `json:"accountId,omitempty"` 542 // The UNIX epoch when the key was created, in seconds. 543 CreatedAt EpochSeconds `json:"createdAt,omitempty"` 544 // The ID of the user key. This can be used to identify a key without revealing the key itself (used to update and delete). 545 ID string `json:"id,omitempty"` 546 // The keystring of the key. 547 Key string `json:"key,omitempty"` 548 // The name of the key. 549 Name string `json:"name,omitempty"` 550 // Any notes can be attached to a key. 551 Notes string `json:"notes,omitempty"` 552 // The type of key, indicating what New Relic APIs it can be used to access. 553 Type APIAccessKeyType `json:"type,omitempty"` 554 // The user this key belongs to. 555 User users.UserReference `json:"user,omitempty"` 556 // The user ID of the key. 557 UserID int `json:"userId,omitempty"` 558 } 559 560 func (x *APIAccessUserKey) ImplementsAPIAccessKey() {} 561 562 // APIAccessUserKeyError - A user key error. Each error maps to a single key input. 563 type APIAccessUserKeyError struct { 564 // The account ID of the key. 565 AccountID int `json:"accountId,omitempty"` 566 // The error type of the error. 567 ErrorType APIAccessUserKeyErrorType `json:"errorType,omitempty"` 568 // The `id` of the key being updated. 569 ID string `json:"id,omitempty"` 570 // A message about why the key creation failed. 571 Message string `json:"message,omitempty"` 572 // The type of the key. 573 Type APIAccessKeyType `json:"type,omitempty"` 574 // The user ID of the key. 575 UserID int `json:"userId,omitempty"` 576 } 577 578 func (x *APIAccessUserKeyError) ImplementsAPIAccessKeyError() {} 579 580 // EpochSeconds - The `EpochSeconds` scalar represents the number of seconds since the Unix epoch 581 type EpochSeconds string 582 583 // APIAccessKey - A key for accessing New Relic APIs. 584 type APIAccessKeyInterface interface { 585 ImplementsAPIAccessKey() 586 } 587 588 // UnmarshalAPIAccessKeyInterface unmarshals the interface into the correct type 589 // based on __typename provided by GraphQL 590 func UnmarshalAPIAccessKeyInterface(b []byte) (*APIAccessKeyInterface, error) { 591 var err error 592 593 var rawMessageAPIAccessKey map[string]*json.RawMessage 594 err = json.Unmarshal(b, &rawMessageAPIAccessKey) 595 if err != nil { 596 return nil, err 597 } 598 599 // Nothing to unmarshal 600 if len(rawMessageAPIAccessKey) < 1 { 601 return nil, nil 602 } 603 604 var typeName string 605 606 if rawTypeName, ok := rawMessageAPIAccessKey["__typename"]; ok { 607 err = json.Unmarshal(*rawTypeName, &typeName) 608 if err != nil { 609 return nil, err 610 } 611 612 switch typeName { 613 case "ApiAccessIngestKey": 614 var interfaceType APIAccessIngestKey 615 err = json.Unmarshal(b, &interfaceType) 616 if err != nil { 617 return nil, err 618 } 619 620 var xxx APIAccessKeyInterface = &interfaceType 621 622 return &xxx, nil 623 case "ApiAccessUserKey": 624 var interfaceType APIAccessUserKey 625 err = json.Unmarshal(b, &interfaceType) 626 if err != nil { 627 return nil, err 628 } 629 630 var xxx APIAccessKeyInterface = &interfaceType 631 632 return &xxx, nil 633 } 634 } else { 635 keys := []string{} 636 for k := range rawMessageAPIAccessKey { 637 keys = append(keys, k) 638 } 639 return nil, fmt.Errorf("interface APIAccessKey did not include a __typename field for inspection: %s", keys) 640 } 641 642 return nil, fmt.Errorf("interface APIAccessKey was not matched against all PossibleTypes: %s", typeName) 643 } 644 645 // APIAccessKeyError - A key error. Each error maps to a single key input. 646 type APIAccessKeyErrorInterface interface { 647 ImplementsAPIAccessKeyError() 648 GetError() error 649 } 650 651 // UnmarshalAPIAccessKeyErrorInterface unmarshals the interface into the correct type 652 // based on __typename provided by GraphQL 653 func UnmarshalAPIAccessKeyErrorInterface(b []byte) (*APIAccessKeyErrorInterface, error) { 654 var err error 655 656 var rawMessageAPIAccessKeyError map[string]*json.RawMessage 657 err = json.Unmarshal(b, &rawMessageAPIAccessKeyError) 658 if err != nil { 659 return nil, err 660 } 661 662 // Nothing to unmarshal 663 if len(rawMessageAPIAccessKeyError) < 1 { 664 return nil, nil 665 } 666 667 var typeName string 668 669 if rawTypeName, ok := rawMessageAPIAccessKeyError["__typename"]; ok { 670 err = json.Unmarshal(*rawTypeName, &typeName) 671 if err != nil { 672 return nil, err 673 } 674 675 switch typeName { 676 case "ApiAccessIngestKeyError": 677 var interfaceType APIAccessIngestKeyError 678 err = json.Unmarshal(b, &interfaceType) 679 if err != nil { 680 return nil, err 681 } 682 683 var xxx APIAccessKeyErrorInterface = &interfaceType 684 685 return &xxx, nil 686 case "ApiAccessUserKeyError": 687 var interfaceType APIAccessUserKeyError 688 err = json.Unmarshal(b, &interfaceType) 689 if err != nil { 690 return nil, err 691 } 692 693 var xxx APIAccessKeyErrorInterface = &interfaceType 694 695 return &xxx, nil 696 } 697 } else { 698 keys := []string{} 699 for k := range rawMessageAPIAccessKeyError { 700 keys = append(keys, k) 701 } 702 return nil, fmt.Errorf("interface APIAccessKeyError did not include a __typename field for inspection: %s", keys) 703 } 704 705 return nil, fmt.Errorf("interface APIAccessKeyError was not matched against all PossibleTypes: %s", typeName) 706 }