1# -*- coding: utf-8 -*- #
2# Copyright 2018 Google LLC. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#    http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15"""Wrapper for user-visible error exceptions to raise in the CLI."""
16
17from __future__ import absolute_import
18from __future__ import division
19from __future__ import unicode_literals
20
21from googlecloudsdk.api_lib.util import exceptions as api_lib_exceptions
22from googlecloudsdk.core import exceptions as core_exceptions
23
24
25class Error(core_exceptions.Error):
26  """Exceptions for Services errors."""
27
28
29class EnableServicePermissionDeniedException(Error):
30  """Permission denied exception for enable service command."""
31  pass
32
33
34class ListServicesPermissionDeniedException(Error):
35  """Permission denied exception for list services command."""
36  pass
37
38
39class GetServicePermissionDeniedException(Error):
40  """Permission denied exception for get service command."""
41  pass
42
43
44class CreateQuotaOverridePermissionDeniedException(Error):
45  """Permission denied exception for create quota override command."""
46  pass
47
48
49class UpdateQuotaOverridePermissionDeniedException(Error):
50  """Permission denied exception for update quota override command."""
51  pass
52
53
54class DeleteQuotaOverridePermissionDeniedException(Error):
55  """Permission denied exception for delete quota override command."""
56  pass
57
58
59class CreateConnectionsPermissionDeniedException(Error):
60  """Permission denied exception for create connection command."""
61  pass
62
63
64class ListConnectionsPermissionDeniedException(Error):
65  """Permission denied exception for list connections command."""
66  pass
67
68
69class EnableVpcServiceControlsPermissionDeniedException(Error):
70  """Permission denied exception for enable vpc service controls command."""
71  pass
72
73
74class DisableVpcServiceControlsPermissionDeniedException(Error):
75  """Permission denied exception for disable vpc service controls command."""
76  pass
77
78
79class CreatePeeredDnsDomainPermissionDeniedException(Error):
80  """Permission denied exception for create peered dns domain command."""
81  pass
82
83
84class DeletePeeredDnsDomainPermissionDeniedException(Error):
85  """Permission denied exception for delete peered dns domain command."""
86  pass
87
88
89class ListPeeredDnsDomainsPermissionDeniedException(Error):
90  """Permission denied exception for list peered dns domains command."""
91  pass
92
93
94class GenerateServiceIdentityPermissionDeniedException(Error):
95  """Permission denied exception for generate service identitiy command."""
96  pass
97
98
99class OperationErrorException(Error):
100  """Exception for operation error."""
101  pass
102
103
104class TimeoutError(Error):
105  """Exception for timeout error."""
106  pass
107
108
109def ReraiseError(err, klass):
110  """Transform and re-raise error helper."""
111  core_exceptions.reraise(klass(api_lib_exceptions.HttpException(err)))
112