Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/google/cloud/secretmanager_v1beta1/types/resources.py: 97%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

32 statements  

1# -*- coding: utf-8 -*- 

2# Copyright 2025 Google LLC 

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# 

16from __future__ import annotations 

17 

18from typing import MutableMapping, MutableSequence 

19 

20import google.protobuf.timestamp_pb2 as timestamp_pb2 # type: ignore 

21import proto # type: ignore 

22 

23__protobuf__ = proto.module( 

24 package="google.cloud.secrets.v1beta1", 

25 manifest={ 

26 "Secret", 

27 "SecretVersion", 

28 "Replication", 

29 "SecretPayload", 

30 }, 

31) 

32 

33 

34class Secret(proto.Message): 

35 r"""A [Secret][google.cloud.secrets.v1beta1.Secret] is a logical secret 

36 whose value and versions can be accessed. 

37 

38 A [Secret][google.cloud.secrets.v1beta1.Secret] is made up of zero 

39 or more [SecretVersions][google.cloud.secrets.v1beta1.SecretVersion] 

40 that represent the secret data. 

41 

42 Attributes: 

43 name (str): 

44 Output only. The resource name of the 

45 [Secret][google.cloud.secrets.v1beta1.Secret] in the format 

46 ``projects/*/secrets/*``. 

47 replication (google.cloud.secretmanager_v1beta1.types.Replication): 

48 Required. Immutable. The replication policy of the secret 

49 data attached to the 

50 [Secret][google.cloud.secrets.v1beta1.Secret]. 

51 

52 The replication policy cannot be changed after the Secret 

53 has been created. 

54 create_time (google.protobuf.timestamp_pb2.Timestamp): 

55 Output only. The time at which the 

56 [Secret][google.cloud.secrets.v1beta1.Secret] was created. 

57 labels (MutableMapping[str, str]): 

58 The labels assigned to this Secret. 

59 

60 Label keys must be between 1 and 63 characters long, have a 

61 UTF-8 encoding of maximum 128 bytes, and must conform to the 

62 following PCRE regular expression: 

63 ``[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}`` 

64 

65 Label values must be between 0 and 63 characters long, have 

66 a UTF-8 encoding of maximum 128 bytes, and must conform to 

67 the following PCRE regular expression: 

68 ``[\p{Ll}\p{Lo}\p{N}_-]{0,63}`` 

69 

70 No more than 64 labels can be assigned to a given resource. 

71 """ 

72 

73 name: str = proto.Field( 

74 proto.STRING, 

75 number=1, 

76 ) 

77 replication: "Replication" = proto.Field( 

78 proto.MESSAGE, 

79 number=2, 

80 message="Replication", 

81 ) 

82 create_time: timestamp_pb2.Timestamp = proto.Field( 

83 proto.MESSAGE, 

84 number=3, 

85 message=timestamp_pb2.Timestamp, 

86 ) 

87 labels: MutableMapping[str, str] = proto.MapField( 

88 proto.STRING, 

89 proto.STRING, 

90 number=4, 

91 ) 

92 

93 

94class SecretVersion(proto.Message): 

95 r"""A secret version resource in the Secret Manager API. 

96 

97 Attributes: 

98 name (str): 

99 Output only. The resource name of the 

100 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] 

101 in the format ``projects/*/secrets/*/versions/*``. 

102 

103 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] 

104 IDs in a [Secret][google.cloud.secrets.v1beta1.Secret] start 

105 at 1 and are incremented for each subsequent version of the 

106 secret. 

107 create_time (google.protobuf.timestamp_pb2.Timestamp): 

108 Output only. The time at which the 

109 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] 

110 was created. 

111 destroy_time (google.protobuf.timestamp_pb2.Timestamp): 

112 Output only. The time this 

113 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] 

114 was destroyed. Only present if 

115 [state][google.cloud.secrets.v1beta1.SecretVersion.state] is 

116 [DESTROYED][google.cloud.secrets.v1beta1.SecretVersion.State.DESTROYED]. 

117 state (google.cloud.secretmanager_v1beta1.types.SecretVersion.State): 

118 Output only. The current state of the 

119 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. 

120 """ 

121 

122 class State(proto.Enum): 

123 r"""The state of a 

124 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion], 

125 indicating if it can be accessed. 

126 

127 Values: 

128 STATE_UNSPECIFIED (0): 

129 Not specified. This value is unused and 

130 invalid. 

131 ENABLED (1): 

132 The 

133 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] 

134 may be accessed. 

135 DISABLED (2): 

136 The 

137 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] 

138 may not be accessed, but the secret data is still available 

139 and can be placed back into the 

140 [ENABLED][google.cloud.secrets.v1beta1.SecretVersion.State.ENABLED] 

141 state. 

142 DESTROYED (3): 

143 The 

144 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion] 

145 is destroyed and the secret data is no longer stored. A 

146 version may not leave this state once entered. 

147 """ 

