// ProblemDetailsToStatusCode inspects the given ProblemDetails to figure out
// what HTTP status code it should represent. It should only be used by the WFE
// but is included in this package because of its reliance on ProblemTypes.
197214
func ProblemDetailsToStatusCode(prob *ProblemDetails) int {
	if prob.HTTPStatus != 0 {
		return prob.HTTPStatus
	}
	switch prob.Type {
	case
		ConnectionProblem,
		MalformedProblem,
		BadSignatureAlgorithmProblem,
		BadPublicKeyProblem,
		TLSProblem,
		UnknownHostProblem,
		BadNonceProblem,
		InvalidEmailProblem,
		RejectedIdentifierProblem,
		AccountDoesNotExistProblem:
		return http.StatusBadRequest
	case ServerInternalProblem:
		return http.StatusInternalServerError
	case
		UnauthorizedProblem,
		CAAProblem:
		return http.StatusForbidden
	case RateLimitedProblem:
		return statusTooManyRequests
	default:
		return http.StatusInternalServerError
	}
}
996416
func StatusCode(err error) int {
	if err == nil {
		return http.StatusOK
	}
	if val, ok := errors.TagValueIn(statusCodeTagKey, err); ok {
		return val.(int)
	}
	return 0
}
914860
func InvalidContentType(detail string, a ...interface{}) *ProblemDetails {
	return &ProblemDetails{
		Type:       MalformedProblem,
		Detail:     fmt.Sprintf(detail, a...),
		HTTPStatus: http.StatusUnsupportedMediaType,
	}
}
313750
func (o *ListTasksDefault) WithStatusCode(code int) *ListTasksDefault {
	o._statusCode = code
	return o
}
425268
func (e *Error) StatusCode() int {
	code, ok := errorTypeToStatusCodeMap[e.Type]
	if !ok || code == 0 {
		return 500
	}

	return code
}
611583
func TLSError(detail string, a ...interface{}) *ProblemDetails {
	return &ProblemDetails{
		Type:       TLSProblem,
		Detail:     fmt.Sprintf(detail, a...),
		HTTPStatus: http.StatusBadRequest,
	}
}
776723
func (s *GetMaintenanceWindowExecutionTaskOutput) SetStatusDetails(v string) *GetMaintenanceWindowExecutionTaskOutput {
	s.StatusDetails = &v
	return s
}
488982
func (_class VBDClass) GetStatusCode(sessionID SessionRef, self VBDRef) (_retval int, _err error) {
	_method := "VBD.get_status_code"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_selfArg, _err := convertVBDRefToXen(fmt.Sprintf("%s(%s)", _method, "self"), self)
	if _err != nil {
		return
	}
	_result, _err := _class.client.APICall(_method, _sessionIDArg, _selfArg)
	if _err != nil {
		return
	}
	_retval, _err = convertIntToGo(_method + " -> ", _result.Value)
	return
}
1218650
func (s *JobExecution) SetStatusDetails(v *JobExecutionStatusDetails) *JobExecution {
	s.StatusDetails = v
	return s
}
1111194
func (s State) HTTPCode() int {
	if v, y := GetStatus(s); y {
		return v.Code
	}
	return http.StatusOK
}
387633
func HasDenialStatusCode(err error) bool {
	if err == nil {
		return false
	}

	// http/url.Error is constructed with status code in mind and, at the time of writing for go-1.10,
	// contains response status code and description in error.Error.
	// We have to examine the error message to determine whether the error is related to authentication failure.
	if cause, ok := errors.Cause(err).(*url.Error); ok {
		for code, desc := range AuthorisationFailureStatusCodes {
			if strings.Contains(cause.Error(), fmt.Sprintf(": %v %v", code, desc)) {
				return true
			}
		}
	}
	return false

}
477141
func (s *Playlist) SetStatusDetail(v string) *Playlist {
	s.StatusDetail = &v
	return s
}
75022
func (s *JobExecutionState) SetStatusDetails(v map[string]*string) *JobExecutionState {
	s.StatusDetails = v
	return s
}
297602
func (e ServerErrorConditionFailed) ToStatus() (s keybase1.Status) {
	s.Code = StatusCodeServerErrorConditionFailed
	s.Name = "CONDITION_FAILED"
	s.Desc = e.Err.Error()
	s.Fields = []keybase1.StringKVPair{
		keybase1.StringKVPair{
			Key:   "ShouldThrottle",
			Value: strconv.FormatBool(e.ShouldThrottle),
		},
	}
	return
}
1025494
func GetStatusCode(o dhcp6.Options) (*StatusCode, error) {
	v, err := o.GetOne(dhcp6.OptionStatusCode)
	if err != nil {
		return nil, err
	}

	s := new(StatusCode)
	err = s.UnmarshalBinary(v)
	return s, err
}
1228405
func toTraceStatusCode(httpStatusCode int) int32 {
	switch {
	case http.StatusOK <= httpStatusCode && httpStatusCode < http.StatusBadRequest:
		return trace.StatusCodeOK
	case httpStatusCode == http.StatusBadRequest:
		return trace.StatusCodeInvalidArgument
	case httpStatusCode == http.StatusUnauthorized: // 401 is actually unauthenticated.
		return trace.StatusCodeUnauthenticated
	case httpStatusCode == http.StatusForbidden:
		return trace.StatusCodePermissionDenied
	case httpStatusCode == http.StatusNotFound:
		return trace.StatusCodeNotFound
	case httpStatusCode == http.StatusTooManyRequests:
		return trace.StatusCodeResourceExhausted
	case httpStatusCode == 499:
		return trace.StatusCodeCancelled
	case httpStatusCode == http.StatusNotImplemented:
		return trace.StatusCodeUnimplemented
	case httpStatusCode == http.StatusServiceUnavailable:
		return trace.StatusCodeUnavailable
	case httpStatusCode == http.StatusGatewayTimeout:
		return trace.StatusCodeDeadlineExceeded
	default:
		return trace.StatusCodeUnknown
	}
}
485586
func (o *GetIDDefault) WithStatusCode(code int) *GetIDDefault {
	o._statusCode = code
	return o
}