diff --git a/external/nextcloud-server b/external/nextcloud-server index 5d20baec..3c5d8410 160000 --- a/external/nextcloud-server +++ b/external/nextcloud-server @@ -1 +1 @@ -Subproject commit 5d20baec01daec7b7aefe7cb17f8db5611dcd176 +Subproject commit 3c5d8410fa3d3f4ded01eed8c5cf1718532c174e diff --git a/packages/nextcloud/lib/src/api/core.openapi.dart b/packages/nextcloud/lib/src/api/core.openapi.dart index cf3c6fbe..3e64ba4b 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.dart @@ -78,6 +78,7 @@ class CoreClient extends DynamiteClient { CoreGuestAvatarClient get guestAvatar => CoreGuestAvatarClient(this); CoreHoverCardClient get hoverCard => CoreHoverCardClient(this); CoreNavigationClient get navigation => CoreNavigationClient(this); + CoreOcmClient get ocm => CoreOcmClient(this); CoreOcsClient get ocs => CoreOcsClient(this); CorePreviewClient get preview => CorePreviewClient(this); CoreProfileApiClient get profileApi => CoreProfileApiClient(this); @@ -998,6 +999,53 @@ class CoreNavigationClient { } } +/// Controller about the endpoint /ocm-provider/ +class CoreOcmClient { + CoreOcmClient(this._rootClient); + + final CoreClient _rootClient; + + /// generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php + Future> discovery() async { + const path = '/index.php/ocm-provider'; + final queryParameters = {}; + final headers = { + 'Accept': 'application/json', + }; + Uint8List? body; + // coverage:ignore-start + if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'bearer').isNotEmpty) { + headers.addAll( + _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'bearer').headers, + ); + } else if (_rootClient.authentications.where((final a) => a.type == 'http' && a.scheme == 'basic').isNotEmpty) { + headers.addAll( + _rootClient.authentications.singleWhere((final a) => a.type == 'http' && a.scheme == 'basic').headers, + ); + } + // coverage:ignore-end + final response = await _rootClient.doRequest( + 'get', + Uri(path: path, queryParameters: queryParameters.isNotEmpty ? queryParameters : null), + headers, + body, + ); + if (response.statusCode == 200) { + return CoreResponse( + _jsonSerializers.deserialize( + await response.jsonBody, + specifiedType: const FullType(CoreOcmDiscoveryResponseApplicationJson), + )! as CoreOcmDiscoveryResponseApplicationJson, + _jsonSerializers.deserialize( + response.responseHeaders, + specifiedType: const FullType(CoreOcmOcmDiscoveryHeaders), + )! as CoreOcmOcmDiscoveryHeaders, + ); + } + throw await CoreApiException.fromResponse(response); // coverage:ignore-line + } +} + class CoreOcsClient { CoreOcsClient(this._rootClient); @@ -3664,6 +3712,182 @@ abstract class CoreNavigationGetSettingsNavigationResponseApplicationJson _$coreNavigationGetSettingsNavigationResponseApplicationJsonSerializer; } +@BuiltValue(instantiable: false) +abstract interface class CoreOcmOcmDiscoveryHeadersInterface { + @BuiltValueField(wireName: 'x-nextcloud-ocm-providers') + bool? get xNextcloudOcmProviders; + CoreOcmOcmDiscoveryHeadersInterface rebuild(final void Function(CoreOcmOcmDiscoveryHeadersInterfaceBuilder) updates); + CoreOcmOcmDiscoveryHeadersInterfaceBuilder toBuilder(); +} + +abstract class CoreOcmOcmDiscoveryHeaders + implements + CoreOcmOcmDiscoveryHeadersInterface, + Built { + factory CoreOcmOcmDiscoveryHeaders([final void Function(CoreOcmOcmDiscoveryHeadersBuilder)? b]) = + _$CoreOcmOcmDiscoveryHeaders; + + // coverage:ignore-start + const CoreOcmOcmDiscoveryHeaders._(); + // coverage:ignore-end + + // coverage:ignore-start + factory CoreOcmOcmDiscoveryHeaders.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + // coverage:ignore-end + + // coverage:ignore-start + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + // coverage:ignore-end + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _$CoreOcmOcmDiscoveryHeadersSerializer(); +} + +class _$CoreOcmOcmDiscoveryHeadersSerializer implements StructuredSerializer { + @override + final Iterable types = const [CoreOcmOcmDiscoveryHeaders, _$CoreOcmOcmDiscoveryHeaders]; + + @override + final String wireName = 'CoreOcmOcmDiscoveryHeaders'; + + @override + Iterable serialize( + final Serializers serializers, + final CoreOcmOcmDiscoveryHeaders object, { + final FullType specifiedType = FullType.unspecified, + }) { + throw UnimplementedError(); + } + + @override + CoreOcmOcmDiscoveryHeaders deserialize( + final Serializers serializers, + final Iterable serialized, { + final FullType specifiedType = FullType.unspecified, + }) { + final result = CoreOcmOcmDiscoveryHeadersBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final value = iterator.current! as String; + switch (key) { + case 'x-nextcloud-ocm-providers': + result.xNextcloudOcmProviders = (value == 'true'); + } + } + + return result.build(); + } +} + +@BuiltValue(instantiable: false) +abstract interface class CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterface { + String get webdav; + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterface rebuild( + final void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterfaceBuilder) updates, + ); + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterfaceBuilder toBuilder(); +} + +abstract class CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols + implements + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterface, + Built { + factory CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols([ + final void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder)? b, + ]) = _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols; + + // coverage:ignore-start + const CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols._(); + // coverage:ignore-end + + // coverage:ignore-start + factory CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + // coverage:ignore-end + + // coverage:ignore-start + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + // coverage:ignore-end + static Serializer get serializer => + _$coreOcmDiscoveryResponseApplicationJsonResourceTypesProtocolsSerializer; +} + +@BuiltValue(instantiable: false) +abstract interface class CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterface { + String get name; + BuiltList get shareTypes; + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols get protocols; + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterface rebuild( + final void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterfaceBuilder) updates, + ); + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterfaceBuilder toBuilder(); +} + +abstract class CoreOcmDiscoveryResponseApplicationJson_ResourceTypes + implements + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterface, + Built { + factory CoreOcmDiscoveryResponseApplicationJson_ResourceTypes([ + final void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder)? b, + ]) = _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes; + + // coverage:ignore-start + const CoreOcmDiscoveryResponseApplicationJson_ResourceTypes._(); + // coverage:ignore-end + + // coverage:ignore-start + factory CoreOcmDiscoveryResponseApplicationJson_ResourceTypes.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + // coverage:ignore-end + + // coverage:ignore-start + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + // coverage:ignore-end + static Serializer get serializer => + _$coreOcmDiscoveryResponseApplicationJsonResourceTypesSerializer; +} + +@BuiltValue(instantiable: false) +abstract interface class CoreOcmDiscoveryResponseApplicationJsonInterface { + bool get enabled; + String get apiVersion; + String get endPoint; + BuiltList get resourceTypes; + CoreOcmDiscoveryResponseApplicationJsonInterface rebuild( + final void Function(CoreOcmDiscoveryResponseApplicationJsonInterfaceBuilder) updates, + ); + CoreOcmDiscoveryResponseApplicationJsonInterfaceBuilder toBuilder(); +} + +abstract class CoreOcmDiscoveryResponseApplicationJson + implements + CoreOcmDiscoveryResponseApplicationJsonInterface, + Built { + factory CoreOcmDiscoveryResponseApplicationJson([ + final void Function(CoreOcmDiscoveryResponseApplicationJsonBuilder)? b, + ]) = _$CoreOcmDiscoveryResponseApplicationJson; + + // coverage:ignore-start + const CoreOcmDiscoveryResponseApplicationJson._(); + // coverage:ignore-end + + // coverage:ignore-start + factory CoreOcmDiscoveryResponseApplicationJson.fromJson(final Map json) => + _jsonSerializers.deserializeWith(serializer, json)!; + // coverage:ignore-end + + // coverage:ignore-start + Map toJson() => _jsonSerializers.serializeWith(serializer, this)! as Map; + // coverage:ignore-end + static Serializer get serializer => + _$coreOcmDiscoveryResponseApplicationJsonSerializer; +} + @BuiltValue(instantiable: false) abstract interface class CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data_VersionInterface { int get major; @@ -7734,6 +7958,28 @@ final Serializers _serializers = (Serializers().toBuilder() CoreNavigationGetSettingsNavigationResponseApplicationJson_Ocs.new, ) ..add(CoreNavigationGetSettingsNavigationResponseApplicationJson_Ocs.serializer) + ..addBuilderFactory(const FullType(CoreOcmOcmDiscoveryHeaders), CoreOcmOcmDiscoveryHeaders.new) + ..add(CoreOcmOcmDiscoveryHeaders.serializer) + ..addBuilderFactory( + const FullType(CoreOcmDiscoveryResponseApplicationJson), + CoreOcmDiscoveryResponseApplicationJson.new, + ) + ..add(CoreOcmDiscoveryResponseApplicationJson.serializer) + ..addBuilderFactory( + const FullType(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes), + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes.new, + ) + ..add(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes.serializer) + ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new) + ..addBuilderFactory( + const FullType(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols), + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols.new, + ) + ..add(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols.serializer) + ..addBuilderFactory( + const FullType(BuiltList, [FullType(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes)]), + ListBuilder.new, + ) ..addBuilderFactory( const FullType(CoreOcsGetCapabilitiesResponseApplicationJson), CoreOcsGetCapabilitiesResponseApplicationJson.new, @@ -7861,7 +8107,6 @@ final Serializers _serializers = (Serializers().toBuilder() ..add(CoreNotesCapabilities.serializer) ..addBuilderFactory(const FullType(CoreNotesCapabilities_Notes), CoreNotesCapabilities_Notes.new) ..add(CoreNotesCapabilities_Notes.serializer) - ..addBuilderFactory(const FullType(BuiltList, [FullType(String)]), ListBuilder.new) ..addBuilderFactory(const FullType(CoreNotificationsCapabilities), CoreNotificationsCapabilities.new) ..add(CoreNotificationsCapabilities.serializer) ..addBuilderFactory( diff --git a/packages/nextcloud/lib/src/api/core.openapi.g.dart b/packages/nextcloud/lib/src/api/core.openapi.g.dart index e4c01bd1..633ad258 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/core.openapi.g.dart @@ -107,6 +107,14 @@ Serializer Serializer _$coreNavigationGetSettingsNavigationResponseApplicationJsonSerializer = _$CoreNavigationGetSettingsNavigationResponseApplicationJsonSerializer(); +Serializer + _$coreOcmDiscoveryResponseApplicationJsonResourceTypesProtocolsSerializer = + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsSerializer(); +Serializer + _$coreOcmDiscoveryResponseApplicationJsonResourceTypesSerializer = + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypesSerializer(); +Serializer _$coreOcmDiscoveryResponseApplicationJsonSerializer = + _$CoreOcmDiscoveryResponseApplicationJsonSerializer(); Serializer _$coreOcsGetCapabilitiesResponseApplicationJsonOcsDataVersionSerializer = _$CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data_VersionSerializer(); @@ -2523,6 +2531,168 @@ class _$CoreNavigationGetSettingsNavigationResponseApplicationJsonSerializer } } +class _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols, + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols + ]; + @override + final String wireName = 'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols'; + + @override + Iterable serialize( + Serializers serializers, CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'webdav', + serializers.serialize(object.webdav, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'webdav': + result.webdav = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypesSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes, + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes + ]; + @override + final String wireName = 'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes'; + + @override + Iterable serialize(Serializers serializers, CoreOcmDiscoveryResponseApplicationJson_ResourceTypes object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + 'shareTypes', + serializers.serialize(object.shareTypes, specifiedType: const FullType(BuiltList, [FullType(String)])), + 'protocols', + serializers.serialize(object.protocols, + specifiedType: const FullType(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols)), + ]; + + return result; + } + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'name': + result.name = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + case 'shareTypes': + result.shareTypes.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, [FullType(String)]))! as BuiltList); + break; + case 'protocols': + result.protocols.replace(serializers.deserialize(value, + specifiedType: const FullType(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols))! + as CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols); + break; + } + } + + return result.build(); + } +} + +class _$CoreOcmDiscoveryResponseApplicationJsonSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + CoreOcmDiscoveryResponseApplicationJson, + _$CoreOcmDiscoveryResponseApplicationJson + ]; + @override + final String wireName = 'CoreOcmDiscoveryResponseApplicationJson'; + + @override + Iterable serialize(Serializers serializers, CoreOcmDiscoveryResponseApplicationJson object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'enabled', + serializers.serialize(object.enabled, specifiedType: const FullType(bool)), + 'apiVersion', + serializers.serialize(object.apiVersion, specifiedType: const FullType(String)), + 'endPoint', + serializers.serialize(object.endPoint, specifiedType: const FullType(String)), + 'resourceTypes', + serializers.serialize(object.resourceTypes, + specifiedType: const FullType(BuiltList, [FullType(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes)])), + ]; + + return result; + } + + @override + CoreOcmDiscoveryResponseApplicationJson deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = CoreOcmDiscoveryResponseApplicationJsonBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'enabled': + result.enabled = serializers.deserialize(value, specifiedType: const FullType(bool))! as bool; + break; + case 'apiVersion': + result.apiVersion = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + case 'endPoint': + result.endPoint = serializers.deserialize(value, specifiedType: const FullType(String))! as String; + break; + case 'resourceTypes': + result.resourceTypes.replace(serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, [FullType(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes)]))! + as BuiltList); + break; + } + } + + return result.build(); + } +} + class _$CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data_VersionSerializer implements StructuredSerializer { @override @@ -13439,6 +13609,500 @@ class CoreNavigationGetSettingsNavigationResponseApplicationJsonBuilder } } +abstract mixin class CoreOcmOcmDiscoveryHeadersInterfaceBuilder { + void replace(CoreOcmOcmDiscoveryHeadersInterface other); + void update(void Function(CoreOcmOcmDiscoveryHeadersInterfaceBuilder) updates); + bool? get xNextcloudOcmProviders; + set xNextcloudOcmProviders(bool? xNextcloudOcmProviders); +} + +class _$CoreOcmOcmDiscoveryHeaders extends CoreOcmOcmDiscoveryHeaders { + @override + final bool? xNextcloudOcmProviders; + + factory _$CoreOcmOcmDiscoveryHeaders([void Function(CoreOcmOcmDiscoveryHeadersBuilder)? updates]) => + (CoreOcmOcmDiscoveryHeadersBuilder()..update(updates))._build(); + + _$CoreOcmOcmDiscoveryHeaders._({this.xNextcloudOcmProviders}) : super._(); + + @override + CoreOcmOcmDiscoveryHeaders rebuild(void Function(CoreOcmOcmDiscoveryHeadersBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + CoreOcmOcmDiscoveryHeadersBuilder toBuilder() => CoreOcmOcmDiscoveryHeadersBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is CoreOcmOcmDiscoveryHeaders && xNextcloudOcmProviders == other.xNextcloudOcmProviders; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, xNextcloudOcmProviders.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'CoreOcmOcmDiscoveryHeaders') + ..add('xNextcloudOcmProviders', xNextcloudOcmProviders)) + .toString(); + } +} + +class CoreOcmOcmDiscoveryHeadersBuilder + implements + Builder, + CoreOcmOcmDiscoveryHeadersInterfaceBuilder { + _$CoreOcmOcmDiscoveryHeaders? _$v; + + bool? _xNextcloudOcmProviders; + bool? get xNextcloudOcmProviders => _$this._xNextcloudOcmProviders; + set xNextcloudOcmProviders(covariant bool? xNextcloudOcmProviders) => + _$this._xNextcloudOcmProviders = xNextcloudOcmProviders; + + CoreOcmOcmDiscoveryHeadersBuilder(); + + CoreOcmOcmDiscoveryHeadersBuilder get _$this { + final $v = _$v; + if ($v != null) { + _xNextcloudOcmProviders = $v.xNextcloudOcmProviders; + _$v = null; + } + return this; + } + + @override + void replace(covariant CoreOcmOcmDiscoveryHeaders other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$CoreOcmOcmDiscoveryHeaders; + } + + @override + void update(void Function(CoreOcmOcmDiscoveryHeadersBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + CoreOcmOcmDiscoveryHeaders build() => _build(); + + _$CoreOcmOcmDiscoveryHeaders _build() { + final _$result = _$v ?? _$CoreOcmOcmDiscoveryHeaders._(xNextcloudOcmProviders: xNextcloudOcmProviders); + replace(_$result); + return _$result; + } +} + +abstract mixin class CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterfaceBuilder { + void replace(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterface other); + void update(void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterfaceBuilder) updates); + String? get webdav; + set webdav(String? webdav); +} + +class _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols + extends CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols { + @override + final String webdav; + + factory _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols( + [void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder)? updates]) => + (CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder()..update(updates))._build(); + + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols._({required this.webdav}) : super._() { + BuiltValueNullFieldError.checkNotNull( + webdav, r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols', 'webdav'); + } + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols rebuild( + void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder toBuilder() => + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols && webdav == other.webdav; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, webdav.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols') + ..add('webdav', webdav)) + .toString(); + } +} + +class CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder + implements + Builder, + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsInterfaceBuilder { + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols? _$v; + + String? _webdav; + String? get webdav => _$this._webdav; + set webdav(covariant String? webdav) => _$this._webdav = webdav; + + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder(); + + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _webdav = $v.webdav; + _$v = null; + } + return this; + } + + @override + void replace(covariant CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols; + } + + @override + void update(void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols build() => _build(); + + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols _build() { + final _$result = _$v ?? + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols._( + webdav: BuiltValueNullFieldError.checkNotNull( + webdav, r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols', 'webdav')); + replace(_$result); + return _$result; + } +} + +abstract mixin class CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterfaceBuilder { + void replace(CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterface other); + void update(void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterfaceBuilder) updates); + String? get name; + set name(String? name); + + ListBuilder get shareTypes; + set shareTypes(ListBuilder? shareTypes); + + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder get protocols; + set protocols(CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder? protocols); +} + +class _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes + extends CoreOcmDiscoveryResponseApplicationJson_ResourceTypes { + @override + final String name; + @override + final BuiltList shareTypes; + @override + final CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_Protocols protocols; + + factory _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes( + [void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder)? updates]) => + (CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder()..update(updates))._build(); + + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes._( + {required this.name, required this.shareTypes, required this.protocols}) + : super._() { + BuiltValueNullFieldError.checkNotNull(name, r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes', 'name'); + BuiltValueNullFieldError.checkNotNull( + shareTypes, r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes', 'shareTypes'); + BuiltValueNullFieldError.checkNotNull( + protocols, r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes', 'protocols'); + } + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes rebuild( + void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder toBuilder() => + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is CoreOcmDiscoveryResponseApplicationJson_ResourceTypes && + name == other.name && + shareTypes == other.shareTypes && + protocols == other.protocols; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, shareTypes.hashCode); + _$hash = $jc(_$hash, protocols.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes') + ..add('name', name) + ..add('shareTypes', shareTypes) + ..add('protocols', protocols)) + .toString(); + } +} + +class CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder + implements + Builder, + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesInterfaceBuilder { + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes? _$v; + + String? _name; + String? get name => _$this._name; + set name(covariant String? name) => _$this._name = name; + + ListBuilder? _shareTypes; + ListBuilder get shareTypes => _$this._shareTypes ??= ListBuilder(); + set shareTypes(covariant ListBuilder? shareTypes) => _$this._shareTypes = shareTypes; + + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder? _protocols; + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder get protocols => + _$this._protocols ??= CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder(); + set protocols(covariant CoreOcmDiscoveryResponseApplicationJson_ResourceTypes_ProtocolsBuilder? protocols) => + _$this._protocols = protocols; + + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder(); + + CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder get _$this { + final $v = _$v; + if ($v != null) { + _name = $v.name; + _shareTypes = $v.shareTypes.toBuilder(); + _protocols = $v.protocols.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant CoreOcmDiscoveryResponseApplicationJson_ResourceTypes other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes; + } + + @override + void update(void Function(CoreOcmDiscoveryResponseApplicationJson_ResourceTypesBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + CoreOcmDiscoveryResponseApplicationJson_ResourceTypes build() => _build(); + + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes _build() { + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes _$result; + try { + _$result = _$v ?? + _$CoreOcmDiscoveryResponseApplicationJson_ResourceTypes._( + name: BuiltValueNullFieldError.checkNotNull( + name, r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes', 'name'), + shareTypes: shareTypes.build(), + protocols: protocols.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'shareTypes'; + shareTypes.build(); + _$failedField = 'protocols'; + protocols.build(); + } catch (e) { + throw BuiltValueNestedFieldError( + r'CoreOcmDiscoveryResponseApplicationJson_ResourceTypes', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +abstract mixin class CoreOcmDiscoveryResponseApplicationJsonInterfaceBuilder { + void replace(CoreOcmDiscoveryResponseApplicationJsonInterface other); + void update(void Function(CoreOcmDiscoveryResponseApplicationJsonInterfaceBuilder) updates); + bool? get enabled; + set enabled(bool? enabled); + + String? get apiVersion; + set apiVersion(String? apiVersion); + + String? get endPoint; + set endPoint(String? endPoint); + + ListBuilder get resourceTypes; + set resourceTypes(ListBuilder? resourceTypes); +} + +class _$CoreOcmDiscoveryResponseApplicationJson extends CoreOcmDiscoveryResponseApplicationJson { + @override + final bool enabled; + @override + final String apiVersion; + @override + final String endPoint; + @override + final BuiltList resourceTypes; + + factory _$CoreOcmDiscoveryResponseApplicationJson( + [void Function(CoreOcmDiscoveryResponseApplicationJsonBuilder)? updates]) => + (CoreOcmDiscoveryResponseApplicationJsonBuilder()..update(updates))._build(); + + _$CoreOcmDiscoveryResponseApplicationJson._( + {required this.enabled, required this.apiVersion, required this.endPoint, required this.resourceTypes}) + : super._() { + BuiltValueNullFieldError.checkNotNull(enabled, r'CoreOcmDiscoveryResponseApplicationJson', 'enabled'); + BuiltValueNullFieldError.checkNotNull(apiVersion, r'CoreOcmDiscoveryResponseApplicationJson', 'apiVersion'); + BuiltValueNullFieldError.checkNotNull(endPoint, r'CoreOcmDiscoveryResponseApplicationJson', 'endPoint'); + BuiltValueNullFieldError.checkNotNull(resourceTypes, r'CoreOcmDiscoveryResponseApplicationJson', 'resourceTypes'); + } + + @override + CoreOcmDiscoveryResponseApplicationJson rebuild( + void Function(CoreOcmDiscoveryResponseApplicationJsonBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + CoreOcmDiscoveryResponseApplicationJsonBuilder toBuilder() => + CoreOcmDiscoveryResponseApplicationJsonBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is CoreOcmDiscoveryResponseApplicationJson && + enabled == other.enabled && + apiVersion == other.apiVersion && + endPoint == other.endPoint && + resourceTypes == other.resourceTypes; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, enabled.hashCode); + _$hash = $jc(_$hash, apiVersion.hashCode); + _$hash = $jc(_$hash, endPoint.hashCode); + _$hash = $jc(_$hash, resourceTypes.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'CoreOcmDiscoveryResponseApplicationJson') + ..add('enabled', enabled) + ..add('apiVersion', apiVersion) + ..add('endPoint', endPoint) + ..add('resourceTypes', resourceTypes)) + .toString(); + } +} + +class CoreOcmDiscoveryResponseApplicationJsonBuilder + implements + Builder, + CoreOcmDiscoveryResponseApplicationJsonInterfaceBuilder { + _$CoreOcmDiscoveryResponseApplicationJson? _$v; + + bool? _enabled; + bool? get enabled => _$this._enabled; + set enabled(covariant bool? enabled) => _$this._enabled = enabled; + + String? _apiVersion; + String? get apiVersion => _$this._apiVersion; + set apiVersion(covariant String? apiVersion) => _$this._apiVersion = apiVersion; + + String? _endPoint; + String? get endPoint => _$this._endPoint; + set endPoint(covariant String? endPoint) => _$this._endPoint = endPoint; + + ListBuilder? _resourceTypes; + ListBuilder get resourceTypes => + _$this._resourceTypes ??= ListBuilder(); + set resourceTypes(covariant ListBuilder? resourceTypes) => + _$this._resourceTypes = resourceTypes; + + CoreOcmDiscoveryResponseApplicationJsonBuilder(); + + CoreOcmDiscoveryResponseApplicationJsonBuilder get _$this { + final $v = _$v; + if ($v != null) { + _enabled = $v.enabled; + _apiVersion = $v.apiVersion; + _endPoint = $v.endPoint; + _resourceTypes = $v.resourceTypes.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(covariant CoreOcmDiscoveryResponseApplicationJson other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$CoreOcmDiscoveryResponseApplicationJson; + } + + @override + void update(void Function(CoreOcmDiscoveryResponseApplicationJsonBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + CoreOcmDiscoveryResponseApplicationJson build() => _build(); + + _$CoreOcmDiscoveryResponseApplicationJson _build() { + _$CoreOcmDiscoveryResponseApplicationJson _$result; + try { + _$result = _$v ?? + _$CoreOcmDiscoveryResponseApplicationJson._( + enabled: + BuiltValueNullFieldError.checkNotNull(enabled, r'CoreOcmDiscoveryResponseApplicationJson', 'enabled'), + apiVersion: BuiltValueNullFieldError.checkNotNull( + apiVersion, r'CoreOcmDiscoveryResponseApplicationJson', 'apiVersion'), + endPoint: BuiltValueNullFieldError.checkNotNull( + endPoint, r'CoreOcmDiscoveryResponseApplicationJson', 'endPoint'), + resourceTypes: resourceTypes.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'resourceTypes'; + resourceTypes.build(); + } catch (e) { + throw BuiltValueNestedFieldError(r'CoreOcmDiscoveryResponseApplicationJson', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + abstract mixin class CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data_VersionInterfaceBuilder { void replace(CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data_VersionInterface other); void update(void Function(CoreOcsGetCapabilitiesResponseApplicationJson_Ocs_Data_VersionInterfaceBuilder) updates); diff --git a/packages/nextcloud/lib/src/api/core.openapi.json b/packages/nextcloud/lib/src/api/core.openapi.json index 6063f54a..74047877 100644 --- a/packages/nextcloud/lib/src/api/core.openapi.json +++ b/packages/nextcloud/lib/src/api/core.openapi.json @@ -1929,6 +1929,111 @@ } } }, + "/index.php/ocm-provider": { + "get": { + "operationId": "ocm-discovery", + "summary": "generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php", + "tags": [ + "ocm" + ], + "security": [ + {}, + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "responses": { + "200": { + "description": "OCM Provider details returned", + "headers": { + "X-NEXTCLOUD-OCM-PROVIDERS": { + "schema": { + "type": "boolean" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "enabled", + "apiVersion", + "endPoint", + "resourceTypes" + ], + "properties": { + "enabled": { + "type": "boolean" + }, + "apiVersion": { + "type": "string" + }, + "endPoint": { + "type": "string" + }, + "resourceTypes": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "shareTypes", + "protocols" + ], + "properties": { + "name": { + "type": "string" + }, + "shareTypes": { + "type": "array", + "items": { + "type": "string" + } + }, + "protocols": { + "type": "object", + "required": [ + "webdav" + ], + "properties": { + "webdav": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + }, + "500": { + "description": "OCM not supported", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, "/ocs/v2.php/cloud/capabilities": { "get": { "operationId": "ocs-get-capabilities", @@ -5683,6 +5788,10 @@ { "name": "guest_avatar", "description": "This controller handles guest avatar requests." + }, + { + "name": "ocm", + "description": "Controller about the endpoint /ocm-provider/" } ] } diff --git a/packages/nextcloud/lib/src/api/dashboard.openapi.dart b/packages/nextcloud/lib/src/api/dashboard.openapi.dart index b85761c1..a4f86f5c 100644 --- a/packages/nextcloud/lib/src/api/dashboard.openapi.dart +++ b/packages/nextcloud/lib/src/api/dashboard.openapi.dart @@ -329,7 +329,7 @@ abstract class DashboardWidget implements DashboardWidgetInterface, Built get data; + BuiltMap get data; DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsInterface rebuild( final void Function(DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsInterfaceBuilder) updates, ); @@ -615,7 +615,10 @@ final Serializers _serializers = (Serializers().toBuilder() const FullType(BuiltList, [FullType(DashboardWidget_Buttons)]), ListBuilder.new, ) - ..addBuilderFactory(const FullType(BuiltList, [FullType(DashboardWidget)]), ListBuilder.new) + ..addBuilderFactory( + const FullType(BuiltMap, [FullType(String), FullType(DashboardWidget)]), + MapBuilder.new, + ) ..addBuilderFactory( const FullType(BuiltMap, [FullType(String), FullType(String)]), MapBuilder.new, diff --git a/packages/nextcloud/lib/src/api/dashboard.openapi.g.dart b/packages/nextcloud/lib/src/api/dashboard.openapi.g.dart index 4cdb380d..43738fc4 100644 --- a/packages/nextcloud/lib/src/api/dashboard.openapi.g.dart +++ b/packages/nextcloud/lib/src/api/dashboard.openapi.g.dart @@ -260,7 +260,8 @@ class _$DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsSerializer 'meta', serializers.serialize(object.meta, specifiedType: const FullType(DashboardOCSMeta)), 'data', - serializers.serialize(object.data, specifiedType: const FullType(BuiltList, [FullType(DashboardWidget)])), + serializers.serialize(object.data, + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(DashboardWidget)])), ]; return result; @@ -284,7 +285,7 @@ class _$DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsSerializer break; case 'data': result.data.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, [FullType(DashboardWidget)]))! as BuiltList); + specifiedType: const FullType(BuiltMap, [FullType(String), FullType(DashboardWidget)]))!); break; } } @@ -1179,8 +1180,8 @@ abstract mixin class DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsI DashboardOCSMetaBuilder get meta; set meta(DashboardOCSMetaBuilder? meta); - ListBuilder get data; - set data(ListBuilder? data); + MapBuilder get data; + set data(MapBuilder? data); } class _$DashboardDashboardApiGetWidgetsResponseApplicationJson_Ocs @@ -1188,7 +1189,7 @@ class _$DashboardDashboardApiGetWidgetsResponseApplicationJson_Ocs @override final DashboardOCSMeta meta; @override - final BuiltList data; + final BuiltMap data; factory _$DashboardDashboardApiGetWidgetsResponseApplicationJson_Ocs( [void Function(DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsBuilder)? updates]) => @@ -1245,9 +1246,9 @@ class DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsBuilder DashboardOCSMetaBuilder get meta => _$this._meta ??= DashboardOCSMetaBuilder(); set meta(covariant DashboardOCSMetaBuilder? meta) => _$this._meta = meta; - ListBuilder? _data; - ListBuilder get data => _$this._data ??= ListBuilder(); - set data(covariant ListBuilder? data) => _$this._data = data; + MapBuilder? _data; + MapBuilder get data => _$this._data ??= MapBuilder(); + set data(covariant MapBuilder? data) => _$this._data = data; DashboardDashboardApiGetWidgetsResponseApplicationJson_OcsBuilder(); diff --git a/packages/nextcloud/lib/src/api/dashboard.openapi.json b/packages/nextcloud/lib/src/api/dashboard.openapi.json index 62180035..3f33c906 100644 --- a/packages/nextcloud/lib/src/api/dashboard.openapi.json +++ b/packages/nextcloud/lib/src/api/dashboard.openapi.json @@ -221,8 +221,8 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "type": "array", - "items": { + "type": "object", + "additionalProperties": { "$ref": "#/components/schemas/Widget" } } diff --git a/packages/nextcloud/test/dashboard_test.dart b/packages/nextcloud/test/dashboard_test.dart new file mode 100644 index 00000000..ef7b6801 --- /dev/null +++ b/packages/nextcloud/test/dashboard_test.dart @@ -0,0 +1,44 @@ +import 'package:test/test.dart'; + +import 'helper.dart'; + +void main() { + group( + 'dashboard', + () { + late DockerImage image; + setUpAll(() async => image = await getDockerImage()); + + late DockerContainer container; + late TestNextcloudClient client; + setUp(() async { + container = await getDockerContainer(image); + client = await getTestClient(container); + }); + tearDown(() => container.destroy()); + + test('Get widgets', () async { + final response = await client.dashboard.dashboardApi.getWidgets(); + expect(response.ocs.data.keys, equals(['activity', 'notes', 'recommendations', 'user_status'])); + }); + + group('Get widget items', () { + test('v1', () async { + final response = await client.dashboard.dashboardApi.getWidgetItems(); + expect(response.ocs.data.keys, equals(['recommendations'])); + final items = response.ocs.data['recommendations']!; + expect(items, hasLength(7)); + }); + + test('v2', () async { + final response = await client.dashboard.dashboardApi.getWidgetItemsV2(); + expect(response.ocs.data.keys, equals(['recommendations'])); + final items = response.ocs.data['recommendations']!.items; + expect(items, hasLength(7)); + }); + }); + }, + retry: retryCount, + timeout: timeout, + ); +}