148 

149 STATE_UNSPECIFIED = 0 

150 ENABLED = 1 

151 DISABLED = 2 

152 DESTROYED = 3 

153 

154 name: str = proto.Field( 

155 proto.STRING, 

156 number=1, 

157 ) 

158 create_time: timestamp_pb2.Timestamp = proto.Field( 

159 proto.MESSAGE, 

160 number=2, 

161 message=timestamp_pb2.Timestamp, 

162 ) 

163 destroy_time: timestamp_pb2.Timestamp = proto.Field( 

164 proto.MESSAGE, 

165 number=3, 

166 message=timestamp_pb2.Timestamp, 

167 ) 

168 state: State = proto.Field( 

169 proto.ENUM, 

170 number=4, 

171 enum=State, 

172 ) 

173 

174 

175class Replication(proto.Message): 

176 r"""A policy that defines the replication configuration of data. 

177 

178 This message has `oneof`_ fields (mutually exclusive fields). 

179 For each oneof, at most one member field can be set at the same time. 

180 Setting any member of the oneof automatically clears all other 

181 members. 

182 

183 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields 

184 

185 Attributes: 

186 automatic (google.cloud.secretmanager_v1beta1.types.Replication.Automatic): 

187 The [Secret][google.cloud.secrets.v1beta1.Secret] will 

188 automatically be replicated without any restrictions. 

189 

190 This field is a member of `oneof`_ ``replication``. 

191 user_managed (google.cloud.secretmanager_v1beta1.types.Replication.UserManaged): 

192 The [Secret][google.cloud.secrets.v1beta1.Secret] will only 

193 be replicated into the locations specified. 

194 

195 This field is a member of `oneof`_ ``replication``. 

196 """ 

197 

198 class Automatic(proto.Message): 

199 r"""A replication policy that replicates the 

200 [Secret][google.cloud.secrets.v1beta1.Secret] payload without any 

201 restrictions. 

202 

203 """ 

204 

205 class UserManaged(proto.Message): 

206 r"""A replication policy that replicates the 

207 [Secret][google.cloud.secrets.v1beta1.Secret] payload into the 

208 locations specified in 

209 [Replication.UserManaged.replicas][google.cloud.secrets.v1beta1.Replication.UserManaged.replicas] 

210 

211 Attributes: 

212 replicas (MutableSequence[google.cloud.secretmanager_v1beta1.types.Replication.UserManaged.Replica]): 

213 Required. The list of Replicas for this 

214 [Secret][google.cloud.secrets.v1beta1.Secret]. 

215 

216 Cannot be empty. 

217 """ 

218 

219 class Replica(proto.Message): 

220 r"""Represents a Replica for this 

221 [Secret][google.cloud.secrets.v1beta1.Secret]. 

222 

223 Attributes: 

224 location (str): 

225 The canonical IDs of the location to replicate data. For 

226 example: ``"us-east1"``. 

227 """ 

228 

229 location: str = proto.Field( 

230 proto.STRING, 

231 number=1, 

232 ) 

233 

234 replicas: MutableSequence["Replication.UserManaged.Replica"] = ( 

235 proto.RepeatedField( 

236 proto.MESSAGE, 

237 number=1, 

238 message="Replication.UserManaged.Replica", 

239 ) 

240 ) 

241 

242 automatic: Automatic = proto.Field( 

243 proto.MESSAGE, 

244 number=1, 

245 oneof="replication", 

246 message=Automatic, 

247 ) 

248 user_managed: UserManaged = proto.Field( 

249 proto.MESSAGE, 

250 number=2, 

251 oneof="replication", 

252 message=UserManaged, 

253 ) 

254 

255 

256class SecretPayload(proto.Message): 

257 r"""A secret payload resource in the Secret Manager API. This contains 

258 the sensitive secret data that is associated with a 

259 [SecretVersion][google.cloud.secrets.v1beta1.SecretVersion]. 

260 

261 Attributes: 

262 data (bytes): 

263 The secret data. Must be no larger than 

264 64KiB. 

265 """ 

266 

267 data: bytes = proto.Field( 

268 proto.BYTES, 

269 number=1, 

270 ) 

271 

272 

273__all__ = tuple(sorted(__protobuf__.manifest))