$createShare_Request method
- @experimental
Create a share.
Returns a DynamiteRequest backing the createShare operation.
Throws a DynamiteApiException if the API call does not return an expected status code.
Parameters:
pathPath of the share.permissionsPermissions for the share.shareTypeType of the share. Defaults to-1.shareWithThe entity this should be shared with.publicUploadIf public uploading is allowed. Defaults to"false".passwordPassword for the share. Defaults to"".sendPasswordByTalkSend the password for the share over Talk.expireDateExpiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used. Defaults to"".noteNote for the share. Defaults to"".labelLabel for the share (only used in link and email). Defaults to"".attributesAdditional attributes for the share.oCSAPIRequestRequired to be true for the API request to pass. Defaults totrue.
Status codes:
- 200: Share created
- 400: Unknown share type
- 403: Creating the share is not allowed
- 404: Creating the share failed
See:
- createShare for a method executing this request and parsing the response.
- $createShare_Serializer for a converter to parse the
Responsefrom an executed this request.
Implementation
@_i2.experimental
_i3.Request $createShare_Request({
String? path,
int? permissions,
int? shareType,
String? shareWith,
String? publicUpload,
String? password,
String? sendPasswordByTalk,
String? expireDate,
String? note,
String? label,
String? attributes,
bool? oCSAPIRequest,
}) {
final _parameters = <String, Object?>{};
final $path = _$jsonSerializers.serialize(path, specifiedType: const FullType(String));
_parameters['path'] = $path;
final $permissions = _$jsonSerializers.serialize(permissions, specifiedType: const FullType(int));
_parameters['permissions'] = $permissions;
var $shareType = _$jsonSerializers.serialize(shareType, specifiedType: const FullType(int));
$shareType ??= -1;
_parameters['shareType'] = $shareType;
final $shareWith = _$jsonSerializers.serialize(shareWith, specifiedType: const FullType(String));
_parameters['shareWith'] = $shareWith;
var $publicUpload = _$jsonSerializers.serialize(publicUpload, specifiedType: const FullType(String));
$publicUpload ??= 'false';
_parameters['publicUpload'] = $publicUpload;
var $password = _$jsonSerializers.serialize(password, specifiedType: const FullType(String));
$password ??= '';
_parameters['password'] = $password;
final $sendPasswordByTalk = _$jsonSerializers.serialize(sendPasswordByTalk, specifiedType: const FullType(String));
_parameters['sendPasswordByTalk'] = $sendPasswordByTalk;
var $expireDate = _$jsonSerializers.serialize(expireDate, specifiedType: const FullType(String));
$expireDate ??= '';
_parameters['expireDate'] = $expireDate;
var $note = _$jsonSerializers.serialize(note, specifiedType: const FullType(String));
$note ??= '';
_parameters['note'] = $note;
var $label = _$jsonSerializers.serialize(label, specifiedType: const FullType(String));
$label ??= '';
_parameters['label'] = $label;
final $attributes = _$jsonSerializers.serialize(attributes, specifiedType: const FullType(String));
_parameters['attributes'] = $attributes;
final _path = _i5.UriTemplate(
'/ocs/v2.php/apps/files_sharing/api/v1/shares{?path*,permissions*,shareType*,shareWith*,publicUpload*,password*,sendPasswordByTalk*,expireDate*,note*,label*,attributes*}',
).expand(_parameters);
final _uri = Uri.parse('${_rootClient.baseURL}$_path');
final _request = _i3.Request('post', _uri);
_request.headers['Accept'] = 'application/json';
// coverage:ignore-start
final authentication = _rootClient.authentications?.firstWhereOrNull(
(auth) => switch (auth) {
_i1.DynamiteHttpBearerAuthentication() || _i1.DynamiteHttpBasicAuthentication() => true,
_ => false,
},
);
if (authentication != null) {
_request.headers.addAll(
authentication.headers,
);
} else {
throw Exception('Missing authentication for bearer_auth or basic_auth');
}
// coverage:ignore-end
var $oCSAPIRequest = _$jsonSerializers.serialize(oCSAPIRequest, specifiedType: const FullType(bool));
$oCSAPIRequest ??= true;
_request.headers['OCS-APIRequest'] = const _i4.HeaderEncoder().convert($oCSAPIRequest);
return _request;
}