diff --git a/.gitignore b/.gitignore index c2057cf..e67d803 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .local/ .public-dns/ DerivedData/ +xcuserdata/ *.xcuserstate .DS_Store .tmp diff --git a/README.md b/README.md index 4705b04..9ea91c3 100644 --- a/README.md +++ b/README.md @@ -132,9 +132,9 @@ try await qiongcheSDK.saveConfigAndInit(configString: configStringFromTrustedCha let ready = await qiongcheSDK.isReadyToUpload() ``` -`saveConfigAndInit(configString:)` 接收穹彻可信渠道下发的完整配置字符串,完成设备初始化并写入本地文件。`isReadyToUpload()` 用于上传前判断本地配置和服务连通性是否满足创建上传客户端的条件。 +`saveConfigAndInit(configString:)` 接收穹彻可信渠道下发的完整配置字符串,完成设备初始化并写入本地文件。设备尚未 initialized 时会调用远端 `InitDevice`;设备已 initialized 时会在收到 `DATA_GATEWAY_DEVICE_ALREADY_INITIALIZED` 后静默改调远端 `ReinitDevice`,拿到新凭证后再覆盖本地配置。`isReadyToUpload()` 用于上传前判断本地配置和服务连通性是否满足创建上传客户端的条件。 -穹彻封装不提供 `reinit`、`reset` 或 `replaceConfig` 入口。需要更新配置时,继续调用 `saveConfigAndInit(configString:)`;该方法会在远端初始化成功后覆盖本地 endpoint、设备配置和穹彻 state。 +穹彻封装不提供 `reinit`、`reset` 或 `replaceConfig` 入口。需要更新配置时,继续调用 `saveConfigAndInit(configString:)`;该方法会在远端 init 或 reinit 成功后覆盖本地 endpoint、设备配置和穹彻 state。 完成 ready 检查后,上传仍使用通用上传客户端: @@ -174,10 +174,10 @@ let client = try await DataGatewayClient.fromArchebaseConfig( `saveConfigAndInit(configString:)` 的覆盖规则: -1. 先解析配置并使用本次 `deviceInit` endpoint 调远端初始化。 -2. 远端初始化成功后,覆盖写入 `archebase-endpoints.json`、`archebase-config.json` 和 `qiongche-sdk-state.json`。 +1. 先解析配置并使用本次 `deviceInit` endpoint 调远端 init;如果服务端提示已 initialized,则内部改调远端 reinit。 +2. 远端 init 或 reinit 成功后,覆盖写入 `archebase-endpoints.json`、`archebase-config.json` 和 `qiongche-sdk-state.json`。 3. 本地已有 endpoint、设备配置或 state 时,不因为内容不同报错。 -4. 远端初始化失败时,不覆盖本地已有 endpoint、设备配置或 state。 +4. 远端 init 和必要的 reinit 失败时,不覆盖本地已有 endpoint、设备配置或 state。 5. endpoint 文件只保存 `auth`、`gateway`、`deviceInit`,不会保存 `device_id`。 `isReadyToUpload()` 的判断范围: @@ -229,7 +229,7 @@ Examples/qiongche-sdk-demo/ open Examples/qiongche-sdk-demo/qiongche-sdk-demo.xcodeproj ``` -示例 App 面向穹彻 SDK 接入者,首屏提供配置输入、保存并初始化、本地状态、ready 检查、生成样例文件和上传样例文件。示例 App 不提供 reinit 按钮;再次提交配置会继续调用 `saveConfigAndInit(configString:)` 覆盖本地 endpoint、设备配置和穹彻 state。 +示例 App 面向穹彻 SDK 接入者,首屏提供配置输入、保存并初始化、本地状态、ready 检查、生成样例文件和上传样例文件。示例 App 不提供 reinit 按钮;再次提交配置会继续调用 `saveConfigAndInit(configString:)`,由 SDK 内部按服务端状态执行 init 或 reinit 并覆盖本地 endpoint、设备配置和穹彻 state。 ## 6. 文件目录建议 @@ -272,9 +272,10 @@ print(deviceConfig.tags) `initDevice(deviceID:)` 的行为: 1. 从 `archebase-endpoints.json` 读取 `deviceInit` endpoint。 -2. 本地没有 `archebase-config.json` 时,向公共初始化端点请求设备配置并写入本地文件。 +2. 本地没有 `archebase-config.json` 时,调用远端 `DeviceInitService.InitDevice` 请求设备配置并写入本地文件。 3. 本地已经存在配置文件时,抛出 `DataGatewayClientError.alreadyInitialized(configURL:)`。 -4. 写入成功后返回 `ArchebaseConfig`,其中包含 `API Key` 和设备 tags。 +4. 如果服务端返回 `DATA_GATEWAY_DEVICE_ALREADY_INITIALIZED`,错误会以 `DataGatewayClientError.gatewayFailed` 向上暴露,不会自动 fallback 到 reinit。 +5. 写入成功后返回 `ArchebaseConfig`,其中包含 `API Key` 和设备 tags。 如果 `archebase-endpoints.json` 不存在,构造 `ArchebaseDeviceInitializer(config:)` 时会抛出 `DataGatewayClientError.endpointsNotInitialized(endpointsURL:)`。App 应先获取 endpoint JSON,调用 `DataGatewayClient.initialize(endpointsJSON:endpointsURL:)`,成功后重试设备初始化。 @@ -289,8 +290,9 @@ let newDeviceConfig = try await initializer.reinitDevice(deviceID: "260427-00000 `reinitDevice(deviceID:)` 的行为: 1. 本地没有配置文件时,抛出 `DataGatewayClientError.notInitialized(configURL:)`。 -2. 本地已经存在配置文件时,重新获取设备配置并原子替换本地文件。 -3. 重新初始化会轮换上传凭证,旧配置中的凭证会失效。 +2. 本地已经存在配置文件时,调用远端 `DeviceInitService.ReinitDevice` 重新获取设备配置并原子替换本地文件。 +3. 如果服务端返回 `DATA_GATEWAY_DEVICE_NOT_INITIALIZED`,错误会以 `DataGatewayClientError.gatewayFailed` 向上暴露,不会自动 fallback 到 init。 +4. 重新初始化会轮换上传凭证,旧配置中的凭证会失效。 已经开始且仍在本地快照中的上传,会继续使用创建上传时保存的 tags 和恢复状态。重新初始化只影响后续新建的上传客户端和新上传。 diff --git a/Scripts/simulator_smoke.sh b/Scripts/simulator_smoke.sh index 4f8f6b3..57ae7a9 100644 --- a/Scripts/simulator_smoke.sh +++ b/Scripts/simulator_smoke.sh @@ -10,11 +10,8 @@ DESTINATION_TIMEOUT_SECONDS="${DGW_IOS_SMOKE_DESTINATION_TIMEOUT_SECONDS:-30}" CHECK_COMMAND_TIMEOUT_SECONDS="${DGW_IOS_SMOKE_CHECK_COMMAND_TIMEOUT_SECONDS:-60}" DEFAULT_TEST_TIMEOUT_SECONDS="${DGW_IOS_SMOKE_DEFAULT_TEST_TIMEOUT_SECONDS:-120}" MAX_TEST_TIMEOUT_SECONDS="${DGW_IOS_SMOKE_MAX_TEST_TIMEOUT_SECONDS:-300}" +DEPLOYMENT_TARGET="${DGW_IOS_SMOKE_DEPLOYMENT_TARGET:-18.0}" OTHER_SWIFT_FLAGS_VALUE="${DGW_IOS_SMOKE_OTHER_SWIFT_FLAGS:-}" -XCODEBUILD_BUILD_SETTINGS=() -if [[ -n "$OTHER_SWIFT_FLAGS_VALUE" ]]; then - XCODEBUILD_BUILD_SETTINGS+=(OTHER_SWIFT_FLAGS="$OTHER_SWIFT_FLAGS_VALUE") -fi read_public_endpoint_field() { python3 - "$PUBLIC_ENDPOINTS_RESOURCE" "$1" "$2" <<'PY' @@ -65,6 +62,7 @@ Environment overrides: DGW_IOS_SMOKE_CHECK_COMMAND_TIMEOUT_SECONDS DGW_IOS_SMOKE_DEFAULT_TEST_TIMEOUT_SECONDS DGW_IOS_SMOKE_MAX_TEST_TIMEOUT_SECONDS + DGW_IOS_SMOKE_DEPLOYMENT_TARGET (defaults to 18.0) DGW_IOS_SMOKE_TEST_ONE DGW_IOS_SMOKE_TEST_TWO DGW_IOS_SMOKE_TEST_THREE @@ -218,13 +216,21 @@ PY } build_for_testing() { + local build_settings=( + "IPHONEOS_DEPLOYMENT_TARGET=${DEPLOYMENT_TARGET}" + ) + if [[ -n "$OTHER_SWIFT_FLAGS_VALUE" ]]; then + build_settings+=("OTHER_SWIFT_FLAGS=${OTHER_SWIFT_FLAGS_VALUE}") + fi + xcodebuild build-for-testing \ + -skipMacroValidation \ -skipPackageUpdates \ -scheme "$SCHEME" \ -destination "$DESTINATION" \ -destination-timeout "$DESTINATION_TIMEOUT_SECONDS" \ -derivedDataPath "$DERIVED_DATA_PATH" \ - "${XCODEBUILD_BUILD_SETTINGS[@]}" + "${build_settings[@]}" } resolve_xctestrun_path() { @@ -278,6 +284,7 @@ for extra_key in ( "DGW_OSS_TEST_OBJECT_PREFIX", "DATA_GATEWAY_CLIENT_USE_MOCK_OSS", f"{prefix}_TLS_MODE", + f"{prefix}_DEVICE_INIT_INTEGRATION", ): extra_value = os.environ.get(extra_key) if extra_value: @@ -390,7 +397,7 @@ case "$MODE" in AUTH_ENDPOINT_KEY="${RUNTIME_ENV_PREFIX}_AUTH_ENDPOINT" GATEWAY_ENDPOINT_KEY="${RUNTIME_ENV_PREFIX}_GATEWAY_ENDPOINT" INIT_ENDPOINT_KEY="${RUNTIME_ENV_PREFIX}_INIT_ENDPOINT" - for key in "$AUTH_ENDPOINT_KEY" "$GATEWAY_ENDPOINT_KEY"; do + for key in "$AUTH_ENDPOINT_KEY" "$GATEWAY_ENDPOINT_KEY" "$INIT_ENDPOINT_KEY"; do if [[ -z "${!key:-}" ]]; then echo "${key} is required for simulator smoke execution" >&2 exit 1 diff --git a/Sources/DGWControlPlane/ControlPlaneTransport.swift b/Sources/DGWControlPlane/ControlPlaneTransport.swift index b88dc29..adea05e 100644 --- a/Sources/DGWControlPlane/ControlPlaneTransport.swift +++ b/Sources/DGWControlPlane/ControlPlaneTransport.swift @@ -221,6 +221,12 @@ package protocol DeviceInitTransport: Sendable { sdkVersion: String, platform: String ) async throws -> Archebase_DataGateway_V1_InitDeviceResponse + + func reinitDevice( + deviceID: String, + sdkVersion: String, + platform: String + ) async throws -> Archebase_DataGateway_V1_InitDeviceResponse } package final class DeviceInitServiceClientTransport: DeviceInitTransport, @unchecked Sendable { @@ -252,6 +258,27 @@ package final class DeviceInitServiceClientTransport Archebase_DataGateway_V1_InitDeviceResponse { + var request = Archebase_DataGateway_V1_ReinitDeviceRequest() + request.deviceID = deviceID + request.sdkVersion = sdkVersion + request.platform = platform + + let options = self.optionsBuilder.make(authorizationHeader: nil) + let response: ClientResponse = try await self.client.reinitDevice( + request, + metadata: options.metadata, + options: options.callOptions, + onResponse: { response in response } + ) + + return try response.message + } } package protocol GatewayControlPlaneClientProtocol: Sendable { @@ -423,6 +450,11 @@ public enum DataGatewayClientError: Error, Sendable, Equatable { case cancelled } +package enum DeviceInitGatewayDetailCode { + package static let alreadyInitialized = "DATA_GATEWAY_DEVICE_ALREADY_INITIALIZED" + package static let notInitialized = "DATA_GATEWAY_DEVICE_NOT_INITIALIZED" +} + package enum ControlPlaneErrorMapper { package static func map(_ error: any Error) -> DataGatewayClientError { if let clientError = error as? DataGatewayClientError { diff --git a/Sources/DGWProto/Generated/auth.pb.swift b/Sources/DGWProto/Generated/auth.pb.swift index 5bd19d9..7ebf25e 100644 --- a/Sources/DGWProto/Generated/auth.pb.swift +++ b/Sources/DGWProto/Generated/auth.pb.swift @@ -58,6 +58,62 @@ public enum Archebase_Auth_V1_UserRole: SwiftProtobuf.Enum, Swift.CaseIterable { } +/// Business identity, orthogonal to UserRole (privilege). See +/// docs/design/abac-design.md §3. Service accounts always carry +/// USER_CLASS_UNSPECIFIED; every HUMAN user must have one of the +/// concrete classes per ck_users_admin_class_consistency / +/// ck_users_normal_class_consistency / ck_users_service_account_class +/// in migration 0018. +public enum Archebase_Auth_V1_UserClass: SwiftProtobuf.Enum, Swift.CaseIterable { + public typealias RawValue = Int + case unspecified // = 0 + case systemAdmin // = 1 + case orgAdmin // = 2 + case annotator // = 3 + case reviewer // = 4 + case viewer // = 5 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .systemAdmin + case 2: self = .orgAdmin + case 3: self = .annotator + case 4: self = .reviewer + case 5: self = .viewer + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .systemAdmin: return 1 + case .orgAdmin: return 2 + case .annotator: return 3 + case .reviewer: return 4 + case .viewer: return 5 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Archebase_Auth_V1_UserClass] = [ + .unspecified, + .systemAdmin, + .orgAdmin, + .annotator, + .reviewer, + .viewer, + ] + +} + public enum Archebase_Auth_V1_AuthErrorCode: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int case unspecified // = 0 @@ -156,35 +212,50 @@ public struct Archebase_Auth_V1_LoginRequest: Sendable { public init() {} } -public struct Archebase_Auth_V1_LoginResponse: Sendable { +public struct Archebase_Auth_V1_LoginResponse: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - public var accessToken: String = String() + public var accessToken: String { + get {_storage._accessToken} + set {_uniqueStorage()._accessToken = newValue} + } - public var accessTokenExpiresAtUnix: Int64 = 0 + public var accessTokenExpiresAtUnix: Int64 { + get {_storage._accessTokenExpiresAtUnix} + set {_uniqueStorage()._accessTokenExpiresAtUnix = newValue} + } - public var refreshToken: String = String() + public var refreshToken: String { + get {_storage._refreshToken} + set {_uniqueStorage()._refreshToken = newValue} + } - public var refreshTokenExpiresAtUnix: Int64 = 0 + public var refreshTokenExpiresAtUnix: Int64 { + get {_storage._refreshTokenExpiresAtUnix} + set {_uniqueStorage()._refreshTokenExpiresAtUnix = newValue} + } - public var tokenType: String = String() + public var tokenType: String { + get {_storage._tokenType} + set {_uniqueStorage()._tokenType = newValue} + } public var user: Archebase_Auth_V1_User { - get {_user ?? Archebase_Auth_V1_User()} - set {_user = newValue} + get {_storage._user ?? Archebase_Auth_V1_User()} + set {_uniqueStorage()._user = newValue} } /// Returns true if `user` has been explicitly set. - public var hasUser: Bool {self._user != nil} + public var hasUser: Bool {_storage._user != nil} /// Clears the value of `user`. Subsequent reads from it will return its default value. - public mutating func clearUser() {self._user = nil} + public mutating func clearUser() {_uniqueStorage()._user = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} - fileprivate var _user: Archebase_Auth_V1_User? = nil + fileprivate var _storage = _StorageClass.defaultInstance } public struct Archebase_Auth_V1_RefreshTokenRequest: Sendable { @@ -199,35 +270,50 @@ public struct Archebase_Auth_V1_RefreshTokenRequest: Sendable { public init() {} } -public struct Archebase_Auth_V1_RefreshTokenResponse: Sendable { +public struct Archebase_Auth_V1_RefreshTokenResponse: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - public var accessToken: String = String() + public var accessToken: String { + get {_storage._accessToken} + set {_uniqueStorage()._accessToken = newValue} + } - public var accessTokenExpiresAtUnix: Int64 = 0 + public var accessTokenExpiresAtUnix: Int64 { + get {_storage._accessTokenExpiresAtUnix} + set {_uniqueStorage()._accessTokenExpiresAtUnix = newValue} + } - public var refreshToken: String = String() + public var refreshToken: String { + get {_storage._refreshToken} + set {_uniqueStorage()._refreshToken = newValue} + } - public var refreshTokenExpiresAtUnix: Int64 = 0 + public var refreshTokenExpiresAtUnix: Int64 { + get {_storage._refreshTokenExpiresAtUnix} + set {_uniqueStorage()._refreshTokenExpiresAtUnix = newValue} + } - public var tokenType: String = String() + public var tokenType: String { + get {_storage._tokenType} + set {_uniqueStorage()._tokenType = newValue} + } public var user: Archebase_Auth_V1_User { - get {_user ?? Archebase_Auth_V1_User()} - set {_user = newValue} + get {_storage._user ?? Archebase_Auth_V1_User()} + set {_uniqueStorage()._user = newValue} } /// Returns true if `user` has been explicitly set. - public var hasUser: Bool {self._user != nil} + public var hasUser: Bool {_storage._user != nil} /// Clears the value of `user`. Subsequent reads from it will return its default value. - public mutating func clearUser() {self._user = nil} + public mutating func clearUser() {_uniqueStorage()._user = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} - fileprivate var _user: Archebase_Auth_V1_User? = nil + fileprivate var _storage = _StorageClass.defaultInstance } public struct Archebase_Auth_V1_ExchangeSystemCredentialRequest: Sendable { @@ -300,6 +386,12 @@ public struct Archebase_Auth_V1_User: Sendable { /// Clears the value of `updatedAt`. Subsequent reads from it will return its default value. public mutating func clearUpdatedAt() {self._updatedAt = nil} + public var userClass: Archebase_Auth_V1_UserClass = .unspecified + + public var organizationID: Int64 = 0 + + public var userID: Int64 = 0 + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -944,35 +1036,34 @@ public struct Archebase_Auth_V1_CreateOrganizationRequest: Sendable { public init() {} } -public struct Archebase_Auth_V1_CreateOrganizationResponse: Sendable { +public struct Archebase_Auth_V1_CreateOrganizationResponse: @unchecked Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. public var organization: Archebase_Auth_V1_Organization { - get {_organization ?? Archebase_Auth_V1_Organization()} - set {_organization = newValue} + get {_storage._organization ?? Archebase_Auth_V1_Organization()} + set {_uniqueStorage()._organization = newValue} } /// Returns true if `organization` has been explicitly set. - public var hasOrganization: Bool {self._organization != nil} + public var hasOrganization: Bool {_storage._organization != nil} /// Clears the value of `organization`. Subsequent reads from it will return its default value. - public mutating func clearOrganization() {self._organization = nil} + public mutating func clearOrganization() {_uniqueStorage()._organization = nil} public var bootstrapAdmin: Archebase_Auth_V1_User { - get {_bootstrapAdmin ?? Archebase_Auth_V1_User()} - set {_bootstrapAdmin = newValue} + get {_storage._bootstrapAdmin ?? Archebase_Auth_V1_User()} + set {_uniqueStorage()._bootstrapAdmin = newValue} } /// Returns true if `bootstrapAdmin` has been explicitly set. - public var hasBootstrapAdmin: Bool {self._bootstrapAdmin != nil} + public var hasBootstrapAdmin: Bool {_storage._bootstrapAdmin != nil} /// Clears the value of `bootstrapAdmin`. Subsequent reads from it will return its default value. - public mutating func clearBootstrapAdmin() {self._bootstrapAdmin = nil} + public mutating func clearBootstrapAdmin() {_uniqueStorage()._bootstrapAdmin = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} - fileprivate var _organization: Archebase_Auth_V1_Organization? = nil - fileprivate var _bootstrapAdmin: Archebase_Auth_V1_User? = nil + fileprivate var _storage = _StorageClass.defaultInstance } public struct Archebase_Auth_V1_GetOrganizationRequest: Sendable { @@ -1107,6 +1198,12 @@ public struct Archebase_Auth_V1_CreateUserRequest: Sendable { public var role: Archebase_Auth_V1_UserRole = .unspecified + /// Required for HUMAN users; service accounts carry + /// USER_CLASS_UNSPECIFIED implicitly. Server validates the + /// (role, account_kind, user_class) tuple per + /// docs/design/abac-design.md §3.3. + public var userClass: Archebase_Auth_V1_UserClass = .unspecified + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} @@ -1213,12 +1310,26 @@ public struct Archebase_Auth_V1_UpdateUserRequest: Sendable { /// Clears the value of `role`. Subsequent reads from it will return its default value. public mutating func clearRole() {self._role = nil} + /// Optional: change the business identity. Server rejects the + /// update if the resulting (role, account_kind, user_class) tuple + /// violates the consistency constraints in + /// docs/design/abac-design.md §3.3. + public var userClass: Archebase_Auth_V1_UserClass { + get {_userClass ?? .unspecified} + set {_userClass = newValue} + } + /// Returns true if `userClass` has been explicitly set. + public var hasUserClass: Bool {self._userClass != nil} + /// Clears the value of `userClass`. Subsequent reads from it will return its default value. + public mutating func clearUserClass() {self._userClass = nil} + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} fileprivate var _password: String? = nil fileprivate var _role: Archebase_Auth_V1_UserRole? = nil + fileprivate var _userClass: Archebase_Auth_V1_UserClass? = nil } public struct Archebase_Auth_V1_UpdateUserResponse: Sendable { @@ -1272,6 +1383,10 @@ extension Archebase_Auth_V1_UserRole: SwiftProtobuf._ProtoNameProviding { public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0USER_ROLE_UNSPECIFIED\0\u{1}USER_ROLE_ADMINISTRATORS\0\u{1}USER_ROLE_NORMAL_USERS\0") } +extension Archebase_Auth_V1_UserClass: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0USER_CLASS_UNSPECIFIED\0\u{1}USER_CLASS_SYSTEM_ADMIN\0\u{1}USER_CLASS_ORG_ADMIN\0\u{1}USER_CLASS_ANNOTATOR\0\u{1}USER_CLASS_REVIEWER\0\u{1}USER_CLASS_VIEWER\0") +} + extension Archebase_Auth_V1_AuthErrorCode: SwiftProtobuf._ProtoNameProviding { public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0AUTH_ERROR_CODE_UNSPECIFIED\0\u{1}AUTH_ERROR_CODE_INVALID_CREDENTIAL\0\u{1}AUTH_ERROR_CODE_KEY_DISABLED\0\u{1}AUTH_ERROR_CODE_KEY_EXPIRED\0\u{1}AUTH_ERROR_CODE_SITE_DISABLED\0\u{1}AUTH_ERROR_CODE_INTERNAL_ERROR\0") } @@ -1400,56 +1515,102 @@ extension Archebase_Auth_V1_LoginResponse: SwiftProtobuf.Message, SwiftProtobuf. public static let protoMessageName: String = _protobuf_package + ".LoginResponse" public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}access_token\0\u{3}access_token_expires_at_unix\0\u{3}refresh_token\0\u{3}refresh_token_expires_at_unix\0\u{3}token_type\0\u{1}user\0") + fileprivate class _StorageClass { + var _accessToken: String = String() + var _accessTokenExpiresAtUnix: Int64 = 0 + var _refreshToken: String = String() + var _refreshTokenExpiresAtUnix: Int64 = 0 + var _tokenType: String = String() + var _user: Archebase_Auth_V1_User? = nil + + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _accessToken = source._accessToken + _accessTokenExpiresAtUnix = source._accessTokenExpiresAtUnix + _refreshToken = source._refreshToken + _refreshTokenExpiresAtUnix = source._refreshTokenExpiresAtUnix + _tokenType = source._tokenType + _user = source._user + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.accessToken) }() - case 2: try { try decoder.decodeSingularInt64Field(value: &self.accessTokenExpiresAtUnix) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.refreshToken) }() - case 4: try { try decoder.decodeSingularInt64Field(value: &self.refreshTokenExpiresAtUnix) }() - case 5: try { try decoder.decodeSingularStringField(value: &self.tokenType) }() - case 6: try { try decoder.decodeSingularMessageField(value: &self._user) }() - default: break + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &_storage._accessToken) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &_storage._accessTokenExpiresAtUnix) }() + case 3: try { try decoder.decodeSingularStringField(value: &_storage._refreshToken) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &_storage._refreshTokenExpiresAtUnix) }() + case 5: try { try decoder.decodeSingularStringField(value: &_storage._tokenType) }() + case 6: try { try decoder.decodeSingularMessageField(value: &_storage._user) }() + default: break + } } } } public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.accessToken.isEmpty { - try visitor.visitSingularStringField(value: self.accessToken, fieldNumber: 1) - } - if self.accessTokenExpiresAtUnix != 0 { - try visitor.visitSingularInt64Field(value: self.accessTokenExpiresAtUnix, fieldNumber: 2) - } - if !self.refreshToken.isEmpty { - try visitor.visitSingularStringField(value: self.refreshToken, fieldNumber: 3) - } - if self.refreshTokenExpiresAtUnix != 0 { - try visitor.visitSingularInt64Field(value: self.refreshTokenExpiresAtUnix, fieldNumber: 4) - } - if !self.tokenType.isEmpty { - try visitor.visitSingularStringField(value: self.tokenType, fieldNumber: 5) + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !_storage._accessToken.isEmpty { + try visitor.visitSingularStringField(value: _storage._accessToken, fieldNumber: 1) + } + if _storage._accessTokenExpiresAtUnix != 0 { + try visitor.visitSingularInt64Field(value: _storage._accessTokenExpiresAtUnix, fieldNumber: 2) + } + if !_storage._refreshToken.isEmpty { + try visitor.visitSingularStringField(value: _storage._refreshToken, fieldNumber: 3) + } + if _storage._refreshTokenExpiresAtUnix != 0 { + try visitor.visitSingularInt64Field(value: _storage._refreshTokenExpiresAtUnix, fieldNumber: 4) + } + if !_storage._tokenType.isEmpty { + try visitor.visitSingularStringField(value: _storage._tokenType, fieldNumber: 5) + } + try { if let v = _storage._user { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() } - try { if let v = self._user { - try visitor.visitSingularMessageField(value: v, fieldNumber: 6) - } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Archebase_Auth_V1_LoginResponse, rhs: Archebase_Auth_V1_LoginResponse) -> Bool { - if lhs.accessToken != rhs.accessToken {return false} - if lhs.accessTokenExpiresAtUnix != rhs.accessTokenExpiresAtUnix {return false} - if lhs.refreshToken != rhs.refreshToken {return false} - if lhs.refreshTokenExpiresAtUnix != rhs.refreshTokenExpiresAtUnix {return false} - if lhs.tokenType != rhs.tokenType {return false} - if lhs._user != rhs._user {return false} + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._accessToken != rhs_storage._accessToken {return false} + if _storage._accessTokenExpiresAtUnix != rhs_storage._accessTokenExpiresAtUnix {return false} + if _storage._refreshToken != rhs_storage._refreshToken {return false} + if _storage._refreshTokenExpiresAtUnix != rhs_storage._refreshTokenExpiresAtUnix {return false} + if _storage._tokenType != rhs_storage._tokenType {return false} + if _storage._user != rhs_storage._user {return false} + return true + } + if !storagesAreEqual {return false} + } if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -1489,56 +1650,102 @@ extension Archebase_Auth_V1_RefreshTokenResponse: SwiftProtobuf.Message, SwiftPr public static let protoMessageName: String = _protobuf_package + ".RefreshTokenResponse" public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}access_token\0\u{3}access_token_expires_at_unix\0\u{3}refresh_token\0\u{3}refresh_token_expires_at_unix\0\u{3}token_type\0\u{1}user\0") + fileprivate class _StorageClass { + var _accessToken: String = String() + var _accessTokenExpiresAtUnix: Int64 = 0 + var _refreshToken: String = String() + var _refreshTokenExpiresAtUnix: Int64 = 0 + var _tokenType: String = String() + var _user: Archebase_Auth_V1_User? = nil + + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _accessToken = source._accessToken + _accessTokenExpiresAtUnix = source._accessTokenExpiresAtUnix + _refreshToken = source._refreshToken + _refreshTokenExpiresAtUnix = source._refreshTokenExpiresAtUnix + _tokenType = source._tokenType + _user = source._user + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.accessToken) }() - case 2: try { try decoder.decodeSingularInt64Field(value: &self.accessTokenExpiresAtUnix) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.refreshToken) }() - case 4: try { try decoder.decodeSingularInt64Field(value: &self.refreshTokenExpiresAtUnix) }() - case 5: try { try decoder.decodeSingularStringField(value: &self.tokenType) }() - case 6: try { try decoder.decodeSingularMessageField(value: &self._user) }() - default: break + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &_storage._accessToken) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &_storage._accessTokenExpiresAtUnix) }() + case 3: try { try decoder.decodeSingularStringField(value: &_storage._refreshToken) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &_storage._refreshTokenExpiresAtUnix) }() + case 5: try { try decoder.decodeSingularStringField(value: &_storage._tokenType) }() + case 6: try { try decoder.decodeSingularMessageField(value: &_storage._user) }() + default: break + } } } } public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.accessToken.isEmpty { - try visitor.visitSingularStringField(value: self.accessToken, fieldNumber: 1) - } - if self.accessTokenExpiresAtUnix != 0 { - try visitor.visitSingularInt64Field(value: self.accessTokenExpiresAtUnix, fieldNumber: 2) - } - if !self.refreshToken.isEmpty { - try visitor.visitSingularStringField(value: self.refreshToken, fieldNumber: 3) - } - if self.refreshTokenExpiresAtUnix != 0 { - try visitor.visitSingularInt64Field(value: self.refreshTokenExpiresAtUnix, fieldNumber: 4) - } - if !self.tokenType.isEmpty { - try visitor.visitSingularStringField(value: self.tokenType, fieldNumber: 5) + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !_storage._accessToken.isEmpty { + try visitor.visitSingularStringField(value: _storage._accessToken, fieldNumber: 1) + } + if _storage._accessTokenExpiresAtUnix != 0 { + try visitor.visitSingularInt64Field(value: _storage._accessTokenExpiresAtUnix, fieldNumber: 2) + } + if !_storage._refreshToken.isEmpty { + try visitor.visitSingularStringField(value: _storage._refreshToken, fieldNumber: 3) + } + if _storage._refreshTokenExpiresAtUnix != 0 { + try visitor.visitSingularInt64Field(value: _storage._refreshTokenExpiresAtUnix, fieldNumber: 4) + } + if !_storage._tokenType.isEmpty { + try visitor.visitSingularStringField(value: _storage._tokenType, fieldNumber: 5) + } + try { if let v = _storage._user { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() } - try { if let v = self._user { - try visitor.visitSingularMessageField(value: v, fieldNumber: 6) - } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Archebase_Auth_V1_RefreshTokenResponse, rhs: Archebase_Auth_V1_RefreshTokenResponse) -> Bool { - if lhs.accessToken != rhs.accessToken {return false} - if lhs.accessTokenExpiresAtUnix != rhs.accessTokenExpiresAtUnix {return false} - if lhs.refreshToken != rhs.refreshToken {return false} - if lhs.refreshTokenExpiresAtUnix != rhs.refreshTokenExpiresAtUnix {return false} - if lhs.tokenType != rhs.tokenType {return false} - if lhs._user != rhs._user {return false} + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._accessToken != rhs_storage._accessToken {return false} + if _storage._accessTokenExpiresAtUnix != rhs_storage._accessTokenExpiresAtUnix {return false} + if _storage._refreshToken != rhs_storage._refreshToken {return false} + if _storage._refreshTokenExpiresAtUnix != rhs_storage._refreshTokenExpiresAtUnix {return false} + if _storage._tokenType != rhs_storage._tokenType {return false} + if _storage._user != rhs_storage._user {return false} + return true + } + if !storagesAreEqual {return false} + } if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -1626,7 +1833,7 @@ extension Archebase_Auth_V1_ExchangeSystemCredentialResponse: SwiftProtobuf.Mess extension Archebase_Auth_V1_User: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".User" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}organization\0\u{3}user_name\0\u{1}role\0\u{3}last_login_at\0\u{3}created_at\0\u{3}updated_at\0") + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}organization\0\u{3}user_name\0\u{1}role\0\u{3}last_login_at\0\u{3}created_at\0\u{3}updated_at\0\u{3}user_class\0\u{3}organization_id\0\u{3}user_id\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -1640,6 +1847,9 @@ extension Archebase_Auth_V1_User: SwiftProtobuf.Message, SwiftProtobuf._MessageI case 4: try { try decoder.decodeSingularMessageField(value: &self._lastLoginAt) }() case 5: try { try decoder.decodeSingularMessageField(value: &self._createdAt) }() case 6: try { try decoder.decodeSingularMessageField(value: &self._updatedAt) }() + case 7: try { try decoder.decodeSingularEnumField(value: &self.userClass) }() + case 8: try { try decoder.decodeSingularInt64Field(value: &self.organizationID) }() + case 9: try { try decoder.decodeSingularInt64Field(value: &self.userID) }() default: break } } @@ -1668,6 +1878,15 @@ extension Archebase_Auth_V1_User: SwiftProtobuf.Message, SwiftProtobuf._MessageI try { if let v = self._updatedAt { try visitor.visitSingularMessageField(value: v, fieldNumber: 6) } }() + if self.userClass != .unspecified { + try visitor.visitSingularEnumField(value: self.userClass, fieldNumber: 7) + } + if self.organizationID != 0 { + try visitor.visitSingularInt64Field(value: self.organizationID, fieldNumber: 8) + } + if self.userID != 0 { + try visitor.visitSingularInt64Field(value: self.userID, fieldNumber: 9) + } try unknownFields.traverse(visitor: &visitor) } @@ -1678,6 +1897,9 @@ extension Archebase_Auth_V1_User: SwiftProtobuf.Message, SwiftProtobuf._MessageI if lhs._lastLoginAt != rhs._lastLoginAt {return false} if lhs._createdAt != rhs._createdAt {return false} if lhs._updatedAt != rhs._updatedAt {return false} + if lhs.userClass != rhs.userClass {return false} + if lhs.organizationID != rhs.organizationID {return false} + if lhs.userID != rhs.userID {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -2839,36 +3061,74 @@ extension Archebase_Auth_V1_CreateOrganizationResponse: SwiftProtobuf.Message, S public static let protoMessageName: String = _protobuf_package + ".CreateOrganizationResponse" public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}organization\0\u{3}bootstrap_admin\0") + fileprivate class _StorageClass { + var _organization: Archebase_Auth_V1_Organization? = nil + var _bootstrapAdmin: Archebase_Auth_V1_User? = nil + + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _organization = source._organization + _bootstrapAdmin = source._bootstrapAdmin + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularMessageField(value: &self._organization) }() - case 2: try { try decoder.decodeSingularMessageField(value: &self._bootstrapAdmin) }() - default: break + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &_storage._organization) }() + case 2: try { try decoder.decodeSingularMessageField(value: &_storage._bootstrapAdmin) }() + default: break + } } } } public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - try { if let v = self._organization { - try visitor.visitSingularMessageField(value: v, fieldNumber: 1) - } }() - try { if let v = self._bootstrapAdmin { - try visitor.visitSingularMessageField(value: v, fieldNumber: 2) - } }() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = _storage._organization { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = _storage._bootstrapAdmin { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Archebase_Auth_V1_CreateOrganizationResponse, rhs: Archebase_Auth_V1_CreateOrganizationResponse) -> Bool { - if lhs._organization != rhs._organization {return false} - if lhs._bootstrapAdmin != rhs._bootstrapAdmin {return false} + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._organization != rhs_storage._organization {return false} + if _storage._bootstrapAdmin != rhs_storage._bootstrapAdmin {return false} + return true + } + if !storagesAreEqual {return false} + } if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -3111,7 +3371,7 @@ extension Archebase_Auth_V1_DeleteOrganizationResponse: SwiftProtobuf.Message, S extension Archebase_Auth_V1_CreateUserRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".CreateUserRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}user_name\0\u{1}password\0\u{1}role\0") + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}user_name\0\u{1}password\0\u{1}role\0\u{3}user_class\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -3122,6 +3382,7 @@ extension Archebase_Auth_V1_CreateUserRequest: SwiftProtobuf.Message, SwiftProto case 1: try { try decoder.decodeSingularStringField(value: &self.userName) }() case 2: try { try decoder.decodeSingularStringField(value: &self.password) }() case 3: try { try decoder.decodeSingularEnumField(value: &self.role) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self.userClass) }() default: break } } @@ -3137,6 +3398,9 @@ extension Archebase_Auth_V1_CreateUserRequest: SwiftProtobuf.Message, SwiftProto if self.role != .unspecified { try visitor.visitSingularEnumField(value: self.role, fieldNumber: 3) } + if self.userClass != .unspecified { + try visitor.visitSingularEnumField(value: self.userClass, fieldNumber: 4) + } try unknownFields.traverse(visitor: &visitor) } @@ -3144,6 +3408,7 @@ extension Archebase_Auth_V1_CreateUserRequest: SwiftProtobuf.Message, SwiftProto if lhs.userName != rhs.userName {return false} if lhs.password != rhs.password {return false} if lhs.role != rhs.role {return false} + if lhs.userClass != rhs.userClass {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -3298,7 +3563,7 @@ extension Archebase_Auth_V1_ListUsersResponse: SwiftProtobuf.Message, SwiftProto extension Archebase_Auth_V1_UpdateUserRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".UpdateUserRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}user_name\0\u{1}password\0\u{1}role\0") + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}user_name\0\u{1}password\0\u{1}role\0\u{3}user_class\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -3309,6 +3574,7 @@ extension Archebase_Auth_V1_UpdateUserRequest: SwiftProtobuf.Message, SwiftProto case 1: try { try decoder.decodeSingularStringField(value: &self.userName) }() case 2: try { try decoder.decodeSingularStringField(value: &self._password) }() case 3: try { try decoder.decodeSingularEnumField(value: &self._role) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self._userClass) }() default: break } } @@ -3328,6 +3594,9 @@ extension Archebase_Auth_V1_UpdateUserRequest: SwiftProtobuf.Message, SwiftProto try { if let v = self._role { try visitor.visitSingularEnumField(value: v, fieldNumber: 3) } }() + try { if let v = self._userClass { + try visitor.visitSingularEnumField(value: v, fieldNumber: 4) + } }() try unknownFields.traverse(visitor: &visitor) } @@ -3335,6 +3604,7 @@ extension Archebase_Auth_V1_UpdateUserRequest: SwiftProtobuf.Message, SwiftProto if lhs.userName != rhs.userName {return false} if lhs._password != rhs._password {return false} if lhs._role != rhs._role {return false} + if lhs._userClass != rhs._userClass {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/DGWProto/Generated/data_gateway.grpc.swift b/Sources/DGWProto/Generated/data_gateway.grpc.swift index 97f3103..c6ffdc7 100644 --- a/Sources/DGWProto/Generated/data_gateway.grpc.swift +++ b/Sources/DGWProto/Generated/data_gateway.grpc.swift @@ -653,6 +653,815 @@ extension Archebase_DataGateway_V1_DataGatewayService.ClientProtocol { } } +// MARK: - archebase.data_gateway.v1.DataGatewayDownloadService + +/// Namespace containing generated types for the "archebase.data_gateway.v1.DataGatewayDownloadService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Archebase_DataGateway_V1_DataGatewayDownloadService: Sendable { + /// Service descriptor for the "archebase.data_gateway.v1.DataGatewayDownloadService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayDownloadService") + /// Namespace for method metadata. + public enum Method: Sendable { + /// Namespace for "RequestDownload" metadata. + public enum RequestDownload: Sendable { + /// Request type for "RequestDownload". + public typealias Input = Archebase_DataGateway_V1_RequestDownloadRequest + /// Response type for "RequestDownload". + public typealias Output = Archebase_DataGateway_V1_RequestDownloadResponse + /// Descriptor for "RequestDownload". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayDownloadService"), + method: "RequestDownload", + type: .unary + ) + } + /// Descriptors for all methods in the "archebase.data_gateway.v1.DataGatewayDownloadService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + RequestDownload.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "archebase.data_gateway.v1.DataGatewayDownloadService" service. + public static let archebase_dataGateway_v1_DataGatewayDownloadService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayDownloadService") +} + +// MARK: archebase.data_gateway.v1.DataGatewayDownloadService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Archebase_DataGateway_V1_DataGatewayDownloadService { + /// Generated client protocol for the "archebase.data_gateway.v1.DataGatewayDownloadService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + /// + /// > Source IDL Documentation: + /// > + /// > SDK-facing download authorization service exposed on the public gRPC port. + /// > + /// > This service uses user access JWT authentication and returns short-lived + /// > presigned read operations rather than cloud credentials. + public protocol ClientProtocol: Sendable { + /// Call the "RequestDownload" method. + /// + /// > Source IDL Documentation: + /// > + /// > Authorizes direct object downloads for the requested file IDs. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_RequestDownloadRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_RequestDownloadRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_RequestDownloadResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func requestDownload( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "archebase.data_gateway.v1.DataGatewayDownloadService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + /// + /// > Source IDL Documentation: + /// > + /// > SDK-facing download authorization service exposed on the public gRPC port. + /// > + /// > This service uses user access JWT authentication and returns short-lived + /// > presigned read operations rather than cloud credentials. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "RequestDownload" method. + /// + /// > Source IDL Documentation: + /// > + /// > Authorizes direct object downloads for the requested file IDs. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_RequestDownloadRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_RequestDownloadRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_RequestDownloadResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func requestDownload( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Archebase_DataGateway_V1_DataGatewayDownloadService.Method.RequestDownload.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Archebase_DataGateway_V1_DataGatewayDownloadService.ClientProtocol { + /// Call the "RequestDownload" method. + /// + /// > Source IDL Documentation: + /// > + /// > Authorizes direct object downloads for the requested file IDs. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_RequestDownloadRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func requestDownload( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.requestDownload( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Archebase_DataGateway_V1_DataGatewayDownloadService.ClientProtocol { + /// Call the "RequestDownload" method. + /// + /// > Source IDL Documentation: + /// > + /// > Authorizes direct object downloads for the requested file IDs. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func requestDownload( + _ message: Archebase_DataGateway_V1_RequestDownloadRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.requestDownload( + request: request, + options: options, + onResponse: handleResponse + ) + } +} + +// MARK: - archebase.data_gateway.v1.DataGatewayCopyService + +/// Namespace containing generated types for the "archebase.data_gateway.v1.DataGatewayCopyService" service. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +public enum Archebase_DataGateway_V1_DataGatewayCopyService: Sendable { + /// Service descriptor for the "archebase.data_gateway.v1.DataGatewayCopyService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayCopyService") + /// Namespace for method metadata. + public enum Method: Sendable { + /// Namespace for "CreateCopyJob" metadata. + public enum CreateCopyJob: Sendable { + /// Request type for "CreateCopyJob". + public typealias Input = Archebase_DataGateway_V1_CreateCopyJobRequest + /// Response type for "CreateCopyJob". + public typealias Output = Archebase_DataGateway_V1_CreateCopyJobResponse + /// Descriptor for "CreateCopyJob". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayCopyService"), + method: "CreateCopyJob", + type: .unary + ) + } + /// Namespace for "GetCopyJob" metadata. + public enum GetCopyJob: Sendable { + /// Request type for "GetCopyJob". + public typealias Input = Archebase_DataGateway_V1_GetCopyJobRequest + /// Response type for "GetCopyJob". + public typealias Output = Archebase_DataGateway_V1_GetCopyJobResponse + /// Descriptor for "GetCopyJob". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayCopyService"), + method: "GetCopyJob", + type: .unary + ) + } + /// Namespace for "ListCopyJobItems" metadata. + public enum ListCopyJobItems: Sendable { + /// Request type for "ListCopyJobItems". + public typealias Input = Archebase_DataGateway_V1_ListCopyJobItemsRequest + /// Response type for "ListCopyJobItems". + public typealias Output = Archebase_DataGateway_V1_ListCopyJobItemsResponse + /// Descriptor for "ListCopyJobItems". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayCopyService"), + method: "ListCopyJobItems", + type: .unary + ) + } + /// Namespace for "CancelCopyJob" metadata. + public enum CancelCopyJob: Sendable { + /// Request type for "CancelCopyJob". + public typealias Input = Archebase_DataGateway_V1_CancelCopyJobRequest + /// Response type for "CancelCopyJob". + public typealias Output = Archebase_DataGateway_V1_CancelCopyJobResponse + /// Descriptor for "CancelCopyJob". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayCopyService"), + method: "CancelCopyJob", + type: .unary + ) + } + /// Descriptors for all methods in the "archebase.data_gateway.v1.DataGatewayCopyService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + CreateCopyJob.descriptor, + GetCopyJob.descriptor, + ListCopyJobItems.descriptor, + CancelCopyJob.descriptor + ] + } +} + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "archebase.data_gateway.v1.DataGatewayCopyService" service. + public static let archebase_dataGateway_v1_DataGatewayCopyService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DataGatewayCopyService") +} + +// MARK: archebase.data_gateway.v1.DataGatewayCopyService (client) + +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Archebase_DataGateway_V1_DataGatewayCopyService { + /// Generated client protocol for the "archebase.data_gateway.v1.DataGatewayCopyService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + /// + /// > Source IDL Documentation: + /// > + /// > SDK-facing asynchronous object copy service exposed on the public gRPC port. + /// > + /// > This service accepts logical file IDs and persists copy jobs for background + /// > workers. It never exposes source OSS bucket, object key, or source-side + /// > credentials to the caller. + public protocol ClientProtocol: Sendable { + /// Call the "CreateCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Creates an asynchronous copy job for the requested file IDs. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_CreateCopyJobRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_CreateCopyJobRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_CreateCopyJobResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func createCopyJob( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "GetCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the aggregate state of one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_GetCopyJobRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_GetCopyJobRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_GetCopyJobResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func getCopyJob( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "ListCopyJobItems" method. + /// + /// > Source IDL Documentation: + /// > + /// > Lists item-level copy outcomes for one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_ListCopyJobItemsRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_ListCopyJobItemsRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_ListCopyJobItemsResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func listCopyJobItems( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "CancelCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Requests cancellation of one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_CancelCopyJobRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_CancelCopyJobRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_CancelCopyJobResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func cancelCopyJob( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "archebase.data_gateway.v1.DataGatewayCopyService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + /// + /// > Source IDL Documentation: + /// > + /// > SDK-facing asynchronous object copy service exposed on the public gRPC port. + /// > + /// > This service accepts logical file IDs and persists copy jobs for background + /// > workers. It never exposes source OSS bucket, object key, or source-side + /// > credentials to the caller. + public struct Client: ClientProtocol where Transport: GRPCCore.ClientTransport { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "CreateCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Creates an asynchronous copy job for the requested file IDs. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_CreateCopyJobRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_CreateCopyJobRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_CreateCopyJobResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func createCopyJob( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Archebase_DataGateway_V1_DataGatewayCopyService.Method.CreateCopyJob.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the aggregate state of one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_GetCopyJobRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_GetCopyJobRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_GetCopyJobResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getCopyJob( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Archebase_DataGateway_V1_DataGatewayCopyService.Method.GetCopyJob.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "ListCopyJobItems" method. + /// + /// > Source IDL Documentation: + /// > + /// > Lists item-level copy outcomes for one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_ListCopyJobItemsRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_ListCopyJobItemsRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_ListCopyJobItemsResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func listCopyJobItems( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Archebase_DataGateway_V1_DataGatewayCopyService.Method.ListCopyJobItems.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "CancelCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Requests cancellation of one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_CancelCopyJobRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_CancelCopyJobRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_CancelCopyJobResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cancelCopyJob( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Archebase_DataGateway_V1_DataGatewayCopyService.Method.CancelCopyJob.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Archebase_DataGateway_V1_DataGatewayCopyService.ClientProtocol { + /// Call the "CreateCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Creates an asynchronous copy job for the requested file IDs. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_CreateCopyJobRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func createCopyJob( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.createCopyJob( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the aggregate state of one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_GetCopyJobRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getCopyJob( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.getCopyJob( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "ListCopyJobItems" method. + /// + /// > Source IDL Documentation: + /// > + /// > Lists item-level copy outcomes for one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_ListCopyJobItemsRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func listCopyJobItems( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.listCopyJobItems( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "CancelCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Requests cancellation of one copy job. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_CancelCopyJobRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cancelCopyJob( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.cancelCopyJob( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } +} + +// Helpers providing sugared APIs for 'ClientProtocol' methods. +@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +extension Archebase_DataGateway_V1_DataGatewayCopyService.ClientProtocol { + /// Call the "CreateCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Creates an asynchronous copy job for the requested file IDs. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func createCopyJob( + _ message: Archebase_DataGateway_V1_CreateCopyJobRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.createCopyJob( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "GetCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Returns the aggregate state of one copy job. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func getCopyJob( + _ message: Archebase_DataGateway_V1_GetCopyJobRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.getCopyJob( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "ListCopyJobItems" method. + /// + /// > Source IDL Documentation: + /// > + /// > Lists item-level copy outcomes for one copy job. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func listCopyJobItems( + _ message: Archebase_DataGateway_V1_ListCopyJobItemsRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.listCopyJobItems( + request: request, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "CancelCopyJob" method. + /// + /// > Source IDL Documentation: + /// > + /// > Requests cancellation of one copy job. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cancelCopyJob( + _ message: Archebase_DataGateway_V1_CancelCopyJobRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.cancelCopyJob( + request: request, + options: options, + onResponse: handleResponse + ) + } +} + // MARK: - archebase.data_gateway.v1.DeviceInitService /// Namespace containing generated types for the "archebase.data_gateway.v1.DeviceInitService" service. @@ -675,9 +1484,23 @@ public enum Archebase_DataGateway_V1_DeviceInitService: Sendable { type: .unary ) } + /// Namespace for "ReinitDevice" metadata. + public enum ReinitDevice: Sendable { + /// Request type for "ReinitDevice". + public typealias Input = Archebase_DataGateway_V1_ReinitDeviceRequest + /// Response type for "ReinitDevice". + public typealias Output = Archebase_DataGateway_V1_InitDeviceResponse + /// Descriptor for "ReinitDevice". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "archebase.data_gateway.v1.DeviceInitService"), + method: "ReinitDevice", + type: .unary + ) + } /// Descriptors for all methods in the "archebase.data_gateway.v1.DeviceInitService" service. public static let descriptors: [GRPCCore.MethodDescriptor] = [ - InitDevice.descriptor + InitDevice.descriptor, + ReinitDevice.descriptor ] } } @@ -700,7 +1523,7 @@ extension Archebase_DataGateway_V1_DeviceInitService { /// > Source IDL Documentation: /// > /// > SDK-facing device initialization service exposed on the dedicated init port. - /// > + /// > /// > This surface intentionally does not require the upload API key because it is /// > used to provision that key for a registered device. Deployment-level network /// > controls and rate limiting are required before exposing it outside controlled @@ -710,7 +1533,7 @@ extension Archebase_DataGateway_V1_DeviceInitService { /// /// > Source IDL Documentation: /// > - /// > Initializes or re-initializes one registered device and returns the upload API key. + /// > Initializes one registered device and returns the upload API key. /// /// - Parameters: /// - request: A request containing a single `Archebase_DataGateway_V1_InitDeviceRequest` message. @@ -728,6 +1551,29 @@ extension Archebase_DataGateway_V1_DeviceInitService { options: GRPCCore.CallOptions, onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable + + /// Call the "ReinitDevice" method. + /// + /// > Source IDL Documentation: + /// > + /// > Re-initializes one registered device and returns a rotated upload API key. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_ReinitDeviceRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_ReinitDeviceRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_InitDeviceResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func reinitDevice( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable } /// Generated client for the "archebase.data_gateway.v1.DeviceInitService" service. @@ -739,7 +1585,7 @@ extension Archebase_DataGateway_V1_DeviceInitService { /// > Source IDL Documentation: /// > /// > SDK-facing device initialization service exposed on the dedicated init port. - /// > + /// > /// > This surface intentionally does not require the upload API key because it is /// > used to provision that key for a registered device. Deployment-level network /// > controls and rate limiting are required before exposing it outside controlled @@ -759,7 +1605,7 @@ extension Archebase_DataGateway_V1_DeviceInitService { /// /// > Source IDL Documentation: /// > - /// > Initializes or re-initializes one registered device and returns the upload API key. + /// > Initializes one registered device and returns the upload API key. /// /// - Parameters: /// - request: A request containing a single `Archebase_DataGateway_V1_InitDeviceRequest` message. @@ -788,6 +1634,40 @@ extension Archebase_DataGateway_V1_DeviceInitService { onResponse: handleResponse ) } + + /// Call the "ReinitDevice" method. + /// + /// > Source IDL Documentation: + /// > + /// > Re-initializes one registered device and returns a rotated upload API key. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_ReinitDeviceRequest` message. + /// - serializer: A serializer for `Archebase_DataGateway_V1_ReinitDeviceRequest` messages. + /// - deserializer: A deserializer for `Archebase_DataGateway_V1_InitDeviceResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func reinitDevice( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Archebase_DataGateway_V1_DeviceInitService.Method.ReinitDevice.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } } } @@ -798,7 +1678,7 @@ extension Archebase_DataGateway_V1_DeviceInitService.ClientProtocol { /// /// > Source IDL Documentation: /// > - /// > Initializes or re-initializes one registered device and returns the upload API key. + /// > Initializes one registered device and returns the upload API key. /// /// - Parameters: /// - request: A request containing a single `Archebase_DataGateway_V1_InitDeviceRequest` message. @@ -822,6 +1702,35 @@ extension Archebase_DataGateway_V1_DeviceInitService.ClientProtocol { onResponse: handleResponse ) } + + /// Call the "ReinitDevice" method. + /// + /// > Source IDL Documentation: + /// > + /// > Re-initializes one registered device and returns a rotated upload API key. + /// + /// - Parameters: + /// - request: A request containing a single `Archebase_DataGateway_V1_ReinitDeviceRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func reinitDevice( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.reinitDevice( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } } // Helpers providing sugared APIs for 'ClientProtocol' methods. @@ -831,7 +1740,7 @@ extension Archebase_DataGateway_V1_DeviceInitService.ClientProtocol { /// /// > Source IDL Documentation: /// > - /// > Initializes or re-initializes one registered device and returns the upload API key. + /// > Initializes one registered device and returns the upload API key. /// /// - Parameters: /// - message: request message to send. @@ -859,6 +1768,39 @@ extension Archebase_DataGateway_V1_DeviceInitService.ClientProtocol { onResponse: handleResponse ) } + + /// Call the "ReinitDevice" method. + /// + /// > Source IDL Documentation: + /// > + /// > Re-initializes one registered device and returns a rotated upload API key. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func reinitDevice( + _ message: Archebase_DataGateway_V1_ReinitDeviceRequest, + metadata: GRPCCore.Metadata = [:], + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + let request = GRPCCore.ClientRequest( + message: message, + metadata: metadata + ) + return try await self.reinitDevice( + request: request, + options: options, + onResponse: handleResponse + ) + } } // MARK: - archebase.data_gateway.v1.InternalStorageService diff --git a/Sources/DGWProto/Generated/data_gateway.pb.swift b/Sources/DGWProto/Generated/data_gateway.pb.swift index 9dd2062..4ae32a9 100644 --- a/Sources/DGWProto/Generated/data_gateway.pb.swift +++ b/Sources/DGWProto/Generated/data_gateway.pb.swift @@ -112,6 +112,120 @@ public enum Archebase_DataGateway_V1_LogicalUploadStatus: SwiftProtobuf.Enum, Sw } +/// User-visible aggregate copy job state. +public enum Archebase_DataGateway_V1_CopyJobStatus: SwiftProtobuf.Enum, Swift.CaseIterable { + public typealias RawValue = Int + case unspecified // = 0 + case queued // = 1 + case running // = 2 + case succeeded // = 3 + case partialFailed // = 4 + case failed // = 5 + case canceling // = 6 + case canceled // = 7 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .queued + case 2: self = .running + case 3: self = .succeeded + case 4: self = .partialFailed + case 5: self = .failed + case 6: self = .canceling + case 7: self = .canceled + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .queued: return 1 + case .running: return 2 + case .succeeded: return 3 + case .partialFailed: return 4 + case .failed: return 5 + case .canceling: return 6 + case .canceled: return 7 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Archebase_DataGateway_V1_CopyJobStatus] = [ + .unspecified, + .queued, + .running, + .succeeded, + .partialFailed, + .failed, + .canceling, + .canceled, + ] + +} + +/// User-visible per-file copy item state. +public enum Archebase_DataGateway_V1_CopyItemStatus: SwiftProtobuf.Enum, Swift.CaseIterable { + public typealias RawValue = Int + case unspecified // = 0 + case queued // = 1 + case copying // = 2 + case succeeded // = 3 + case failedTerminal // = 4 + case skipped // = 5 + case canceled // = 6 + case UNRECOGNIZED(Int) + + public init() { + self = .unspecified + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .unspecified + case 1: self = .queued + case 2: self = .copying + case 3: self = .succeeded + case 4: self = .failedTerminal + case 5: self = .skipped + case 6: self = .canceled + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .unspecified: return 0 + case .queued: return 1 + case .copying: return 2 + case .succeeded: return 3 + case .failedTerminal: return 4 + case .skipped: return 5 + case .canceled: return 6 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Archebase_DataGateway_V1_CopyItemStatus] = [ + .unspecified, + .queued, + .copying, + .succeeded, + .failedTerminal, + .skipped, + .canceled, + ] + +} + /// Declares the requested presigned access mode. public enum Archebase_DataGateway_V1_PresignAccessMode: SwiftProtobuf.Enum, Swift.CaseIterable { public typealias RawValue = Int @@ -237,6 +351,26 @@ public struct Archebase_DataGateway_V1_InitDeviceRequest: Sendable { public init() {} } +/// Request sent by SDKs when explicitly rotating an existing upload API key. +public struct Archebase_DataGateway_V1_ReinitDeviceRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Bare platform-assigned device identifier provided by the operator. + public var deviceID: String = String() + + /// SDK version reported for operator visibility and diagnostics. + public var sdkVersion: String = String() + + /// SDK platform string, for example "ios". + public var platform: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + /// Response persisted by SDKs into archebase-config.json. public struct Archebase_DataGateway_V1_InitDeviceResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the @@ -464,218 +598,1053 @@ public struct Archebase_DataGateway_V1_CompleteUploadResponse: Sendable { public init() {} } -/// Identifies an object within the configured OSS bucket. -public struct Archebase_DataGateway_V1_StorageObject: Sendable { +/// Requests presigned read operations for file IDs. +public struct Archebase_DataGateway_V1_RequestDownloadRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// Target bucket name. - public var bucket: String = String() - - /// Target object key. - public var objectKey: String = String() + /// Non-empty file IDs. Empty or duplicate IDs are rejected by data-gateway. + public var fileIds: [String] = [] public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} } -/// Represents one presigned HTTP operation. -public struct Archebase_DataGateway_V1_PresignedOperation: Sendable { +/// Contains the presigned read operation for one requested file. +public struct Archebase_DataGateway_V1_DownloadObjectLocation: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// HTTP method that must be used by the caller. - public var method: String = String() - - /// Fully qualified presigned URI. - public var uri: String = String() + /// File ID echoed from the request. + public var fileID: String = String() - /// Required request headers. - public var headers: Dictionary = [:] + /// Presigned GET operation. Clients may add a Range header for ranged reads. + public var read: Archebase_DataGateway_V1_PresignedOperation { + get {_read ?? Archebase_DataGateway_V1_PresignedOperation()} + set {_read = newValue} + } + /// Returns true if `read` has been explicitly set. + public var hasRead: Bool {self._read != nil} + /// Clears the value of `read`. Subsequent reads from it will return its default value. + public mutating func clearRead() {self._read = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} + + fileprivate var _read: Archebase_DataGateway_V1_PresignedOperation? = nil } -/// Requests presigned access for a single object. -public struct Archebase_DataGateway_V1_PresignObjectRequest: Sendable { +/// Returns presigned read operations and client download hints. +public struct Archebase_DataGateway_V1_RequestDownloadResponse: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// Object to presign. - public var object: Archebase_DataGateway_V1_StorageObject { - get {_object ?? Archebase_DataGateway_V1_StorageObject()} - set {_object = newValue} - } - /// Returns true if `object` has been explicitly set. - public var hasObject: Bool {self._object != nil} - /// Clears the value of `object`. Subsequent reads from it will return its default value. - public mutating func clearObject() {self._object = nil} + /// Files in the same order as request.file_ids. + public var files: [Archebase_DataGateway_V1_DownloadObjectLocation] = [] - /// Requested access mode. - public var accessMode: Archebase_DataGateway_V1_PresignAccessMode = .unspecified + /// Absolute expiration time shared by returned read operations, as Unix seconds. + public var expiresAtUnix: Int64 = 0 - /// Requested presign TTL in seconds. - public var expiresInSeconds: Int64 = 0 + /// Client hint for deciding when to use ranged parallel download. + public var largeFileThresholdBytes: Int64 = 0 + + /// Client hint for ranged GET part size. + public var rangePartSizeBytes: Int64 = 0 public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} - - fileprivate var _object: Archebase_DataGateway_V1_StorageObject? = nil } -/// Returns presigned operations for the requested object. -public struct Archebase_DataGateway_V1_PresignObjectResponse: Sendable { +/// Requests creation of an asynchronous OSS server-side copy job. +public struct Archebase_DataGateway_V1_CreateCopyJobRequest: Sendable { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for // methods supported on all messages. - /// Object that was presigned. - public var object: Archebase_DataGateway_V1_StorageObject { - get {_object ?? Archebase_DataGateway_V1_StorageObject()} - set {_object = newValue} - } - /// Returns true if `object` has been explicitly set. - public var hasObject: Bool {self._object != nil} - /// Clears the value of `object`. Subsequent reads from it will return its default value. - public mutating func clearObject() {self._object = nil} - - /// Presigned read operation, present for read-enabled modes. - public var read: Archebase_DataGateway_V1_PresignedOperation { - get {_read ?? Archebase_DataGateway_V1_PresignedOperation()} - set {_read = newValue} - } - /// Returns true if `read` has been explicitly set. - public var hasRead: Bool {self._read != nil} - /// Clears the value of `read`. Subsequent reads from it will return its default value. - public mutating func clearRead() {self._read = nil} + /// Non-empty file IDs. Empty or duplicate IDs are rejected by data-gateway. + public var fileIds: [String] = [] - /// Presigned write operation, present for write-enabled modes. - public var write: Archebase_DataGateway_V1_PresignedOperation { - get {_write ?? Archebase_DataGateway_V1_PresignedOperation()} - set {_write = newValue} + /// Destination bucket, endpoint, region, and object key template. + public var destination: Archebase_DataGateway_V1_CopyDestination { + get {_destination ?? Archebase_DataGateway_V1_CopyDestination()} + set {_destination = newValue} } - /// Returns true if `write` has been explicitly set. - public var hasWrite: Bool {self._write != nil} - /// Clears the value of `write`. Subsequent reads from it will return its default value. - public mutating func clearWrite() {self._write = nil} + /// Returns true if `destination` has been explicitly set. + public var hasDestination: Bool {self._destination != nil} + /// Clears the value of `destination`. Subsequent reads from it will return its default value. + public mutating func clearDestination() {self._destination = nil} - /// Absolute expiration time as Unix seconds. - public var expiresAtUnix: Int64 = 0 + /// Optional caller-provided key used to make create retries idempotent. + public var idempotencyKey: String = String() public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} - fileprivate var _object: Archebase_DataGateway_V1_StorageObject? = nil - fileprivate var _read: Archebase_DataGateway_V1_PresignedOperation? = nil - fileprivate var _write: Archebase_DataGateway_V1_PresignedOperation? = nil + fileprivate var _destination: Archebase_DataGateway_V1_CopyDestination? = nil } -// MARK: - Code below here is support for the SwiftProtobuf runtime. +/// Describes the user-owned destination for copied objects. +public struct Archebase_DataGateway_V1_CopyDestination: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. -fileprivate let _protobuf_package = "archebase.data_gateway.v1" + /// Target OSS bucket name. + public var bucket: String = String() -extension Archebase_DataGateway_V1_UploadRecoveryAction: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0UPLOAD_RECOVERY_ACTION_UNSPECIFIED\0\u{1}UPLOAD_RECOVERY_ACTION_CONTINUE\0\u{1}UPLOAD_RECOVERY_ACTION_COMPLETE_ONLY\0\u{1}UPLOAD_RECOVERY_ACTION_RESTART\0\u{1}UPLOAD_RECOVERY_ACTION_ABORT\0") + /// Target OSS endpoint used by copy workers. + public var endpoint: String = String() + + /// Target OSS region. Server-side copy only supports same-region buckets. + public var region: String = String() + + /// Object key template used to render the destination object key for each + /// copied file. + /// + /// Template syntax: + /// - Empty or whitespace-only values are normalized to "{file_id}". + /// - The only supported variable is "{file_id}". + /// - "{file_id}" is replaced by the source file ID from the request. + /// - All other text is treated as a literal prefix, suffix, or path segment. + /// - Date values are not expanded by data-gateway. + /// - Callers that want a date prefix must format it before sending the request. + /// + /// Examples: + /// - "{file_id}" renders "file-a" for file ID "file-a". + /// - "exports/{file_id}.bin" renders "exports/file-a.bin". + /// - "exports/20260503/{file_id}" appends yyyyMMdd as part of the prefix. + /// - For file ID "file-a", that template renders "exports/20260503/file-a". + /// - "20260503" is caller-provided literal text. + /// + /// Safety rules after rendering: + /// - The key must be non-empty and relative; it must not start with "/". + /// - The key must not contain a ".." path segment. + /// - The key must not contain control characters. + /// - The rendered UTF-8 byte length must fit the OSS object key limit. + /// - Within one CreateCopyJob request, every file ID must render to a unique key. + /// - A fixed template such as "latest.bin" is only valid when it cannot collide. + public var keyTemplate: String = String() + + /// Optional target cloud account identifier for auditing and diagnostics. + public var accountID: String = String() + + /// Optional KMS key ID used when writing destination objects. + public var kmsKeyID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} } -extension Archebase_DataGateway_V1_LogicalUploadStatus: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0LOGICAL_UPLOAD_STATUS_UNSPECIFIED\0\u{1}LOGICAL_UPLOAD_STATUS_ACTIVE\0\u{1}LOGICAL_UPLOAD_STATUS_COMPLETING\0\u{1}LOGICAL_UPLOAD_STATUS_COMPLETED\0\u{1}LOGICAL_UPLOAD_STATUS_TERMINAL\0") +/// Returns the identity and initial state of a newly created copy job. +public struct Archebase_DataGateway_V1_CreateCopyJobResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Stable job identifier used by all subsequent copy RPCs. + public var copyJobID: String = String() + + /// Initial or reused job status. + public var status: Archebase_DataGateway_V1_CopyJobStatus = .unspecified + + /// Total number of file IDs accepted into the job. + public var totalItems: Int32 = 0 + + /// Sum of known source file sizes, in bytes. + public var estimatedTotalBytes: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} } -extension Archebase_DataGateway_V1_PresignAccessMode: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0PRESIGN_ACCESS_MODE_UNSPECIFIED\0\u{1}PRESIGN_ACCESS_MODE_READ\0\u{1}PRESIGN_ACCESS_MODE_WRITE\0\u{1}PRESIGN_ACCESS_MODE_READ_WRITE\0") +/// Requests the aggregate state of one copy job. +public struct Archebase_DataGateway_V1_GetCopyJobRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Stable copy job identifier returned by CreateCopyJob. + public var copyJobID: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} } -extension Archebase_DataGateway_V1_DataGatewayErrorCode: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0DATA_GATEWAY_ERROR_CODE_UNSPECIFIED\0\u{1}DATA_GATEWAY_ERROR_CODE_UNAUTHENTICATED\0\u{1}DATA_GATEWAY_ERROR_CODE_UPLOAD_NOT_FOUND\0\u{1}DATA_GATEWAY_ERROR_CODE_UPLOAD_NOT_OWNED\0\u{1}DATA_GATEWAY_ERROR_CODE_UPLOAD_NOT_REFRESHABLE\0\u{1}DATA_GATEWAY_ERROR_CODE_INVALID_ARGUMENT\0\u{1}DATA_GATEWAY_ERROR_CODE_FAILED_PRECONDITION\0\u{1}DATA_GATEWAY_ERROR_CODE_STS_UNAVAILABLE\0\u{1}DATA_GATEWAY_ERROR_CODE_INTERNAL_ERROR\0") +/// Returns the aggregate state of one copy job. +public struct Archebase_DataGateway_V1_GetCopyJobResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Current job view. + public var job: Archebase_DataGateway_V1_CopyJobView { + get {_job ?? Archebase_DataGateway_V1_CopyJobView()} + set {_job = newValue} + } + /// Returns true if `job` has been explicitly set. + public var hasJob: Bool {self._job != nil} + /// Clears the value of `job`. Subsequent reads from it will return its default value. + public mutating func clearJob() {self._job = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _job: Archebase_DataGateway_V1_CopyJobView? = nil } -extension Archebase_DataGateway_V1_InitDeviceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".InitDeviceRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}device_id\0\u{3}sdk_version\0\u{1}platform\0") +/// User-visible aggregate state for one copy job. +public struct Archebase_DataGateway_V1_CopyJobView: @unchecked Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.deviceID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.sdkVersion) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.platform) }() - default: break - } - } + /// Stable copy job identifier. + public var copyJobID: String { + get {_storage._copyJobID} + set {_uniqueStorage()._copyJobID = newValue} } - public func traverse(visitor: inout V) throws { - if !self.deviceID.isEmpty { - try visitor.visitSingularStringField(value: self.deviceID, fieldNumber: 1) - } - if !self.sdkVersion.isEmpty { - try visitor.visitSingularStringField(value: self.sdkVersion, fieldNumber: 2) - } - if !self.platform.isEmpty { - try visitor.visitSingularStringField(value: self.platform, fieldNumber: 3) - } - try unknownFields.traverse(visitor: &visitor) + /// Current aggregate status. + public var status: Archebase_DataGateway_V1_CopyJobStatus { + get {_storage._status} + set {_uniqueStorage()._status = newValue} } - public static func ==(lhs: Archebase_DataGateway_V1_InitDeviceRequest, rhs: Archebase_DataGateway_V1_InitDeviceRequest) -> Bool { - if lhs.deviceID != rhs.deviceID {return false} - if lhs.sdkVersion != rhs.sdkVersion {return false} - if lhs.platform != rhs.platform {return false} - if lhs.unknownFields != rhs.unknownFields {return false} - return true + /// Destination selected at create time. + public var destination: Archebase_DataGateway_V1_CopyDestination { + get {_storage._destination ?? Archebase_DataGateway_V1_CopyDestination()} + set {_uniqueStorage()._destination = newValue} } -} + /// Returns true if `destination` has been explicitly set. + public var hasDestination: Bool {_storage._destination != nil} + /// Clears the value of `destination`. Subsequent reads from it will return its default value. + public mutating func clearDestination() {_uniqueStorage()._destination = nil} -extension Archebase_DataGateway_V1_InitDeviceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".InitDeviceResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}api_key\0\u{1}tags\0") + /// Total number of items in the job. + public var totalItems: Int32 { + get {_storage._totalItems} + set {_uniqueStorage()._totalItems = newValue} + } - public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.apiKey) }() - case 2: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.tags) }() - default: break - } - } + /// Number of items that finished successfully. + public var completedItems: Int32 { + get {_storage._completedItems} + set {_uniqueStorage()._completedItems = newValue} } - public func traverse(visitor: inout V) throws { - if !self.apiKey.isEmpty { - try visitor.visitSingularStringField(value: self.apiKey, fieldNumber: 1) + /// Number of terminally failed items. + public var failedItems: Int32 { + get {_storage._failedItems} + set {_uniqueStorage()._failedItems = newValue} + } + + /// Number of items skipped by overwrite policy. + public var skippedItems: Int32 { + get {_storage._skippedItems} + set {_uniqueStorage()._skippedItems = newValue} + } + + /// Total source bytes planned for the job. + public var totalBytes: Int64 { + get {_storage._totalBytes} + set {_uniqueStorage()._totalBytes = newValue} + } + + /// Bytes confirmed copied or skipped so far. + public var copiedBytes: Int64 { + get {_storage._copiedBytes} + set {_uniqueStorage()._copiedBytes = newValue} + } + + /// Unix seconds when the job was created. + public var createdAtUnix: Int64 { + get {_storage._createdAtUnix} + set {_uniqueStorage()._createdAtUnix = newValue} + } + + /// Unix seconds when execution first started, or zero if not started. + public var startedAtUnix: Int64 { + get {_storage._startedAtUnix} + set {_uniqueStorage()._startedAtUnix = newValue} + } + + /// Unix seconds when the job reached a terminal state, or zero otherwise. + public var finishedAtUnix: Int64 { + get {_storage._finishedAtUnix} + set {_uniqueStorage()._finishedAtUnix = newValue} + } + + /// Terminal or job-level failure reason, if any. + public var terminalReason: String { + get {_storage._terminalReason} + set {_uniqueStorage()._terminalReason = newValue} + } + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _storage = _StorageClass.defaultInstance +} + +/// Requests item-level copy state for one job. +public struct Archebase_DataGateway_V1_ListCopyJobItemsRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Stable copy job identifier returned by CreateCopyJob. + public var copyJobID: String = String() + + /// Optional status filter. Empty means all item statuses. + public var statuses: [Archebase_DataGateway_V1_CopyItemStatus] = [] + + /// Maximum number of items to return. + public var pageSize: Int32 = 0 + + /// Opaque token returned by a previous page. + public var pageToken: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// User-visible per-file state for one copy item. +public struct Archebase_DataGateway_V1_CopyJobItemView: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// File ID requested by the user. + public var fileID: String = String() + + /// Destination object key rendered from the job key template. + public var destinationObjectKey: String = String() + + /// Current item status. + public var status: Archebase_DataGateway_V1_CopyItemStatus = .unspecified + + /// Planned source object size, in bytes. + public var sourceSize: Int64 = 0 + + /// Bytes confirmed copied for this item. + public var copiedBytes: Int64 = 0 + + /// Stable machine-readable failure code, if any. + public var errorCode: String = String() + + /// Redacted human-readable failure message, if any. + public var errorMessage: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Returns one page of copy job items. +public struct Archebase_DataGateway_V1_ListCopyJobItemsResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Copy items in page order. + public var items: [Archebase_DataGateway_V1_CopyJobItemView] = [] + + /// Opaque token for the next page, or empty when no more pages exist. + public var nextPageToken: String = String() + + /// Total number of items matching the filter. + public var totalSize: Int32 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Requests cancellation of one copy job. +public struct Archebase_DataGateway_V1_CancelCopyJobRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Stable copy job identifier returned by CreateCopyJob. + public var copyJobID: String = String() + + /// Optional operator or user reason recorded in job audit fields. + public var reason: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Returns the state after a cancel request is accepted. +public struct Archebase_DataGateway_V1_CancelCopyJobResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Stable copy job identifier. + public var copyJobID: String = String() + + /// Status after cancellation was requested. + public var status: Archebase_DataGateway_V1_CopyJobStatus = .unspecified + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Identifies an object within the configured OSS bucket. +public struct Archebase_DataGateway_V1_StorageObject: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Target bucket name. + public var bucket: String = String() + + /// Target object key. + public var objectKey: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Represents one presigned HTTP operation. +public struct Archebase_DataGateway_V1_PresignedOperation: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// HTTP method that must be used by the caller. + public var method: String = String() + + /// Fully qualified presigned URI. + public var uri: String = String() + + /// Required request headers. + public var headers: Dictionary = [:] + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} +} + +/// Requests presigned access for a single object. +public struct Archebase_DataGateway_V1_PresignObjectRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Object to presign. + public var object: Archebase_DataGateway_V1_StorageObject { + get {_object ?? Archebase_DataGateway_V1_StorageObject()} + set {_object = newValue} + } + /// Returns true if `object` has been explicitly set. + public var hasObject: Bool {self._object != nil} + /// Clears the value of `object`. Subsequent reads from it will return its default value. + public mutating func clearObject() {self._object = nil} + + /// Requested access mode. + public var accessMode: Archebase_DataGateway_V1_PresignAccessMode = .unspecified + + /// Requested presign TTL in seconds. + public var expiresInSeconds: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _object: Archebase_DataGateway_V1_StorageObject? = nil +} + +/// Returns presigned operations for the requested object. +public struct Archebase_DataGateway_V1_PresignObjectResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Object that was presigned. + public var object: Archebase_DataGateway_V1_StorageObject { + get {_object ?? Archebase_DataGateway_V1_StorageObject()} + set {_object = newValue} + } + /// Returns true if `object` has been explicitly set. + public var hasObject: Bool {self._object != nil} + /// Clears the value of `object`. Subsequent reads from it will return its default value. + public mutating func clearObject() {self._object = nil} + + /// Presigned read operation, present for read-enabled modes. + public var read: Archebase_DataGateway_V1_PresignedOperation { + get {_read ?? Archebase_DataGateway_V1_PresignedOperation()} + set {_read = newValue} + } + /// Returns true if `read` has been explicitly set. + public var hasRead: Bool {self._read != nil} + /// Clears the value of `read`. Subsequent reads from it will return its default value. + public mutating func clearRead() {self._read = nil} + + /// Presigned write operation, present for write-enabled modes. + public var write: Archebase_DataGateway_V1_PresignedOperation { + get {_write ?? Archebase_DataGateway_V1_PresignedOperation()} + set {_write = newValue} + } + /// Returns true if `write` has been explicitly set. + public var hasWrite: Bool {self._write != nil} + /// Clears the value of `write`. Subsequent reads from it will return its default value. + public mutating func clearWrite() {self._write = nil} + + /// Absolute expiration time as Unix seconds. + public var expiresAtUnix: Int64 = 0 + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _object: Archebase_DataGateway_V1_StorageObject? = nil + fileprivate var _read: Archebase_DataGateway_V1_PresignedOperation? = nil + fileprivate var _write: Archebase_DataGateway_V1_PresignedOperation? = nil +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "archebase.data_gateway.v1" + +extension Archebase_DataGateway_V1_UploadRecoveryAction: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0UPLOAD_RECOVERY_ACTION_UNSPECIFIED\0\u{1}UPLOAD_RECOVERY_ACTION_CONTINUE\0\u{1}UPLOAD_RECOVERY_ACTION_COMPLETE_ONLY\0\u{1}UPLOAD_RECOVERY_ACTION_RESTART\0\u{1}UPLOAD_RECOVERY_ACTION_ABORT\0") +} + +extension Archebase_DataGateway_V1_LogicalUploadStatus: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0LOGICAL_UPLOAD_STATUS_UNSPECIFIED\0\u{1}LOGICAL_UPLOAD_STATUS_ACTIVE\0\u{1}LOGICAL_UPLOAD_STATUS_COMPLETING\0\u{1}LOGICAL_UPLOAD_STATUS_COMPLETED\0\u{1}LOGICAL_UPLOAD_STATUS_TERMINAL\0") +} + +extension Archebase_DataGateway_V1_CopyJobStatus: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0COPY_JOB_STATUS_UNSPECIFIED\0\u{1}COPY_JOB_STATUS_QUEUED\0\u{1}COPY_JOB_STATUS_RUNNING\0\u{1}COPY_JOB_STATUS_SUCCEEDED\0\u{1}COPY_JOB_STATUS_PARTIAL_FAILED\0\u{1}COPY_JOB_STATUS_FAILED\0\u{1}COPY_JOB_STATUS_CANCELING\0\u{1}COPY_JOB_STATUS_CANCELED\0") +} + +extension Archebase_DataGateway_V1_CopyItemStatus: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0COPY_ITEM_STATUS_UNSPECIFIED\0\u{1}COPY_ITEM_STATUS_QUEUED\0\u{1}COPY_ITEM_STATUS_COPYING\0\u{1}COPY_ITEM_STATUS_SUCCEEDED\0\u{1}COPY_ITEM_STATUS_FAILED_TERMINAL\0\u{1}COPY_ITEM_STATUS_SKIPPED\0\u{1}COPY_ITEM_STATUS_CANCELED\0") +} + +extension Archebase_DataGateway_V1_PresignAccessMode: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0PRESIGN_ACCESS_MODE_UNSPECIFIED\0\u{1}PRESIGN_ACCESS_MODE_READ\0\u{1}PRESIGN_ACCESS_MODE_WRITE\0\u{1}PRESIGN_ACCESS_MODE_READ_WRITE\0") +} + +extension Archebase_DataGateway_V1_DataGatewayErrorCode: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0DATA_GATEWAY_ERROR_CODE_UNSPECIFIED\0\u{1}DATA_GATEWAY_ERROR_CODE_UNAUTHENTICATED\0\u{1}DATA_GATEWAY_ERROR_CODE_UPLOAD_NOT_FOUND\0\u{1}DATA_GATEWAY_ERROR_CODE_UPLOAD_NOT_OWNED\0\u{1}DATA_GATEWAY_ERROR_CODE_UPLOAD_NOT_REFRESHABLE\0\u{1}DATA_GATEWAY_ERROR_CODE_INVALID_ARGUMENT\0\u{1}DATA_GATEWAY_ERROR_CODE_FAILED_PRECONDITION\0\u{1}DATA_GATEWAY_ERROR_CODE_STS_UNAVAILABLE\0\u{1}DATA_GATEWAY_ERROR_CODE_INTERNAL_ERROR\0") +} + +extension Archebase_DataGateway_V1_InitDeviceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InitDeviceRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}device_id\0\u{3}sdk_version\0\u{1}platform\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.deviceID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.sdkVersion) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.platform) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.deviceID.isEmpty { + try visitor.visitSingularStringField(value: self.deviceID, fieldNumber: 1) + } + if !self.sdkVersion.isEmpty { + try visitor.visitSingularStringField(value: self.sdkVersion, fieldNumber: 2) + } + if !self.platform.isEmpty { + try visitor.visitSingularStringField(value: self.platform, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_InitDeviceRequest, rhs: Archebase_DataGateway_V1_InitDeviceRequest) -> Bool { + if lhs.deviceID != rhs.deviceID {return false} + if lhs.sdkVersion != rhs.sdkVersion {return false} + if lhs.platform != rhs.platform {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_ReinitDeviceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ReinitDeviceRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}device_id\0\u{3}sdk_version\0\u{1}platform\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.deviceID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.sdkVersion) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.platform) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.deviceID.isEmpty { + try visitor.visitSingularStringField(value: self.deviceID, fieldNumber: 1) + } + if !self.sdkVersion.isEmpty { + try visitor.visitSingularStringField(value: self.sdkVersion, fieldNumber: 2) + } + if !self.platform.isEmpty { + try visitor.visitSingularStringField(value: self.platform, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_ReinitDeviceRequest, rhs: Archebase_DataGateway_V1_ReinitDeviceRequest) -> Bool { + if lhs.deviceID != rhs.deviceID {return false} + if lhs.sdkVersion != rhs.sdkVersion {return false} + if lhs.platform != rhs.platform {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_InitDeviceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".InitDeviceResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}api_key\0\u{1}tags\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.apiKey) }() + case 2: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.tags) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.apiKey.isEmpty { + try visitor.visitSingularStringField(value: self.apiKey, fieldNumber: 1) + } + if !self.tags.isEmpty { + try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.tags, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_InitDeviceResponse, rhs: Archebase_DataGateway_V1_InitDeviceResponse) -> Bool { + if lhs.apiKey != rhs.apiKey {return false} + if lhs.tags != rhs.tags {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_UploadCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".UploadCredentials" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}bucket\0\u{1}endpoint\0\u{3}object_key\0\u{3}sts_access_key_id\0\u{3}sts_access_key_secret\0\u{3}sts_security_token\0\u{3}sts_expire_at_unix\0\u{3}part_size_bytes\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.bucket) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.endpoint) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.objectKey) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.stsAccessKeyID) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.stsAccessKeySecret) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.stsSecurityToken) }() + case 7: try { try decoder.decodeSingularInt64Field(value: &self.stsExpireAtUnix) }() + case 8: try { try decoder.decodeSingularInt64Field(value: &self.partSizeBytes) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.bucket.isEmpty { + try visitor.visitSingularStringField(value: self.bucket, fieldNumber: 1) + } + if !self.endpoint.isEmpty { + try visitor.visitSingularStringField(value: self.endpoint, fieldNumber: 2) + } + if !self.objectKey.isEmpty { + try visitor.visitSingularStringField(value: self.objectKey, fieldNumber: 3) + } + if !self.stsAccessKeyID.isEmpty { + try visitor.visitSingularStringField(value: self.stsAccessKeyID, fieldNumber: 4) + } + if !self.stsAccessKeySecret.isEmpty { + try visitor.visitSingularStringField(value: self.stsAccessKeySecret, fieldNumber: 5) + } + if !self.stsSecurityToken.isEmpty { + try visitor.visitSingularStringField(value: self.stsSecurityToken, fieldNumber: 6) + } + if self.stsExpireAtUnix != 0 { + try visitor.visitSingularInt64Field(value: self.stsExpireAtUnix, fieldNumber: 7) + } + if self.partSizeBytes != 0 { + try visitor.visitSingularInt64Field(value: self.partSizeBytes, fieldNumber: 8) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_UploadCredentials, rhs: Archebase_DataGateway_V1_UploadCredentials) -> Bool { + if lhs.bucket != rhs.bucket {return false} + if lhs.endpoint != rhs.endpoint {return false} + if lhs.objectKey != rhs.objectKey {return false} + if lhs.stsAccessKeyID != rhs.stsAccessKeyID {return false} + if lhs.stsAccessKeySecret != rhs.stsAccessKeySecret {return false} + if lhs.stsSecurityToken != rhs.stsSecurityToken {return false} + if lhs.stsExpireAtUnix != rhs.stsExpireAtUnix {return false} + if lhs.partSizeBytes != rhs.partSizeBytes {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_CreateLogicalUploadRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateLogicalUploadRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}client_hints\0\u{3}restart_from_upload_id\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.clientHints) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.restartFromUploadID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.clientHints.isEmpty { + try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.clientHints, fieldNumber: 1) + } + if !self.restartFromUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.restartFromUploadID, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_CreateLogicalUploadRequest, rhs: Archebase_DataGateway_V1_CreateLogicalUploadRequest) -> Bool { + if lhs.clientHints != rhs.clientHints {return false} + if lhs.restartFromUploadID != rhs.restartFromUploadID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_CreateLogicalUploadResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateLogicalUploadResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}upload_id\0\u{1}credentials\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._credentials) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.logicalUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + } + if !self.uploadID.isEmpty { + try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 2) + } + try { if let v = self._credentials { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_CreateLogicalUploadResponse, rhs: Archebase_DataGateway_V1_CreateLogicalUploadResponse) -> Bool { + if lhs.logicalUploadID != rhs.logicalUploadID {return false} + if lhs.uploadID != rhs.uploadID {return false} + if lhs._credentials != rhs._credentials {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_GetUploadRecoveryRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetUploadRecoveryRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.logicalUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_GetUploadRecoveryRequest, rhs: Archebase_DataGateway_V1_GetUploadRecoveryRequest) -> Bool { + if lhs.logicalUploadID != rhs.logicalUploadID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_GetUploadRecoveryResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetUploadRecoveryResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}logical_upload_status\0\u{3}current_upload_id\0\u{1}bucket\0\u{1}endpoint\0\u{3}object_key\0\u{3}can_refresh_credentials\0\u{3}restart_allowed\0\u{3}terminal_reason\0\u{3}credential_refresh_count\0\u{3}session_expire_at_unix\0\u{3}next_action\0\u{3}completed_part_count\0\u{3}oss_object_etag\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.logicalUploadStatus) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.currentUploadID) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.bucket) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.endpoint) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.objectKey) }() + case 7: try { try decoder.decodeSingularBoolField(value: &self.canRefreshCredentials) }() + case 8: try { try decoder.decodeSingularBoolField(value: &self.restartAllowed) }() + case 9: try { try decoder.decodeSingularStringField(value: &self.terminalReason) }() + case 10: try { try decoder.decodeSingularInt32Field(value: &self.credentialRefreshCount) }() + case 11: try { try decoder.decodeSingularInt64Field(value: &self.sessionExpireAtUnix) }() + case 12: try { try decoder.decodeSingularEnumField(value: &self.nextAction) }() + case 13: try { try decoder.decodeSingularInt32Field(value: &self.completedPartCount) }() + case 14: try { try decoder.decodeSingularStringField(value: &self.ossObjectEtag) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.logicalUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + } + if self.logicalUploadStatus != .unspecified { + try visitor.visitSingularEnumField(value: self.logicalUploadStatus, fieldNumber: 2) + } + if !self.currentUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.currentUploadID, fieldNumber: 3) + } + if !self.bucket.isEmpty { + try visitor.visitSingularStringField(value: self.bucket, fieldNumber: 4) + } + if !self.endpoint.isEmpty { + try visitor.visitSingularStringField(value: self.endpoint, fieldNumber: 5) + } + if !self.objectKey.isEmpty { + try visitor.visitSingularStringField(value: self.objectKey, fieldNumber: 6) + } + if self.canRefreshCredentials != false { + try visitor.visitSingularBoolField(value: self.canRefreshCredentials, fieldNumber: 7) + } + if self.restartAllowed != false { + try visitor.visitSingularBoolField(value: self.restartAllowed, fieldNumber: 8) + } + if !self.terminalReason.isEmpty { + try visitor.visitSingularStringField(value: self.terminalReason, fieldNumber: 9) + } + if self.credentialRefreshCount != 0 { + try visitor.visitSingularInt32Field(value: self.credentialRefreshCount, fieldNumber: 10) + } + if self.sessionExpireAtUnix != 0 { + try visitor.visitSingularInt64Field(value: self.sessionExpireAtUnix, fieldNumber: 11) + } + if self.nextAction != .unspecified { + try visitor.visitSingularEnumField(value: self.nextAction, fieldNumber: 12) + } + if self.completedPartCount != 0 { + try visitor.visitSingularInt32Field(value: self.completedPartCount, fieldNumber: 13) + } + if !self.ossObjectEtag.isEmpty { + try visitor.visitSingularStringField(value: self.ossObjectEtag, fieldNumber: 14) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_GetUploadRecoveryResponse, rhs: Archebase_DataGateway_V1_GetUploadRecoveryResponse) -> Bool { + if lhs.logicalUploadID != rhs.logicalUploadID {return false} + if lhs.logicalUploadStatus != rhs.logicalUploadStatus {return false} + if lhs.currentUploadID != rhs.currentUploadID {return false} + if lhs.bucket != rhs.bucket {return false} + if lhs.endpoint != rhs.endpoint {return false} + if lhs.objectKey != rhs.objectKey {return false} + if lhs.canRefreshCredentials != rhs.canRefreshCredentials {return false} + if lhs.restartAllowed != rhs.restartAllowed {return false} + if lhs.terminalReason != rhs.terminalReason {return false} + if lhs.credentialRefreshCount != rhs.credentialRefreshCount {return false} + if lhs.sessionExpireAtUnix != rhs.sessionExpireAtUnix {return false} + if lhs.nextAction != rhs.nextAction {return false} + if lhs.completedPartCount != rhs.completedPartCount {return false} + if lhs.ossObjectEtag != rhs.ossObjectEtag {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_ReissueUploadCredentialsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ReissueUploadCredentialsRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}upload_id\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.uploadID.isEmpty { + try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_ReissueUploadCredentialsRequest, rhs: Archebase_DataGateway_V1_ReissueUploadCredentialsRequest) -> Bool { + if lhs.uploadID != rhs.uploadID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_ReissueUploadCredentialsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ReissueUploadCredentialsResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}upload_id\0\u{1}credentials\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._credentials) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.logicalUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + } + if !self.uploadID.isEmpty { + try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 2) + } + try { if let v = self._credentials { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_ReissueUploadCredentialsResponse, rhs: Archebase_DataGateway_V1_ReissueUploadCredentialsResponse) -> Bool { + if lhs.logicalUploadID != rhs.logicalUploadID {return false} + if lhs.uploadID != rhs.uploadID {return false} + if lhs._credentials != rhs._credentials {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_AbortUploadRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AbortUploadRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{1}reason\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.reason) }() + default: break + } } - if !self.tags.isEmpty { - try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.tags, fieldNumber: 2) + } + + public func traverse(visitor: inout V) throws { + if !self.logicalUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + } + if !self.reason.isEmpty { + try visitor.visitSingularStringField(value: self.reason, fieldNumber: 2) } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_InitDeviceResponse, rhs: Archebase_DataGateway_V1_InitDeviceResponse) -> Bool { - if lhs.apiKey != rhs.apiKey {return false} - if lhs.tags != rhs.tags {return false} + public static func ==(lhs: Archebase_DataGateway_V1_AbortUploadRequest, rhs: Archebase_DataGateway_V1_AbortUploadRequest) -> Bool { + if lhs.logicalUploadID != rhs.logicalUploadID {return false} + if lhs.reason != rhs.reason {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_UploadCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".UploadCredentials" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}bucket\0\u{1}endpoint\0\u{3}object_key\0\u{3}sts_access_key_id\0\u{3}sts_access_key_secret\0\u{3}sts_security_token\0\u{3}sts_expire_at_unix\0\u{3}part_size_bytes\0") +extension Archebase_DataGateway_V1_AbortUploadResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".AbortUploadResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}upload_id\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -683,64 +1652,103 @@ extension Archebase_DataGateway_V1_UploadCredentials: SwiftProtobuf.Message, Swi // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.bucket) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.endpoint) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.objectKey) }() - case 4: try { try decoder.decodeSingularStringField(value: &self.stsAccessKeyID) }() - case 5: try { try decoder.decodeSingularStringField(value: &self.stsAccessKeySecret) }() - case 6: try { try decoder.decodeSingularStringField(value: &self.stsSecurityToken) }() - case 7: try { try decoder.decodeSingularInt64Field(value: &self.stsExpireAtUnix) }() - case 8: try { try decoder.decodeSingularInt64Field(value: &self.partSizeBytes) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() default: break } } } public func traverse(visitor: inout V) throws { - if !self.bucket.isEmpty { - try visitor.visitSingularStringField(value: self.bucket, fieldNumber: 1) + if !self.logicalUploadID.isEmpty { + try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) } - if !self.endpoint.isEmpty { - try visitor.visitSingularStringField(value: self.endpoint, fieldNumber: 2) + if !self.uploadID.isEmpty { + try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 2) } - if !self.objectKey.isEmpty { - try visitor.visitSingularStringField(value: self.objectKey, fieldNumber: 3) + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_AbortUploadResponse, rhs: Archebase_DataGateway_V1_AbortUploadResponse) -> Bool { + if lhs.logicalUploadID != rhs.logicalUploadID {return false} + if lhs.uploadID != rhs.uploadID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_CompleteUploadRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CompleteUploadRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}upload_id\0\u{3}file_size\0\u{3}raw_tags\0\u{3}completed_part_count\0\u{3}oss_object_etag\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self.fileSize) }() + case 3: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.rawTags) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &self.completedPartCount) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.ossObjectEtag) }() + default: break + } } - if !self.stsAccessKeyID.isEmpty { - try visitor.visitSingularStringField(value: self.stsAccessKeyID, fieldNumber: 4) + } + + public func traverse(visitor: inout V) throws { + if !self.uploadID.isEmpty { + try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 1) } - if !self.stsAccessKeySecret.isEmpty { - try visitor.visitSingularStringField(value: self.stsAccessKeySecret, fieldNumber: 5) + if self.fileSize != 0 { + try visitor.visitSingularInt64Field(value: self.fileSize, fieldNumber: 2) } - if !self.stsSecurityToken.isEmpty { - try visitor.visitSingularStringField(value: self.stsSecurityToken, fieldNumber: 6) + if !self.rawTags.isEmpty { + try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.rawTags, fieldNumber: 3) } - if self.stsExpireAtUnix != 0 { - try visitor.visitSingularInt64Field(value: self.stsExpireAtUnix, fieldNumber: 7) + if self.completedPartCount != 0 { + try visitor.visitSingularInt32Field(value: self.completedPartCount, fieldNumber: 4) } - if self.partSizeBytes != 0 { - try visitor.visitSingularInt64Field(value: self.partSizeBytes, fieldNumber: 8) + if !self.ossObjectEtag.isEmpty { + try visitor.visitSingularStringField(value: self.ossObjectEtag, fieldNumber: 5) } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_UploadCredentials, rhs: Archebase_DataGateway_V1_UploadCredentials) -> Bool { - if lhs.bucket != rhs.bucket {return false} - if lhs.endpoint != rhs.endpoint {return false} - if lhs.objectKey != rhs.objectKey {return false} - if lhs.stsAccessKeyID != rhs.stsAccessKeyID {return false} - if lhs.stsAccessKeySecret != rhs.stsAccessKeySecret {return false} - if lhs.stsSecurityToken != rhs.stsSecurityToken {return false} - if lhs.stsExpireAtUnix != rhs.stsExpireAtUnix {return false} - if lhs.partSizeBytes != rhs.partSizeBytes {return false} + public static func ==(lhs: Archebase_DataGateway_V1_CompleteUploadRequest, rhs: Archebase_DataGateway_V1_CompleteUploadRequest) -> Bool { + if lhs.uploadID != rhs.uploadID {return false} + if lhs.fileSize != rhs.fileSize {return false} + if lhs.rawTags != rhs.rawTags {return false} + if lhs.completedPartCount != rhs.completedPartCount {return false} + if lhs.ossObjectEtag != rhs.ossObjectEtag {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_CreateLogicalUploadRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".CreateLogicalUploadRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}client_hints\0\u{3}restart_from_upload_id\0") +extension Archebase_DataGateway_V1_CompleteUploadResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CompleteUploadResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_CompleteUploadResponse, rhs: Archebase_DataGateway_V1_CompleteUploadResponse) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_RequestDownloadRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RequestDownloadRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}file_ids\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -748,34 +1756,212 @@ extension Archebase_DataGateway_V1_CreateLogicalUploadRequest: SwiftProtobuf.Mes // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.clientHints) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.restartFromUploadID) }() + case 1: try { try decoder.decodeRepeatedStringField(value: &self.fileIds) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.fileIds.isEmpty { + try visitor.visitRepeatedStringField(value: self.fileIds, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_RequestDownloadRequest, rhs: Archebase_DataGateway_V1_RequestDownloadRequest) -> Bool { + if lhs.fileIds != rhs.fileIds {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_DownloadObjectLocation: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".DownloadObjectLocation" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}file_id\0\u{1}read\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.fileID) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._read) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.fileID.isEmpty { + try visitor.visitSingularStringField(value: self.fileID, fieldNumber: 1) + } + try { if let v = self._read { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_DownloadObjectLocation, rhs: Archebase_DataGateway_V1_DownloadObjectLocation) -> Bool { + if lhs.fileID != rhs.fileID {return false} + if lhs._read != rhs._read {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_RequestDownloadResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".RequestDownloadResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}files\0\u{3}expires_at_unix\0\u{3}large_file_threshold_bytes\0\u{3}range_part_size_bytes\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.files) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self.expiresAtUnix) }() + case 3: try { try decoder.decodeSingularInt64Field(value: &self.largeFileThresholdBytes) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self.rangePartSizeBytes) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.files.isEmpty { + try visitor.visitRepeatedMessageField(value: self.files, fieldNumber: 1) + } + if self.expiresAtUnix != 0 { + try visitor.visitSingularInt64Field(value: self.expiresAtUnix, fieldNumber: 2) + } + if self.largeFileThresholdBytes != 0 { + try visitor.visitSingularInt64Field(value: self.largeFileThresholdBytes, fieldNumber: 3) + } + if self.rangePartSizeBytes != 0 { + try visitor.visitSingularInt64Field(value: self.rangePartSizeBytes, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_RequestDownloadResponse, rhs: Archebase_DataGateway_V1_RequestDownloadResponse) -> Bool { + if lhs.files != rhs.files {return false} + if lhs.expiresAtUnix != rhs.expiresAtUnix {return false} + if lhs.largeFileThresholdBytes != rhs.largeFileThresholdBytes {return false} + if lhs.rangePartSizeBytes != rhs.rangePartSizeBytes {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_CreateCopyJobRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateCopyJobRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}file_ids\0\u{1}destination\0\u{3}idempotency_key\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedStringField(value: &self.fileIds) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._destination) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.idempotencyKey) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.fileIds.isEmpty { + try visitor.visitRepeatedStringField(value: self.fileIds, fieldNumber: 1) + } + try { if let v = self._destination { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + if !self.idempotencyKey.isEmpty { + try visitor.visitSingularStringField(value: self.idempotencyKey, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Archebase_DataGateway_V1_CreateCopyJobRequest, rhs: Archebase_DataGateway_V1_CreateCopyJobRequest) -> Bool { + if lhs.fileIds != rhs.fileIds {return false} + if lhs._destination != rhs._destination {return false} + if lhs.idempotencyKey != rhs.idempotencyKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Archebase_DataGateway_V1_CopyDestination: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CopyDestination" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}bucket\0\u{1}endpoint\0\u{1}region\0\u{3}key_template\0\u{3}account_id\0\u{3}kms_key_id\0") + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.bucket) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.endpoint) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.region) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.keyTemplate) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.accountID) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.kmsKeyID) }() default: break } } - } - - public func traverse(visitor: inout V) throws { - if !self.clientHints.isEmpty { - try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.clientHints, fieldNumber: 1) + } + + public func traverse(visitor: inout V) throws { + if !self.bucket.isEmpty { + try visitor.visitSingularStringField(value: self.bucket, fieldNumber: 1) + } + if !self.endpoint.isEmpty { + try visitor.visitSingularStringField(value: self.endpoint, fieldNumber: 2) + } + if !self.region.isEmpty { + try visitor.visitSingularStringField(value: self.region, fieldNumber: 3) } - if !self.restartFromUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.restartFromUploadID, fieldNumber: 2) + if !self.keyTemplate.isEmpty { + try visitor.visitSingularStringField(value: self.keyTemplate, fieldNumber: 4) + } + if !self.accountID.isEmpty { + try visitor.visitSingularStringField(value: self.accountID, fieldNumber: 5) + } + if !self.kmsKeyID.isEmpty { + try visitor.visitSingularStringField(value: self.kmsKeyID, fieldNumber: 6) } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_CreateLogicalUploadRequest, rhs: Archebase_DataGateway_V1_CreateLogicalUploadRequest) -> Bool { - if lhs.clientHints != rhs.clientHints {return false} - if lhs.restartFromUploadID != rhs.restartFromUploadID {return false} + public static func ==(lhs: Archebase_DataGateway_V1_CopyDestination, rhs: Archebase_DataGateway_V1_CopyDestination) -> Bool { + if lhs.bucket != rhs.bucket {return false} + if lhs.endpoint != rhs.endpoint {return false} + if lhs.region != rhs.region {return false} + if lhs.keyTemplate != rhs.keyTemplate {return false} + if lhs.accountID != rhs.accountID {return false} + if lhs.kmsKeyID != rhs.kmsKeyID {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_CreateLogicalUploadResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".CreateLogicalUploadResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}upload_id\0\u{1}credentials\0") +extension Archebase_DataGateway_V1_CreateCopyJobResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CreateCopyJobResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}copy_job_id\0\u{1}status\0\u{3}total_items\0\u{3}estimated_total_bytes\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -783,43 +1969,44 @@ extension Archebase_DataGateway_V1_CreateLogicalUploadResponse: SwiftProtobuf.Me // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._credentials) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.copyJobID) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.status) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.totalItems) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self.estimatedTotalBytes) }() default: break } } } public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.logicalUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + if !self.copyJobID.isEmpty { + try visitor.visitSingularStringField(value: self.copyJobID, fieldNumber: 1) } - if !self.uploadID.isEmpty { - try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 2) + if self.status != .unspecified { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 2) + } + if self.totalItems != 0 { + try visitor.visitSingularInt32Field(value: self.totalItems, fieldNumber: 3) + } + if self.estimatedTotalBytes != 0 { + try visitor.visitSingularInt64Field(value: self.estimatedTotalBytes, fieldNumber: 4) } - try { if let v = self._credentials { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_CreateLogicalUploadResponse, rhs: Archebase_DataGateway_V1_CreateLogicalUploadResponse) -> Bool { - if lhs.logicalUploadID != rhs.logicalUploadID {return false} - if lhs.uploadID != rhs.uploadID {return false} - if lhs._credentials != rhs._credentials {return false} + public static func ==(lhs: Archebase_DataGateway_V1_CreateCopyJobResponse, rhs: Archebase_DataGateway_V1_CreateCopyJobResponse) -> Bool { + if lhs.copyJobID != rhs.copyJobID {return false} + if lhs.status != rhs.status {return false} + if lhs.totalItems != rhs.totalItems {return false} + if lhs.estimatedTotalBytes != rhs.estimatedTotalBytes {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_GetUploadRecoveryRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetUploadRecoveryRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0") +extension Archebase_DataGateway_V1_GetCopyJobRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetCopyJobRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}copy_job_id\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -827,29 +2014,29 @@ extension Archebase_DataGateway_V1_GetUploadRecoveryRequest: SwiftProtobuf.Messa // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.copyJobID) }() default: break } } } public func traverse(visitor: inout V) throws { - if !self.logicalUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + if !self.copyJobID.isEmpty { + try visitor.visitSingularStringField(value: self.copyJobID, fieldNumber: 1) } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_GetUploadRecoveryRequest, rhs: Archebase_DataGateway_V1_GetUploadRecoveryRequest) -> Bool { - if lhs.logicalUploadID != rhs.logicalUploadID {return false} + public static func ==(lhs: Archebase_DataGateway_V1_GetCopyJobRequest, rhs: Archebase_DataGateway_V1_GetCopyJobRequest) -> Bool { + if lhs.copyJobID != rhs.copyJobID {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_GetUploadRecoveryResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".GetUploadRecoveryResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}logical_upload_status\0\u{3}current_upload_id\0\u{1}bucket\0\u{1}endpoint\0\u{3}object_key\0\u{3}can_refresh_credentials\0\u{3}restart_allowed\0\u{3}terminal_reason\0\u{3}credential_refresh_count\0\u{3}session_expire_at_unix\0\u{3}next_action\0\u{3}completed_part_count\0\u{3}oss_object_etag\0") +extension Archebase_DataGateway_V1_GetCopyJobResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".GetCopyJobResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}job\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -857,124 +2044,187 @@ extension Archebase_DataGateway_V1_GetUploadRecoveryResponse: SwiftProtobuf.Mess // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() - case 2: try { try decoder.decodeSingularEnumField(value: &self.logicalUploadStatus) }() - case 3: try { try decoder.decodeSingularStringField(value: &self.currentUploadID) }() - case 4: try { try decoder.decodeSingularStringField(value: &self.bucket) }() - case 5: try { try decoder.decodeSingularStringField(value: &self.endpoint) }() - case 6: try { try decoder.decodeSingularStringField(value: &self.objectKey) }() - case 7: try { try decoder.decodeSingularBoolField(value: &self.canRefreshCredentials) }() - case 8: try { try decoder.decodeSingularBoolField(value: &self.restartAllowed) }() - case 9: try { try decoder.decodeSingularStringField(value: &self.terminalReason) }() - case 10: try { try decoder.decodeSingularInt32Field(value: &self.credentialRefreshCount) }() - case 11: try { try decoder.decodeSingularInt64Field(value: &self.sessionExpireAtUnix) }() - case 12: try { try decoder.decodeSingularEnumField(value: &self.nextAction) }() - case 13: try { try decoder.decodeSingularInt32Field(value: &self.completedPartCount) }() - case 14: try { try decoder.decodeSingularStringField(value: &self.ossObjectEtag) }() + case 1: try { try decoder.decodeSingularMessageField(value: &self._job) }() default: break } } } public func traverse(visitor: inout V) throws { - if !self.logicalUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) - } - if self.logicalUploadStatus != .unspecified { - try visitor.visitSingularEnumField(value: self.logicalUploadStatus, fieldNumber: 2) - } - if !self.currentUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.currentUploadID, fieldNumber: 3) - } - if !self.bucket.isEmpty { - try visitor.visitSingularStringField(value: self.bucket, fieldNumber: 4) - } - if !self.endpoint.isEmpty { - try visitor.visitSingularStringField(value: self.endpoint, fieldNumber: 5) - } - if !self.objectKey.isEmpty { - try visitor.visitSingularStringField(value: self.objectKey, fieldNumber: 6) - } - if self.canRefreshCredentials != false { - try visitor.visitSingularBoolField(value: self.canRefreshCredentials, fieldNumber: 7) - } - if self.restartAllowed != false { - try visitor.visitSingularBoolField(value: self.restartAllowed, fieldNumber: 8) - } - if !self.terminalReason.isEmpty { - try visitor.visitSingularStringField(value: self.terminalReason, fieldNumber: 9) - } - if self.credentialRefreshCount != 0 { - try visitor.visitSingularInt32Field(value: self.credentialRefreshCount, fieldNumber: 10) - } - if self.sessionExpireAtUnix != 0 { - try visitor.visitSingularInt64Field(value: self.sessionExpireAtUnix, fieldNumber: 11) - } - if self.nextAction != .unspecified { - try visitor.visitSingularEnumField(value: self.nextAction, fieldNumber: 12) - } - if self.completedPartCount != 0 { - try visitor.visitSingularInt32Field(value: self.completedPartCount, fieldNumber: 13) - } - if !self.ossObjectEtag.isEmpty { - try visitor.visitSingularStringField(value: self.ossObjectEtag, fieldNumber: 14) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._job { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_GetUploadRecoveryResponse, rhs: Archebase_DataGateway_V1_GetUploadRecoveryResponse) -> Bool { - if lhs.logicalUploadID != rhs.logicalUploadID {return false} - if lhs.logicalUploadStatus != rhs.logicalUploadStatus {return false} - if lhs.currentUploadID != rhs.currentUploadID {return false} - if lhs.bucket != rhs.bucket {return false} - if lhs.endpoint != rhs.endpoint {return false} - if lhs.objectKey != rhs.objectKey {return false} - if lhs.canRefreshCredentials != rhs.canRefreshCredentials {return false} - if lhs.restartAllowed != rhs.restartAllowed {return false} - if lhs.terminalReason != rhs.terminalReason {return false} - if lhs.credentialRefreshCount != rhs.credentialRefreshCount {return false} - if lhs.sessionExpireAtUnix != rhs.sessionExpireAtUnix {return false} - if lhs.nextAction != rhs.nextAction {return false} - if lhs.completedPartCount != rhs.completedPartCount {return false} - if lhs.ossObjectEtag != rhs.ossObjectEtag {return false} + public static func ==(lhs: Archebase_DataGateway_V1_GetCopyJobResponse, rhs: Archebase_DataGateway_V1_GetCopyJobResponse) -> Bool { + if lhs._job != rhs._job {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_ReissueUploadCredentialsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ReissueUploadCredentialsRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}upload_id\0") +extension Archebase_DataGateway_V1_CopyJobView: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CopyJobView" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}copy_job_id\0\u{1}status\0\u{1}destination\0\u{3}total_items\0\u{3}completed_items\0\u{3}failed_items\0\u{3}skipped_items\0\u{3}total_bytes\0\u{3}copied_bytes\0\u{3}created_at_unix\0\u{3}started_at_unix\0\u{3}finished_at_unix\0\u{3}terminal_reason\0") + + fileprivate class _StorageClass { + var _copyJobID: String = String() + var _status: Archebase_DataGateway_V1_CopyJobStatus = .unspecified + var _destination: Archebase_DataGateway_V1_CopyDestination? = nil + var _totalItems: Int32 = 0 + var _completedItems: Int32 = 0 + var _failedItems: Int32 = 0 + var _skippedItems: Int32 = 0 + var _totalBytes: Int64 = 0 + var _copiedBytes: Int64 = 0 + var _createdAtUnix: Int64 = 0 + var _startedAtUnix: Int64 = 0 + var _finishedAtUnix: Int64 = 0 + var _terminalReason: String = String() + + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _copyJobID = source._copyJobID + _status = source._status + _destination = source._destination + _totalItems = source._totalItems + _completedItems = source._completedItems + _failedItems = source._failedItems + _skippedItems = source._skippedItems + _totalBytes = source._totalBytes + _copiedBytes = source._copiedBytes + _createdAtUnix = source._createdAtUnix + _startedAtUnix = source._startedAtUnix + _finishedAtUnix = source._finishedAtUnix + _terminalReason = source._terminalReason + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } public mutating func decodeMessage(decoder: inout D) throws { - while let fieldNumber = try decoder.nextFieldNumber() { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every case branch when no optimizations are - // enabled. https://github.com/apple/swift-protobuf/issues/1034 - switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() - default: break + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &_storage._copyJobID) }() + case 2: try { try decoder.decodeSingularEnumField(value: &_storage._status) }() + case 3: try { try decoder.decodeSingularMessageField(value: &_storage._destination) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &_storage._totalItems) }() + case 5: try { try decoder.decodeSingularInt32Field(value: &_storage._completedItems) }() + case 6: try { try decoder.decodeSingularInt32Field(value: &_storage._failedItems) }() + case 7: try { try decoder.decodeSingularInt32Field(value: &_storage._skippedItems) }() + case 8: try { try decoder.decodeSingularInt64Field(value: &_storage._totalBytes) }() + case 9: try { try decoder.decodeSingularInt64Field(value: &_storage._copiedBytes) }() + case 10: try { try decoder.decodeSingularInt64Field(value: &_storage._createdAtUnix) }() + case 11: try { try decoder.decodeSingularInt64Field(value: &_storage._startedAtUnix) }() + case 12: try { try decoder.decodeSingularInt64Field(value: &_storage._finishedAtUnix) }() + case 13: try { try decoder.decodeSingularStringField(value: &_storage._terminalReason) }() + default: break + } } } } public func traverse(visitor: inout V) throws { - if !self.uploadID.isEmpty { - try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 1) + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !_storage._copyJobID.isEmpty { + try visitor.visitSingularStringField(value: _storage._copyJobID, fieldNumber: 1) + } + if _storage._status != .unspecified { + try visitor.visitSingularEnumField(value: _storage._status, fieldNumber: 2) + } + try { if let v = _storage._destination { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + if _storage._totalItems != 0 { + try visitor.visitSingularInt32Field(value: _storage._totalItems, fieldNumber: 4) + } + if _storage._completedItems != 0 { + try visitor.visitSingularInt32Field(value: _storage._completedItems, fieldNumber: 5) + } + if _storage._failedItems != 0 { + try visitor.visitSingularInt32Field(value: _storage._failedItems, fieldNumber: 6) + } + if _storage._skippedItems != 0 { + try visitor.visitSingularInt32Field(value: _storage._skippedItems, fieldNumber: 7) + } + if _storage._totalBytes != 0 { + try visitor.visitSingularInt64Field(value: _storage._totalBytes, fieldNumber: 8) + } + if _storage._copiedBytes != 0 { + try visitor.visitSingularInt64Field(value: _storage._copiedBytes, fieldNumber: 9) + } + if _storage._createdAtUnix != 0 { + try visitor.visitSingularInt64Field(value: _storage._createdAtUnix, fieldNumber: 10) + } + if _storage._startedAtUnix != 0 { + try visitor.visitSingularInt64Field(value: _storage._startedAtUnix, fieldNumber: 11) + } + if _storage._finishedAtUnix != 0 { + try visitor.visitSingularInt64Field(value: _storage._finishedAtUnix, fieldNumber: 12) + } + if !_storage._terminalReason.isEmpty { + try visitor.visitSingularStringField(value: _storage._terminalReason, fieldNumber: 13) + } } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_ReissueUploadCredentialsRequest, rhs: Archebase_DataGateway_V1_ReissueUploadCredentialsRequest) -> Bool { - if lhs.uploadID != rhs.uploadID {return false} + public static func ==(lhs: Archebase_DataGateway_V1_CopyJobView, rhs: Archebase_DataGateway_V1_CopyJobView) -> Bool { + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._copyJobID != rhs_storage._copyJobID {return false} + if _storage._status != rhs_storage._status {return false} + if _storage._destination != rhs_storage._destination {return false} + if _storage._totalItems != rhs_storage._totalItems {return false} + if _storage._completedItems != rhs_storage._completedItems {return false} + if _storage._failedItems != rhs_storage._failedItems {return false} + if _storage._skippedItems != rhs_storage._skippedItems {return false} + if _storage._totalBytes != rhs_storage._totalBytes {return false} + if _storage._copiedBytes != rhs_storage._copiedBytes {return false} + if _storage._createdAtUnix != rhs_storage._createdAtUnix {return false} + if _storage._startedAtUnix != rhs_storage._startedAtUnix {return false} + if _storage._finishedAtUnix != rhs_storage._finishedAtUnix {return false} + if _storage._terminalReason != rhs_storage._terminalReason {return false} + return true + } + if !storagesAreEqual {return false} + } if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_ReissueUploadCredentialsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".ReissueUploadCredentialsResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}upload_id\0\u{1}credentials\0") +extension Archebase_DataGateway_V1_ListCopyJobItemsRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ListCopyJobItemsRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}copy_job_id\0\u{1}statuses\0\u{3}page_size\0\u{3}page_token\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -982,43 +2232,44 @@ extension Archebase_DataGateway_V1_ReissueUploadCredentialsResponse: SwiftProtob // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() - case 3: try { try decoder.decodeSingularMessageField(value: &self._credentials) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.copyJobID) }() + case 2: try { try decoder.decodeRepeatedEnumField(value: &self.statuses) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.pageSize) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.pageToken) }() default: break } } } public func traverse(visitor: inout V) throws { - // The use of inline closures is to circumvent an issue where the compiler - // allocates stack space for every if/case branch local when no optimizations - // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and - // https://github.com/apple/swift-protobuf/issues/1182 - if !self.logicalUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + if !self.copyJobID.isEmpty { + try visitor.visitSingularStringField(value: self.copyJobID, fieldNumber: 1) } - if !self.uploadID.isEmpty { - try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 2) + if !self.statuses.isEmpty { + try visitor.visitPackedEnumField(value: self.statuses, fieldNumber: 2) + } + if self.pageSize != 0 { + try visitor.visitSingularInt32Field(value: self.pageSize, fieldNumber: 3) + } + if !self.pageToken.isEmpty { + try visitor.visitSingularStringField(value: self.pageToken, fieldNumber: 4) } - try { if let v = self._credentials { - try visitor.visitSingularMessageField(value: v, fieldNumber: 3) - } }() try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_ReissueUploadCredentialsResponse, rhs: Archebase_DataGateway_V1_ReissueUploadCredentialsResponse) -> Bool { - if lhs.logicalUploadID != rhs.logicalUploadID {return false} - if lhs.uploadID != rhs.uploadID {return false} - if lhs._credentials != rhs._credentials {return false} + public static func ==(lhs: Archebase_DataGateway_V1_ListCopyJobItemsRequest, rhs: Archebase_DataGateway_V1_ListCopyJobItemsRequest) -> Bool { + if lhs.copyJobID != rhs.copyJobID {return false} + if lhs.statuses != rhs.statuses {return false} + if lhs.pageSize != rhs.pageSize {return false} + if lhs.pageToken != rhs.pageToken {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_AbortUploadRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".AbortUploadRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{1}reason\0") +extension Archebase_DataGateway_V1_CopyJobItemView: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CopyJobItemView" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}file_id\0\u{3}destination_object_key\0\u{1}status\0\u{3}source_size\0\u{3}copied_bytes\0\u{3}error_code\0\u{3}error_message\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -1026,34 +2277,59 @@ extension Archebase_DataGateway_V1_AbortUploadRequest: SwiftProtobuf.Message, Sw // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.reason) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.fileID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.destinationObjectKey) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self.status) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self.sourceSize) }() + case 5: try { try decoder.decodeSingularInt64Field(value: &self.copiedBytes) }() + case 6: try { try decoder.decodeSingularStringField(value: &self.errorCode) }() + case 7: try { try decoder.decodeSingularStringField(value: &self.errorMessage) }() default: break } } } public func traverse(visitor: inout V) throws { - if !self.logicalUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + if !self.fileID.isEmpty { + try visitor.visitSingularStringField(value: self.fileID, fieldNumber: 1) } - if !self.reason.isEmpty { - try visitor.visitSingularStringField(value: self.reason, fieldNumber: 2) + if !self.destinationObjectKey.isEmpty { + try visitor.visitSingularStringField(value: self.destinationObjectKey, fieldNumber: 2) + } + if self.status != .unspecified { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 3) + } + if self.sourceSize != 0 { + try visitor.visitSingularInt64Field(value: self.sourceSize, fieldNumber: 4) + } + if self.copiedBytes != 0 { + try visitor.visitSingularInt64Field(value: self.copiedBytes, fieldNumber: 5) + } + if !self.errorCode.isEmpty { + try visitor.visitSingularStringField(value: self.errorCode, fieldNumber: 6) + } + if !self.errorMessage.isEmpty { + try visitor.visitSingularStringField(value: self.errorMessage, fieldNumber: 7) } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_AbortUploadRequest, rhs: Archebase_DataGateway_V1_AbortUploadRequest) -> Bool { - if lhs.logicalUploadID != rhs.logicalUploadID {return false} - if lhs.reason != rhs.reason {return false} + public static func ==(lhs: Archebase_DataGateway_V1_CopyJobItemView, rhs: Archebase_DataGateway_V1_CopyJobItemView) -> Bool { + if lhs.fileID != rhs.fileID {return false} + if lhs.destinationObjectKey != rhs.destinationObjectKey {return false} + if lhs.status != rhs.status {return false} + if lhs.sourceSize != rhs.sourceSize {return false} + if lhs.copiedBytes != rhs.copiedBytes {return false} + if lhs.errorCode != rhs.errorCode {return false} + if lhs.errorMessage != rhs.errorMessage {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_AbortUploadResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".AbortUploadResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}logical_upload_id\0\u{3}upload_id\0") +extension Archebase_DataGateway_V1_ListCopyJobItemsResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ListCopyJobItemsResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}items\0\u{3}next_page_token\0\u{3}total_size\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -1061,34 +2337,39 @@ extension Archebase_DataGateway_V1_AbortUploadResponse: SwiftProtobuf.Message, S // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.logicalUploadID) }() - case 2: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.items) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.nextPageToken) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self.totalSize) }() default: break } } } public func traverse(visitor: inout V) throws { - if !self.logicalUploadID.isEmpty { - try visitor.visitSingularStringField(value: self.logicalUploadID, fieldNumber: 1) + if !self.items.isEmpty { + try visitor.visitRepeatedMessageField(value: self.items, fieldNumber: 1) } - if !self.uploadID.isEmpty { - try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 2) + if !self.nextPageToken.isEmpty { + try visitor.visitSingularStringField(value: self.nextPageToken, fieldNumber: 2) + } + if self.totalSize != 0 { + try visitor.visitSingularInt32Field(value: self.totalSize, fieldNumber: 3) } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_AbortUploadResponse, rhs: Archebase_DataGateway_V1_AbortUploadResponse) -> Bool { - if lhs.logicalUploadID != rhs.logicalUploadID {return false} - if lhs.uploadID != rhs.uploadID {return false} + public static func ==(lhs: Archebase_DataGateway_V1_ListCopyJobItemsResponse, rhs: Archebase_DataGateway_V1_ListCopyJobItemsResponse) -> Bool { + if lhs.items != rhs.items {return false} + if lhs.nextPageToken != rhs.nextPageToken {return false} + if lhs.totalSize != rhs.totalSize {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_CompleteUploadRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".CompleteUploadRequest" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}upload_id\0\u{3}file_size\0\u{3}raw_tags\0\u{3}completed_part_count\0\u{3}oss_object_etag\0") +extension Archebase_DataGateway_V1_CancelCopyJobRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CancelCopyJobRequest" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}copy_job_id\0\u{1}reason\0") public mutating func decodeMessage(decoder: inout D) throws { while let fieldNumber = try decoder.nextFieldNumber() { @@ -1096,60 +2377,61 @@ extension Archebase_DataGateway_V1_CompleteUploadRequest: SwiftProtobuf.Message, // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularStringField(value: &self.uploadID) }() - case 2: try { try decoder.decodeSingularInt64Field(value: &self.fileSize) }() - case 3: try { try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.rawTags) }() - case 4: try { try decoder.decodeSingularInt32Field(value: &self.completedPartCount) }() - case 5: try { try decoder.decodeSingularStringField(value: &self.ossObjectEtag) }() + case 1: try { try decoder.decodeSingularStringField(value: &self.copyJobID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.reason) }() default: break } } } public func traverse(visitor: inout V) throws { - if !self.uploadID.isEmpty { - try visitor.visitSingularStringField(value: self.uploadID, fieldNumber: 1) - } - if self.fileSize != 0 { - try visitor.visitSingularInt64Field(value: self.fileSize, fieldNumber: 2) - } - if !self.rawTags.isEmpty { - try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.rawTags, fieldNumber: 3) - } - if self.completedPartCount != 0 { - try visitor.visitSingularInt32Field(value: self.completedPartCount, fieldNumber: 4) + if !self.copyJobID.isEmpty { + try visitor.visitSingularStringField(value: self.copyJobID, fieldNumber: 1) } - if !self.ossObjectEtag.isEmpty { - try visitor.visitSingularStringField(value: self.ossObjectEtag, fieldNumber: 5) + if !self.reason.isEmpty { + try visitor.visitSingularStringField(value: self.reason, fieldNumber: 2) } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_CompleteUploadRequest, rhs: Archebase_DataGateway_V1_CompleteUploadRequest) -> Bool { - if lhs.uploadID != rhs.uploadID {return false} - if lhs.fileSize != rhs.fileSize {return false} - if lhs.rawTags != rhs.rawTags {return false} - if lhs.completedPartCount != rhs.completedPartCount {return false} - if lhs.ossObjectEtag != rhs.ossObjectEtag {return false} + public static func ==(lhs: Archebase_DataGateway_V1_CancelCopyJobRequest, rhs: Archebase_DataGateway_V1_CancelCopyJobRequest) -> Bool { + if lhs.copyJobID != rhs.copyJobID {return false} + if lhs.reason != rhs.reason {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Archebase_DataGateway_V1_CompleteUploadResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { - public static let protoMessageName: String = _protobuf_package + ".CompleteUploadResponse" - public static let _protobuf_nameMap = SwiftProtobuf._NameMap() +extension Archebase_DataGateway_V1_CancelCopyJobResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".CancelCopyJobResponse" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}copy_job_id\0\u{1}status\0") public mutating func decodeMessage(decoder: inout D) throws { - // Load everything into unknown fields - while try decoder.nextFieldNumber() != nil {} + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.copyJobID) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.status) }() + default: break + } + } } public func traverse(visitor: inout V) throws { + if !self.copyJobID.isEmpty { + try visitor.visitSingularStringField(value: self.copyJobID, fieldNumber: 1) + } + if self.status != .unspecified { + try visitor.visitSingularEnumField(value: self.status, fieldNumber: 2) + } try unknownFields.traverse(visitor: &visitor) } - public static func ==(lhs: Archebase_DataGateway_V1_CompleteUploadResponse, rhs: Archebase_DataGateway_V1_CompleteUploadResponse) -> Bool { + public static func ==(lhs: Archebase_DataGateway_V1_CancelCopyJobResponse, rhs: Archebase_DataGateway_V1_CancelCopyJobResponse) -> Bool { + if lhs.copyJobID != rhs.copyJobID {return false} + if lhs.status != rhs.status {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Sources/DataGatewayClient/DeviceInitConfigFetcher.swift b/Sources/DataGatewayClient/DeviceInitConfigFetcher.swift new file mode 100644 index 0000000..813219b --- /dev/null +++ b/Sources/DataGatewayClient/DeviceInitConfigFetcher.swift @@ -0,0 +1,39 @@ +import DGWControlPlane +import DGWStore + +package enum DeviceInitRemoteMode: Sendable { + case initDevice + case reinitDevice +} + +package enum DeviceInitConfigFetcher { + package static func fetch( + mode: DeviceInitRemoteMode, + deviceID: String, + transport: any DeviceInitTransport, + sdkVersion: String, + platform: String + ) async throws -> ArchebaseConfig { + do { + let response = switch mode { + case .initDevice: + try await transport.initDevice( + deviceID: deviceID, + sdkVersion: sdkVersion, + platform: platform + ) + case .reinitDevice: + try await transport.reinitDevice( + deviceID: deviceID, + sdkVersion: sdkVersion, + platform: platform + ) + } + return try ArchebaseConfig(apiKey: response.apiKey, tags: response.tags) + } catch let error as DataGatewayClientError { + throw error + } catch { + throw ControlPlaneErrorMapper.map(error) + } + } +} diff --git a/Sources/DataGatewayClient/FilePreparation.swift b/Sources/DataGatewayClient/FilePreparation.swift index b024836..f858c31 100644 --- a/Sources/DataGatewayClient/FilePreparation.swift +++ b/Sources/DataGatewayClient/FilePreparation.swift @@ -496,34 +496,28 @@ public actor ArchebaseDeviceInitializer { if await self.configStore.exists() { throw DataGatewayClientError.alreadyInitialized(configURL: await self.configStore.resolvedConfigURL()) } - let config = try await self.remoteConfig(deviceID: deviceID) + let config = try await self.remoteConfig(deviceID: deviceID, mode: .initDevice) try await self.configStore.initialize(config) return config } - /// Reinitializes a device by rotating the remote credential and replacing the local configuration. + /// Reinitializes a device by rotating the remote credential and writing the local configuration. + /// + /// This can recover a missing local config after a prior remote init succeeded but local persistence did not complete. public func reinitDevice(deviceID: String) async throws -> ArchebaseConfig { - if await !self.configStore.exists() { - throw DataGatewayClientError.notInitialized(configURL: await self.configStore.resolvedConfigURL()) - } - let config = try await self.remoteConfig(deviceID: deviceID) - try await self.configStore.replaceForReinit(config) + let config = try await self.remoteConfig(deviceID: deviceID, mode: .reinitDevice) + try await self.configStore.replaceOrInitialize(config) return config } - private func remoteConfig(deviceID: String) async throws -> ArchebaseConfig { - do { - let response = try await self.initTransport.initDevice( - deviceID: deviceID, - sdkVersion: self.sdkVersion, - platform: self.platform - ) - return try ArchebaseConfig(apiKey: response.apiKey, tags: response.tags) - } catch let error as DataGatewayClientError { - throw error - } catch { - throw ControlPlaneErrorMapper.map(error) - } + private func remoteConfig(deviceID: String, mode: DeviceInitRemoteMode) async throws -> ArchebaseConfig { + try await DeviceInitConfigFetcher.fetch( + mode: mode, + deviceID: deviceID, + transport: self.initTransport, + sdkVersion: self.sdkVersion, + platform: self.platform + ) } } diff --git a/Sources/DataGatewayClient/QiongcheDataGatewaySDK.swift b/Sources/DataGatewayClient/QiongcheDataGatewaySDK.swift index 30c0023..30986d8 100644 --- a/Sources/DataGatewayClient/QiongcheDataGatewaySDK.swift +++ b/Sources/DataGatewayClient/QiongcheDataGatewaySDK.swift @@ -92,6 +92,10 @@ public actor QiongcheDataGatewaySDK { timeout: self.deviceInitTimeout ) + // A successful remote init/reinit can invalidate the previous credential. + // Keep readiness false until endpoints, config, and state all commit again. + try self.stateStore.removeIfExists() + try await self.localPersister.replaceEndpoints( endpointsJSON: parsed.normalizedEndpointsJSONString, endpointsURL: self.paths.endpointsURL @@ -114,6 +118,11 @@ public actor QiongcheDataGatewaySDK { } do { + let state = try self.stateStore.load() + let endpointsData = try Data(contentsOf: self.paths.endpointsURL) + guard state.endpointsSHA256 == QiongcheConfigParser.sha256Hex(endpointsData) else { + return false + } _ = try await ArchebaseConfigStore(configURL: self.paths.configURL).load() let endpoints = try ArchebasePublicEndpoints.load(endpointsURL: self.paths.endpointsURL) @@ -268,6 +277,19 @@ package struct QiongcheSDKStateStore { } } + package func removeIfExists() throws { + guard self.fileManager.fileExists(atPath: self.stateURL.path) else { + return + } + do { + try self.fileManager.removeItem(at: self.stateURL) + } catch { + throw DataGatewayClientError.persistenceFailed( + "failed to remove qiongche sdk state: \(error.localizedDescription)" + ) + } + } + private static let encoder: JSONEncoder = { let encoder = JSONEncoder() encoder.outputFormatting = [.prettyPrinted, .sortedKeys] diff --git a/Sources/DataGatewayClient/QiongcheDeviceProvisioner.swift b/Sources/DataGatewayClient/QiongcheDeviceProvisioner.swift index 9caf666..3f3f2a1 100644 --- a/Sources/DataGatewayClient/QiongcheDeviceProvisioner.swift +++ b/Sources/DataGatewayClient/QiongcheDeviceProvisioner.swift @@ -11,8 +11,31 @@ package protocol QiongcheDeviceProvisioning: Sendable { ) async throws -> ArchebaseConfig } +package struct QiongcheDeviceInitTransportHandle: Sendable { + package let serviceClient: any DeviceInitTransport + private let shutdownHandler: @Sendable () -> Void + + package init( + serviceClient: any DeviceInitTransport, + shutdown: @escaping @Sendable () -> Void + ) { + self.serviceClient = serviceClient + self.shutdownHandler = shutdown + } + + package func shutdown() { + self.shutdownHandler() + } +} + package struct DefaultQiongcheDeviceProvisioner: QiongcheDeviceProvisioning { - package init() {} + private let makeTransport: @Sendable (URL, TLSMode, Duration) throws -> QiongcheDeviceInitTransportHandle + + package init( + makeTransport: @escaping @Sendable (URL, TLSMode, Duration) throws -> QiongcheDeviceInitTransportHandle = Self.makeDefaultTransport + ) { + self.makeTransport = makeTransport + } package func initDevice( deviceID: String, @@ -22,6 +45,35 @@ package struct DefaultQiongcheDeviceProvisioner: QiongcheDeviceProvisioning { ) async throws -> ArchebaseConfig { try DataGatewayClientConfig.validate(endpoint: deviceInitEndpoint, tls: tls, fieldName: "deviceInitEndpoint") + let transport = try self.makeTransport(deviceInitEndpoint, tls, timeout) + defer { + transport.shutdown() + } + + do { + return try await DeviceInitConfigFetcher.fetch( + mode: .initDevice, + deviceID: deviceID, + transport: transport.serviceClient, + sdkVersion: DataGatewayClientModule.version, + platform: "ios" + ) + } catch let error as DataGatewayClientError where error.isDeviceAlreadyInitialized { + return try await DeviceInitConfigFetcher.fetch( + mode: .reinitDevice, + deviceID: deviceID, + transport: transport.serviceClient, + sdkVersion: DataGatewayClientModule.version, + platform: "ios" + ) + } + } + + private static func makeDefaultTransport( + deviceInitEndpoint: URL, + tls: TLSMode, + timeout: Duration + ) throws -> QiongcheDeviceInitTransportHandle { let security: ControlPlaneTransportSecurity = switch tls { case .plaintext: .plaintext case .tls: .tls @@ -34,21 +86,20 @@ package struct DefaultQiongcheDeviceProvisioner: QiongcheDeviceProvisioning { ) ) let managedTransport = try factory.makeDeviceInitTransport() - defer { - managedTransport.shutdown() - } + return QiongcheDeviceInitTransportHandle( + serviceClient: managedTransport.serviceClient, + shutdown: { + managedTransport.shutdown() + } + ) + } +} - do { - let response = try await managedTransport.serviceClient.initDevice( - deviceID: deviceID, - sdkVersion: DataGatewayClientModule.version, - platform: "ios" - ) - return try ArchebaseConfig(apiKey: response.apiKey, tags: response.tags) - } catch let error as DataGatewayClientError { - throw error - } catch { - throw ControlPlaneErrorMapper.map(error) +private extension DataGatewayClientError { + var isDeviceAlreadyInitialized: Bool { + guard case .gatewayFailed(_, let detailCode, _) = self else { + return false } + return detailCode == DeviceInitGatewayDetailCode.alreadyInitialized } } diff --git a/Tests/DGWControlPlaneTests/ControlPlaneTransportTests.swift b/Tests/DGWControlPlaneTests/ControlPlaneTransportTests.swift index 757b88c..a64fc95 100644 --- a/Tests/DGWControlPlaneTests/ControlPlaneTransportTests.swift +++ b/Tests/DGWControlPlaneTests/ControlPlaneTransportTests.swift @@ -117,6 +117,30 @@ import GRPCCore ]) } +@Test func deviceInitTransportBuildsReinitRequestWithoutAuthorization() async throws { + let stub = DeviceInitServiceClientStub() + let transport = DeviceInitServiceClientTransport(client: stub, requestTimeout: .seconds(6)) + + let response = try await transport.reinitDevice( + deviceID: "260427-000001", + sdkVersion: "1.2.3", + platform: "ios" + ) + + #expect(response.apiKey == "credential-v2") + #expect(response.tags == ["device": "robot-reinit"]) + + let invocations = await stub.invocations() + #expect(invocations == [ + InvocationRecord( + method: "ReinitDevice", + metadata: ["authorization": []], + timeout: .seconds(6), + requestSummary: "260427-000001:1.2.3:ios" + ), + ]) +} + @Test func deviceInitErrorMapperDecodesGatewayDetail() { let error = makeRPCError( code: .failedPrecondition, @@ -321,6 +345,30 @@ private actor DeviceInitServiceClientStub: Archebase_DataGateway_V1_DeviceInitSe return try await handleResponse(ClientResponse(message: response)) } + func reinitDevice( + request: ClientRequest, + serializer: some MessageSerializer, + deserializer: some MessageDeserializer, + options: CallOptions, + onResponse handleResponse: @Sendable @escaping (ClientResponse) async throws -> Result + ) async throws -> Result where Result : Sendable { + self.records.append( + InvocationRecord( + method: "ReinitDevice", + metadata: Dictionary(uniqueKeysWithValues: [ + ("authorization", Array(request.metadata[stringValues: "authorization"])), + ]), + timeout: options.timeout, + requestSummary: "\(request.message.deviceID):\(request.message.sdkVersion):\(request.message.platform)" + ) + ) + + var response = Archebase_DataGateway_V1_InitDeviceResponse() + response.apiKey = "credential-v2" + response.tags = ["device": "robot-reinit"] + return try await handleResponse(ClientResponse(message: response)) + } + func invocations() -> [InvocationRecord] { self.records } diff --git a/Tests/DataGatewayClientIntegrationTests/DeviceInitializerTests.swift b/Tests/DataGatewayClientIntegrationTests/DeviceInitializerTests.swift index 72a4395..e6b565c 100644 --- a/Tests/DataGatewayClientIntegrationTests/DeviceInitializerTests.swift +++ b/Tests/DataGatewayClientIntegrationTests/DeviceInitializerTests.swift @@ -37,23 +37,51 @@ import DGWStore let expected = try ArchebaseConfig(apiKey: "credential-v1", tags: ["device": "robot"]) #expect(config == expected) #expect(try await store.load() == config) - #expect(await transport.requests() == [DeviceInitRequestRecord(deviceID: "260427-000001", sdkVersion: "1.2.3", platform: "ios-simulator")]) + #expect(await transport.requests() == [ + DeviceInitRequestRecord( + method: .initDevice, + deviceID: "260427-000001", + sdkVersion: "1.2.3", + platform: "ios-simulator" + ), + ]) } -@Test func reinitDeviceRejectsWhenConfigMissingWithoutRemoteCall() async throws { +@Test func initDeviceDoesNotFallbackWhenRemoteAlreadyInitialized() async throws { let store = ArchebaseConfigStore(configURL: temporaryConfigURL()) - let transport = RecordingDeviceInitTransport(response: .success(response(apiKey: "credential-new"))) + let transport = RecordingDeviceInitTransport( + response: .failure( + DataGatewayClientError.gatewayFailed( + statusCode: 9, + detailCode: DeviceInitGatewayDetailCode.alreadyInitialized, + message: "device has already been initialized" + ) + ) + ) let initializer = try ArchebaseDeviceInitializer(configStore: store, initTransport: transport) let error = await #expect(throws: DataGatewayClientError.self) { - _ = try await initializer.reinitDevice(deviceID: "260427-000001") + _ = try await initializer.initDevice(deviceID: "260427-000001") } - guard case .notInitialized = error else { - Issue.record("expected notInitialized, got \(String(describing: error))") - return - } - #expect(await transport.requests().isEmpty) + #expect(error == .gatewayFailed( + statusCode: 9, + detailCode: DeviceInitGatewayDetailCode.alreadyInitialized, + message: "device has already been initialized" + )) + #expect(await transport.requests().map(\.method) == [.initDevice]) +} + +@Test func reinitDeviceCanRecoverWhenConfigMissing() async throws { + let store = ArchebaseConfigStore(configURL: temporaryConfigURL()) + let transport = RecordingDeviceInitTransport(response: .success(response(apiKey: "credential-new"))) + let initializer = try ArchebaseDeviceInitializer(configStore: store, initTransport: transport) + + let config = try await initializer.reinitDevice(deviceID: "260427-000001") + + #expect(config == (try ArchebaseConfig(apiKey: "credential-new", tags: [:]))) + #expect(try await store.load() == config) + #expect(await transport.requests().map(\.method) == [.reinitDevice]) } @Test func reinitDeviceReplacesExistingConfig() async throws { @@ -68,10 +96,42 @@ import DGWStore let expected = try ArchebaseConfig(apiKey: "credential-v2", tags: ["device": "new"]) #expect(config == expected) #expect(try await store.load() == config) - #expect(await transport.requests().count == 1) + #expect(await transport.requests().map(\.method) == [.reinitDevice]) +} + +@Test func reinitDeviceDoesNotFallbackWhenRemoteNotInitialized() async throws { + let store = ArchebaseConfigStore(configURL: temporaryConfigURL()) + try await store.initialize(ArchebaseConfig(apiKey: "credential-v1", tags: [:])) + let transport = RecordingDeviceInitTransport( + response: .failure( + DataGatewayClientError.gatewayFailed( + statusCode: 9, + detailCode: DeviceInitGatewayDetailCode.notInitialized, + message: "device has not been initialized" + ) + ) + ) + let initializer = try ArchebaseDeviceInitializer(configStore: store, initTransport: transport) + + let error = await #expect(throws: DataGatewayClientError.self) { + _ = try await initializer.reinitDevice(deviceID: "260427-000001") + } + + #expect(error == .gatewayFailed( + statusCode: 9, + detailCode: DeviceInitGatewayDetailCode.notInitialized, + message: "device has not been initialized" + )) + #expect(await transport.requests().map(\.method) == [.reinitDevice]) +} + +private enum DeviceInitRequestMethod: Sendable, Equatable { + case initDevice + case reinitDevice } private struct DeviceInitRequestRecord: Sendable, Equatable { + let method: DeviceInitRequestMethod let deviceID: String let sdkVersion: String let platform: String @@ -90,7 +150,16 @@ private actor RecordingDeviceInitTransport: DeviceInitTransport { sdkVersion: String, platform: String ) async throws -> Archebase_DataGateway_V1_InitDeviceResponse { - self.records.append(DeviceInitRequestRecord(deviceID: deviceID, sdkVersion: sdkVersion, platform: platform)) + self.records.append(DeviceInitRequestRecord(method: .initDevice, deviceID: deviceID, sdkVersion: sdkVersion, platform: platform)) + return try self.response.get() + } + + func reinitDevice( + deviceID: String, + sdkVersion: String, + platform: String + ) async throws -> Archebase_DataGateway_V1_InitDeviceResponse { + self.records.append(DeviceInitRequestRecord(method: .reinitDevice, deviceID: deviceID, sdkVersion: sdkVersion, platform: platform)) return try self.response.get() } diff --git a/Tests/DataGatewayClientIntegrationTests/LocalStackHarnessTests.swift b/Tests/DataGatewayClientIntegrationTests/LocalStackHarnessTests.swift index db61e33..a9afc4e 100644 --- a/Tests/DataGatewayClientIntegrationTests/LocalStackHarnessTests.swift +++ b/Tests/DataGatewayClientIntegrationTests/LocalStackHarnessTests.swift @@ -54,6 +54,12 @@ struct LocalStackHarnessTests { #expect(config.gatewayEndpoint == URL(string: "http://127.0.0.1:15053")!) } +@Test func realEnvironmentURLHelperNormalizesSingleSlashSimulatorURLs() throws { + let url = try #require(normalizedURLFromEnvironmentValue("http:/example.com:50057")) + + #expect(url == URL(string: "http://example.com:50057")!) +} + @Test func localStackEnvironmentFailsWhenRequiredVariablesAreMissing() { let environment = LocalStackTestEnvironment(environment: [:]) @@ -172,6 +178,7 @@ struct LocalStackHarnessTests { #expect(script.contains("xcodebuild build-for-testing")) #expect(script.contains("-skipPackageUpdates")) + #expect(script.contains(#"for key in "$AUTH_ENDPOINT_KEY" "$GATEWAY_ENDPOINT_KEY" "$INIT_ENDPOINT_KEY"; do"#)) } @Test func aliyunEnvironmentContractValidatesPresenceOfCredentials() { @@ -952,8 +959,27 @@ private func requiredValueFromEnvironment(_ key: String) throws -> String { private func requiredURLFromEnvironment(_ key: String) throws -> URL { let value = try requiredValueFromEnvironment(key) - guard let url = URL(string: value), url.host?.isEmpty == false else { + guard let url = normalizedURLFromEnvironmentValue(value) else { throw LocalStackHarnessError.invalidEndpoint(key) } return url } + +private func normalizedURLFromEnvironmentValue(_ value: String) -> URL? { + if let url = URL(string: value), url.host?.isEmpty == false { + return url + } + + guard + let schemeRange = value.range(of: ":/"), + !value[schemeRange.upperBound...].hasPrefix("/") + else { + return nil + } + + let normalized = value.replacingCharacters(in: schemeRange, with: "://") + guard let url = URL(string: normalized), url.host?.isEmpty == false else { + return nil + } + return url +} diff --git a/Tests/DataGatewayClientIntegrationTests/QiongcheDataGatewaySDKTests.swift b/Tests/DataGatewayClientIntegrationTests/QiongcheDataGatewaySDKTests.swift index 410d062..5a78ba8 100644 --- a/Tests/DataGatewayClientIntegrationTests/QiongcheDataGatewaySDKTests.swift +++ b/Tests/DataGatewayClientIntegrationTests/QiongcheDataGatewaySDKTests.swift @@ -1,4 +1,5 @@ import DGWControlPlane +import DGWProto import DGWStore import Foundation import GRPCCore @@ -113,6 +114,63 @@ import Testing _ = DefaultQiongcheDeviceProvisioner() } +@Test func qiongcheDefaultDeviceProvisionerDoesNotReinitWhenInitSucceeds() async throws { + let transport = SequencedDeviceInitTransport(outcomes: [ + .success(deviceInitResponse(apiKey: "credential-v1", tags: ["device": "robot"])), + ]) + let provisioner = DefaultQiongcheDeviceProvisioner(makeTransport: { endpoint, tls, timeout in + #expect(endpoint == URL(string: "https://init.example.com:443")!) + #expect(tls == .tls) + #expect(timeout == .seconds(7)) + return QiongcheDeviceInitTransportHandle(serviceClient: transport, shutdown: {}) + }) + + let config = try await provisioner.initDevice( + deviceID: "robot-001", + deviceInitEndpoint: URL(string: "https://init.example.com:443")!, + tls: .tls, + timeout: .seconds(7) + ) + + #expect(config == (try ArchebaseConfig(apiKey: "credential-v1", tags: ["device": "robot"]))) + #expect(await transport.methods() == [.initDevice]) +} + +@Test func qiongcheSaveConfigAndInitFallsBackToReinitWhenAlreadyInitialized() async throws { + let root = try qiongcheTemporaryRoot() + let paths = try QiongcheSDKPaths(rootURL: root) + let reinitResponse = deviceInitResponse(apiKey: "credential-v2", tags: ["device": "robot-reinit"]) + let transport = SequencedDeviceInitTransport(outcomes: [ + .failure(.gatewayFailed( + statusCode: 9, + detailCode: DeviceInitGatewayDetailCode.alreadyInitialized, + message: "device has already been initialized" + )), + .success(reinitResponse), + ]) + let provisioner = DefaultQiongcheDeviceProvisioner(makeTransport: { _, _, _ in + QiongcheDeviceInitTransportHandle(serviceClient: transport, shutdown: {}) + }) + let sdk = try QiongcheDataGatewaySDK( + rootURL: root, + deviceProvisioner: provisioner, + clock: FixedQiongcheSDKClock(date: Date(timeIntervalSince1970: 1_778_840_000)) + ) + + try await sdk.saveConfigAndInit(configString: validQiongcheConfig(deviceID: "robot-001")) + + #expect(await transport.methods() == [.initDevice, .reinitDevice]) + #expect(try await ArchebaseConfigStore(configURL: paths.configURL).load() == (try ArchebaseConfig( + apiKey: "credential-v2", + tags: ["device": "robot-reinit"] + ))) + let endpoints = try ArchebasePublicEndpoints.load(endpointsURL: paths.endpointsURL) + #expect(endpoints.deviceInit == URL(string: "https://init.example.com:443")!) + let state = try QiongcheSDKStateStore(stateURL: paths.stateURL).load() + #expect(state.deviceID == "robot-001") + #expect(state.initializedAtUnix == 1_778_840_000) +} + @Test func qiongcheSDKActorDefaultInitSucceedsWithTemporaryRoot() throws { _ = try QiongcheDataGatewaySDK(rootURL: qiongcheTemporaryRoot()) } @@ -330,6 +388,50 @@ import Testing #expect(await provisioner.records().count == 2) } +@Test func qiongcheSaveConfigAndInitInvalidatesReadyStateAfterRemoteSuccessWhenLocalPersistenceFailsAndRecovers() async throws { + let root = try qiongcheTemporaryRoot() + let paths = try QiongcheSDKPaths(rootURL: root) + let oldConfigString = validQiongcheConfig(deviceID: "robot-001", authHost: "old-auth.example.com") + try await writeQiongcheReadyFiles( + rootURL: root, + configString: oldConfigString, + remoteConfig: try ArchebaseConfig(apiKey: "credential-old", tags: ["device": "old"]) + ) + let newConfigString = validQiongcheConfig(deviceID: "robot-001", authHost: "new-auth.example.com") + let recoveredConfig = try ArchebaseConfig(apiKey: "credential-v3", tags: ["device": "recovered"]) + let provisioner = SequencedQiongcheDeviceProvisioner(configs: [ + try ArchebaseConfig(apiKey: "credential-v2", tags: ["device": "rotated"]), + recoveredConfig, + ]) + let persister = FailingDefaultQiongcheLocalPersister(failures: [.endpoints]) + let sdk = try QiongcheDataGatewaySDK( + rootURL: root, + deviceProvisioner: provisioner, + readinessProbe: AlwaysReachableQiongcheProbe(), + localPersister: persister, + clock: FixedQiongcheSDKClock(date: Date(timeIntervalSince1970: 2)) + ) + + await #expect(throws: DataGatewayClientError.self) { + try await sdk.saveConfigAndInit(configString: newConfigString) + } + + #expect(await sdk.isReadyToUpload() == false) + #expect(throws: DataGatewayClientError.self) { + _ = try QiongcheSDKStateStore(stateURL: paths.stateURL).load() + } + + try await sdk.saveConfigAndInit(configString: newConfigString) + + #expect(try await ArchebaseConfigStore(configURL: paths.configURL).load() == recoveredConfig) + let parsed = try QiongcheConfigParser.parse(newConfigString) + let state = try QiongcheSDKStateStore(stateURL: paths.stateURL).load() + #expect(state.deviceID == "robot-001") + #expect(state.endpointsSHA256 == parsed.endpointsSHA256Hex) + #expect(await sdk.isReadyToUpload()) + #expect(await provisioner.records().count == 2) +} + @Test func qiongcheEndpointReachabilityClassifiesReachableRPCFailures() { for code in [ RPCError.Code.unauthenticated, @@ -471,11 +573,22 @@ func qiongcheTemporaryRoot() throws -> URL { return root } -private func writeQiongcheReadyFiles(rootURL: URL) async throws { +private func writeQiongcheReadyFiles( + rootURL: URL, + configString: String = validQiongcheConfig(), + remoteConfig: ArchebaseConfig? = nil, + initializedAtUnix: Int64 = 1 +) async throws { let paths = try QiongcheSDKPaths(rootURL: rootURL) - try ArchebasePublicEndpoints.replace(endpointsJSON: validQiongcheConfig(), endpointsURL: paths.endpointsURL) + let parsed = try QiongcheConfigParser.parse(configString) + try ArchebasePublicEndpoints.replace(endpointsJSON: configString, endpointsURL: paths.endpointsURL) try await ArchebaseConfigStore(configURL: paths.configURL) - .replaceOrInitialize(try ArchebaseConfig(apiKey: "credential-v1", tags: [:])) + .replaceOrInitialize(remoteConfig ?? (try ArchebaseConfig(apiKey: "credential-v1", tags: [:]))) + try QiongcheSDKStateStore(stateURL: paths.stateURL).replace(try QiongcheSDKState( + deviceID: parsed.deviceID, + endpointsSHA256: parsed.endpointsSHA256Hex, + initializedAtUnix: initializedAtUnix + )) } private func qiongcheReadySDK( @@ -493,6 +606,70 @@ private func qiongcheReadySDK( ) } +private enum SequencedDeviceInitMethod: Sendable, Equatable { + case initDevice + case reinitDevice +} + +private enum SequencedDeviceInitOutcome: Sendable { + case success(Archebase_DataGateway_V1_InitDeviceResponse) + case failure(DataGatewayClientError) +} + +private actor SequencedDeviceInitTransport: DeviceInitTransport { + private var outcomes: [SequencedDeviceInitOutcome] + private var recorded: [SequencedDeviceInitMethod] = [] + + init(outcomes: [SequencedDeviceInitOutcome]) { + self.outcomes = outcomes + } + + func initDevice( + deviceID: String, + sdkVersion: String, + platform: String + ) async throws -> Archebase_DataGateway_V1_InitDeviceResponse { + _ = (deviceID, sdkVersion, platform) + return try self.next(method: .initDevice) + } + + func reinitDevice( + deviceID: String, + sdkVersion: String, + platform: String + ) async throws -> Archebase_DataGateway_V1_InitDeviceResponse { + _ = (deviceID, sdkVersion, platform) + return try self.next(method: .reinitDevice) + } + + func methods() -> [SequencedDeviceInitMethod] { + self.recorded + } + + private func next(method: SequencedDeviceInitMethod) throws -> Archebase_DataGateway_V1_InitDeviceResponse { + self.recorded.append(method) + guard !self.outcomes.isEmpty else { + throw DataGatewayClientError.invalidConfiguration("device init test outcome missing") + } + switch self.outcomes.removeFirst() { + case .success(let response): + return response + case .failure(let error): + throw error + } + } +} + +private func deviceInitResponse( + apiKey: String, + tags: [String: String] = [:] +) -> Archebase_DataGateway_V1_InitDeviceResponse { + var response = Archebase_DataGateway_V1_InitDeviceResponse() + response.apiKey = apiKey + response.tags = tags + return response +} + private actor RecordingQiongcheDeviceProvisioner: QiongcheDeviceProvisioning { struct Record: Equatable { var deviceID: String @@ -537,6 +714,32 @@ private actor RecordingQiongcheDeviceProvisioner: QiongcheDeviceProvisioning { } } +private actor SequencedQiongcheDeviceProvisioner: QiongcheDeviceProvisioning { + private var configs: [ArchebaseConfig] + private var recorded: [RecordingQiongcheDeviceProvisioner.Record] = [] + + init(configs: [ArchebaseConfig]) { + self.configs = configs + } + + func initDevice( + deviceID: String, + deviceInitEndpoint: URL, + tls: TLSMode, + timeout: Duration + ) async throws -> ArchebaseConfig { + self.recorded.append(.init(deviceID: deviceID, endpoint: deviceInitEndpoint, tls: tls, timeout: timeout)) + guard !self.configs.isEmpty else { + throw DataGatewayClientError.invalidConfiguration("qiongche provisioner test config missing") + } + return self.configs.removeFirst() + } + + func records() -> [RecordingQiongcheDeviceProvisioner.Record] { + self.recorded + } +} + private struct AlwaysReachableQiongcheProbe: QiongcheEndpointProbing { func authEndpointReachable(endpoint: URL, tls: TLSMode, timeout: Duration) async -> Bool { _ = (endpoint, tls, timeout) @@ -636,3 +839,40 @@ private actor RecordingQiongcheLocalPersister: QiongcheLocalPersisting { } } } + +private actor FailingDefaultQiongcheLocalPersister: QiongcheLocalPersisting { + enum Stage: Equatable, Sendable { + case endpoints + case config + case state + } + + private let delegate = DefaultQiongcheLocalPersister() + private var failures: [Stage] + + init(failures: [Stage]) { + self.failures = failures + } + + func replaceEndpoints(endpointsJSON: String, endpointsURL: URL) async throws { + try self.failIfNeeded(.endpoints) + try await self.delegate.replaceEndpoints(endpointsJSON: endpointsJSON, endpointsURL: endpointsURL) + } + + func replaceConfig(_ config: ArchebaseConfig, configURL: URL) async throws { + try self.failIfNeeded(.config) + try await self.delegate.replaceConfig(config, configURL: configURL) + } + + func replaceState(_ state: QiongcheSDKState, stateURL: URL) async throws { + try self.failIfNeeded(.state) + try await self.delegate.replaceState(state, stateURL: stateURL) + } + + private func failIfNeeded(_ stage: Stage) throws { + if self.failures.first == stage { + self.failures.removeFirst() + throw DataGatewayClientError.persistenceFailed("injected qiongche \(stage) failure") + } + } +} diff --git a/protos/data_gateway.proto b/protos/data_gateway.proto index 5d18756..4d4b705 100644 --- a/protos/data_gateway.proto +++ b/protos/data_gateway.proto @@ -50,8 +50,10 @@ service DataGatewayCopyService { // controls and rate limiting are required before exposing it outside controlled // environments. service DeviceInitService { - // Initializes or re-initializes one registered device and returns the upload API key. + // Initializes one registered device and returns the upload API key. rpc InitDevice(InitDeviceRequest) returns (InitDeviceResponse); + // Re-initializes one registered device and returns a rotated upload API key. + rpc ReinitDevice(ReinitDeviceRequest) returns (InitDeviceResponse); } // Request sent by SDKs before they have an upload API key. @@ -64,6 +66,16 @@ message InitDeviceRequest { string platform = 3; } +// Request sent by SDKs when explicitly rotating an existing upload API key. +message ReinitDeviceRequest { + // Bare platform-assigned device identifier provided by the operator. + string device_id = 1; + // SDK version reported for operator visibility and diagnostics. + string sdk_version = 2; + // SDK platform string, for example "ios". + string platform = 3; +} + // Response persisted by SDKs into archebase-config.json. message InitDeviceResponse { // Base64-encoded credential returned by auth and used for later uploads.