Updated documentation and adjusted field names

This commit is contained in:
Clayton Coleman
2015-03-26 17:24:17 -04:00
parent 524f8731b5
commit aa44d29d10
7 changed files with 65 additions and 30 deletions

View File

@@ -198,15 +198,15 @@ func NewMethodNotSupported(kind, action string) error {
// NewServerTimeout returns an error indicating the requested action could not be completed due to a
// transient error, and the client should try again.
func NewServerTimeout(kind, operation string, retryAfter int) error {
func NewServerTimeout(kind, operation string, retryAfterSeconds int) error {
return &StatusError{api.Status{
Status: api.StatusFailure,
Code: http.StatusInternalServerError,
Reason: api.StatusReasonServerTimeout,
Details: &api.StatusDetails{
Kind: kind,
ID: operation,
RetryAfter: retryAfter,
Kind: kind,
ID: operation,
RetryAfterSeconds: retryAfterSeconds,
},
Message: fmt.Sprintf("The %s operation against %s could not be completed at this time, please try again.", operation, kind),
}}
@@ -227,14 +227,14 @@ func NewInternalError(err error) error {
// NewTimeoutError returns an error indicating that a timeout occurred before the request
// could be completed. Clients may retry, but the operation may still complete.
func NewTimeoutError(message string, retryAfter int) error {
func NewTimeoutError(message string, retryAfterSeconds int) error {
return &StatusError{api.Status{
Status: api.StatusFailure,
Code: StatusServerTimeout,
Reason: api.StatusReasonTimeout,
Message: fmt.Sprintf("Timeout: %s", message),
Details: &api.StatusDetails{
RetryAfter: retryAfter,
RetryAfterSeconds: retryAfterSeconds,
},
}}
}
@@ -308,7 +308,7 @@ func SuggestsClientDelay(err error) (int, bool) {
if t.Status().Details != nil {
switch t.Status().Reason {
case api.StatusReasonServerTimeout, api.StatusReasonTimeout:
return t.Status().Details.RetryAfter, true
return t.Status().Details.RetryAfterSeconds, true
}
}
}

View File

@@ -1201,7 +1201,7 @@ type StatusDetails struct {
// failure. Not all StatusReasons may provide detailed causes.
Causes []StatusCause `json:"causes,omitempty"`
// If specified, the time in seconds before the operation should be retried.
RetryAfter int `json:"retryAfter,omitempty"`
RetryAfterSeconds int `json:"retryAfterSeconds,omitempty"`
}
// Values of Status.Status
@@ -1285,7 +1285,7 @@ const (
// Details (optional):
// "kind" string - the kind attribute of the resource being acted on.
// "id" string - the operation that is being attempted.
// "retryAfter" int - the number of seconds before the operation should be retried
// "retryAfterSeconds" int - the number of seconds before the operation should be retried
// Status code 500
StatusReasonServerTimeout StatusReason = "ServerTimeout"
@@ -1293,9 +1293,9 @@ const (
// Clients can get this response only when they specified a timeout param in the request,
// or if the server cannot complete the operation within a reasonable amount of time.
// The request might succeed with an increased value of timeout param. The client *should*
// wait at least the number of seconds specified by the retryAfter field.
// wait at least the number of seconds specified by the retryAfterSeconds field.
// Details (optional):
// "retryAfter" int - the number of seconds before the operation should be retried
// "retryAfterSeconds" int - the number of seconds before the operation should be retried
// Status code 504
StatusReasonTimeout StatusReason = "Timeout"

View File

@@ -1015,7 +1015,7 @@ type StatusDetails struct {
// failure. Not all StatusReasons may provide detailed causes.
Causes []StatusCause `json:"causes,omitempty" description:"the Causes array includes more details associated with the StatusReason failure; not all StatusReasons may provide detailed causes"`
// If specified, the time in seconds before the operation should be retried.
RetryAfter int `json:"retryAfter,omitempty" description:"the number of seconds before the client should attempt to retry this operation"`
RetryAfterSeconds int `json:"retryAfterSeconds,omitempty" description:"the number of seconds before the client should attempt to retry this operation"`
}
// Values of Status.Status

View File

@@ -1029,7 +1029,7 @@ type StatusDetails struct {
// failure. Not all StatusReasons may provide detailed causes.
Causes []StatusCause `json:"causes,omitempty" description:"the Causes array includes more details associated with the StatusReason failure; not all StatusReasons may provide detailed causes"`
// If specified, the time in seconds before the operation should be retried.
RetryAfter int `json:"retryAfter,omitempty" description:"the number of seconds before the client should attempt to retry this operation"`
RetryAfterSeconds int `json:"retryAfterSeconds,omitempty" description:"the number of seconds before the client should attempt to retry this operation"`
}
// Values of Status.Status

View File

@@ -1188,7 +1188,7 @@ type StatusDetails struct {
// failure. Not all StatusReasons may provide detailed causes.
Causes []StatusCause `json:"causes,omitempty" description:"the Causes array includes more details associated with the StatusReason failure; not all StatusReasons may provide detailed causes"`
// If specified, the time in seconds before the operation should be retried.
RetryAfter int `json:"retryAfter,omitempty" description:"the number of seconds before the client should attempt to retry this operation"`
RetryAfterSeconds int `json:"retryAfterSeconds,omitempty" description:"the number of seconds before the client should attempt to retry this operation"`
}
// Values of Status.Status