2020-06-30 12:25:05 +02:00
|
|
|
// -*- Mode: Go; indent-tabs-mode: t -*-
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 Canonical Ltd
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License version 3 as
|
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package client
|
|
|
|
|
|
2020-08-02 15:45:55 +02:00
|
|
|
// ErrorKind distinguishes kind of errors.
|
|
|
|
|
type ErrorKind string
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-07-26 16:49:51 +02:00
|
|
|
// error kind const value doc comments here have a non-default,
|
|
|
|
|
// specialized style (to help docs/error-kind.go):
|
|
|
|
|
//
|
2020-08-05 14:50:18 +02:00
|
|
|
// // ErrorKind...: DESCRIPTION .
|
2020-07-26 16:49:51 +02:00
|
|
|
//
|
2020-08-05 14:50:18 +02:00
|
|
|
// Note the mandatory dot at the end.
|
2020-07-26 16:49:51 +02:00
|
|
|
// `code-like` quoting should be used when meaningful.
|
|
|
|
|
|
2020-08-05 14:50:18 +02:00
|
|
|
// Error kinds. Keep https://forum.snapcraft.io/t/using-the-rest-api/18603#heading--errors in sync using doc/error-kinds.go.
|
2020-06-30 12:25:05 +02:00
|
|
|
const (
|
2020-07-26 16:49:51 +02:00
|
|
|
// ErrorKindTwoFactorRequired: the client needs to retry the
|
2020-08-05 14:50:18 +02:00
|
|
|
// `login` command including an OTP.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindTwoFactorRequired ErrorKind = "two-factor-required"
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindTwoFactorFailed: the OTP provided wasn't recognised.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindTwoFactorFailed ErrorKind = "two-factor-failed"
|
2020-07-01 15:59:18 +02:00
|
|
|
// ErrorKindLoginRequired: the requested operation cannot be
|
|
|
|
|
// performed without an authenticated user. This is the kind
|
|
|
|
|
// of any other 401 Unauthorized response.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindLoginRequired ErrorKind = "login-required"
|
2020-07-01 15:59:18 +02:00
|
|
|
// ErrorKindInvalidAuthData: the authentication data provided
|
|
|
|
|
// failed to validate (e.g. a malformed email address). The
|
2020-07-26 16:49:51 +02:00
|
|
|
// `value` of the error is an object with a key per failed field
|
2020-07-01 15:59:18 +02:00
|
|
|
// and a list of the failures on each field.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindInvalidAuthData ErrorKind = "invalid-auth-data"
|
2020-08-02 16:06:39 +02:00
|
|
|
// ErrorKindPasswordPolicy: provided password doesn't meet
|
2020-08-05 14:50:18 +02:00
|
|
|
// system policy.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindPasswordPolicy ErrorKind = "password-policy"
|
2020-08-05 17:48:21 +02:00
|
|
|
// ErrorKindAuthCancelled: authentication was cancelled by the user.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindAuthCancelled ErrorKind = "auth-cancelled"
|
|
|
|
|
|
2020-08-05 17:48:21 +02:00
|
|
|
// ErrorKindTermsNotAccepted: deprecated, do not document.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindTermsNotAccepted ErrorKind = "terms-not-accepted"
|
2020-08-05 17:48:21 +02:00
|
|
|
// ErrorKindNoPaymentMethods: deprecated, do not document.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindNoPaymentMethods ErrorKind = "no-payment-methods"
|
2020-08-05 17:48:21 +02:00
|
|
|
// ErrorKindPaymentDeclined: deprecated, do not document.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindPaymentDeclined ErrorKind = "payment-declined"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-07-01 15:59:18 +02:00
|
|
|
// ErrorKindSnapAlreadyInstalled: the requested snap is
|
2020-08-05 14:50:18 +02:00
|
|
|
// already installed.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapAlreadyInstalled ErrorKind = "snap-already-installed"
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindSnapNotInstalled: the requested snap is not installed.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapNotInstalled ErrorKind = "snap-not-installed"
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindSnapNotFound: the requested snap couldn't be found.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapNotFound ErrorKind = "snap-not-found"
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindAppNotFound: the requested app couldn't be found.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindAppNotFound ErrorKind = "app-not-found"
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindSnapLocal: cannot perform operation on local snap.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapLocal ErrorKind = "snap-local"
|
2020-07-01 15:59:18 +02:00
|
|
|
// ErrorKindSnapNeedsDevMode: the requested snap needs devmode
|
2020-08-05 14:50:18 +02:00
|
|
|
// to be installed.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapNeedsDevMode ErrorKind = "snap-needs-devmode"
|
2020-07-01 15:59:18 +02:00
|
|
|
// ErrorKindSnapNeedsClassic: the requested snap needs classic
|
2020-08-05 14:50:18 +02:00
|
|
|
// confinement to be installed.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapNeedsClassic ErrorKind = "snap-needs-classic"
|
2020-07-26 16:49:51 +02:00
|
|
|
// ErrorKindSnapNeedsClassicSystem: the requested snap can't
|
2020-08-05 14:50:18 +02:00
|
|
|
// be installed on the current non-classic system.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapNeedsClassicSystem ErrorKind = "snap-needs-classic-system"
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindSnapNotClassic: snap not compatible with classic mode.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSnapNotClassic ErrorKind = "snap-not-classic"
|
2020-08-02 16:06:39 +02:00
|
|
|
// ErrorKindSnapNoUpdateAvailable: the requested snap does not
|
2020-08-05 14:50:18 +02:00
|
|
|
// have an update available.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindSnapNoUpdateAvailable ErrorKind = "snap-no-update-available"
|
|
|
|
|
// ErrorKindSnapRevisionNotAvailable: no snap revision available
|
2020-08-05 14:50:18 +02:00
|
|
|
// as specified.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindSnapRevisionNotAvailable ErrorKind = "snap-revision-not-available"
|
|
|
|
|
// ErrorKindSnapChannelNotAvailable: no snap revision on specified
|
2020-07-26 16:49:51 +02:00
|
|
|
// channel. The `value` of the error is a rich object with
|
|
|
|
|
// requested `snap-name`, `action`, `channel`, `architecture`, and
|
|
|
|
|
// actually available `releases` as list of
|
|
|
|
|
// `{"architecture":... , "channel": ...}` objects.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindSnapChannelNotAvailable ErrorKind = "snap-channel-not-available"
|
|
|
|
|
// ErrorKindSnapArchitectureNotAvailable: no snap revision on
|
2020-07-01 15:59:18 +02:00
|
|
|
// specified architecture. Value has the same format as for
|
2020-07-26 16:49:51 +02:00
|
|
|
// `snap-channel-not-available`.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindSnapArchitectureNotAvailable ErrorKind = "snap-architecture-not-available"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-08-02 16:06:39 +02:00
|
|
|
// ErrorKindSnapChangeConflict: the requested operation would
|
2020-07-01 15:59:18 +02:00
|
|
|
// conflict with currently ongoing change. This is a temporary
|
2020-07-26 16:49:51 +02:00
|
|
|
// error. The error `value` is an object with optional fields
|
|
|
|
|
// `snap-name`, `change-kind` of the ongoing change.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindSnapChangeConflict ErrorKind = "snap-change-conflict"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2021-07-05 13:30:29 -05:00
|
|
|
// ErrorKindQuotaChangeConflict: the requested operation would
|
|
|
|
|
// conflict with a currently ongoing change affecting the quota
|
|
|
|
|
// group. This is a temporary error. The error `value` is an
|
|
|
|
|
// object with optional fields `quota-name`, `change-kind` of the
|
|
|
|
|
// ongoing change.
|
|
|
|
|
ErrorKindQuotaChangeConflict ErrorKind = "quota-change-conflict"
|
|
|
|
|
|
2020-07-26 16:49:51 +02:00
|
|
|
// ErrorKindNotSnap: the given snap or directory does not
|
2020-08-05 14:50:18 +02:00
|
|
|
// look like a snap.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindNotSnap ErrorKind = "snap-not-a-snap"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-07-26 16:49:51 +02:00
|
|
|
// ErrorKindInterfacesUnchanged: the requested interfaces'
|
2020-08-05 14:50:18 +02:00
|
|
|
// operation would have no effect.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindInterfacesUnchanged ErrorKind = "interfaces-unchanged"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindBadQuery: a bad query was provided.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindBadQuery ErrorKind = "bad-query"
|
2020-07-01 15:59:18 +02:00
|
|
|
// ErrorKindConfigNoSuchOption: the given configuration option
|
2020-08-05 14:50:18 +02:00
|
|
|
// does not exist.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindConfigNoSuchOption ErrorKind = "option-not-found"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindAssertionNotFound: assertion can not be found.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindAssertionNotFound ErrorKind = "assertion-not-found"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindUnsuccessful: snapctl command was unsuccessful.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindUnsuccessful ErrorKind = "unsuccessful"
|
2020-06-30 12:25:05 +02:00
|
|
|
|
2020-08-05 17:48:21 +02:00
|
|
|
// ErrorKindNetworkTimeout: a timeout occurred during the request.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindNetworkTimeout ErrorKind = "network-timeout"
|
|
|
|
|
|
2020-08-05 17:48:21 +02:00
|
|
|
// ErrorKindDNSFailure: DNS not responding.
|
2020-08-02 16:06:39 +02:00
|
|
|
ErrorKindDNSFailure ErrorKind = "dns-failure"
|
2020-09-02 11:57:45 +02:00
|
|
|
|
2020-09-07 16:44:40 +02:00
|
|
|
// ErrorKindInsufficientDiskSpace: not enough disk space to perform the request.
|
|
|
|
|
ErrorKindInsufficientDiskSpace ErrorKind = "insufficient-disk-space"
|
2020-09-24 09:08:07 +02:00
|
|
|
|
|
|
|
|
// ErrorKindValidationSetNotFound: validation set cannot be found.
|
|
|
|
|
ErrorKindValidationSetNotFound ErrorKind = "validation-set-not-found"
|
2020-07-26 16:49:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Maintenance error kinds.
|
|
|
|
|
// These are used only inside the maintenance field of responses.
|
2020-08-05 14:50:18 +02:00
|
|
|
// Keep https://forum.snapcraft.io/t/using-the-rest-api/18603#heading--maint-errors in sync using doc/error-kinds.go.
|
2020-07-26 16:49:51 +02:00
|
|
|
const (
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindDaemonRestart: daemon is restarting.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindDaemonRestart ErrorKind = "daemon-restart"
|
2020-08-05 14:50:18 +02:00
|
|
|
// ErrorKindSystemRestart: system is restarting.
|
2020-08-02 15:45:55 +02:00
|
|
|
ErrorKindSystemRestart ErrorKind = "system-restart"
|
2020-06-30 12:25:05 +02:00
|
|
|
)
|