1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
|
/**
* Go SDK for OpenFGA
*
* API version: 1.x
* Website: https://openfga.dev
* Documentation: https://openfga.dev/docs
* Support: https://openfga.dev/community
* License: [Apache-2.0](https://github.com/openfga/go-sdk/blob/main/LICENSE)
*
* NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
*/
package openfga
import (
"fmt"
"net/http"
"strconv"
"time"
"github.com/openfga/go-sdk/internal/utils/retryutils"
)
// GenericOpenAPIError Provides access to the body, error and model on returned errors.
type GenericOpenAPIError struct {
body []byte
error string
model interface{}
}
// Error returns non-empty string if there was an error.
func (e GenericOpenAPIError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e GenericOpenAPIError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e GenericOpenAPIError) Model() interface{} {
return e.model
}
// FgaApiAuthenticationError is raised when API has errors due to invalid authentication
type FgaApiAuthenticationError struct {
body []byte
error string
model interface{}
storeId string
requestHost string
endpointCategory string
modelDecodeError error
responseStatusCode int
responseHeader http.Header
requestId string
responseCode string
}
// Error returns non-empty string if there was an error.
func (e FgaApiAuthenticationError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e FgaApiAuthenticationError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e FgaApiAuthenticationError) Model() interface{} {
return e.model
}
// StoreId returns the store ID for the API that causes the error
func (e FgaApiAuthenticationError) StoreId() string {
return e.storeId
}
// RequestHost returns the base host of the call to the API
func (e FgaApiAuthenticationError) RequestHost() string {
return e.requestHost
}
// EndpointCategory returns the original API category
func (e FgaApiAuthenticationError) EndpointCategory() string {
return e.endpointCategory
}
// ModelDecodeError returns any error when decoding the unpacked model of the error
func (e FgaApiAuthenticationError) ModelDecodeError() error {
return e.modelDecodeError
}
// ResponseStatusCode returns the original API response status HTTP code
func (e FgaApiAuthenticationError) ResponseStatusCode() int {
return e.responseStatusCode
}
// ResponseHeader returns the original API response header
func (e FgaApiAuthenticationError) ResponseHeader() http.Header {
return e.responseHeader
}
// RequestId returns the FGA request ID associated with the response
func (e FgaApiAuthenticationError) RequestId() string {
return e.requestId
}
// ResponseCode returns response code
func (e FgaApiAuthenticationError) ResponseCode() string {
return e.responseCode
}
func NewFgaApiAuthenticationError(
operationName string,
_ interface{},
httpResponse *http.Response,
responseBody []byte,
storeId string,
) FgaApiAuthenticationError {
err := FgaApiAuthenticationError{
body: responseBody,
storeId: storeId,
endpointCategory: operationName,
requestHost: httpResponse.Request.URL.Host,
responseStatusCode: httpResponse.StatusCode,
responseHeader: httpResponse.Header,
error: fmt.Sprintf("%[1]s auth error for %[2]s %[1]s with body %[3]s", httpResponse.Request.Method, operationName, string(responseBody)),
}
requestID := httpResponse.Header.Get("Fga-Request-Id")
if requestID != "" {
err.requestId = requestID
} else {
requestID = httpResponse.Header.Get("X-Request-Id")
if requestID != "" {
err.requestId = requestID
}
}
return err
}
// FgaApiError will be returned if there are errors in the API
type FgaApiError struct {
body []byte
error string
model interface{}
storeId string
endpointCategory string
requestBody interface{}
requestMethod string
requestHost string
modelDecodeError error
responseStatusCode int
responseHeader http.Header
requestId string
responseCode string
}
// Error returns non-empty string if there was an error.
func (e FgaApiError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e FgaApiError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e FgaApiError) Model() interface{} {
return e.model
}
// StoreId returns the store ID for the API that causes the error
func (e FgaApiError) StoreId() string {
return e.storeId
}
// RequestBody returns the original request body
func (e FgaApiError) RequestBody() interface{} {
return e.requestBody
}
// RequestMethod returns the method calling the API
func (e FgaApiError) RequestMethod() string {
return e.requestMethod
}
// RequestHost returns the base host of the call to the API
func (e FgaApiError) RequestHost() string {
return e.requestHost
}
// EndpointCategory returns the original API category
func (e FgaApiError) EndpointCategory() string {
return e.endpointCategory
}
// ModelDecodeError returns any error when decoding the unpacked model of the error
func (e FgaApiError) ModelDecodeError() error {
return e.modelDecodeError
}
// ResponseStatusCode returns the original API response HTTP status code
func (e FgaApiError) ResponseStatusCode() int {
return e.responseStatusCode
}
// ResponseHeader returns the original API response header
func (e FgaApiError) ResponseHeader() http.Header {
return e.responseHeader
}
// RequestId returns the FGA request ID associated with the response
func (e FgaApiError) RequestId() string {
return e.requestId
}
// ResponseCode returns response code
func (e FgaApiError) ResponseCode() string {
return e.responseCode
}
func NewFgaApiError(
operationName string,
requestBody interface{},
httpResponse *http.Response,
responseBody []byte,
storeId string,
) FgaApiError {
err := FgaApiError{
body: responseBody,
storeId: storeId,
endpointCategory: operationName,
requestBody: requestBody,
requestMethod: httpResponse.Request.Method,
requestHost: httpResponse.Request.URL.Host,
responseStatusCode: httpResponse.StatusCode,
responseHeader: httpResponse.Header,
error: fmt.Sprintf("%[1]s error for %[2]s %[1]s with body %[3]s", httpResponse.Request.Method, operationName, string(responseBody)),
}
requestID := httpResponse.Header.Get("Fga-Request-Id")
if requestID != "" {
err.requestId = requestID
} else {
requestID = httpResponse.Header.Get("X-Request-Id")
if requestID != "" {
err.requestId = requestID
}
}
return err
}
// FgaApiValidationError will be returned if there are errors in the API's parameters
type FgaApiValidationError struct {
body []byte
error string
model interface{}
storeId string
endpointCategory string
requestBody interface{}
requestMethod string
requestHost string
modelDecodeError error
responseStatusCode int
responseHeader http.Header
requestId string
responseCode ErrorCode
}
// Error returns non-empty string if there was an error.
func (e FgaApiValidationError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e FgaApiValidationError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e FgaApiValidationError) Model() interface{} {
return e.model
}
// StoreId returns the store ID for the API that causes the error
func (e FgaApiValidationError) StoreId() string {
return e.storeId
}
// RequestBody returns the original request body
func (e FgaApiValidationError) RequestBody() interface{} {
return e.requestBody
}
// RequestMethod returns the method calling the API
func (e FgaApiValidationError) RequestMethod() string {
return e.requestMethod
}
// RequestHost returns the base host of the call to the API
func (e FgaApiValidationError) RequestHost() string {
return e.requestHost
}
// EndpointCategory returns the original API category
func (e FgaApiValidationError) EndpointCategory() string {
return e.endpointCategory
}
// ModelDecodeError returns any error when decoding the unpacked model of the error
func (e FgaApiValidationError) ModelDecodeError() error {
return e.modelDecodeError
}
// ResponseStatusCode returns the original API response HTTP status code
func (e FgaApiValidationError) ResponseStatusCode() int {
return e.responseStatusCode
}
// ResponseHeader returns the original API response header
func (e FgaApiValidationError) ResponseHeader() http.Header {
return e.responseHeader
}
// RequestId returns the FGA request ID associated with the response
func (e FgaApiValidationError) RequestId() string {
return e.requestId
}
// ResponseCode returns response code
func (e FgaApiValidationError) ResponseCode() ErrorCode {
return e.responseCode
}
func NewFgaApiValidationError(
operationName string,
requestBody interface{},
httpResponse *http.Response,
responseBody []byte,
storeId string,
) FgaApiValidationError {
err := FgaApiValidationError{
body: responseBody,
storeId: storeId,
endpointCategory: operationName,
requestBody: requestBody,
requestMethod: httpResponse.Request.Method,
requestHost: httpResponse.Request.URL.Host,
responseStatusCode: httpResponse.StatusCode,
responseHeader: httpResponse.Header,
error: fmt.Sprintf("%[1]s validation error for %[2]s %[1]s with body %[3]s", httpResponse.Request.Method, operationName, string(responseBody)),
}
requestID := httpResponse.Header.Get("Fga-Request-Id")
if requestID != "" {
err.requestId = requestID
} else {
requestID = httpResponse.Header.Get("X-Request-Id")
if requestID != "" {
err.requestId = requestID
}
}
return err
}
// FgaApiNotFoundError will be returned if the endpoint cannot be found
type FgaApiNotFoundError struct {
body []byte
error string
model interface{}
storeId string
endpointCategory string
requestBody interface{}
requestMethod string
requestHost string
modelDecodeError error
responseStatusCode int
responseHeader http.Header
requestId string
responseCode NotFoundErrorCode
}
// Error returns non-empty string if there was an error.
func (e FgaApiNotFoundError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e FgaApiNotFoundError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e FgaApiNotFoundError) Model() interface{} {
return e.model
}
// StoreId returns the store ID for the API that causes the error
func (e FgaApiNotFoundError) StoreId() string {
return e.storeId
}
// RequestBody returns the original request body
func (e FgaApiNotFoundError) RequestBody() interface{} {
return e.requestBody
}
// RequestMethod returns the method calling the API
func (e FgaApiNotFoundError) RequestMethod() string {
return e.requestMethod
}
// RequestHost returns the base host of the call to the API
func (e FgaApiNotFoundError) RequestHost() string {
return e.requestHost
}
// EndpointCategory returns the original API category
func (e FgaApiNotFoundError) EndpointCategory() string {
return e.endpointCategory
}
// ModelDecodeError returns any error when decoding the unpacked model of the error
func (e FgaApiNotFoundError) ModelDecodeError() error {
return e.modelDecodeError
}
// ResponseStatusCode returns the original API response HTTP status code
func (e FgaApiNotFoundError) ResponseStatusCode() int {
return e.responseStatusCode
}
// ResponseHeader returns the original API response header
func (e FgaApiNotFoundError) ResponseHeader() http.Header {
return e.responseHeader
}
// RequestId returns the FGA request ID associated with the response
func (e FgaApiNotFoundError) RequestId() string {
return e.requestId
}
// ResponseCode returns response code
func (e FgaApiNotFoundError) ResponseCode() NotFoundErrorCode {
return e.responseCode
}
func NewFgaApiNotFoundError(
operationName string,
requestBody interface{},
httpResponse *http.Response,
responseBody []byte,
storeId string,
) FgaApiNotFoundError {
err := FgaApiNotFoundError{
body: responseBody,
storeId: storeId,
endpointCategory: operationName,
requestBody: requestBody,
requestMethod: httpResponse.Request.Method,
requestHost: httpResponse.Request.URL.Host,
responseStatusCode: httpResponse.StatusCode,
responseHeader: httpResponse.Header,
error: fmt.Sprintf("%[1]s not found error for %[2]s %[1]s with body %[3]s", httpResponse.Request.Method, operationName, string(responseBody)),
}
requestID := httpResponse.Header.Get("Fga-Request-Id")
if requestID != "" {
err.requestId = requestID
} else {
requestID = httpResponse.Header.Get("X-Request-Id")
if requestID != "" {
err.requestId = requestID
}
}
return err
}
// FgaApiInternalError will be returned if there are internal errors in OpenFGA
type FgaApiInternalError struct {
body []byte
error string
model interface{}
storeId string
endpointCategory string
requestBody interface{}
requestHost string
requestMethod string
modelDecodeError error
responseStatusCode int
responseHeader http.Header
requestId string
responseCode InternalErrorCode
retryAfterDurationInMs int
retryAfterEpoc string
shouldRetry bool
}
// Error returns non-empty string if there was an error.
func (e FgaApiInternalError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e FgaApiInternalError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e FgaApiInternalError) Model() interface{} {
return e.model
}
// StoreId returns the store ID for the API that causes the error
func (e FgaApiInternalError) StoreId() string {
return e.storeId
}
// RequestBody returns the original request body
func (e FgaApiInternalError) RequestBody() interface{} {
return e.requestBody
}
// RequestMethod returns the method calling the API
func (e FgaApiInternalError) RequestMethod() string {
return e.requestMethod
}
// RequestHost returns the base host of the call to the API
func (e FgaApiInternalError) RequestHost() string {
return e.requestHost
}
// RetryAfterDurationInMs returns the retry duration in milliseconds
func (e FgaApiInternalError) RetryAfterDurationInMs() int {
return e.retryAfterDurationInMs
}
// RetryAfterEpoc returns the retry duration in RFC3339 format
func (e FgaApiInternalError) RetryAfterEpoc() string {
return e.retryAfterEpoc
}
// EndpointCategory returns the original API category
func (e FgaApiInternalError) EndpointCategory() string {
return e.endpointCategory
}
// ModelDecodeError returns any error when decoding the unpacked model of the error
func (e FgaApiInternalError) ModelDecodeError() error {
return e.modelDecodeError
}
// ResponseStatusCode returns the original API response HTTP status code
func (e FgaApiInternalError) ResponseStatusCode() int {
return e.responseStatusCode
}
// ResponseHeader returns the original API response header
func (e FgaApiInternalError) ResponseHeader() http.Header {
return e.responseHeader
}
// RequestId returns the FGA request ID associated with the response
func (e FgaApiInternalError) RequestId() string {
return e.requestId
}
// ResponseCode returns response code
func (e FgaApiInternalError) ResponseCode() InternalErrorCode {
return e.responseCode
}
// ShouldRetry returns whether this error is retryable
func (e FgaApiInternalError) ShouldRetry() bool {
return e.responseStatusCode != http.StatusNotImplemented
}
// GetTimeToWait returns how much time is needed before we can retry
func (e FgaApiInternalError) GetTimeToWait(retryCount int, retryParams retryutils.RetryParams) time.Duration {
if !e.shouldRetry {
return time.Duration(0)
}
return retryutils.GetTimeToWait(retryCount, retryParams.MaxRetry, retryParams.MinWaitInMs, e.responseHeader, e.endpointCategory)
}
func NewFgaApiInternalError(
operationName string,
requestBody interface{},
httpResponse *http.Response,
responseBody []byte,
storeId string,
) FgaApiInternalError {
err := FgaApiInternalError{
body: responseBody,
storeId: storeId,
endpointCategory: operationName,
requestBody: requestBody,
requestMethod: httpResponse.Request.Method,
requestHost: httpResponse.Request.URL.Host,
responseStatusCode: httpResponse.StatusCode,
responseHeader: httpResponse.Header,
error: fmt.Sprintf("%[1]s internal error for %[2]s %[1]s with body %[3]s", httpResponse.Request.Method, operationName, string(responseBody)),
}
requestID := httpResponse.Header.Get("Fga-Request-Id")
if requestID != "" {
err.requestId = requestID
} else {
requestID = httpResponse.Header.Get("X-Request-Id")
if requestID != "" {
err.requestId = requestID
}
}
retryAfter := retryutils.ParseRetryAfterHeaderValue(httpResponse.Header, "Retry-After")
if retryAfter > 0 {
err.retryAfterDurationInMs = int(retryAfter.Milliseconds())
err.retryAfterEpoc = time.Now().Add(retryAfter).Format(time.RFC3339)
}
return err
}
// FgaApiRateLimitExceededError will be returned if error happens because the API's rate limit has been exceeded (429 HTTP response)
type FgaApiRateLimitExceededError struct {
body []byte
error string
model interface{}
storeId string
endpointCategory string
requestBody interface{}
requestMethod string
requestHost string
modelDecodeError error
responseStatusCode int
responseHeader http.Header
requestId string
responseCode string
retryAfterDurationInMs int
retryAfterEpoc string
rateLimit int
rateUnit string
rateLimitResetEpoch string
}
// Error returns non-empty string if there was an error.
func (e FgaApiRateLimitExceededError) Error() string {
return e.error
}
// Body returns the raw bytes of the response
func (e FgaApiRateLimitExceededError) Body() []byte {
return e.body
}
// Model returns the unpacked model of the error
func (e FgaApiRateLimitExceededError) Model() interface{} {
return e.model
}
// StoreId returns the store ID for the API that causes the error
func (e FgaApiRateLimitExceededError) StoreId() string {
return e.storeId
}
// RequestBody returns the original request body
func (e FgaApiRateLimitExceededError) RequestBody() interface{} {
return e.requestBody
}
// RequestMethod returns the method calling the API
func (e FgaApiRateLimitExceededError) RequestMethod() string {
return e.requestMethod
}
// RequestHost returns the base host of the call to the API
func (e FgaApiRateLimitExceededError) RequestHost() string {
return e.requestHost
}
// RetryAfterDurationInMs returns the retry duration in milliseconds
func (e FgaApiRateLimitExceededError) RetryAfterDurationInMs() int {
return e.retryAfterDurationInMs
}
// RetryAfterEpoc returns the retry duration in RFC3339 format
func (e FgaApiRateLimitExceededError) RetryAfterEpoc() string {
return e.retryAfterEpoc
}
// RateLimit returns the limit for the API
func (e FgaApiRateLimitExceededError) RateLimit() int {
return e.rateLimit
}
// RateUnit returns the unit used for rate limit
func (e FgaApiRateLimitExceededError) RateUnit() string {
return e.rateUnit
}
// RateLimitResetEpoch returns the unit used for rate limit
func (e FgaApiRateLimitExceededError) RateLimitResetEpoch() string {
return e.rateLimitResetEpoch
}
// EndpointCategory returns the original API category
func (e FgaApiRateLimitExceededError) EndpointCategory() string {
return e.endpointCategory
}
// ModelDecodeError returns any error when decoding the unpacked model of the error
func (e FgaApiRateLimitExceededError) ModelDecodeError() error {
return e.modelDecodeError
}
// ResponseStatusCode returns the original API response HTTP status code
func (e FgaApiRateLimitExceededError) ResponseStatusCode() int {
return e.responseStatusCode
}
// ResponseHeader returns the original API response header
func (e FgaApiRateLimitExceededError) ResponseHeader() http.Header {
return e.responseHeader
}
// RequestId returns the FGA request ID associated with the response
func (e FgaApiRateLimitExceededError) RequestId() string {
return e.requestId
}
// ResponseCode returns response code
func (e FgaApiRateLimitExceededError) ResponseCode() string {
return e.responseCode
}
// ShouldRetry returns whether this error is retryable
func (e FgaApiRateLimitExceededError) ShouldRetry() bool {
return true
}
// GetTimeToWait returns how much time is needed before we can retry
func (e FgaApiRateLimitExceededError) GetTimeToWait(retryCount int, retryParams retryutils.RetryParams) time.Duration {
return retryutils.GetTimeToWait(retryCount, retryParams.MaxRetry, retryParams.MinWaitInMs, e.responseHeader, e.endpointCategory)
}
func NewFgaApiRateLimitExceededError(
operationName string,
requestBody interface{},
httpResponse *http.Response,
responseBody []byte,
storeId string,
) FgaApiRateLimitExceededError {
err := FgaApiRateLimitExceededError{
body: responseBody,
storeId: storeId,
endpointCategory: operationName,
requestBody: requestBody,
requestMethod: httpResponse.Request.Method,
requestHost: httpResponse.Request.URL.Host,
responseStatusCode: httpResponse.StatusCode,
responseHeader: httpResponse.Header,
error: fmt.Sprintf("%[1]s rate limit error for %[2]s %[1]s with body %[3]s", httpResponse.Request.Method, operationName, string(responseBody)),
}
requestID := httpResponse.Header.Get("Fga-Request-Id")
if requestID != "" {
err.requestId = requestID
} else {
requestID = httpResponse.Header.Get("X-Request-Id")
if requestID != "" {
err.requestId = requestID
}
}
retryAfter := retryutils.ParseRetryAfterHeaderValue(httpResponse.Header, retryutils.RetryAfterHeaderName)
if retryAfter > 0 {
err.retryAfterDurationInMs = int(retryAfter.Milliseconds())
err.retryAfterEpoc = time.Now().Add(retryAfter).Format(time.RFC3339)
}
rateLimitHeader := httpResponse.Header.Get("X-RateLimit-Limit")
if rateLimitHeader != "" {
err.rateLimit, _ = strconv.Atoi(rateLimitHeader)
}
rateUnitHeader := httpResponse.Header.Get("X-RateLimit-Unit")
if rateUnitHeader != "" {
err.rateUnit = rateUnitHeader
}
rateLimitResetHeader := httpResponse.Header.Get(retryutils.RateLimitResetHeaderName)
if rateLimitResetHeader != "" {
err.rateLimitResetEpoch = rateLimitResetHeader
} else {
rateLimitResetHeader = httpResponse.Header.Get(retryutils.RateLimitResetAltHeaderName)
if rateLimitResetHeader != "" {
err.rateLimitResetEpoch = rateLimitResetHeader
}
}
return err
}
|