From b7f8dbb357bb7d0dab29ede428e3487ee487e236 Mon Sep 17 00:00:00 2001 From: xuty <xty50337@hotmail.com> Date: Sun, 28 Mar 2021 18:39:50 +0800 Subject: [PATCH] nnbd --- example/miniox_example.dart | 2 +- lib/io.dart | 12 +- lib/src/minio.dart | 204 ++--- lib/src/minio_client.dart | 90 +- lib/src/minio_errors.dart | 8 +- lib/src/minio_helpers.dart | 26 +- lib/src/minio_models.dart | 77 +- lib/src/minio_models_generated.dart | 1184 ++++++++++++++------------- lib/src/minio_poller.dart | 6 +- lib/src/minio_s3.dart | 1 - lib/src/minio_sign.dart | 10 +- lib/src/minio_uploader.dart | 22 +- lib/src/utils.dart | 4 +- pubspec.yaml | 2 +- test/minio_dart_test.dart | 21 +- util/generate_models.dart | 34 +- 16 files changed, 854 insertions(+), 849 deletions(-) diff --git a/example/miniox_example.dart b/example/miniox_example.dart index bef232f..4b6a709 100644 --- a/example/miniox_example.dart +++ b/example/miniox_example.dart @@ -14,4 +14,4 @@ void main() async { final stat = await minio.statObject('testbucket', 'test.png'); assert(stat.size == File('example/custed.png').lengthSync()); -} \ No newline at end of file +} diff --git a/lib/io.dart b/lib/io.dart index 112aad8..2a278f3 100644 --- a/lib/io.dart +++ b/lib/io.dart @@ -11,7 +11,7 @@ extension MinioX on Minio { String bucket, String object, String filePath, [ - Map<String, String> metadata, + Map<String, String>? metadata, ]) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); @@ -24,7 +24,7 @@ extension MinioX on Minio { final stat = await file.stat(); if (stat.size > maxObjectSize) { throw MinioError( - '${filePath} size : ${stat.size}, max allowed size : 5TB', + '$filePath size : ${stat.size}, max allowed size : 5TB', ); } @@ -32,7 +32,7 @@ extension MinioX on Minio { bucket, object, file.openRead(), - stat.size, + size: stat.size, metadata: metadata, ); } @@ -50,12 +50,14 @@ extension MinioX on Minio { final dir = dirname(filePath); await Directory(dir).create(recursive: true); - final partFileName = '${filePath}.${stat.etag}.part.minio'; + final partFileName = '$filePath.${stat.etag}.part.minio'; final partFile = File(partFileName); IOSink partFileStream; var offset = 0; - final rename = () => partFile.rename(filePath); + final rename = () { + partFile.rename(filePath); + }; if (await partFile.exists()) { final localStat = await partFile.stat(); diff --git a/lib/src/minio.dart b/lib/src/minio.dart index d351b4b..cae7473 100644 --- a/lib/src/minio.dart +++ b/lib/src/minio.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'package:http/http.dart'; @@ -10,6 +11,7 @@ import 'package:minio/src/minio_sign.dart'; import 'package:minio/src/minio_uploader.dart'; import 'package:minio/src/utils.dart'; import 'package:xml/xml.dart' as xml; +import 'package:xml/xml.dart' show XmlElement; import '../models.dart'; import 'minio_helpers.dart'; @@ -20,16 +22,13 @@ class Minio { this.endPoint, this.port, this.useSSL = true, - this.accessKey = '', - this.secretKey = '', + required this.accessKey, + required this.secretKey, this.sessionToken, this.region, this.enableTrace = false, }) : assert(isValidEndpoint(endPoint)), - assert(port == null || isValidPort(port)), - assert(useSSL != null), - assert(accessKey != null), - assert(secretKey != null) { + assert(port == null || isValidPort(port)) { _client = MinioClient(this); } @@ -43,10 +42,10 @@ class Minio { final maxObjectSize = 5 * 1024 * 1024 * 1024 * 1024; /// endPoint is a host name or an IP address. - final String endPoint; + final String? endPoint; /// TCP/IP port number. This input is optional. Default value set to 80 for HTTP and 443 for HTTPs. - final int port; + final int? port; /// If set to true, https is used instead of http. Default is true. final bool useSSL; @@ -58,16 +57,16 @@ class Minio { final String secretKey; /// Set this value to provide x-amz-security-token (AWS S3 specific). (Optional) - final String sessionToken; + final String? sessionToken; /// Set this value to override region cache. (Optional) - final String region; + final String? region; /// Set this value to enable tracing. (Optional) final bool enableTrace; - MinioClient _client; - final _regionMap = <String, String>{}; + late MinioClient _client; + final _regionMap = <String?, String>{}; /// Checks if a bucket exists. /// @@ -81,7 +80,7 @@ class Minio { validate(response); return response.statusCode == 200; } on MinioS3Error catch (e) { - final code = e.error.code; + final code = e.error?.code; if (code == 'NoSuchBucket' || code == 'NotFound' || code == 'Not Found') { return false; } @@ -101,16 +100,12 @@ class Minio { } int _calculatePartSize(int size) { - assert(size != null && size >= 0); + assert(size >= 0); if (size > maxObjectSize) { throw ArgumentError('size should not be more than $maxObjectSize'); } - if (this.partSize != null) { - return this.partSize; - } - var partSize = this.partSize; while (true) { if ((partSize * 10000) > size) { @@ -131,9 +126,6 @@ class Minio { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); - assert(uploadId != null); - assert(parts != null); - var queries = {'uploadId': uploadId}; var payload = CompleteMultipartUpload(parts).toXml().toString(); @@ -162,7 +154,7 @@ class Minio { String bucket, String object, String srcObject, [ - CopyConditions conditions, + CopyConditions? conditions, ]) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); @@ -173,17 +165,18 @@ class Minio { if (conditions != null) { if (conditions.modified != null) { - headers['x-amz-copy-source-if-modified-since'] = conditions.modified; + headers['x-amz-copy-source-if-modified-since'] = conditions.modified!; } if (conditions.unmodified != null) { headers['x-amz-copy-source-if-unmodified-since'] = - conditions.unmodified; + conditions.unmodified!; } if (conditions.matchETag != null) { - headers['x-amz-copy-source-if-match'] = conditions.matchETag; + headers['x-amz-copy-source-if-match'] = conditions.matchETag!; } if (conditions.matchETagExcept != null) { - headers['x-amz-copy-source-if-none-match'] = conditions.matchETagExcept; + headers['x-amz-copy-source-if-none-match'] = + conditions.matchETagExcept!; } } @@ -198,19 +191,19 @@ class Minio { final node = xml.XmlDocument.parse(resp.body); final result = CopyObjectResult.fromXml(node.rootElement); - result.eTag = trimDoubleQuote(result.eTag); + result.eTag = trimDoubleQuote(result.eTag!); return result; } /// Find uploadId of an incomplete upload. - Future<String> findUploadId(String bucket, String object) async { + Future<String?> findUploadId(String bucket, String object) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); - MultipartUpload latestUpload; - String keyMarker; - String uploadIdMarker; - var isTruncated = false; + MultipartUpload? latestUpload; + String? keyMarker; + String? uploadIdMarker; + bool? isTruncated = false; do { final result = await listIncompleteUploadsQuery( @@ -223,14 +216,14 @@ class Minio { for (var upload in result.uploads) { if (upload.key != object) continue; if (latestUpload == null || - upload.initiated.isAfter(latestUpload.initiated)) { + upload.initiated!.isAfter(latestUpload.initiated!)) { latestUpload = upload; } } keyMarker = result.nextKeyMarker; uploadIdMarker = result.nextUploadIdMarker; isTruncated = result.isTruncated; - } while (isTruncated); + } while (isTruncated!); return latestUpload?.uploadId; } @@ -255,7 +248,7 @@ class Minio { /// Get the bucket policy associated with the specified bucket. If `objectPrefix` /// is not empty, the bucket policy will be filtered based on object permissions /// as well. - Future<Map<String, dynamic>> getBucketPolicy(bucket) async { + Future<Map<String, dynamic>?> getBucketPolicy(bucket) async { MinioInvalidBucketNameError.check(bucket); final resp = await _client.request( @@ -273,8 +266,13 @@ class Minio { Future<String> getBucketRegion(String bucket) async { MinioInvalidBucketNameError.check(bucket); - if (region != null) return region; - if (_regionMap.containsKey(bucket)) return _regionMap[bucket]; + if (region != null) { + return region!; + } + + if (_regionMap.containsKey(bucket)) { + return _regionMap[bucket]!; + } final resp = await _client.request( method: 'GET', @@ -288,7 +286,8 @@ class Minio { final node = xml.XmlDocument.parse(resp.body); var location = node.findAllElements('LocationConstraint').first.text; - if (location == null || location.isEmpty) { + // if (location == null || location.isEmpty) { + if (location.isEmpty) { location = 'us-east-1'; } @@ -307,8 +306,8 @@ class Minio { Future<ByteStream> getPartialObject( String bucket, String object, [ - int offset, - int length, + int? offset, + int? length, ]) async { assert(offset == null || offset >= 0); assert(length == null || length > 0); @@ -316,7 +315,7 @@ class Minio { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); - String range; + String? range; if (offset != null || length != null) { if (offset != null) { range = 'bytes=$offset-'; @@ -347,7 +346,7 @@ class Minio { Future<String> initiateNewMultipartUpload( String bucket, String object, - Map<String, String> metaData, + Map<String, String>? metaData, ) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); @@ -377,8 +376,8 @@ class Minio { final delimiter = recursive ? '' : '/'; - String keyMarker; - String uploadIdMarker; + String? keyMarker; + String? uploadIdMarker; var isTruncated = false; do { @@ -390,13 +389,14 @@ class Minio { delimiter, ); for (var upload in result.uploads) { - final parts = await listParts(bucket, upload.key, upload.uploadId); - final size = await parts.fold(0, (acc, item) => acc + item.size); + final parts = listParts(bucket, upload.key!, upload.uploadId!); + final size = + await parts.fold(0, (dynamic acc, item) => acc + item.size); yield IncompleteUpload(upload: upload, size: size); } keyMarker = result.nextKeyMarker; uploadIdMarker = result.nextUploadIdMarker; - isTruncated = result.isTruncated; + isTruncated = result.isTruncated!; } while (isTruncated); } @@ -404,8 +404,8 @@ class Minio { Future<ListMultipartUploadsOutput> listIncompleteUploadsQuery( String bucket, String prefix, - String keyMarker, - String uploadIdMarker, + String? keyMarker, + String? uploadIdMarker, String delimiter, ) async { MinioInvalidBucketNameError.check(bucket); @@ -434,7 +434,7 @@ class Minio { validate(resp); final node = xml.XmlDocument.parse(resp.body); - return ListMultipartUploadsOutput.fromXml(node.root); + return ListMultipartUploadsOutput.fromXml(node.root as XmlElement); } /// Listen for notifications on a bucket. Additionally one can provider @@ -443,9 +443,9 @@ class Minio { /// are regitered and unregistered by the server automatically based on incoming requests. NotificationPoller listenBucketNotification( String bucket, { - String prefix, - String suffix, - List<String> events, + String? prefix, + String? suffix, + List<String>? events, }) { MinioInvalidBucketNameError.check(bucket); @@ -465,7 +465,9 @@ class Minio { validate(resp); final bucketsNode = xml.XmlDocument.parse(resp.body).findAllElements('Buckets').first; - return bucketsNode.children.map((n) => Bucket.fromXml(n)).toList(); + return bucketsNode.children + .map((n) => Bucket.fromXml(n as XmlElement)) + .toList(); } /// Returns all [Object]s in a bucket. @@ -479,7 +481,7 @@ class Minio { MinioInvalidPrefixError.check(prefix); final delimiter = recursive ? '' : '/'; - String marker; + String? marker; var isTruncated = false; do { @@ -490,11 +492,12 @@ class Minio { delimiter, 1000, ); - isTruncated = resp.isTruncated; + isTruncated = resp.isTruncated!; marker = resp.nextMarker; - yield ListObjectsChunk() - ..objects = resp.contents - ..prefixes = resp.commonPrefixes.map((e) => e.prefix).toList(); + yield ListObjectsChunk( + objects: resp.contents!, + prefixes: resp.commonPrefixes.map((e) => e.prefix).toList(), + ); } while (isTruncated); } @@ -502,9 +505,9 @@ class Minio { Future<ListObjectsOutput> listObjectsQuery( String bucket, String prefix, - String marker, + String? marker, String delimiter, - int maxKeys, + int? maxKeys, ) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidPrefixError.check(prefix); @@ -531,7 +534,7 @@ class Minio { validate(resp); final node = xml.XmlDocument.parse(resp.body); - final isTruncated = getNodeProp(node.rootElement, 'IsTruncated')?.text; + final isTruncated = getNodeProp(node.rootElement, 'IsTruncated')!.text; final nextMarker = getNodeProp(node.rootElement, 'NextMarker')?.text; final objs = node.findAllElements('Contents').map((c) => Object.fromXml(c)); final prefixes = node @@ -551,14 +554,14 @@ class Minio { String bucket, { String prefix = '', bool recursive = false, - String startAfter, + String? startAfter, }) async* { MinioInvalidBucketNameError.check(bucket); MinioInvalidPrefixError.check(prefix); final delimiter = recursive ? '' : '/'; - var isTruncated = false; - String continuationToken; + bool? isTruncated = false; + String? continuationToken; do { final resp = await listObjectsV2Query( @@ -571,20 +574,21 @@ class Minio { ); isTruncated = resp.isTruncated; continuationToken = resp.nextContinuationToken; - yield ListObjectsChunk() - ..objects = resp.contents - ..prefixes = resp.commonPrefixes.map((e) => e.prefix).toList(); - } while (isTruncated); + yield ListObjectsChunk( + objects: resp.contents!, + prefixes: resp.commonPrefixes.map((e) => e.prefix).toList(), + ); + } while (isTruncated!); } /// listObjectsV2Query - (List Objects V2) - List some or all (up to 1000) of the objects in a bucket. Future<ListObjectsV2Output> listObjectsV2Query( String bucket, String prefix, - String continuationToken, + String? continuationToken, String delimiter, - int maxKeys, - String startAfter, + int? maxKeys, + String? startAfter, ) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidPrefixError.check(prefix); @@ -616,7 +620,7 @@ class Minio { validate(resp); final node = xml.XmlDocument.parse(resp.body); - final isTruncated = getNodeProp(node.rootElement, 'IsTruncated')?.text; + final isTruncated = getNodeProp(node.rootElement, 'IsTruncated')!.text; final nextContinuationToken = getNodeProp(node.rootElement, 'NextContinuationToken')?.text; final objs = node.findAllElements('Contents').map((c) => Object.fromXml(c)); @@ -652,10 +656,10 @@ class Minio { /// Called by listParts to fetch a batch of part-info Future<ListPartsOutput> listPartsQuery( - String bucket, - String object, - String uploadId, - int marker, + String? bucket, + String? object, + String? uploadId, + int? marker, ) async { var queries = <String, dynamic>{'uploadId': uploadId}; @@ -673,11 +677,11 @@ class Minio { validate(resp); final node = xml.XmlDocument.parse(resp.body); - return ListPartsOutput.fromXml(node.root); + return ListPartsOutput.fromXml(node.root as XmlElement); } /// Creates the bucket [bucket]. - Future<void> makeBucket(String bucket, [String region]) async { + Future<void> makeBucket(String bucket, [String? region]) async { MinioInvalidBucketNameError.check(bucket); if (this.region != null && region != null && this.region != region) { throw MinioInvalidArgumentError( @@ -698,7 +702,7 @@ class Minio { ); validate(resp); - return resp.body; + // return resp.body; } /// Generate a presigned URL for GET @@ -711,9 +715,9 @@ class Minio { Future<String> presignedGetObject( String bucket, String object, { - int expires, - Map<String, String> respHeaders, - DateTime requestDate, + int? expires, + Map<String, String>? respHeaders, + DateTime? requestDate, }) { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); @@ -738,7 +742,7 @@ class Minio { ); } - final region = await getBucketRegion(postPolicy.formData['bucket']); + final region = await getBucketRegion(postPolicy.formData['bucket']!); var date = DateTime.now().toUtc(); var dateStr = makeDateLong(date); @@ -779,7 +783,7 @@ class Minio { null, null, null) .url; var portStr = (port == 80 || port == 443 || port == null) ? '' : ':$port'; - var urlStr = '${url.scheme}://${url.host}${portStr}${url.path}'; + var urlStr = '${url.scheme}://${url.host}$portStr${url.path}'; return PostPolicyResult(postURL: urlStr, formData: postPolicy.formData); } @@ -792,7 +796,7 @@ class Minio { Future<String> presignedPutObject( String bucket, String object, { - int expires, + int? expires, }) { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); @@ -812,10 +816,10 @@ class Minio { String method, String bucket, String object, { - int expires, - String resource, - Map<String, String> reqParams, - DateTime requestDate, + int? expires, + String? resource, + Map<String, String>? reqParams, + DateTime? requestDate, }) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); @@ -843,15 +847,14 @@ class Minio { Future<String> putObject( String bucket, String object, - Stream<List<int>> data, - int size, { - Map<String, String> metadata, + Stream<List<int>> data, { + int? size, + Map<String, String>? metadata, }) async { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); - assert(data != null); - assert(size >= 0 || size == null); + assert(size == null || size >= 0); metadata = prependXAMZMeta(metadata ?? <String, String>{}); @@ -950,7 +953,6 @@ class Minio { NotificationConfiguration config, ) async { MinioInvalidBucketNameError.check(bucket); - assert(config != null); final resp = await _client.request( method: 'PUT', @@ -967,7 +969,7 @@ class Minio { /// [policy] is detailed [here](https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html). Future<void> setBucketPolicy( String bucket, [ - Map<String, dynamic> policy, + Map<String, dynamic>? policy, ]) async { MinioInvalidBucketNameError.check(bucket); @@ -988,7 +990,7 @@ class Minio { MinioInvalidBucketNameError.check(bucket); MinioInvalidObjectNameError.check(object); - final resp = await _client.request( + await _client.request( method: 'PUT', bucket: bucket, object: object, @@ -1008,7 +1010,7 @@ class Minio { ); return AccessControlPolicy.fromXml( - xml.XmlDocument.parse(resp.body).firstChild, + xml.XmlDocument.parse(resp.body).firstChild as XmlElement?, ); } @@ -1032,9 +1034,9 @@ class Minio { return StatObjectResult( etag: etag, - size: int.parse(resp.headers['content-length']), + size: int.parse(resp.headers['content-length']!), metaData: extractMetadata(resp.headers), - lastModified: parseRfc7231Time(resp.headers['last-modified']), + lastModified: parseRfc7231Time(resp.headers['last-modified']!), acl: await getObjectACL(bucket, object), ); } diff --git a/lib/src/minio_client.dart b/lib/src/minio_client.dart index 7bb8d08..0c3acaa 100644 --- a/lib/src/minio_client.dart +++ b/lib/src/minio_client.dart @@ -31,9 +31,9 @@ class MinioRequest extends BaseRequest { } MinioRequest replace({ - String method, - Uri url, - Map<String, String> headers, + String? method, + Uri? url, + Map<String, String>? headers, body, }) { final result = MinioRequest(method ?? this.method, url ?? this.url); @@ -53,21 +53,25 @@ class MinioClient { final Minio minio; final String userAgent = 'MinIO (Unknown; Unknown) minio-dart/0.1.9'; - bool enableSHA256; - bool anonymous; - int port; + late bool enableSHA256; + late bool anonymous; + int? port; Future<StreamedResponse> _request({ - String method, - String bucket, - String object, - String region, - String resource, + required String method, + String? bucket, + String? object, + String? region, + String? resource, dynamic payload = '', - Map<String, dynamic> queries, - Map<String, String> headers, + Map<String, dynamic>? queries, + Map<String, String>? headers, }) async { - region ??= await minio.getBucketRegion(bucket); + if (bucket != null) { + region ??= await minio.getBucketRegion(bucket); + } + + region ??= 'us-east-1'; final request = getBaseRequest( method, bucket, object, region, resource, queries, headers); @@ -90,14 +94,14 @@ class MinioClient { } Future<Response> request({ - String method, - String bucket, - String object, - String region, - String resource, + required String method, + String? bucket, + String? object, + String? region, + String? resource, dynamic payload = '', - Map<String, dynamic> queries, - Map<String, String> headers, + Map<String, dynamic>? queries, + Map<String, String>? headers, }) async { final stream = await _request( method: method, @@ -117,14 +121,14 @@ class MinioClient { } Future<StreamedResponse> requestStream({ - String method, - String bucket, - String object, - String region, - String resource, + required String method, + String? bucket, + String? object, + String? region, + String? resource, dynamic payload = '', - Map<String, dynamic> queries, - Map<String, String> headers, + Map<String, dynamic>? queries, + Map<String, String>? headers, }) async { final response = await _request( method: method, @@ -143,12 +147,12 @@ class MinioClient { MinioRequest getBaseRequest( String method, - String bucket, - String object, + String? bucket, + String? object, String region, - String resource, - Map<String, dynamic> queries, - Map<String, String> headers, + String? resource, + Map<String, dynamic>? queries, + Map<String, String>? headers, ) { final url = getRequestUrl(bucket, object, resource, queries); final request = MinioRequest(method, url); @@ -162,24 +166,24 @@ class MinioClient { } Uri getRequestUrl( - String bucket, - String object, - String resource, - Map<String, dynamic> queries, + String? bucket, + String? object, + String? resource, + Map<String, dynamic>? queries, ) { - var host = minio.endPoint.toLowerCase(); + var host = minio.endPoint!.toLowerCase(); var path = '/'; if (isAmazonEndpoint(host)) { - host = getS3Endpoint(minio.region); + host = getS3Endpoint(minio.region!); } if (isVirtualHostStyle(host, minio.useSSL, bucket)) { - if (bucket != null) host = '${bucket}.${host}'; - if (object != null) path = '/${object}'; + if (bucket != null) host = '$bucket.$host'; + if (object != null) path = '/$object'; } else { - if (bucket != null) path = '/${bucket}'; - if (object != null) path = '/${bucket}/${object}'; + if (bucket != null) path = '/$bucket'; + if (object != null) path = '/$bucket/$object'; } final resourcePart = resource == null ? '' : '$resource'; diff --git a/lib/src/minio_errors.dart b/lib/src/minio_errors.dart index e46592f..54a9950 100644 --- a/lib/src/minio_errors.dart +++ b/lib/src/minio_errors.dart @@ -5,7 +5,7 @@ import 'package:minio/src/minio_helpers.dart'; class MinioError { MinioError(this.message); - final String message; + final String? message; @override String toString() { @@ -85,8 +85,8 @@ class MinioInvalidXMLError extends MinioError { } class MinioS3Error extends MinioError { - MinioS3Error(String message, [this.error, this.response]) : super(message); + MinioS3Error(String? message, [this.error, this.response]) : super(message); - Error error; - Response response; + Error? error; + Response? response; } diff --git a/lib/src/minio_helpers.dart b/lib/src/minio_helpers.dart index 57bd145..0eeebe4 100644 --- a/lib/src/minio_helpers.dart +++ b/lib/src/minio_helpers.dart @@ -5,8 +5,6 @@ import 'package:minio/src/minio_models_generated.dart'; import 'package:xml/xml.dart' as xml; bool isValidBucketName(String bucket) { - if (bucket == null) return false; - if (bucket.length < 3 || bucket.length > 63) { return false; } @@ -25,14 +23,13 @@ bool isValidBucketName(String bucket) { return false; } -bool isValidObjectName(objectName) { +bool isValidObjectName(String objectName) { if (!isValidPrefix(objectName)) return false; if (objectName.isEmpty) return false; return true; } bool isValidPrefix(String prefix) { - if (prefix == null) return false; if (prefix.length > 1024) return false; return true; } @@ -42,7 +39,7 @@ bool isAmazonEndpoint(String endpoint) { endpoint == 's3.cn-north-1.amazonaws.com.cn'; } -bool isVirtualHostStyle(String endpoint, bool useSSL, String bucket) { +bool isVirtualHostStyle(String endpoint, bool useSSL, String? bucket) { if (bucket == null) { return false; } @@ -58,12 +55,12 @@ bool isValidEndpoint(endpoint) { return isValidDomain(endpoint) || isValidIPv4(endpoint); } -bool isValidIPv4(String ip) { +bool isValidIPv4(String? ip) { if (ip == null) return false; return RegExp(r'^(\d{1,3}\.){3,3}\d{1,3}$').hasMatch(ip); } -bool isValidDomain(String host) { +bool isValidDomain(String? host) { if (host == null) return false; if (host.isEmpty || host.length > 255) { @@ -91,7 +88,6 @@ bool isValidDomain(String host) { } bool isValidPort(int port) { - if (port == null) return false; if (port < 0) return false; if (port == 0) return true; const minPort = 1; @@ -124,13 +120,13 @@ String makeDateShort(DateTime date) { isoDate.substring(8, 10); } -Map<String, String> prependXAMZMeta(Map<String, String> metadata) { +Map<String, String> prependXAMZMeta(Map<String, String?> metadata) { final newMetadata = Map<String, String>.from(metadata); for (var key in metadata.keys) { if (!isAmzHeader(key) && !isSupportedHeader(key) && !isStorageclassHeader(key)) { - newMetadata['x-amz-meta-' + key] = newMetadata[key]; + newMetadata['x-amz-meta-' + key] = newMetadata[key]!; newMetadata.remove(key); } } @@ -168,9 +164,9 @@ Map<String, String> extractMetadata(Map<String, String> metaData) { isStorageclassHeader(key) || isAmzHeader(key)) { if (key.toLowerCase().startsWith('x-amz-meta-')) { - newMetadata[key.substring(11, key.length)] = metaData[key]; + newMetadata[key.substring(11, key.length)] = metaData[key]!; } else { - newMetadata[key] = metaData[key]; + newMetadata[key] = metaData[key]!; } } } @@ -199,7 +195,7 @@ Map<String, String> insertContentType( Future<void> validateStreamed( StreamedResponse streamedResponse, { - int expect, + int? expect, }) async { if (streamedResponse.statusCode >= 400) { final response = await Response.fromStream(streamedResponse); @@ -215,12 +211,12 @@ Future<void> validateStreamed( } } -void validate(Response response, {int expect}) { +void validate(Response response, {int? expect}) { if (response.statusCode >= 400) { var error; // Parse HTTP response body as XML only when not empty - if (response.body == null || response.body.isEmpty) { + if (response.body.isEmpty) { error = Error(response.reasonPhrase, null, response.reasonPhrase, null); } else { final body = xml.XmlDocument.parse(response.body); diff --git a/lib/src/minio_models.dart b/lib/src/minio_models.dart index 661bc47..3b9cc58 100644 --- a/lib/src/minio_models.dart +++ b/lib/src/minio_models.dart @@ -5,22 +5,27 @@ import 'package:xml/xml.dart'; import '../models.dart'; class ListObjectsChunk { - List<Object> objects; - List<String> prefixes; + ListObjectsChunk({ + required this.objects, + required this.prefixes, + }); + + final List<Object> objects; + final List<String?> prefixes; } class ListObjectsOutput { - bool isTruncated; - String nextMarker; - List<Object> contents; - List<CommonPrefix> commonPrefixes; + bool? isTruncated; + String? nextMarker; + List<Object>? contents; + late List<CommonPrefix> commonPrefixes; } class ListObjectsV2Output { - bool isTruncated; - String nextContinuationToken; - List<Object> contents; - List<CommonPrefix> commonPrefixes; + bool? isTruncated; + String? nextContinuationToken; + List<Object>? contents; + late List<CommonPrefix> commonPrefixes; } class CompleteMultipartUpload { @@ -41,7 +46,7 @@ class CompleteMultipartUpload { class ListMultipartUploadsOutput { ListMultipartUploadsOutput.fromXml(XmlElement xml) { - isTruncated = getProp(xml, 'IsLatest')?.text?.toUpperCase() == 'TRUE'; + isTruncated = getProp(xml, 'IsLatest')?.text.toUpperCase() == 'TRUE'; nextKeyMarker = getProp(xml, 'NextKeyMarker')?.text; nextUploadIdMarker = getProp(xml, 'NextUploadIdMarker')?.text; uploads = xml @@ -50,23 +55,23 @@ class ListMultipartUploadsOutput { .toList(); } - bool isTruncated; - String nextKeyMarker; - String nextUploadIdMarker; - List<MultipartUpload> uploads; + bool? isTruncated; + String? nextKeyMarker; + String? nextUploadIdMarker; + late List<MultipartUpload> uploads; } class ListPartsOutput { ListPartsOutput.fromXml(XmlElement xml) { - isTruncated = getProp(xml, 'IsLatest')?.text?.toUpperCase() == 'TRUE'; + isTruncated = getProp(xml, 'IsLatest')?.text.toUpperCase() == 'TRUE'; nextPartNumberMarker = - int.parse(getProp(xml, 'NextPartNumberMarker')?.text); + int.parse(getProp(xml, 'NextPartNumberMarker')!.text); parts = xml.findElements('Upload').map((e) => Part.fromXml(e)).toList(); } - bool isTruncated; - int nextPartNumberMarker; - List<Part> parts; + late bool isTruncated; + late int nextPartNumberMarker; + late List<Part> parts; } class IncompleteUpload { @@ -75,15 +80,15 @@ class IncompleteUpload { this.size, }); - final MultipartUpload upload; - final int size; + final MultipartUpload? upload; + final int? size; } class CopyConditions { - String modified; - String unmodified; - String matchETag; - String matchETagExcept; + String? modified; + String? unmodified; + String? matchETag; + String? matchETagExcept; void setModified(DateTime date) { modified = date.toUtc().toIso8601String(); @@ -111,11 +116,11 @@ class StatObjectResult { this.acl, }); - final int size; - final String etag; - final DateTime lastModified; - final Map<String, String> metaData; - final AccessControlPolicy acl; + final int? size; + final String? etag; + final DateTime? lastModified; + final Map<String, String?>? metaData; + final AccessControlPolicy? acl; } /// Build PostPolicy object that can be signed by presignedPostPolicy @@ -128,9 +133,6 @@ class PostPolicy { /// set expiration date void setExpires(DateTime date) { - if (date == null) { - throw MinioInvalidDateError('Invalid date : cannot be null'); - } policy['expiration'] = date.toIso8601String(); } @@ -157,9 +159,6 @@ class PostPolicy { /// set Content-Type void setContentType(String type) { - if (type == null) { - throw MinioError('content-type cannot be null'); - } policy['conditions'].push(['eq', r'$Content-Type', type]); formData['Content-Type'] = type; } @@ -182,6 +181,6 @@ class PostPolicy { class PostPolicyResult { PostPolicyResult({this.postURL, this.formData}); - final String postURL; - final Map<String, String> formData; + final String? postURL; + final Map<String, String>? formData; } diff --git a/lib/src/minio_models_generated.dart b/lib/src/minio_models_generated.dart index 5a92210..1e55235 100644 --- a/lib/src/minio_models_generated.dart +++ b/lib/src/minio_models_generated.dart @@ -1,6 +1,6 @@ import 'package:xml/xml.dart'; -XmlElement getProp(XmlElement xml, String name) { +XmlElement? getProp(XmlElement? xml, String name) { if (xml == null) return null; final result = xml.findElements(name); return result.isNotEmpty ? result.first : null; @@ -12,9 +12,9 @@ class AbortIncompleteMultipartUpload { this.daysAfterInitiation, ); - AbortIncompleteMultipartUpload.fromXml(XmlElement xml) { + AbortIncompleteMultipartUpload.fromXml(XmlElement? xml) { daysAfterInitiation = - int.tryParse(getProp(xml, 'DaysAfterInitiation')?.text); + int.tryParse(getProp(xml, 'DaysAfterInitiation')!.text); } XmlNode toXml() { @@ -27,7 +27,7 @@ class AbortIncompleteMultipartUpload { } /// Specifies the number of days after which Amazon S3 aborts an incomplete multipart upload. - int daysAfterInitiation; + int? daysAfterInitiation; } /// Configures the transfer acceleration state for an Amazon S3 bucket. For more information, see Amazon S3 Transfer Acceleration in the Amazon Simple Storage Service Developer Guide. @@ -49,7 +49,7 @@ class AccelerateConfiguration { } /// Specifies the transfer acceleration status of the bucket. - String status; + String? status; } /// Contains the elements that set the ACL permissions for an object per grantee. @@ -59,7 +59,7 @@ class AccessControlPolicy { this.owner, ); - AccessControlPolicy.fromXml(XmlElement xml) { + AccessControlPolicy.fromXml(XmlElement? xml) { grants = Grant.fromXml(getProp(xml, 'Grants')); owner = Owner.fromXml(getProp(xml, 'Owner')); } @@ -67,17 +67,17 @@ class AccessControlPolicy { XmlNode toXml() { final builder = XmlBuilder(); builder.element('AccessControlPolicy', nest: () { - builder.element('Grants', nest: grants.toXml()); - builder.element('Owner', nest: owner.toXml()); + builder.element('Grants', nest: grants!.toXml()); + builder.element('Owner', nest: owner!.toXml()); }); return builder.buildDocument(); } /// A list of grants. - Grant grants; + Grant? grants; /// Container for the bucket owner's display name and ID. - Owner owner; + Owner? owner; } /// A container for information about access control for replicas. @@ -86,7 +86,7 @@ class AccessControlTranslation { this.owner, ); - AccessControlTranslation.fromXml(XmlElement xml) { + AccessControlTranslation.fromXml(XmlElement? xml) { owner = getProp(xml, 'Owner')?.text; } @@ -99,7 +99,7 @@ class AccessControlTranslation { } /// Specifies the replica ownership. For default and valid values, see PUT bucket replication in the Amazon Simple Storage Service API Reference. - String owner; + String? owner; } /// A conjunction (logical AND) of predicates, which is used in evaluating a metrics filter. The operator must have at least two predicates in any combination, and an object must match all of the predicates for the filter to apply. @@ -109,7 +109,7 @@ class AnalyticsAndOperator { this.tags, ); - AnalyticsAndOperator.fromXml(XmlElement xml) { + AnalyticsAndOperator.fromXml(XmlElement? xml) { prefix = getProp(xml, 'Prefix')?.text; tags = Tag.fromXml(getProp(xml, 'Tags')); } @@ -118,16 +118,16 @@ class AnalyticsAndOperator { final builder = XmlBuilder(); builder.element('AnalyticsAndOperator', nest: () { builder.element('Prefix', nest: prefix); - builder.element('Tags', nest: tags.toXml()); + builder.element('Tags', nest: tags!.toXml()); }); return builder.buildDocument(); } /// The prefix to use when evaluating an AND predicate: The prefix that an object must have to be included in the metrics results. - String prefix; + String? prefix; /// The list of tags to use when evaluating an AND predicate. - Tag tags; + Tag? tags; } /// Specifies the configuration and any analyses for the analytics filter of an Amazon S3 bucket. @@ -148,22 +148,22 @@ class AnalyticsConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('AnalyticsConfiguration', nest: () { - builder.element('Filter', nest: filter.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('Id', nest: id); builder.element('StorageClassAnalysis', - nest: storageClassAnalysis.toXml()); + nest: storageClassAnalysis!.toXml()); }); return builder.buildDocument(); } /// The filter used to describe a set of objects for analyses. A filter must have exactly one prefix, one tag, or one conjunction (AnalyticsAndOperator). If no filter is provided, all objects will be considered in any analysis. - AnalyticsFilter filter; + AnalyticsFilter? filter; /// The ID that identifies the analytics configuration. - String id; + String? id; /// Contains data related to access patterns to be collected and made available to analyze the tradeoffs between different storage classes. - StorageClassAnalysis storageClassAnalysis; + StorageClassAnalysis? storageClassAnalysis; } /// Where to publish the analytics results. @@ -172,7 +172,7 @@ class AnalyticsExportDestination { this.s3BucketDestination, ); - AnalyticsExportDestination.fromXml(XmlElement xml) { + AnalyticsExportDestination.fromXml(XmlElement? xml) { s3BucketDestination = AnalyticsS3BucketDestination.fromXml( getProp(xml, 'S3BucketDestination')); } @@ -180,13 +180,14 @@ class AnalyticsExportDestination { XmlNode toXml() { final builder = XmlBuilder(); builder.element('AnalyticsExportDestination', nest: () { - builder.element('S3BucketDestination', nest: s3BucketDestination.toXml()); + builder.element('S3BucketDestination', + nest: s3BucketDestination!.toXml()); }); return builder.buildDocument(); } /// A destination signifying output to an S3 bucket. - AnalyticsS3BucketDestination s3BucketDestination; + AnalyticsS3BucketDestination? s3BucketDestination; } /// The filter used to describe a set of objects for analyses. A filter must have exactly one prefix, one tag, or one conjunction (AnalyticsAndOperator). If no filter is provided, all objects will be considered in any analysis. @@ -197,7 +198,7 @@ class AnalyticsFilter { this.tag, ); - AnalyticsFilter.fromXml(XmlElement xml) { + AnalyticsFilter.fromXml(XmlElement? xml) { and = AnalyticsAndOperator.fromXml(getProp(xml, 'And')); prefix = getProp(xml, 'Prefix')?.text; tag = Tag.fromXml(getProp(xml, 'Tag')); @@ -206,21 +207,21 @@ class AnalyticsFilter { XmlNode toXml() { final builder = XmlBuilder(); builder.element('AnalyticsFilter', nest: () { - builder.element('And', nest: and.toXml()); + builder.element('And', nest: and!.toXml()); builder.element('Prefix', nest: prefix); - builder.element('Tag', nest: tag.toXml()); + builder.element('Tag', nest: tag!.toXml()); }); return builder.buildDocument(); } /// A conjunction (logical AND) of predicates, which is used in evaluating an analytics filter. The operator must have at least two predicates. - AnalyticsAndOperator and; + AnalyticsAndOperator? and; /// The prefix to use when evaluating an analytics filter. - String prefix; + String? prefix; /// The tag to use when evaluating an analytics filter. - Tag tag; + Tag? tag; } /// Contains information about where to publish the analytics results. @@ -232,7 +233,7 @@ class AnalyticsS3BucketDestination { this.prefix, ); - AnalyticsS3BucketDestination.fromXml(XmlElement xml) { + AnalyticsS3BucketDestination.fromXml(XmlElement? xml) { bucket = getProp(xml, 'Bucket')?.text; bucketAccountId = getProp(xml, 'BucketAccountId')?.text; format = getProp(xml, 'Format')?.text; @@ -251,16 +252,16 @@ class AnalyticsS3BucketDestination { } /// The Amazon Resource Name (ARN) of the bucket to which data is exported. - String bucket; + String? bucket; /// The account ID that owns the destination bucket. If no account ID is provided, the owner will not be validated prior to exporting data. - String bucketAccountId; + String? bucketAccountId; /// Specifies the file format used when exporting data to Amazon S3. - String format; + String? format; /// The prefix to use when exporting data. The prefix is prepended to all results. - String prefix; + String? prefix; } /// In terms of implementation, a Bucket is a resource. An Amazon S3 bucket name is globally unique, and the namespace is shared by all AWS accounts. @@ -271,24 +272,24 @@ class Bucket { ); Bucket.fromXml(XmlElement xml) { - creationDate = DateTime.parse(getProp(xml, 'CreationDate')?.text); + creationDate = DateTime.parse(getProp(xml, 'CreationDate')!.text); name = getProp(xml, 'Name')?.text; } XmlNode toXml() { final builder = XmlBuilder(); builder.element('Bucket', nest: () { - builder.element('CreationDate', nest: creationDate.toIso8601String()); + builder.element('CreationDate', nest: creationDate!.toIso8601String()); builder.element('Name', nest: name); }); return builder.buildDocument(); } /// Date the bucket was created. - DateTime creationDate; + DateTime? creationDate; /// The name of the bucket. - String name; + String? name; } /// Specifies the lifecycle configuration for objects in an Amazon S3 bucket. For more information, see Object Lifecycle Management in the Amazon Simple Storage Service Developer Guide. @@ -304,13 +305,13 @@ class BucketLifecycleConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('BucketLifecycleConfiguration', nest: () { - builder.element('Rules', nest: rules.toXml()); + builder.element('Rules', nest: rules!.toXml()); }); return builder.buildDocument(); } /// A lifecycle rule for individual objects in an Amazon S3 bucket. - LifecycleRule rules; + LifecycleRule? rules; } /// Container for logging status information. @@ -326,13 +327,13 @@ class BucketLoggingStatus { XmlNode toXml() { final builder = XmlBuilder(); builder.element('BucketLoggingStatus', nest: () { - builder.element('LoggingEnabled', nest: loggingEnabled.toXml()); + builder.element('LoggingEnabled', nest: loggingEnabled!.toXml()); }); return builder.buildDocument(); } /// Describes where logs are stored and the prefix that Amazon S3 assigns to all log object keys for a bucket. For more information, see PUT Bucket logging in the Amazon Simple Storage Service API Reference. - LoggingEnabled loggingEnabled; + LoggingEnabled? loggingEnabled; } /// Container for specifying the AWS Lambda notification configuration. @@ -345,7 +346,7 @@ class CloudFunctionConfiguration { this.invocationRole, ); - CloudFunctionConfiguration.fromXml(XmlElement xml) { + CloudFunctionConfiguration.fromXml(XmlElement? xml) { cloudFunction = getProp(xml, 'CloudFunction')?.text; event = getProp(xml, 'Event')?.text; events = getProp(xml, 'Events')?.text; @@ -366,19 +367,19 @@ class CloudFunctionConfiguration { } /// Lambda cloud function ARN that Amazon S3 can invoke when it detects events of the specified type. - String cloudFunction; + String? cloudFunction; /// This member has been deprecated. - String event; + String? event; /// Bucket events for which to send notifications. - String events; + String? events; /// An optional unique identifier for configurations in a notification configuration. If you don't provide one, Amazon S3 will assign an ID. - String id; + String? id; /// The role supporting the invocation of the Lambda function - String invocationRole; + String? invocationRole; } /// Container for all (if there are any) keys between Prefix and the next occurrence of the string specified by a delimiter. CommonPrefixes lists keys that act like subdirectories in the directory specified by Prefix. For example, if the prefix is notes/ and the delimiter is a slash (/) as in notes/summer/july, the common prefix is notes/summer/. @@ -400,7 +401,7 @@ class CommonPrefix { } /// Container for the specified common prefix. - String prefix; + String? prefix; } /// The container for the completed multipart upload details. @@ -416,13 +417,13 @@ class CompletedMultipartUpload { XmlNode toXml() { final builder = XmlBuilder(); builder.element('CompletedMultipartUpload', nest: () { - builder.element('Parts', nest: parts.toXml()); + builder.element('Parts', nest: parts!.toXml()); }); return builder.buildDocument(); } /// Array of CompletedPart data types. - CompletedPart parts; + CompletedPart? parts; } /// Details of the parts that were uploaded. @@ -432,9 +433,9 @@ class CompletedPart { this.partNumber, ); - CompletedPart.fromXml(XmlElement xml) { + CompletedPart.fromXml(XmlElement? xml) { eTag = getProp(xml, 'ETag')?.text; - partNumber = int.tryParse(getProp(xml, 'PartNumber')?.text); + partNumber = int.tryParse(getProp(xml, 'PartNumber')!.text); } XmlNode toXml() { @@ -447,10 +448,10 @@ class CompletedPart { } /// Entity tag returned when the part was uploaded. - String eTag; + String? eTag; /// Part number that identifies the part. This is a positive integer between 1 and 10,000. - int partNumber; + int? partNumber; } /// A container for describing a condition that must be met for the specified redirect to apply. For example, 1. If request is for pages in the /docs folder, redirect to the /documents folder. 2. If request results in HTTP error 4xx, redirect request to another host where you might process the error. @@ -460,7 +461,7 @@ class Condition { this.keyPrefixEquals, ); - Condition.fromXml(XmlElement xml) { + Condition.fromXml(XmlElement? xml) { httpErrorCodeReturnedEquals = getProp(xml, 'HttpErrorCodeReturnedEquals')?.text; keyPrefixEquals = getProp(xml, 'KeyPrefixEquals')?.text; @@ -477,17 +478,17 @@ class Condition { } /// The HTTP error code when the redirect is applied. In the event of an error, if the error code equals this value, then the specified redirect is applied. Required when parent element Condition is specified and sibling KeyPrefixEquals is not specified. If both are specified, then both must be true for the redirect to be applied. - String httpErrorCodeReturnedEquals; + String? httpErrorCodeReturnedEquals; /// The object key name prefix when the redirect is applied. For example, to redirect requests for ExamplePage.html, the key prefix will be ExamplePage.html. To redirect request for all pages with the prefix docs/, the key prefix will be /docs, which identifies all objects in the docs/ folder. Required when the parent element Condition is specified and sibling HttpErrorCodeReturnedEquals is not specified. If both conditions are specified, both must be true for the redirect to be applied. - String keyPrefixEquals; + String? keyPrefixEquals; } /// The members of this structure are context-dependent. class ContinuationEvent { ContinuationEvent(); - ContinuationEvent.fromXml(XmlElement xml); + ContinuationEvent.fromXml(XmlElement? xml); XmlNode toXml() { final builder = XmlBuilder(); @@ -505,23 +506,23 @@ class CopyObjectResult { CopyObjectResult.fromXml(XmlElement xml) { eTag = getProp(xml, 'ETag')?.text; - lastModified = DateTime.parse(getProp(xml, 'LastModified')?.text); + lastModified = DateTime.parse(getProp(xml, 'LastModified')!.text); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('CopyObjectResult', nest: () { builder.element('ETag', nest: eTag); - builder.element('LastModified', nest: lastModified.toIso8601String()); + builder.element('LastModified', nest: lastModified!.toIso8601String()); }); return builder.buildDocument(); } /// Returns the ETag of the new object. The ETag reflects only changes to the contents of an object, not its metadata. The source and destination ETag is identical for a successfully copied object. - String eTag; + String? eTag; /// Returns the date that the object was last modified. - DateTime lastModified; + DateTime? lastModified; } /// Container for all response elements. @@ -533,23 +534,23 @@ class CopyPartResult { CopyPartResult.fromXml(XmlElement xml) { eTag = getProp(xml, 'ETag')?.text; - lastModified = DateTime.parse(getProp(xml, 'LastModified')?.text); + lastModified = DateTime.parse(getProp(xml, 'LastModified')!.text); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('CopyPartResult', nest: () { builder.element('ETag', nest: eTag); - builder.element('LastModified', nest: lastModified.toIso8601String()); + builder.element('LastModified', nest: lastModified!.toIso8601String()); }); return builder.buildDocument(); } /// Entity tag of the object. - String eTag; + String? eTag; /// Date and time at which the object was uploaded. - DateTime lastModified; + DateTime? lastModified; } /// Describes the cross-origin access configuration for objects in an Amazon S3 bucket. For more information, see Enabling Cross-Origin Resource Sharing in the Amazon Simple Storage Service Developer Guide. @@ -565,13 +566,13 @@ class CORSConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('CORSConfiguration', nest: () { - builder.element('CORSRules', nest: cORSRules.toXml()); + builder.element('CORSRules', nest: cORSRules!.toXml()); }); return builder.buildDocument(); } /// A set of origins and methods (cross-origin access that you want to allow). You can add up to 100 rules to the configuration. - CORSRule cORSRules; + CORSRule? cORSRules; } /// Specifies a cross-origin access rule for an Amazon S3 bucket. @@ -584,12 +585,12 @@ class CORSRule { this.maxAgeSeconds, ); - CORSRule.fromXml(XmlElement xml) { + CORSRule.fromXml(XmlElement? xml) { allowedHeaders = getProp(xml, 'AllowedHeaders')?.text; allowedMethods = getProp(xml, 'AllowedMethods')?.text; allowedOrigins = getProp(xml, 'AllowedOrigins')?.text; exposeHeaders = getProp(xml, 'ExposeHeaders')?.text; - maxAgeSeconds = int.tryParse(getProp(xml, 'MaxAgeSeconds')?.text); + maxAgeSeconds = int.tryParse(getProp(xml, 'MaxAgeSeconds')!.text); } XmlNode toXml() { @@ -605,19 +606,19 @@ class CORSRule { } /// Headers that are specified in the Access-Control-Request-Headers header. These headers are allowed in a preflight OPTIONS request. In response to any preflight OPTIONS request, Amazon S3 returns any requested headers that are allowed. - String allowedHeaders; + String? allowedHeaders; /// An HTTP method that you allow the origin to execute. Valid values are GET, PUT, HEAD, POST, and DELETE. - String allowedMethods; + String? allowedMethods; /// One or more origins you want customers to be able to access the bucket from. - String allowedOrigins; + String? allowedOrigins; /// One or more headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object). - String exposeHeaders; + String? exposeHeaders; /// The time in seconds that your browser is to cache the preflight response for the specified resource. - int maxAgeSeconds; + int? maxAgeSeconds; } /// The configuration information for the bucket. @@ -639,7 +640,7 @@ class CreateBucketConfiguration { } /// Specifies the Region where the bucket will be created. If you don't specify a Region, the bucket is created in the US East (N. Virginia) Region (us-east-1). - String locationConstraint; + String? locationConstraint; } /// Describes how an uncompressed comma-separated values (CSV)-formatted input object is formatted. @@ -654,9 +655,9 @@ class CSVInput { this.recordDelimiter, ); - CSVInput.fromXml(XmlElement xml) { + CSVInput.fromXml(XmlElement? xml) { allowQuotedRecordDelimiter = - getProp(xml, 'AllowQuotedRecordDelimiter')?.text?.toUpperCase() == + getProp(xml, 'AllowQuotedRecordDelimiter')?.text.toUpperCase() == 'TRUE'; comments = getProp(xml, 'Comments')?.text; fieldDelimiter = getProp(xml, 'FieldDelimiter')?.text; @@ -670,7 +671,7 @@ class CSVInput { final builder = XmlBuilder(); builder.element('CSVInput', nest: () { builder.element('AllowQuotedRecordDelimiter', - nest: allowQuotedRecordDelimiter ? 'TRUE' : 'FALSE'); + nest: allowQuotedRecordDelimiter! ? 'TRUE' : 'FALSE'); builder.element('Comments', nest: comments); builder.element('FieldDelimiter', nest: fieldDelimiter); builder.element('FileHeaderInfo', nest: fileHeaderInfo); @@ -682,25 +683,25 @@ class CSVInput { } /// Specifies that CSV field values may contain quoted record delimiters and such records should be allowed. Default value is FALSE. Setting this value to TRUE may lower performance. - bool allowQuotedRecordDelimiter; + bool? allowQuotedRecordDelimiter; /// A single character used to indicate that a row should be ignored when the character is present at the start of that row. You can specify any character to indicate a comment line. - String comments; + String? comments; /// A single character used to separate individual fields in a record. You can specify an arbitrary delimiter. - String fieldDelimiter; + String? fieldDelimiter; /// Describes the first line of input. Valid values are: - String fileHeaderInfo; + String? fileHeaderInfo; /// A single character used for escaping when the field delimiter is part of the value. For example, if the value is a, b, Amazon S3 wraps this field value in quotation marks, as follows: " a , b ". - String quoteCharacter; + String? quoteCharacter; /// A single character used for escaping the quotation mark character inside an already escaped value. For example, the value """ a , b """ is parsed as " a , b ". - String quoteEscapeCharacter; + String? quoteEscapeCharacter; /// A single character used to separate individual records in the input. Instead of the default value, you can specify an arbitrary delimiter. - String recordDelimiter; + String? recordDelimiter; } /// Describes how uncompressed comma-separated values (CSV)-formatted results are formatted. @@ -713,7 +714,7 @@ class CSVOutput { this.recordDelimiter, ); - CSVOutput.fromXml(XmlElement xml) { + CSVOutput.fromXml(XmlElement? xml) { fieldDelimiter = getProp(xml, 'FieldDelimiter')?.text; quoteCharacter = getProp(xml, 'QuoteCharacter')?.text; quoteEscapeCharacter = getProp(xml, 'QuoteEscapeCharacter')?.text; @@ -734,19 +735,19 @@ class CSVOutput { } /// The value used to separate individual fields in a record. You can specify an arbitrary delimiter. - String fieldDelimiter; + String? fieldDelimiter; /// A single character used for escaping when the field delimiter is part of the value. For example, if the value is a, b, Amazon S3 wraps this field value in quotation marks, as follows: " a , b ". - String quoteCharacter; + String? quoteCharacter; /// The single character used for escaping the quote character inside an already escaped value. - String quoteEscapeCharacter; + String? quoteEscapeCharacter; /// Indicates whether to use quotation marks around output fields. - String quoteFields; + String? quoteFields; /// A single character used to separate individual records in the output. Instead of the default value, you can specify an arbitrary delimiter. - String recordDelimiter; + String? recordDelimiter; } /// The container element for specifying the default Object Lock retention settings for new objects placed in the specified bucket. @@ -757,10 +758,10 @@ class DefaultRetention { this.years, ); - DefaultRetention.fromXml(XmlElement xml) { - days = int.tryParse(getProp(xml, 'Days')?.text); + DefaultRetention.fromXml(XmlElement? xml) { + days = int.tryParse(getProp(xml, 'Days')!.text); mode = getProp(xml, 'Mode')?.text; - years = int.tryParse(getProp(xml, 'Years')?.text); + years = int.tryParse(getProp(xml, 'Years')!.text); } XmlNode toXml() { @@ -774,13 +775,13 @@ class DefaultRetention { } /// The number of days that you want to specify for the default retention period. - int days; + int? days; /// The default Object Lock retention mode you want to apply to new objects placed in the specified bucket. - String mode; + String? mode; /// The number of years that you want to specify for the default retention period. - int years; + int? years; } /// Container for the objects to delete. @@ -823,7 +824,7 @@ class DeletedObject { ); DeletedObject.fromXml(XmlElement xml) { - deleteMarker = getProp(xml, 'DeleteMarker')?.text?.toUpperCase() == 'TRUE'; + deleteMarker = getProp(xml, 'DeleteMarker')?.text.toUpperCase() == 'TRUE'; deleteMarkerVersionId = getProp(xml, 'DeleteMarkerVersionId')?.text; key = getProp(xml, 'Key')?.text; versionId = getProp(xml, 'VersionId')?.text; @@ -832,7 +833,7 @@ class DeletedObject { XmlNode toXml() { final builder = XmlBuilder(); builder.element('DeletedObject', nest: () { - builder.element('DeleteMarker', nest: deleteMarker ? 'TRUE' : 'FALSE'); + builder.element('DeleteMarker', nest: deleteMarker! ? 'TRUE' : 'FALSE'); builder.element('DeleteMarkerVersionId', nest: deleteMarkerVersionId); builder.element('Key', nest: key); builder.element('VersionId', nest: versionId); @@ -841,16 +842,16 @@ class DeletedObject { } /// Specifies whether the versioned object that was permanently deleted was (true) or was not (false) a delete marker. In a simple DELETE, this header indicates whether (true) or not (false) a delete marker was created. - bool deleteMarker; + bool? deleteMarker; /// The version ID of the delete marker created as a result of the DELETE operation. If you delete a specific object version, the value returned by this header is the version ID of the object version deleted. - String deleteMarkerVersionId; + String? deleteMarkerVersionId; /// The name of the deleted object. - String key; + String? key; /// The version ID of the deleted object. - String versionId; + String? versionId; } /// Information about the delete marker. @@ -864,9 +865,9 @@ class DeleteMarkerEntry { ); DeleteMarkerEntry.fromXml(XmlElement xml) { - isLatest = getProp(xml, 'IsLatest')?.text?.toUpperCase() == 'TRUE'; + isLatest = getProp(xml, 'IsLatest')?.text.toUpperCase() == 'TRUE'; key = getProp(xml, 'Key')?.text; - lastModified = DateTime.parse(getProp(xml, 'LastModified')?.text); + lastModified = DateTime.parse(getProp(xml, 'LastModified')!.text); owner = Owner.fromXml(getProp(xml, 'Owner')); versionId = getProp(xml, 'VersionId')?.text; } @@ -874,29 +875,29 @@ class DeleteMarkerEntry { XmlNode toXml() { final builder = XmlBuilder(); builder.element('DeleteMarkerEntry', nest: () { - builder.element('IsLatest', nest: isLatest ? 'TRUE' : 'FALSE'); + builder.element('IsLatest', nest: isLatest! ? 'TRUE' : 'FALSE'); builder.element('Key', nest: key); - builder.element('LastModified', nest: lastModified.toIso8601String()); - builder.element('Owner', nest: owner.toXml()); + builder.element('LastModified', nest: lastModified!.toIso8601String()); + builder.element('Owner', nest: owner!.toXml()); builder.element('VersionId', nest: versionId); }); return builder.buildDocument(); } /// Specifies whether the object is (true) or is not (false) the latest version of an object. - bool isLatest; + bool? isLatest; /// The object key. - String key; + String? key; /// Date and time the object was last modified. - DateTime lastModified; + DateTime? lastModified; /// The account that created the delete marker.> - Owner owner; + Owner? owner; /// Version ID of an object. - String versionId; + String? versionId; } /// Specifies whether Amazon S3 replicates the delete markers. If you specify a Filter, you must specify this element. However, in the latest version of replication configuration (when Filter is specified), Amazon S3 doesn't replicate delete markers. Therefore, the DeleteMarkerReplication element can contain only <Status>Disabled</Status>. For an example configuration, see Basic Rule Configuration. @@ -905,7 +906,7 @@ class DeleteMarkerReplication { this.status, ); - DeleteMarkerReplication.fromXml(XmlElement xml) { + DeleteMarkerReplication.fromXml(XmlElement? xml) { status = getProp(xml, 'Status')?.text; } @@ -918,7 +919,7 @@ class DeleteMarkerReplication { } /// Indicates whether to replicate delete markers. - String status; + String? status; } /// Specifies information about where to publish analysis or configuration results for an Amazon S3 bucket and S3 Replication Time Control (S3 RTC). @@ -933,7 +934,7 @@ class Destination { this.storageClass, ); - Destination.fromXml(XmlElement xml) { + Destination.fromXml(XmlElement? xml) { accessControlTranslation = AccessControlTranslation.fromXml( getProp(xml, 'AccessControlTranslation')); account = getProp(xml, 'Account')?.text; @@ -949,38 +950,38 @@ class Destination { final builder = XmlBuilder(); builder.element('Destination', nest: () { builder.element('AccessControlTranslation', - nest: accessControlTranslation.toXml()); + nest: accessControlTranslation!.toXml()); builder.element('Account', nest: account); builder.element('Bucket', nest: bucket); builder.element('EncryptionConfiguration', - nest: encryptionConfiguration.toXml()); - builder.element('Metrics', nest: metrics.toXml()); - builder.element('ReplicationTime', nest: replicationTime.toXml()); + nest: encryptionConfiguration!.toXml()); + builder.element('Metrics', nest: metrics!.toXml()); + builder.element('ReplicationTime', nest: replicationTime!.toXml()); builder.element('StorageClass', nest: storageClass); }); return builder.buildDocument(); } /// Specify this only in a cross-account scenario (where source and destination bucket owners are not the same), and you want to change replica ownership to the AWS account that owns the destination bucket. If this is not specified in the replication configuration, the replicas are owned by same AWS account that owns the source object. - AccessControlTranslation accessControlTranslation; + AccessControlTranslation? accessControlTranslation; /// Destination bucket owner account ID. In a cross-account scenario, if you direct Amazon S3 to change replica ownership to the AWS account that owns the destination bucket by specifying the AccessControlTranslation property, this is the account ID of the destination bucket owner. For more information, see Replication Additional Configuration: Changing the Replica Owner in the Amazon Simple Storage Service Developer Guide. - String account; + String? account; /// The Amazon Resource Name (ARN) of the bucket where you want Amazon S3 to store the results. - String bucket; + String? bucket; /// A container that provides information about encryption. If SourceSelectionCriteria is specified, you must specify this element. - EncryptionConfiguration encryptionConfiguration; + EncryptionConfiguration? encryptionConfiguration; /// A container specifying replication metrics-related settings enabling metrics and Amazon S3 events for S3 Replication Time Control (S3 RTC). Must be specified together with a ReplicationTime block. - Metrics metrics; + Metrics? metrics; /// A container specifying S3 Replication Time Control (S3 RTC), including whether S3 RTC is enabled and the time when all objects and operations on objects must be replicated. Must be specified together with a Metrics block. - ReplicationTime replicationTime; + ReplicationTime? replicationTime; /// The storage class to use when replicating objects, such as S3 Standard or reduced redundancy. By default, Amazon S3 uses the storage class of the source object to create the object replica. - String storageClass; + String? storageClass; } /// Contains the type of server-side encryption used. @@ -991,7 +992,7 @@ class Encryption { this.kMSKeyId, ); - Encryption.fromXml(XmlElement xml) { + Encryption.fromXml(XmlElement? xml) { encryptionType = getProp(xml, 'EncryptionType')?.text; kMSContext = getProp(xml, 'KMSContext')?.text; kMSKeyId = getProp(xml, 'KMSKeyId')?.text; @@ -1008,13 +1009,13 @@ class Encryption { } /// The server-side encryption algorithm used when storing job results in Amazon S3 (for example, AES256, aws:kms). - String encryptionType; + String? encryptionType; /// If the encryption type is aws:kms, this optional value can be used to specify the encryption context for the restore results. - String kMSContext; + String? kMSContext; /// If the encryption type is aws:kms, this optional value specifies the ID of the symmetric customer managed AWS KMS CMK to use for encryption of job results. Amazon S3 only supports symmetric CMKs. For more information, see Using Symmetric and Asymmetric Keys in the AWS Key Management Service Developer Guide. - String kMSKeyId; + String? kMSKeyId; } /// Specifies encryption-related information for an Amazon S3 bucket that is a destination for replicated objects. @@ -1023,7 +1024,7 @@ class EncryptionConfiguration { this.replicaKmsKeyID, ); - EncryptionConfiguration.fromXml(XmlElement xml) { + EncryptionConfiguration.fromXml(XmlElement? xml) { replicaKmsKeyID = getProp(xml, 'ReplicaKmsKeyID')?.text; } @@ -1036,14 +1037,14 @@ class EncryptionConfiguration { } /// Specifies the ID (Key ARN or Alias ARN) of the customer managed customer master key (CMK) stored in AWS Key Management Service (KMS) for the destination bucket. Amazon S3 uses this key to encrypt replica objects. Amazon S3 only supports symmetric customer managed CMKs. For more information, see Using Symmetric and Asymmetric Keys in the AWS Key Management Service Developer Guide. - String replicaKmsKeyID; + String? replicaKmsKeyID; } /// A message that indicates the request is complete and no more messages will be sent. You should not assume that the request is complete until the client receives an EndEvent. class EndEvent { EndEvent(); - EndEvent.fromXml(XmlElement xml); + EndEvent.fromXml(XmlElement? xml); XmlNode toXml() { final builder = XmlBuilder(); @@ -1080,16 +1081,16 @@ class Error { } /// The error code is a string that uniquely identifies an error condition. It is meant to be read and understood by programs that detect and handle errors by type. - String code; + String? code; /// The error key. - String key; + String? key; /// The error message contains a generic description of the error condition in English. It is intended for a human audience. Simple programs display the message directly to the end user if they encounter an error condition they don't know how or don't care to handle. Sophisticated programs with more exhaustive error handling and proper internationalization are more likely to ignore the error message. - String message; + String? message; /// The version ID of the error. - String versionId; + String? versionId; } /// The error information. @@ -1098,7 +1099,7 @@ class ErrorDocument { this.key, ); - ErrorDocument.fromXml(XmlElement xml) { + ErrorDocument.fromXml(XmlElement? xml) { key = getProp(xml, 'Key')?.text; } @@ -1111,7 +1112,7 @@ class ErrorDocument { } /// The object key name to use when a 4XX class error occurs. - String key; + String? key; } /// Optional configuration to replicate existing source bucket objects. For more information, see Replicating Existing Objects in the Amazon S3 Developer Guide. @@ -1120,7 +1121,7 @@ class ExistingObjectReplication { this.status, ); - ExistingObjectReplication.fromXml(XmlElement xml) { + ExistingObjectReplication.fromXml(XmlElement? xml) { status = getProp(xml, 'Status')?.text; } @@ -1133,7 +1134,7 @@ class ExistingObjectReplication { } /// Type: String - String status; + String? status; } /// Specifies the Amazon S3 object key name to filter on and whether to filter on the suffix or prefix of the key name. @@ -1143,7 +1144,7 @@ class FilterRule { this.value, ); - FilterRule.fromXml(XmlElement xml) { + FilterRule.fromXml(XmlElement? xml) { name = getProp(xml, 'Name')?.text; value = getProp(xml, 'Value')?.text; } @@ -1158,10 +1159,10 @@ class FilterRule { } /// The object key name prefix or suffix identifying one or more objects to which the filtering rule applies. The maximum length is 1,024 characters. Overlapping prefixes and suffixes are not supported. For more information, see Configuring Event Notifications in the Amazon Simple Storage Service Developer Guide. - String name; + String? name; /// The value that the filter searches for in object key names. - String value; + String? value; } /// Container for S3 Glacier job parameters. @@ -1170,7 +1171,7 @@ class GlacierJobParameters { this.tier, ); - GlacierJobParameters.fromXml(XmlElement xml) { + GlacierJobParameters.fromXml(XmlElement? xml) { tier = getProp(xml, 'Tier')?.text; } @@ -1183,7 +1184,7 @@ class GlacierJobParameters { } /// S3 Glacier retrieval tier at which the restore will be processed. - String tier; + String? tier; } /// Container for grant information. @@ -1193,7 +1194,7 @@ class Grant { this.permission, ); - Grant.fromXml(XmlElement xml) { + Grant.fromXml(XmlElement? xml) { grantee = Grantee.fromXml(getProp(xml, 'Grantee')); permission = getProp(xml, 'Permission')?.text; } @@ -1201,17 +1202,17 @@ class Grant { XmlNode toXml() { final builder = XmlBuilder(); builder.element('Grant', nest: () { - builder.element('Grantee', nest: grantee.toXml()); + builder.element('Grantee', nest: grantee!.toXml()); builder.element('Permission', nest: permission); }); return builder.buildDocument(); } /// The person being granted permissions. - Grantee grantee; + Grantee? grantee; /// Specifies the permission given to the grantee. - String permission; + String? permission; } /// Container for the person being granted permissions. @@ -1224,7 +1225,7 @@ class Grantee { this.uRI, ); - Grantee.fromXml(XmlElement xml) { + Grantee.fromXml(XmlElement? xml) { displayName = getProp(xml, 'DisplayName')?.text; emailAddress = getProp(xml, 'EmailAddress')?.text; iD = getProp(xml, 'ID')?.text; @@ -1245,19 +1246,19 @@ class Grantee { } /// Screen name of the grantee. - String displayName; + String? displayName; /// Email address of the grantee. - String emailAddress; + String? emailAddress; /// The canonical user ID of the grantee. - String iD; + String? iD; /// Type of grantee - String type; + String? type; /// URI of the grantee group. - String uRI; + String? uRI; } /// Container for the Suffix element. @@ -1266,7 +1267,7 @@ class IndexDocument { this.suffix, ); - IndexDocument.fromXml(XmlElement xml) { + IndexDocument.fromXml(XmlElement? xml) { suffix = getProp(xml, 'Suffix')?.text; } @@ -1279,7 +1280,7 @@ class IndexDocument { } /// A suffix that is appended to a request that is for a directory on the website endpoint (for example,if the suffix is index.html and you make a request to samplebucket/images/ the data that is returned will be for the object with the key name images/index.html) The suffix must not be empty and must not include a slash character. - String suffix; + String? suffix; } /// Container element that identifies who initiated the multipart upload. @@ -1289,7 +1290,7 @@ class Initiator { this.iD, ); - Initiator.fromXml(XmlElement xml) { + Initiator.fromXml(XmlElement? xml) { displayName = getProp(xml, 'DisplayName')?.text; iD = getProp(xml, 'ID')?.text; } @@ -1304,10 +1305,10 @@ class Initiator { } /// Name of the Principal. - String displayName; + String? displayName; /// If the principal is an AWS account, it provides the Canonical User ID. If the principal is an IAM User, it provides a user ARN value. - String iD; + String? iD; } /// Describes the serialization format of the object. @@ -1319,7 +1320,7 @@ class InputSerialization { this.parquet, ); - InputSerialization.fromXml(XmlElement xml) { + InputSerialization.fromXml(XmlElement? xml) { compressionType = getProp(xml, 'CompressionType')?.text; cSV = CSVInput.fromXml(getProp(xml, 'CSV')); jSON = JSONInput.fromXml(getProp(xml, 'JSON')); @@ -1330,24 +1331,24 @@ class InputSerialization { final builder = XmlBuilder(); builder.element('InputSerialization', nest: () { builder.element('CompressionType', nest: compressionType); - builder.element('CSV', nest: cSV.toXml()); - builder.element('JSON', nest: jSON.toXml()); - builder.element('Parquet', nest: parquet.toXml()); + builder.element('CSV', nest: cSV!.toXml()); + builder.element('JSON', nest: jSON!.toXml()); + builder.element('Parquet', nest: parquet!.toXml()); }); return builder.buildDocument(); } /// Specifies object's compression format. Valid values: NONE, GZIP, BZIP2. Default Value: NONE. - String compressionType; + String? compressionType; /// Describes the serialization of a CSV-encoded object. - CSVInput cSV; + CSVInput? cSV; /// Specifies JSON as object's input serialization format. - JSONInput jSON; + JSONInput? jSON; /// Specifies Parquet as object's input serialization format. - ParquetInput parquet; + ParquetInput? parquet; } /// Specifies the inventory configuration for an Amazon S3 bucket. For more information, see GET Bucket inventory in the Amazon Simple Storage Service API Reference. @@ -1367,7 +1368,7 @@ class InventoryConfiguration { filter = InventoryFilter.fromXml(getProp(xml, 'Filter')); id = getProp(xml, 'Id')?.text; includedObjectVersions = getProp(xml, 'IncludedObjectVersions')?.text; - isEnabled = getProp(xml, 'IsEnabled')?.text?.toUpperCase() == 'TRUE'; + isEnabled = getProp(xml, 'IsEnabled')?.text.toUpperCase() == 'TRUE'; optionalFields = getProp(xml, 'OptionalFields')?.text; schedule = InventorySchedule.fromXml(getProp(xml, 'Schedule')); } @@ -1375,37 +1376,37 @@ class InventoryConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('InventoryConfiguration', nest: () { - builder.element('Destination', nest: destination.toXml()); - builder.element('Filter', nest: filter.toXml()); + builder.element('Destination', nest: destination!.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('Id', nest: id); builder.element('IncludedObjectVersions', nest: includedObjectVersions); - builder.element('IsEnabled', nest: isEnabled ? 'TRUE' : 'FALSE'); + builder.element('IsEnabled', nest: isEnabled! ? 'TRUE' : 'FALSE'); builder.element('OptionalFields', nest: optionalFields); - builder.element('Schedule', nest: schedule.toXml()); + builder.element('Schedule', nest: schedule!.toXml()); }); return builder.buildDocument(); } /// Contains information about where to publish the inventory results. - InventoryDestination destination; + InventoryDestination? destination; /// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria. - InventoryFilter filter; + InventoryFilter? filter; /// The ID used to identify the inventory configuration. - String id; + String? id; /// Object versions to include in the inventory list. If set to All, the list includes all the object versions, which adds the version-related fields VersionId, IsLatest, and DeleteMarker to the list. If set to Current, the list does not contain these version-related fields. - String includedObjectVersions; + String? includedObjectVersions; /// Specifies whether the inventory is enabled or disabled. If set to True, an inventory list is generated. If set to False, no inventory list is generated. - bool isEnabled; + bool? isEnabled; /// Contains the optional fields that are included in the inventory results. - String optionalFields; + String? optionalFields; /// Specifies the schedule for generating inventory results. - InventorySchedule schedule; + InventorySchedule? schedule; } /// Specifies the inventory configuration for an Amazon S3 bucket. @@ -1414,7 +1415,7 @@ class InventoryDestination { this.s3BucketDestination, ); - InventoryDestination.fromXml(XmlElement xml) { + InventoryDestination.fromXml(XmlElement? xml) { s3BucketDestination = InventoryS3BucketDestination.fromXml( getProp(xml, 'S3BucketDestination')); } @@ -1422,13 +1423,14 @@ class InventoryDestination { XmlNode toXml() { final builder = XmlBuilder(); builder.element('InventoryDestination', nest: () { - builder.element('S3BucketDestination', nest: s3BucketDestination.toXml()); + builder.element('S3BucketDestination', + nest: s3BucketDestination!.toXml()); }); return builder.buildDocument(); } /// Contains the bucket name, file format, bucket owner (optional), and prefix (optional) where inventory results are published. - InventoryS3BucketDestination s3BucketDestination; + InventoryS3BucketDestination? s3BucketDestination; } /// Contains the type of server-side encryption used to encrypt the inventory results. @@ -1438,7 +1440,7 @@ class InventoryEncryption { this.sSES3, ); - InventoryEncryption.fromXml(XmlElement xml) { + InventoryEncryption.fromXml(XmlElement? xml) { sSEKMS = SSEKMS.fromXml(getProp(xml, 'SSEKMS')); sSES3 = SSES3.fromXml(getProp(xml, 'SSES3')); } @@ -1446,17 +1448,17 @@ class InventoryEncryption { XmlNode toXml() { final builder = XmlBuilder(); builder.element('InventoryEncryption', nest: () { - builder.element('SSEKMS', nest: sSEKMS.toXml()); - builder.element('SSES3', nest: sSES3.toXml()); + builder.element('SSEKMS', nest: sSEKMS!.toXml()); + builder.element('SSES3', nest: sSES3!.toXml()); }); return builder.buildDocument(); } /// Specifies the use of SSE-KMS to encrypt delivered inventory reports. - SSEKMS sSEKMS; + SSEKMS? sSEKMS; /// Specifies the use of SSE-S3 to encrypt delivered inventory reports. - SSES3 sSES3; + SSES3? sSES3; } /// Specifies an inventory filter. The inventory only includes objects that meet the filter's criteria. @@ -1465,7 +1467,7 @@ class InventoryFilter { this.prefix, ); - InventoryFilter.fromXml(XmlElement xml) { + InventoryFilter.fromXml(XmlElement? xml) { prefix = getProp(xml, 'Prefix')?.text; } @@ -1478,7 +1480,7 @@ class InventoryFilter { } /// The prefix that an object must have to be included in the inventory results. - String prefix; + String? prefix; } /// Contains the bucket name, file format, bucket owner (optional), and prefix (optional) where inventory results are published. @@ -1491,7 +1493,7 @@ class InventoryS3BucketDestination { this.prefix, ); - InventoryS3BucketDestination.fromXml(XmlElement xml) { + InventoryS3BucketDestination.fromXml(XmlElement? xml) { accountId = getProp(xml, 'AccountId')?.text; bucket = getProp(xml, 'Bucket')?.text; encryption = InventoryEncryption.fromXml(getProp(xml, 'Encryption')); @@ -1504,7 +1506,7 @@ class InventoryS3BucketDestination { builder.element('InventoryS3BucketDestination', nest: () { builder.element('AccountId', nest: accountId); builder.element('Bucket', nest: bucket); - builder.element('Encryption', nest: encryption.toXml()); + builder.element('Encryption', nest: encryption!.toXml()); builder.element('Format', nest: format); builder.element('Prefix', nest: prefix); }); @@ -1512,19 +1514,19 @@ class InventoryS3BucketDestination { } /// The ID of the account that owns the destination bucket. Although optional, we recommend that the value be set to prevent problems if the destination bucket ownership changes. - String accountId; + String? accountId; /// The Amazon Resource Name (ARN) of the bucket where inventory results will be published. - String bucket; + String? bucket; /// Contains the type of server-side encryption used to encrypt the inventory results. - InventoryEncryption encryption; + InventoryEncryption? encryption; /// Specifies the output format of the inventory results. - String format; + String? format; /// The prefix that is prepended to all inventory results. - String prefix; + String? prefix; } /// Specifies the schedule for generating inventory results. @@ -1533,7 +1535,7 @@ class InventorySchedule { this.frequency, ); - InventorySchedule.fromXml(XmlElement xml) { + InventorySchedule.fromXml(XmlElement? xml) { frequency = getProp(xml, 'Frequency')?.text; } @@ -1546,7 +1548,7 @@ class InventorySchedule { } /// Specifies how frequently inventory results are produced. - String frequency; + String? frequency; } /// Specifies JSON as object's input serialization format. @@ -1555,7 +1557,7 @@ class JSONInput { this.type, ); - JSONInput.fromXml(XmlElement xml) { + JSONInput.fromXml(XmlElement? xml) { type = getProp(xml, 'Type')?.text; } @@ -1568,7 +1570,7 @@ class JSONInput { } /// The type of JSON. Valid values: Document, Lines. - String type; + String? type; } /// Specifies JSON as request's output serialization format. @@ -1577,7 +1579,7 @@ class JSONOutput { this.recordDelimiter, ); - JSONOutput.fromXml(XmlElement xml) { + JSONOutput.fromXml(XmlElement? xml) { recordDelimiter = getProp(xml, 'RecordDelimiter')?.text; } @@ -1590,7 +1592,7 @@ class JSONOutput { } /// The value used to separate individual records in the output. - String recordDelimiter; + String? recordDelimiter; } /// A container for specifying the configuration for AWS Lambda notifications. @@ -1602,7 +1604,7 @@ class LambdaFunctionConfiguration { this.lambdaFunctionArn, ); - LambdaFunctionConfiguration.fromXml(XmlElement xml) { + LambdaFunctionConfiguration.fromXml(XmlElement? xml) { events = getProp(xml, 'Events')?.text; filter = NotificationConfigurationFilter.fromXml(getProp(xml, 'Filter')); id = getProp(xml, 'Id')?.text; @@ -1613,7 +1615,7 @@ class LambdaFunctionConfiguration { final builder = XmlBuilder(); builder.element('LambdaFunctionConfiguration', nest: () { builder.element('Events', nest: events); - builder.element('Filter', nest: filter.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('Id', nest: id); builder.element('LambdaFunctionArn', nest: lambdaFunctionArn); }); @@ -1621,16 +1623,16 @@ class LambdaFunctionConfiguration { } /// The Amazon S3 bucket event for which to invoke the AWS Lambda function. For more information, see Supported Event Types in the Amazon Simple Storage Service Developer Guide. - String events; + String? events; /// Specifies object key name filtering rules. For information about key name filtering, see Configuring Event Notifications in the Amazon Simple Storage Service Developer Guide. - NotificationConfigurationFilter filter; + NotificationConfigurationFilter? filter; /// An optional unique identifier for configurations in a notification configuration. If you don't provide one, Amazon S3 will assign an ID. - String id; + String? id; /// The Amazon Resource Name (ARN) of the AWS Lambda function that Amazon S3 invokes when the specified event type occurs. - String lambdaFunctionArn; + String? lambdaFunctionArn; } /// Container for lifecycle rules. You can add as many as 1000 rules. @@ -1646,13 +1648,13 @@ class LifecycleConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('LifecycleConfiguration', nest: () { - builder.element('Rules', nest: rules.toXml()); + builder.element('Rules', nest: rules!.toXml()); }); return builder.buildDocument(); } /// Specifies lifecycle configuration rules for an Amazon S3 bucket. - Rule rules; + Rule? rules; } /// Container for the expiration for the lifecycle of the object. @@ -1663,33 +1665,32 @@ class LifecycleExpiration { this.expiredObjectDeleteMarker, ); - LifecycleExpiration.fromXml(XmlElement xml) { - date = DateTime.parse(getProp(xml, 'Date')?.text); - days = int.tryParse(getProp(xml, 'Days')?.text); + LifecycleExpiration.fromXml(XmlElement? xml) { + date = DateTime.parse(getProp(xml, 'Date')!.text); + days = int.tryParse(getProp(xml, 'Days')!.text); expiredObjectDeleteMarker = - getProp(xml, 'ExpiredObjectDeleteMarker')?.text?.toUpperCase() == - 'TRUE'; + getProp(xml, 'ExpiredObjectDeleteMarker')?.text.toUpperCase() == 'TRUE'; } XmlNode toXml() { final builder = XmlBuilder(); builder.element('LifecycleExpiration', nest: () { - builder.element('Date', nest: date.toIso8601String()); + builder.element('Date', nest: date!.toIso8601String()); builder.element('Days', nest: days.toString()); builder.element('ExpiredObjectDeleteMarker', - nest: expiredObjectDeleteMarker ? 'TRUE' : 'FALSE'); + nest: expiredObjectDeleteMarker! ? 'TRUE' : 'FALSE'); }); return builder.buildDocument(); } /// Indicates at what date the object is to be moved or deleted. Should be in GMT ISO 8601 Format. - DateTime date; + DateTime? date; /// Indicates the lifetime, in days, of the objects that are subject to the rule. The value must be a non-zero positive integer. - int days; + int? days; /// Indicates whether Amazon S3 will remove a delete marker with no noncurrent versions. If set to true, the delete marker will be expired; if set to false the policy takes no action. This cannot be specified with Days or Date in a Lifecycle Expiration Policy. - bool expiredObjectDeleteMarker; + bool? expiredObjectDeleteMarker; } /// A lifecycle rule for individual objects in an Amazon S3 bucket. @@ -1706,7 +1707,7 @@ class LifecycleRule { this.transitions, ); - LifecycleRule.fromXml(XmlElement xml) { + LifecycleRule.fromXml(XmlElement? xml) { abortIncompleteMultipartUpload = AbortIncompleteMultipartUpload.fromXml( getProp(xml, 'AbortIncompleteMultipartUpload')); expiration = LifecycleExpiration.fromXml(getProp(xml, 'Expiration')); @@ -1725,47 +1726,47 @@ class LifecycleRule { final builder = XmlBuilder(); builder.element('LifecycleRule', nest: () { builder.element('AbortIncompleteMultipartUpload', - nest: abortIncompleteMultipartUpload.toXml()); - builder.element('Expiration', nest: expiration.toXml()); - builder.element('Filter', nest: filter.toXml()); + nest: abortIncompleteMultipartUpload!.toXml()); + builder.element('Expiration', nest: expiration!.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('ID', nest: iD); builder.element('NoncurrentVersionExpiration', - nest: noncurrentVersionExpiration.toXml()); + nest: noncurrentVersionExpiration!.toXml()); builder.element('NoncurrentVersionTransitions', - nest: noncurrentVersionTransitions.toXml()); + nest: noncurrentVersionTransitions!.toXml()); builder.element('Prefix', nest: prefix); builder.element('Status', nest: status); - builder.element('Transitions', nest: transitions.toXml()); + builder.element('Transitions', nest: transitions!.toXml()); }); return builder.buildDocument(); } /// Specifies the days since the initiation of an incomplete multipart upload that Amazon S3 will wait before permanently removing all parts of the upload. For more information, see Aborting Incomplete Multipart Uploads Using a Bucket Lifecycle Policy in the Amazon Simple Storage Service Developer Guide. - AbortIncompleteMultipartUpload abortIncompleteMultipartUpload; + AbortIncompleteMultipartUpload? abortIncompleteMultipartUpload; /// Specifies the expiration for the lifecycle of the object in the form of date, days and, whether the object has a delete marker. - LifecycleExpiration expiration; + LifecycleExpiration? expiration; /// The Filter is used to identify objects that a Lifecycle Rule applies to. A Filter must have exactly one of Prefix, Tag, or And specified. - LifecycleRuleFilter filter; + LifecycleRuleFilter? filter; /// Unique identifier for the rule. The value cannot be longer than 255 characters. - String iD; + String? iD; /// Specifies when noncurrent object versions expire. Upon expiration, Amazon S3 permanently deletes the noncurrent object versions. You set this lifecycle configuration action on a bucket that has versioning enabled (or suspended) to request that Amazon S3 delete noncurrent object versions at a specific period in the object's lifetime. - NoncurrentVersionExpiration noncurrentVersionExpiration; + NoncurrentVersionExpiration? noncurrentVersionExpiration; /// Specifies the transition rule for the lifecycle rule that describes when noncurrent objects transition to a specific storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set this action to request that Amazon S3 transition noncurrent object versions to a specific storage class at a set period in the object's lifetime. - NoncurrentVersionTransition noncurrentVersionTransitions; + NoncurrentVersionTransition? noncurrentVersionTransitions; /// This member has been deprecated. - String prefix; + String? prefix; /// If 'Enabled', the rule is currently being applied. If 'Disabled', the rule is not currently being applied. - String status; + String? status; /// Specifies when an Amazon S3 object transitions to a specified storage class. - Transition transitions; + Transition? transitions; } /// This is used in a Lifecycle Rule Filter to apply a logical AND to two or more predicates. The Lifecycle Rule will apply to any object matching all of the predicates configured inside the And operator. @@ -1775,7 +1776,7 @@ class LifecycleRuleAndOperator { this.tags, ); - LifecycleRuleAndOperator.fromXml(XmlElement xml) { + LifecycleRuleAndOperator.fromXml(XmlElement? xml) { prefix = getProp(xml, 'Prefix')?.text; tags = Tag.fromXml(getProp(xml, 'Tags')); } @@ -1784,16 +1785,16 @@ class LifecycleRuleAndOperator { final builder = XmlBuilder(); builder.element('LifecycleRuleAndOperator', nest: () { builder.element('Prefix', nest: prefix); - builder.element('Tags', nest: tags.toXml()); + builder.element('Tags', nest: tags!.toXml()); }); return builder.buildDocument(); } /// Prefix identifying one or more objects to which the rule applies. - String prefix; + String? prefix; /// All of these tags must exist in the object's tag set in order for the rule to apply. - Tag tags; + Tag? tags; } /// The Filter is used to identify objects that a Lifecycle Rule applies to. A Filter must have exactly one of Prefix, Tag, or And specified. @@ -1804,7 +1805,7 @@ class LifecycleRuleFilter { this.tag, ); - LifecycleRuleFilter.fromXml(XmlElement xml) { + LifecycleRuleFilter.fromXml(XmlElement? xml) { and = LifecycleRuleAndOperator.fromXml(getProp(xml, 'And')); prefix = getProp(xml, 'Prefix')?.text; tag = Tag.fromXml(getProp(xml, 'Tag')); @@ -1813,21 +1814,21 @@ class LifecycleRuleFilter { XmlNode toXml() { final builder = XmlBuilder(); builder.element('LifecycleRuleFilter', nest: () { - builder.element('And', nest: and.toXml()); + builder.element('And', nest: and!.toXml()); builder.element('Prefix', nest: prefix); - builder.element('Tag', nest: tag.toXml()); + builder.element('Tag', nest: tag!.toXml()); }); return builder.buildDocument(); } /// This is used in a Lifecycle Rule Filter to apply a logical AND to two or more predicates. The Lifecycle Rule will apply to any object matching all of the predicates configured inside the And operator. - LifecycleRuleAndOperator and; + LifecycleRuleAndOperator? and; /// Prefix identifying one or more objects to which the rule applies. - String prefix; + String? prefix; /// This tag must exist in the object's tag set in order for the rule to apply. - Tag tag; + Tag? tag; } /// Describes where logs are stored and the prefix that Amazon S3 assigns to all log object keys for a bucket. For more information, see PUT Bucket logging in the Amazon Simple Storage Service API Reference. @@ -1838,7 +1839,7 @@ class LoggingEnabled { this.targetPrefix, ); - LoggingEnabled.fromXml(XmlElement xml) { + LoggingEnabled.fromXml(XmlElement? xml) { targetBucket = getProp(xml, 'TargetBucket')?.text; targetGrants = TargetGrant.fromXml(getProp(xml, 'TargetGrants')); targetPrefix = getProp(xml, 'TargetPrefix')?.text; @@ -1848,20 +1849,20 @@ class LoggingEnabled { final builder = XmlBuilder(); builder.element('LoggingEnabled', nest: () { builder.element('TargetBucket', nest: targetBucket); - builder.element('TargetGrants', nest: targetGrants.toXml()); + builder.element('TargetGrants', nest: targetGrants!.toXml()); builder.element('TargetPrefix', nest: targetPrefix); }); return builder.buildDocument(); } /// Specifies the bucket where you want Amazon S3 to store server access logs. You can have your logs delivered to any bucket that you own, including the same bucket that is being logged. You can also configure multiple buckets to deliver their logs to the same target bucket. In this case, you should choose a different TargetPrefix for each source bucket so that the delivered log files can be distinguished by key. - String targetBucket; + String? targetBucket; /// Container for granting information. - TargetGrant targetGrants; + TargetGrant? targetGrants; /// A prefix for all log object keys. If you store log files from multiple Amazon S3 buckets in a single bucket, you can use a prefix to distinguish which log files came from which bucket. - String targetPrefix; + String? targetPrefix; } /// A metadata key-value pair to store with an object. @@ -1871,7 +1872,7 @@ class MetadataEntry { this.value, ); - MetadataEntry.fromXml(XmlElement xml) { + MetadataEntry.fromXml(XmlElement? xml) { name = getProp(xml, 'Name')?.text; value = getProp(xml, 'Value')?.text; } @@ -1886,10 +1887,10 @@ class MetadataEntry { } /// Name of the Object. - String name; + String? name; /// Value of the Object. - String value; + String? value; } /// A container specifying replication metrics-related settings enabling metrics and Amazon S3 events for S3 Replication Time Control (S3 RTC). Must be specified together with a ReplicationTime block. @@ -1899,7 +1900,7 @@ class Metrics { this.status, ); - Metrics.fromXml(XmlElement xml) { + Metrics.fromXml(XmlElement? xml) { eventThreshold = ReplicationTimeValue.fromXml(getProp(xml, 'EventThreshold')); status = getProp(xml, 'Status')?.text; @@ -1908,17 +1909,17 @@ class Metrics { XmlNode toXml() { final builder = XmlBuilder(); builder.element('Metrics', nest: () { - builder.element('EventThreshold', nest: eventThreshold.toXml()); + builder.element('EventThreshold', nest: eventThreshold!.toXml()); builder.element('Status', nest: status); }); return builder.buildDocument(); } /// A container specifying the time threshold for emitting the s3:Replication:OperationMissedThreshold event. - ReplicationTimeValue eventThreshold; + ReplicationTimeValue? eventThreshold; /// Specifies whether the replication metrics are enabled. - String status; + String? status; } /// A conjunction (logical AND) of predicates, which is used in evaluating a metrics filter. The operator must have at least two predicates, and an object must match all of the predicates in order for the filter to apply. @@ -1928,7 +1929,7 @@ class MetricsAndOperator { this.tags, ); - MetricsAndOperator.fromXml(XmlElement xml) { + MetricsAndOperator.fromXml(XmlElement? xml) { prefix = getProp(xml, 'Prefix')?.text; tags = Tag.fromXml(getProp(xml, 'Tags')); } @@ -1937,16 +1938,16 @@ class MetricsAndOperator { final builder = XmlBuilder(); builder.element('MetricsAndOperator', nest: () { builder.element('Prefix', nest: prefix); - builder.element('Tags', nest: tags.toXml()); + builder.element('Tags', nest: tags!.toXml()); }); return builder.buildDocument(); } /// The prefix used when evaluating an AND predicate. - String prefix; + String? prefix; /// The list of tags used when evaluating an AND predicate. - Tag tags; + Tag? tags; } /// Specifies a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from an Amazon S3 bucket. If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased. For more information, see PUT Bucket metrics in the Amazon Simple Storage Service API Reference. @@ -1964,17 +1965,17 @@ class MetricsConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('MetricsConfiguration', nest: () { - builder.element('Filter', nest: filter.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('Id', nest: id); }); return builder.buildDocument(); } /// Specifies a metrics configuration filter. The metrics configuration will only include objects that meet the filter's criteria. A filter must be a prefix, a tag, or a conjunction (MetricsAndOperator). - MetricsFilter filter; + MetricsFilter? filter; /// The ID used to identify the metrics configuration. - String id; + String? id; } /// Specifies a metrics configuration filter. The metrics configuration only includes objects that meet the filter's criteria. A filter must be a prefix, a tag, or a conjunction (MetricsAndOperator). @@ -1985,7 +1986,7 @@ class MetricsFilter { this.tag, ); - MetricsFilter.fromXml(XmlElement xml) { + MetricsFilter.fromXml(XmlElement? xml) { and = MetricsAndOperator.fromXml(getProp(xml, 'And')); prefix = getProp(xml, 'Prefix')?.text; tag = Tag.fromXml(getProp(xml, 'Tag')); @@ -1994,21 +1995,21 @@ class MetricsFilter { XmlNode toXml() { final builder = XmlBuilder(); builder.element('MetricsFilter', nest: () { - builder.element('And', nest: and.toXml()); + builder.element('And', nest: and!.toXml()); builder.element('Prefix', nest: prefix); - builder.element('Tag', nest: tag.toXml()); + builder.element('Tag', nest: tag!.toXml()); }); return builder.buildDocument(); } /// A conjunction (logical AND) of predicates, which is used in evaluating a metrics filter. The operator must have at least two predicates, and an object must match all of the predicates in order for the filter to apply. - MetricsAndOperator and; + MetricsAndOperator? and; /// The prefix used when evaluating a metrics filter. - String prefix; + String? prefix; /// The tag used when evaluating a metrics filter. - Tag tag; + Tag? tag; } /// Container for the MultipartUpload for the Amazon S3 object. @@ -2023,7 +2024,7 @@ class MultipartUpload { ); MultipartUpload.fromXml(XmlElement xml) { - initiated = DateTime.parse(getProp(xml, 'Initiated')?.text); + initiated = DateTime.parse(getProp(xml, 'Initiated')!.text); initiator = Initiator.fromXml(getProp(xml, 'Initiator')); key = getProp(xml, 'Key')?.text; owner = Owner.fromXml(getProp(xml, 'Owner')); @@ -2034,10 +2035,10 @@ class MultipartUpload { XmlNode toXml() { final builder = XmlBuilder(); builder.element('MultipartUpload', nest: () { - builder.element('Initiated', nest: initiated.toIso8601String()); - builder.element('Initiator', nest: initiator.toXml()); + builder.element('Initiated', nest: initiated!.toIso8601String()); + builder.element('Initiator', nest: initiator!.toXml()); builder.element('Key', nest: key); - builder.element('Owner', nest: owner.toXml()); + builder.element('Owner', nest: owner!.toXml()); builder.element('StorageClass', nest: storageClass); builder.element('UploadId', nest: uploadId); }); @@ -2045,22 +2046,22 @@ class MultipartUpload { } /// Date and time at which the multipart upload was initiated. - DateTime initiated; + DateTime? initiated; /// Identifies who initiated the multipart upload. - Initiator initiator; + Initiator? initiator; /// Key of the object for which the multipart upload was initiated. - String key; + String? key; /// Specifies the owner of the object that is part of the multipart upload. - Owner owner; + Owner? owner; /// The class of storage used to store the object. - String storageClass; + String? storageClass; /// Upload ID that identifies the multipart upload. - String uploadId; + String? uploadId; } /// Specifies when noncurrent object versions expire. Upon expiration, Amazon S3 permanently deletes the noncurrent object versions. You set this lifecycle configuration action on a bucket that has versioning enabled (or suspended) to request that Amazon S3 delete noncurrent object versions at a specific period in the object's lifetime. @@ -2069,8 +2070,8 @@ class NoncurrentVersionExpiration { this.noncurrentDays, ); - NoncurrentVersionExpiration.fromXml(XmlElement xml) { - noncurrentDays = int.tryParse(getProp(xml, 'NoncurrentDays')?.text); + NoncurrentVersionExpiration.fromXml(XmlElement? xml) { + noncurrentDays = int.tryParse(getProp(xml, 'NoncurrentDays')!.text); } XmlNode toXml() { @@ -2082,7 +2083,7 @@ class NoncurrentVersionExpiration { } /// Specifies the number of days an object is noncurrent before Amazon S3 can perform the associated action. For information about the noncurrent days calculations, see How Amazon S3 Calculates When an Object Became Noncurrent in the Amazon Simple Storage Service Developer Guide. - int noncurrentDays; + int? noncurrentDays; } /// Container for the transition rule that describes when noncurrent objects transition to the STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, or DEEP_ARCHIVE storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set this action to request that Amazon S3 transition noncurrent object versions to the STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, or DEEP_ARCHIVE storage class at a specific period in the object's lifetime. @@ -2092,8 +2093,8 @@ class NoncurrentVersionTransition { this.storageClass, ); - NoncurrentVersionTransition.fromXml(XmlElement xml) { - noncurrentDays = int.tryParse(getProp(xml, 'NoncurrentDays')?.text); + NoncurrentVersionTransition.fromXml(XmlElement? xml) { + noncurrentDays = int.tryParse(getProp(xml, 'NoncurrentDays')!.text); storageClass = getProp(xml, 'StorageClass')?.text; } @@ -2107,10 +2108,10 @@ class NoncurrentVersionTransition { } /// Specifies the number of days an object is noncurrent before Amazon S3 can perform the associated action. For information about the noncurrent days calculations, see How Amazon S3 Calculates How Long an Object Has Been Noncurrent in the Amazon Simple Storage Service Developer Guide. - int noncurrentDays; + int? noncurrentDays; /// The class of storage used to store the object. - String storageClass; + String? storageClass; } /// A container for specifying the notification configuration of the bucket. If this element is empty, notifications are turned off for the bucket. @@ -2135,28 +2136,28 @@ class NotificationConfiguration { builder.element('NotificationConfiguration', nest: () { if (lambdaFunctionConfigurations != null) { builder.element('LambdaFunctionConfigurations', - nest: lambdaFunctionConfigurations.toXml()); + nest: lambdaFunctionConfigurations!.toXml()); } if (queueConfigurations != null) { builder.element('QueueConfigurations', - nest: queueConfigurations.toXml()); + nest: queueConfigurations!.toXml()); } if (topicConfigurations != null) { builder.element('TopicConfigurations', - nest: topicConfigurations.toXml()); + nest: topicConfigurations!.toXml()); } }); return builder.buildDocument(); } /// Describes the AWS Lambda functions to invoke and the events for which to invoke them. - LambdaFunctionConfiguration lambdaFunctionConfigurations; + LambdaFunctionConfiguration? lambdaFunctionConfigurations; /// The Amazon Simple Queue Service queues to publish messages to and the events for which to publish messages. - QueueConfiguration queueConfigurations; + QueueConfiguration? queueConfigurations; /// The topic to which notifications are sent and the events for which notifications are generated. - TopicConfiguration topicConfigurations; + TopicConfiguration? topicConfigurations; } /// Container for specifying the AWS Lambda notification configuration. @@ -2180,21 +2181,21 @@ class NotificationConfigurationDeprecated { final builder = XmlBuilder(); builder.element('NotificationConfigurationDeprecated', nest: () { builder.element('CloudFunctionConfiguration', - nest: cloudFunctionConfiguration.toXml()); - builder.element('QueueConfiguration', nest: queueConfiguration.toXml()); - builder.element('TopicConfiguration', nest: topicConfiguration.toXml()); + nest: cloudFunctionConfiguration!.toXml()); + builder.element('QueueConfiguration', nest: queueConfiguration!.toXml()); + builder.element('TopicConfiguration', nest: topicConfiguration!.toXml()); }); return builder.buildDocument(); } /// Container for specifying the AWS Lambda notification configuration. - CloudFunctionConfiguration cloudFunctionConfiguration; + CloudFunctionConfiguration? cloudFunctionConfiguration; /// This data type is deprecated. This data type specifies the configuration for publishing messages to an Amazon Simple Queue Service (Amazon SQS) queue when Amazon S3 detects specified events. - QueueConfigurationDeprecated queueConfiguration; + QueueConfigurationDeprecated? queueConfiguration; /// This data type is deprecated. A container for specifying the configuration for publication of messages to an Amazon Simple Notification Service (Amazon SNS) topic when Amazon S3 detects specified events. - TopicConfigurationDeprecated topicConfiguration; + TopicConfigurationDeprecated? topicConfiguration; } /// Specifies object key name filtering rules. For information about key name filtering, see Configuring Event Notifications in the Amazon Simple Storage Service Developer Guide. @@ -2203,20 +2204,20 @@ class NotificationConfigurationFilter { this.key, ); - NotificationConfigurationFilter.fromXml(XmlElement xml) { + NotificationConfigurationFilter.fromXml(XmlElement? xml) { key = S3KeyFilter.fromXml(getProp(xml, 'Key')); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('NotificationConfigurationFilter', nest: () { - builder.element('Key', nest: key.toXml()); + builder.element('Key', nest: key!.toXml()); }); return builder.buildDocument(); } /// A container for object key name prefix and suffix filtering rules. - S3KeyFilter key; + S3KeyFilter? key; } /// An object consists of data and its descriptive metadata. @@ -2233,9 +2234,9 @@ class Object { Object.fromXml(XmlElement xml) { eTag = getProp(xml, 'ETag')?.text; key = getProp(xml, 'Key')?.text; - lastModified = DateTime.parse(getProp(xml, 'LastModified')?.text); + lastModified = DateTime.parse(getProp(xml, 'LastModified')!.text); owner = Owner.fromXml(getProp(xml, 'Owner')); - size = int.tryParse(getProp(xml, 'Size')?.text); + size = int.tryParse(getProp(xml, 'Size')!.text); storageClass = getProp(xml, 'StorageClass')?.text; } @@ -2244,8 +2245,8 @@ class Object { builder.element('Object', nest: () { builder.element('ETag', nest: eTag); builder.element('Key', nest: key); - builder.element('LastModified', nest: lastModified.toIso8601String()); - builder.element('Owner', nest: owner.toXml()); + builder.element('LastModified', nest: lastModified!.toIso8601String()); + builder.element('Owner', nest: owner!.toXml()); builder.element('Size', nest: size.toString()); builder.element('StorageClass', nest: storageClass); }); @@ -2253,22 +2254,22 @@ class Object { } /// The entity tag is an MD5 hash of the object. ETag reflects only changes to the contents of an object, not its metadata. - String eTag; + String? eTag; /// The name that you assign to an object. You use the object key to retrieve the object. - String key; + String? key; /// The date the Object was Last Modified - DateTime lastModified; + DateTime? lastModified; /// The owner of the object - Owner owner; + Owner? owner; /// Size in bytes of the object - int size; + int? size; /// The class of storage used to store the object. - String storageClass; + String? storageClass; } /// Object Identifier is unique value to identify objects. @@ -2295,10 +2296,10 @@ class ObjectIdentifier { } /// Key name of the object to delete. - String key; + String? key; /// VersionId for the specific version of the object to delete. - String versionId; + String? versionId; } /// The container element for Object Lock configuration parameters. @@ -2317,16 +2318,16 @@ class ObjectLockConfiguration { final builder = XmlBuilder(); builder.element('ObjectLockConfiguration', nest: () { builder.element('ObjectLockEnabled', nest: objectLockEnabled); - builder.element('Rule', nest: rule.toXml()); + builder.element('Rule', nest: rule!.toXml()); }); return builder.buildDocument(); } /// Indicates whether this bucket has an Object Lock configuration enabled. - String objectLockEnabled; + String? objectLockEnabled; /// The Object Lock rule in place for the specified object. - ObjectLockRule rule; + ObjectLockRule? rule; } /// A Legal Hold configuration for an object. @@ -2348,7 +2349,7 @@ class ObjectLockLegalHold { } /// Indicates whether the specified object has a Legal Hold in place. - String status; + String? status; } /// A Retention configuration for an object. @@ -2360,7 +2361,7 @@ class ObjectLockRetention { ObjectLockRetention.fromXml(XmlElement xml) { mode = getProp(xml, 'Mode')?.text; - retainUntilDate = DateTime.parse(getProp(xml, 'RetainUntilDate')?.text); + retainUntilDate = DateTime.parse(getProp(xml, 'RetainUntilDate')!.text); } XmlNode toXml() { @@ -2368,16 +2369,16 @@ class ObjectLockRetention { builder.element('ObjectLockRetention', nest: () { builder.element('Mode', nest: mode); builder.element('RetainUntilDate', - nest: retainUntilDate.toIso8601String()); + nest: retainUntilDate!.toIso8601String()); }); return builder.buildDocument(); } /// Indicates the Retention mode for the specified object. - String mode; + String? mode; /// The date on which this Object Lock Retention will expire. - DateTime retainUntilDate; + DateTime? retainUntilDate; } /// The container element for an Object Lock rule. @@ -2386,7 +2387,7 @@ class ObjectLockRule { this.defaultRetention, ); - ObjectLockRule.fromXml(XmlElement xml) { + ObjectLockRule.fromXml(XmlElement? xml) { defaultRetention = DefaultRetention.fromXml(getProp(xml, 'DefaultRetention')); } @@ -2394,13 +2395,13 @@ class ObjectLockRule { XmlNode toXml() { final builder = XmlBuilder(); builder.element('ObjectLockRule', nest: () { - builder.element('DefaultRetention', nest: defaultRetention.toXml()); + builder.element('DefaultRetention', nest: defaultRetention!.toXml()); }); return builder.buildDocument(); } /// The default retention period that you want to apply to new objects placed in the specified bucket. - DefaultRetention defaultRetention; + DefaultRetention? defaultRetention; } /// The version of an object. @@ -2418,11 +2419,11 @@ class ObjectVersion { ObjectVersion.fromXml(XmlElement xml) { eTag = getProp(xml, 'ETag')?.text; - isLatest = getProp(xml, 'IsLatest')?.text?.toUpperCase() == 'TRUE'; + isLatest = getProp(xml, 'IsLatest')?.text.toUpperCase() == 'TRUE'; key = getProp(xml, 'Key')?.text; - lastModified = DateTime.parse(getProp(xml, 'LastModified')?.text); + lastModified = DateTime.parse(getProp(xml, 'LastModified')!.text); owner = Owner.fromXml(getProp(xml, 'Owner')); - size = int.tryParse(getProp(xml, 'Size')?.text); + size = int.tryParse(getProp(xml, 'Size')!.text); storageClass = getProp(xml, 'StorageClass')?.text; versionId = getProp(xml, 'VersionId')?.text; } @@ -2431,10 +2432,10 @@ class ObjectVersion { final builder = XmlBuilder(); builder.element('ObjectVersion', nest: () { builder.element('ETag', nest: eTag); - builder.element('IsLatest', nest: isLatest ? 'TRUE' : 'FALSE'); + builder.element('IsLatest', nest: isLatest! ? 'TRUE' : 'FALSE'); builder.element('Key', nest: key); - builder.element('LastModified', nest: lastModified.toIso8601String()); - builder.element('Owner', nest: owner.toXml()); + builder.element('LastModified', nest: lastModified!.toIso8601String()); + builder.element('Owner', nest: owner!.toXml()); builder.element('Size', nest: size.toString()); builder.element('StorageClass', nest: storageClass); builder.element('VersionId', nest: versionId); @@ -2443,28 +2444,28 @@ class ObjectVersion { } /// The entity tag is an MD5 hash of that version of the object. - String eTag; + String? eTag; /// Specifies whether the object is (true) or is not (false) the latest version of an object. - bool isLatest; + bool? isLatest; /// The object key. - String key; + String? key; /// Date and time the object was last modified. - DateTime lastModified; + DateTime? lastModified; /// Specifies the owner of the object. - Owner owner; + Owner? owner; /// Size in bytes of the object. - int size; + int? size; /// The class of storage used to store the object. - String storageClass; + String? storageClass; /// Version ID of an object. - String versionId; + String? versionId; } /// Describes the location where the restore job's output is stored. @@ -2473,20 +2474,20 @@ class OutputLocation { this.s3, ); - OutputLocation.fromXml(XmlElement xml) { + OutputLocation.fromXml(XmlElement? xml) { s3 = S3Location.fromXml(getProp(xml, 'S3')); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('OutputLocation', nest: () { - builder.element('S3', nest: s3.toXml()); + builder.element('S3', nest: s3!.toXml()); }); return builder.buildDocument(); } /// Describes an S3 location that will receive the results of the restore request. - S3Location s3; + S3Location? s3; } /// Describes how results of the Select job are serialized. @@ -2496,7 +2497,7 @@ class OutputSerialization { this.jSON, ); - OutputSerialization.fromXml(XmlElement xml) { + OutputSerialization.fromXml(XmlElement? xml) { cSV = CSVOutput.fromXml(getProp(xml, 'CSV')); jSON = JSONOutput.fromXml(getProp(xml, 'JSON')); } @@ -2504,17 +2505,17 @@ class OutputSerialization { XmlNode toXml() { final builder = XmlBuilder(); builder.element('OutputSerialization', nest: () { - builder.element('CSV', nest: cSV.toXml()); - builder.element('JSON', nest: jSON.toXml()); + builder.element('CSV', nest: cSV!.toXml()); + builder.element('JSON', nest: jSON!.toXml()); }); return builder.buildDocument(); } /// Describes the serialization of CSV-encoded Select results. - CSVOutput cSV; + CSVOutput? cSV; /// Specifies JSON as request's output serialization format. - JSONOutput jSON; + JSONOutput? jSON; } /// Container for the owner's display name and ID. @@ -2524,7 +2525,7 @@ class Owner { this.iD, ); - Owner.fromXml(XmlElement xml) { + Owner.fromXml(XmlElement? xml) { displayName = getProp(xml, 'DisplayName')?.text; iD = getProp(xml, 'ID')?.text; } @@ -2539,17 +2540,17 @@ class Owner { } /// Container for the display name of the owner. - String displayName; + String? displayName; /// Container for the ID of the owner. - String iD; + String? iD; } /// Container for Parquet. class ParquetInput { ParquetInput(); - ParquetInput.fromXml(XmlElement xml); + ParquetInput.fromXml(XmlElement? xml); XmlNode toXml() { final builder = XmlBuilder(); @@ -2569,16 +2570,16 @@ class Part { Part.fromXml(XmlElement xml) { eTag = getProp(xml, 'ETag')?.text; - lastModified = DateTime.parse(getProp(xml, 'LastModified')?.text); - partNumber = int.tryParse(getProp(xml, 'PartNumber')?.text); - size = int.tryParse(getProp(xml, 'Size')?.text); + lastModified = DateTime.parse(getProp(xml, 'LastModified')!.text); + partNumber = int.tryParse(getProp(xml, 'PartNumber')!.text); + size = int.tryParse(getProp(xml, 'Size')!.text); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('Part', nest: () { builder.element('ETag', nest: eTag); - builder.element('LastModified', nest: lastModified.toIso8601String()); + builder.element('LastModified', nest: lastModified!.toIso8601String()); builder.element('PartNumber', nest: partNumber.toString()); builder.element('Size', nest: size.toString()); }); @@ -2586,16 +2587,16 @@ class Part { } /// Entity tag returned when the part was uploaded. - String eTag; + String? eTag; /// Date and time at which the part was uploaded. - DateTime lastModified; + DateTime? lastModified; /// Part number identifying the part. This is a positive integer between 1 and 10,000. - int partNumber; + int? partNumber; /// Size in bytes of the uploaded part data. - int size; + int? size; } /// The container element for a bucket's policy status. @@ -2605,19 +2606,19 @@ class PolicyStatus { ); PolicyStatus.fromXml(XmlElement xml) { - isPublic = getProp(xml, 'IsPublic')?.text?.toUpperCase() == 'TRUE'; + isPublic = getProp(xml, 'IsPublic')?.text.toUpperCase() == 'TRUE'; } XmlNode toXml() { final builder = XmlBuilder(); builder.element('PolicyStatus', nest: () { - builder.element('IsPublic', nest: isPublic ? 'TRUE' : 'FALSE'); + builder.element('IsPublic', nest: isPublic! ? 'TRUE' : 'FALSE'); }); return builder.buildDocument(); } /// The policy status for this bucket. TRUE indicates that this bucket is public. FALSE indicates that the bucket is not public. - bool isPublic; + bool? isPublic; } /// This data type contains information about progress of an operation. @@ -2628,10 +2629,10 @@ class Progress { this.bytesScanned, ); - Progress.fromXml(XmlElement xml) { - bytesProcessed = int.tryParse(getProp(xml, 'BytesProcessed')?.text); - bytesReturned = int.tryParse(getProp(xml, 'BytesReturned')?.text); - bytesScanned = int.tryParse(getProp(xml, 'BytesScanned')?.text); + Progress.fromXml(XmlElement? xml) { + bytesProcessed = int.tryParse(getProp(xml, 'BytesProcessed')!.text); + bytesReturned = int.tryParse(getProp(xml, 'BytesReturned')!.text); + bytesScanned = int.tryParse(getProp(xml, 'BytesScanned')!.text); } XmlNode toXml() { @@ -2645,13 +2646,13 @@ class Progress { } /// The current number of uncompressed object bytes processed. - int bytesProcessed; + int? bytesProcessed; /// The current number of bytes of records payload data returned. - int bytesReturned; + int? bytesReturned; /// The current number of object bytes scanned. - int bytesScanned; + int? bytesScanned; } /// This data type contains information about the progress event of an operation. @@ -2660,20 +2661,20 @@ class ProgressEvent { this.details, ); - ProgressEvent.fromXml(XmlElement xml) { + ProgressEvent.fromXml(XmlElement? xml) { details = Progress.fromXml(getProp(xml, 'Details')); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('ProgressEvent', nest: () { - builder.element('Details', nest: details.toXml()); + builder.element('Details', nest: details!.toXml()); }); return builder.buildDocument(); } /// The Progress event details. - Progress details; + Progress? details; } /// The PublicAccessBlock configuration that you want to apply to this Amazon S3 bucket. You can enable the configuration options in any combination. For more information about when Amazon S3 considers a bucket or object public, see The Meaning of "Public" in the Amazon Simple Storage Service Developer Guide. @@ -2687,41 +2688,41 @@ class PublicAccessBlockConfiguration { PublicAccessBlockConfiguration.fromXml(XmlElement xml) { blockPublicAcls = - getProp(xml, 'BlockPublicAcls')?.text?.toUpperCase() == 'TRUE'; + getProp(xml, 'BlockPublicAcls')?.text.toUpperCase() == 'TRUE'; blockPublicPolicy = - getProp(xml, 'BlockPublicPolicy')?.text?.toUpperCase() == 'TRUE'; + getProp(xml, 'BlockPublicPolicy')?.text.toUpperCase() == 'TRUE'; ignorePublicAcls = - getProp(xml, 'IgnorePublicAcls')?.text?.toUpperCase() == 'TRUE'; + getProp(xml, 'IgnorePublicAcls')?.text.toUpperCase() == 'TRUE'; restrictPublicBuckets = - getProp(xml, 'RestrictPublicBuckets')?.text?.toUpperCase() == 'TRUE'; + getProp(xml, 'RestrictPublicBuckets')?.text.toUpperCase() == 'TRUE'; } XmlNode toXml() { final builder = XmlBuilder(); builder.element('PublicAccessBlockConfiguration', nest: () { builder.element('BlockPublicAcls', - nest: blockPublicAcls ? 'TRUE' : 'FALSE'); + nest: blockPublicAcls! ? 'TRUE' : 'FALSE'); builder.element('BlockPublicPolicy', - nest: blockPublicPolicy ? 'TRUE' : 'FALSE'); + nest: blockPublicPolicy! ? 'TRUE' : 'FALSE'); builder.element('IgnorePublicAcls', - nest: ignorePublicAcls ? 'TRUE' : 'FALSE'); + nest: ignorePublicAcls! ? 'TRUE' : 'FALSE'); builder.element('RestrictPublicBuckets', - nest: restrictPublicBuckets ? 'TRUE' : 'FALSE'); + nest: restrictPublicBuckets! ? 'TRUE' : 'FALSE'); }); return builder.buildDocument(); } /// Specifies whether Amazon S3 should block public access control lists (ACLs) for this bucket and objects in this bucket. Setting this element to TRUE causes the following behavior: - bool blockPublicAcls; + bool? blockPublicAcls; /// Specifies whether Amazon S3 should block public bucket policies for this bucket. Setting this element to TRUE causes Amazon S3 to reject calls to PUT Bucket policy if the specified bucket policy allows public access. - bool blockPublicPolicy; + bool? blockPublicPolicy; /// Specifies whether Amazon S3 should ignore public ACLs for this bucket and objects in this bucket. Setting this element to TRUE causes Amazon S3 to ignore all public ACLs on this bucket and objects in this bucket. - bool ignorePublicAcls; + bool? ignorePublicAcls; /// Specifies whether Amazon S3 should restrict public bucket policies for this bucket. Setting this element to TRUE restricts access to this bucket to only AWS services and authorized users within this account if the bucket has a public policy. - bool restrictPublicBuckets; + bool? restrictPublicBuckets; } /// Specifies the configuration for publishing messages to an Amazon Simple Queue Service (Amazon SQS) queue when Amazon S3 detects specified events. @@ -2733,7 +2734,7 @@ class QueueConfiguration { this.queueArn, ); - QueueConfiguration.fromXml(XmlElement xml) { + QueueConfiguration.fromXml(XmlElement? xml) { events = getProp(xml, 'Events')?.text; filter = NotificationConfigurationFilter.fromXml(getProp(xml, 'Filter')); id = getProp(xml, 'Id')?.text; @@ -2744,7 +2745,7 @@ class QueueConfiguration { final builder = XmlBuilder(); builder.element('QueueConfiguration', nest: () { builder.element('Events', nest: events); - builder.element('Filter', nest: filter.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('Id', nest: id); builder.element('QueueArn', nest: queueArn); }); @@ -2752,16 +2753,16 @@ class QueueConfiguration { } /// A collection of bucket events for which to send notifications - String events; + String? events; /// Specifies object key name filtering rules. For information about key name filtering, see Configuring Event Notifications in the Amazon Simple Storage Service Developer Guide. - NotificationConfigurationFilter filter; + NotificationConfigurationFilter? filter; /// An optional unique identifier for configurations in a notification configuration. If you don't provide one, Amazon S3 will assign an ID. - String id; + String? id; /// The Amazon Resource Name (ARN) of the Amazon SQS queue to which Amazon S3 publishes a message when it detects events of the specified type. - String queueArn; + String? queueArn; } /// This data type is deprecated. Use QueueConfiguration for the same purposes. This data type specifies the configuration for publishing messages to an Amazon Simple Queue Service (Amazon SQS) queue when Amazon S3 detects specified events. @@ -2773,7 +2774,7 @@ class QueueConfigurationDeprecated { this.queue, ); - QueueConfigurationDeprecated.fromXml(XmlElement xml) { + QueueConfigurationDeprecated.fromXml(XmlElement? xml) { event = getProp(xml, 'Event')?.text; events = getProp(xml, 'Events')?.text; id = getProp(xml, 'Id')?.text; @@ -2792,16 +2793,16 @@ class QueueConfigurationDeprecated { } /// This member has been deprecated. - String event; + String? event; /// A collection of bucket events for which to send notifications - String events; + String? events; /// An optional unique identifier for configurations in a notification configuration. If you don't provide one, Amazon S3 will assign an ID. - String id; + String? id; /// The Amazon Resource Name (ARN) of the Amazon SQS queue to which Amazon S3 publishes a message when it detects events of the specified type. - String queue; + String? queue; } /// The container for the records event. @@ -2810,7 +2811,7 @@ class RecordsEvent { this.payload, ); - RecordsEvent.fromXml(XmlElement xml) { + RecordsEvent.fromXml(XmlElement? xml) { payload = getProp(xml, 'Payload')?.text; } @@ -2823,7 +2824,7 @@ class RecordsEvent { } /// The byte array of partial, one or more result records. - String payload; + String? payload; } /// Specifies how requests are redirected. In the event of an error, you can specify a different error code to return. @@ -2836,7 +2837,7 @@ class Redirect { this.replaceKeyWith, ); - Redirect.fromXml(XmlElement xml) { + Redirect.fromXml(XmlElement? xml) { hostName = getProp(xml, 'HostName')?.text; httpRedirectCode = getProp(xml, 'HttpRedirectCode')?.text; protocol = getProp(xml, 'Protocol')?.text; @@ -2857,19 +2858,19 @@ class Redirect { } /// The host name to use in the redirect request. - String hostName; + String? hostName; /// The HTTP redirect code to use on the response. Not required if one of the siblings is present. - String httpRedirectCode; + String? httpRedirectCode; /// Protocol to use when redirecting requests. The default is the protocol that is used in the original request. - String protocol; + String? protocol; /// The object key prefix to use in the redirect request. For example, to redirect requests for all pages with prefix docs/ (objects in the docs/ folder) to documents/, you can set a condition block with KeyPrefixEquals set to docs/ and in the Redirect set ReplaceKeyPrefixWith to /documents. Not required if one of the siblings is present. Can be present only if ReplaceKeyWith is not provided. - String replaceKeyPrefixWith; + String? replaceKeyPrefixWith; /// The specific object key to use in the redirect request. For example, redirect request to error.html. Not required if one of the siblings is present. Can be present only if ReplaceKeyPrefixWith is not provided. - String replaceKeyWith; + String? replaceKeyWith; } /// Specifies the redirect behavior of all requests to a website endpoint of an Amazon S3 bucket. @@ -2879,7 +2880,7 @@ class RedirectAllRequestsTo { this.protocol, ); - RedirectAllRequestsTo.fromXml(XmlElement xml) { + RedirectAllRequestsTo.fromXml(XmlElement? xml) { hostName = getProp(xml, 'HostName')?.text; protocol = getProp(xml, 'Protocol')?.text; } @@ -2894,10 +2895,10 @@ class RedirectAllRequestsTo { } /// Name of the host where requests are redirected. - String hostName; + String? hostName; /// Protocol to use when redirecting requests. The default is the protocol that is used in the original request. - String protocol; + String? protocol; } /// A container for replication rules. You can add up to 1,000 rules. The maximum size of a replication configuration is 2 MB. @@ -2916,16 +2917,16 @@ class ReplicationConfiguration { final builder = XmlBuilder(); builder.element('ReplicationConfiguration', nest: () { builder.element('Role', nest: role); - builder.element('Rules', nest: rules.toXml()); + builder.element('Rules', nest: rules!.toXml()); }); return builder.buildDocument(); } /// The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that Amazon S3 assumes when replicating objects. For more information, see How to Set Up Replication in the Amazon Simple Storage Service Developer Guide. - String role; + String? role; /// A container for one or more replication rules. A replication configuration must have at least one rule and can contain a maximum of 1,000 rules. - ReplicationRule rules; + ReplicationRule? rules; } /// Specifies which Amazon S3 objects to replicate and where to store the replicas. @@ -2942,7 +2943,7 @@ class ReplicationRule { this.status, ); - ReplicationRule.fromXml(XmlElement xml) { + ReplicationRule.fromXml(XmlElement? xml) { deleteMarkerReplication = DeleteMarkerReplication.fromXml( getProp(xml, 'DeleteMarkerReplication')); destination = Destination.fromXml(getProp(xml, 'Destination')); @@ -2951,7 +2952,7 @@ class ReplicationRule { filter = ReplicationRuleFilter.fromXml(getProp(xml, 'Filter')); iD = getProp(xml, 'ID')?.text; prefix = getProp(xml, 'Prefix')?.text; - priority = int.tryParse(getProp(xml, 'Priority')?.text); + priority = int.tryParse(getProp(xml, 'Priority')!.text); sourceSelectionCriteria = SourceSelectionCriteria.fromXml( getProp(xml, 'SourceSelectionCriteria')); status = getProp(xml, 'Status')?.text; @@ -2961,47 +2962,47 @@ class ReplicationRule { final builder = XmlBuilder(); builder.element('ReplicationRule', nest: () { builder.element('DeleteMarkerReplication', - nest: deleteMarkerReplication.toXml()); - builder.element('Destination', nest: destination.toXml()); + nest: deleteMarkerReplication!.toXml()); + builder.element('Destination', nest: destination!.toXml()); builder.element('ExistingObjectReplication', - nest: existingObjectReplication.toXml()); - builder.element('Filter', nest: filter.toXml()); + nest: existingObjectReplication!.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('ID', nest: iD); builder.element('Prefix', nest: prefix); builder.element('Priority', nest: priority.toString()); builder.element('SourceSelectionCriteria', - nest: sourceSelectionCriteria.toXml()); + nest: sourceSelectionCriteria!.toXml()); builder.element('Status', nest: status); }); return builder.buildDocument(); } /// Specifies whether Amazon S3 replicates the delete markers. If you specify a Filter, you must specify this element. However, in the latest version of replication configuration (when Filter is specified), Amazon S3 doesn't replicate delete markers. Therefore, the DeleteMarkerReplication element can contain only <Status>Disabled</Status>. For an example configuration, see Basic Rule Configuration. - DeleteMarkerReplication deleteMarkerReplication; + DeleteMarkerReplication? deleteMarkerReplication; /// A container for information about the replication destination and its configurations including enabling the S3 Replication Time Control (S3 RTC). - Destination destination; + Destination? destination; /// Type: ExistingObjectReplication data type - ExistingObjectReplication existingObjectReplication; + ExistingObjectReplication? existingObjectReplication; /// A filter that identifies the subset of objects to which the replication rule applies. A Filter must specify exactly one Prefix, Tag, or an And child element. - ReplicationRuleFilter filter; + ReplicationRuleFilter? filter; /// A unique identifier for the rule. The maximum value is 255 characters. - String iD; + String? iD; /// This member has been deprecated. - String prefix; + String? prefix; /// The priority associated with the rule. If you specify multiple rules in a replication configuration, Amazon S3 prioritizes the rules to prevent conflicts when filtering. If two or more rules identify the same object based on a specified filter, the rule with higher priority takes precedence. For example: - int priority; + int? priority; /// A container that describes additional filters for identifying the source objects that you want to replicate. You can choose to enable or disable the replication of these objects. Currently, Amazon S3 supports only the filter that you can specify for objects created with server-side encryption using a customer master key (CMK) stored in AWS Key Management Service (SSE-KMS). - SourceSelectionCriteria sourceSelectionCriteria; + SourceSelectionCriteria? sourceSelectionCriteria; /// Specifies whether the rule is enabled. - String status; + String? status; } /// A container for specifying rule filters. The filters determine the subset of objects to which the rule applies. This element is required only if you specify more than one filter. @@ -3011,7 +3012,7 @@ class ReplicationRuleAndOperator { this.tags, ); - ReplicationRuleAndOperator.fromXml(XmlElement xml) { + ReplicationRuleAndOperator.fromXml(XmlElement? xml) { prefix = getProp(xml, 'Prefix')?.text; tags = Tag.fromXml(getProp(xml, 'Tags')); } @@ -3020,16 +3021,16 @@ class ReplicationRuleAndOperator { final builder = XmlBuilder(); builder.element('ReplicationRuleAndOperator', nest: () { builder.element('Prefix', nest: prefix); - builder.element('Tags', nest: tags.toXml()); + builder.element('Tags', nest: tags!.toXml()); }); return builder.buildDocument(); } /// An object key name prefix that identifies the subset of objects to which the rule applies. - String prefix; + String? prefix; /// An array of tags containing key and value pairs. - Tag tags; + Tag? tags; } /// A filter that identifies the subset of objects to which the replication rule applies. A Filter must specify exactly one Prefix, Tag, or an And child element. @@ -3040,7 +3041,7 @@ class ReplicationRuleFilter { this.tag, ); - ReplicationRuleFilter.fromXml(XmlElement xml) { + ReplicationRuleFilter.fromXml(XmlElement? xml) { and = ReplicationRuleAndOperator.fromXml(getProp(xml, 'And')); prefix = getProp(xml, 'Prefix')?.text; tag = Tag.fromXml(getProp(xml, 'Tag')); @@ -3049,21 +3050,21 @@ class ReplicationRuleFilter { XmlNode toXml() { final builder = XmlBuilder(); builder.element('ReplicationRuleFilter', nest: () { - builder.element('And', nest: and.toXml()); + builder.element('And', nest: and!.toXml()); builder.element('Prefix', nest: prefix); - builder.element('Tag', nest: tag.toXml()); + builder.element('Tag', nest: tag!.toXml()); }); return builder.buildDocument(); } /// A container for specifying rule filters. The filters determine the subset of objects to which the rule applies. This element is required only if you specify more than one filter. For example: - ReplicationRuleAndOperator and; + ReplicationRuleAndOperator? and; /// An object key name prefix that identifies the subset of objects to which the rule applies. - String prefix; + String? prefix; /// A container for specifying a tag key and value. - Tag tag; + Tag? tag; } /// A container specifying S3 Replication Time Control (S3 RTC) related information, including whether S3 RTC is enabled and the time when all objects and operations on objects must be replicated. Must be specified together with a Metrics block. @@ -3073,7 +3074,7 @@ class ReplicationTime { this.time, ); - ReplicationTime.fromXml(XmlElement xml) { + ReplicationTime.fromXml(XmlElement? xml) { status = getProp(xml, 'Status')?.text; time = ReplicationTimeValue.fromXml(getProp(xml, 'Time')); } @@ -3082,16 +3083,16 @@ class ReplicationTime { final builder = XmlBuilder(); builder.element('ReplicationTime', nest: () { builder.element('Status', nest: status); - builder.element('Time', nest: time.toXml()); + builder.element('Time', nest: time!.toXml()); }); return builder.buildDocument(); } /// Specifies whether the replication time is enabled. - String status; + String? status; /// A container specifying the time by which replication should be complete for all objects and operations on objects. - ReplicationTimeValue time; + ReplicationTimeValue? time; } /// A container specifying the time value for S3 Replication Time Control (S3 RTC) and replication metrics EventThreshold. @@ -3100,8 +3101,8 @@ class ReplicationTimeValue { this.minutes, ); - ReplicationTimeValue.fromXml(XmlElement xml) { - minutes = int.tryParse(getProp(xml, 'Minutes')?.text); + ReplicationTimeValue.fromXml(XmlElement? xml) { + minutes = int.tryParse(getProp(xml, 'Minutes')!.text); } XmlNode toXml() { @@ -3113,7 +3114,7 @@ class ReplicationTimeValue { } /// Contains an integer specifying time in minutes. - int minutes; + int? minutes; } /// Container for Payer. @@ -3135,7 +3136,7 @@ class RequestPaymentConfiguration { } /// Specifies who pays for the download and request fees. - String payer; + String? payer; } /// Container for specifying if periodic QueryProgress messages should be sent. @@ -3145,19 +3146,19 @@ class RequestProgress { ); RequestProgress.fromXml(XmlElement xml) { - enabled = getProp(xml, 'Enabled')?.text?.toUpperCase() == 'TRUE'; + enabled = getProp(xml, 'Enabled')?.text.toUpperCase() == 'TRUE'; } XmlNode toXml() { final builder = XmlBuilder(); builder.element('RequestProgress', nest: () { - builder.element('Enabled', nest: enabled ? 'TRUE' : 'FALSE'); + builder.element('Enabled', nest: enabled! ? 'TRUE' : 'FALSE'); }); return builder.buildDocument(); } /// Specifies whether periodic QueryProgress frames should be sent. Valid values: TRUE, FALSE. Default value: FALSE. - bool enabled; + bool? enabled; } /// Container for restore job parameters. @@ -3173,7 +3174,7 @@ class RestoreRequest { ); RestoreRequest.fromXml(XmlElement xml) { - days = int.tryParse(getProp(xml, 'Days')?.text); + days = int.tryParse(getProp(xml, 'Days')!.text); description = getProp(xml, 'Description')?.text; glacierJobParameters = GlacierJobParameters.fromXml(getProp(xml, 'GlacierJobParameters')); @@ -3190,9 +3191,9 @@ class RestoreRequest { builder.element('Days', nest: days.toString()); builder.element('Description', nest: description); builder.element('GlacierJobParameters', - nest: glacierJobParameters.toXml()); - builder.element('OutputLocation', nest: outputLocation.toXml()); - builder.element('SelectParameters', nest: selectParameters.toXml()); + nest: glacierJobParameters!.toXml()); + builder.element('OutputLocation', nest: outputLocation!.toXml()); + builder.element('SelectParameters', nest: selectParameters!.toXml()); builder.element('Tier', nest: tier); builder.element('Type', nest: type); }); @@ -3200,25 +3201,25 @@ class RestoreRequest { } /// Lifetime of the active copy in days. Do not use with restores that specify OutputLocation. - int days; + int? days; /// The optional description for the job. - String description; + String? description; /// S3 Glacier related parameters pertaining to this job. Do not use with restores that specify OutputLocation. - GlacierJobParameters glacierJobParameters; + GlacierJobParameters? glacierJobParameters; /// Describes the location where the restore job's output is stored. - OutputLocation outputLocation; + OutputLocation? outputLocation; /// Describes the parameters for Select job types. - SelectParameters selectParameters; + SelectParameters? selectParameters; /// S3 Glacier retrieval tier at which the restore will be processed. - String tier; + String? tier; /// Type of restore request. - String type; + String? type; } /// Specifies the redirect behavior and when a redirect is applied. @@ -3228,7 +3229,7 @@ class RoutingRule { this.redirect, ); - RoutingRule.fromXml(XmlElement xml) { + RoutingRule.fromXml(XmlElement? xml) { condition = Condition.fromXml(getProp(xml, 'Condition')); redirect = Redirect.fromXml(getProp(xml, 'Redirect')); } @@ -3236,17 +3237,17 @@ class RoutingRule { XmlNode toXml() { final builder = XmlBuilder(); builder.element('RoutingRule', nest: () { - builder.element('Condition', nest: condition.toXml()); - builder.element('Redirect', nest: redirect.toXml()); + builder.element('Condition', nest: condition!.toXml()); + builder.element('Redirect', nest: redirect!.toXml()); }); return builder.buildDocument(); } /// A container for describing a condition that must be met for the specified redirect to apply. For example, 1. If request is for pages in the /docs folder, redirect to the /documents folder. 2. If request results in HTTP error 4xx, redirect request to another host where you might process the error. - Condition condition; + Condition? condition; /// Container for redirect information. You can redirect requests to another host, to another page, or with another protocol. In the event of an error, you can specify a different error code to return. - Redirect redirect; + Redirect? redirect; } /// Specifies lifecycle rules for an Amazon S3 bucket. For more information, see Put Bucket Lifecycle Configuration in the Amazon Simple Storage Service API Reference. For examples, see Put Bucket Lifecycle Configuration Examples @@ -3262,7 +3263,7 @@ class Rule { this.transition, ); - Rule.fromXml(XmlElement xml) { + Rule.fromXml(XmlElement? xml) { abortIncompleteMultipartUpload = AbortIncompleteMultipartUpload.fromXml( getProp(xml, 'AbortIncompleteMultipartUpload')); expiration = LifecycleExpiration.fromXml(getProp(xml, 'Expiration')); @@ -3280,43 +3281,43 @@ class Rule { final builder = XmlBuilder(); builder.element('Rule', nest: () { builder.element('AbortIncompleteMultipartUpload', - nest: abortIncompleteMultipartUpload.toXml()); - builder.element('Expiration', nest: expiration.toXml()); + nest: abortIncompleteMultipartUpload!.toXml()); + builder.element('Expiration', nest: expiration!.toXml()); builder.element('ID', nest: iD); builder.element('NoncurrentVersionExpiration', - nest: noncurrentVersionExpiration.toXml()); + nest: noncurrentVersionExpiration!.toXml()); builder.element('NoncurrentVersionTransition', - nest: noncurrentVersionTransition.toXml()); + nest: noncurrentVersionTransition!.toXml()); builder.element('Prefix', nest: prefix); builder.element('Status', nest: status); - builder.element('Transition', nest: transition.toXml()); + builder.element('Transition', nest: transition!.toXml()); }); return builder.buildDocument(); } /// Specifies the days since the initiation of an incomplete multipart upload that Amazon S3 will wait before permanently removing all parts of the upload. For more information, see Aborting Incomplete Multipart Uploads Using a Bucket Lifecycle Policy in the Amazon Simple Storage Service Developer Guide. - AbortIncompleteMultipartUpload abortIncompleteMultipartUpload; + AbortIncompleteMultipartUpload? abortIncompleteMultipartUpload; /// Specifies the expiration for the lifecycle of the object. - LifecycleExpiration expiration; + LifecycleExpiration? expiration; /// Unique identifier for the rule. The value can't be longer than 255 characters. - String iD; + String? iD; /// Specifies when noncurrent object versions expire. Upon expiration, Amazon S3 permanently deletes the noncurrent object versions. You set this lifecycle configuration action on a bucket that has versioning enabled (or suspended) to request that Amazon S3 delete noncurrent object versions at a specific period in the object's lifetime. - NoncurrentVersionExpiration noncurrentVersionExpiration; + NoncurrentVersionExpiration? noncurrentVersionExpiration; /// Container for the transition rule that describes when noncurrent objects transition to the STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, or DEEP_ARCHIVE storage class. If your bucket is versioning-enabled (or versioning is suspended), you can set this action to request that Amazon S3 transition noncurrent object versions to the STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, or DEEP_ARCHIVE storage class at a specific period in the object's lifetime. - NoncurrentVersionTransition noncurrentVersionTransition; + NoncurrentVersionTransition? noncurrentVersionTransition; /// Object key prefix that identifies one or more objects to which this rule applies. - String prefix; + String? prefix; /// If Enabled, the rule is currently being applied. If Disabled, the rule is not currently being applied. - String status; + String? status; /// Specifies when an object transitions to a specified storage class. For more information about Amazon S3 lifecycle configuration rules, see Transitioning Objects Using Amazon S3 Lifecycle in the Amazon Simple Storage Service Developer Guide. - Transition transition; + Transition? transition; } /// A container for object key name prefix and suffix filtering rules. @@ -3325,20 +3326,20 @@ class S3KeyFilter { this.filterRules, ); - S3KeyFilter.fromXml(XmlElement xml) { + S3KeyFilter.fromXml(XmlElement? xml) { filterRules = FilterRule.fromXml(getProp(xml, 'FilterRules')); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('S3KeyFilter', nest: () { - builder.element('FilterRules', nest: filterRules.toXml()); + builder.element('FilterRules', nest: filterRules!.toXml()); }); return builder.buildDocument(); } /// A list of containers for the key-value pair that defines the criteria for the filter rule. - FilterRule filterRules; + FilterRule? filterRules; } /// Describes an Amazon S3 location that will receive the results of the restore request. @@ -3354,7 +3355,7 @@ class S3Location { this.userMetadata, ); - S3Location.fromXml(XmlElement xml) { + S3Location.fromXml(XmlElement? xml) { accessControlList = Grant.fromXml(getProp(xml, 'AccessControlList')); bucketName = getProp(xml, 'BucketName')?.text; cannedACL = getProp(xml, 'CannedACL')?.text; @@ -3368,41 +3369,41 @@ class S3Location { XmlNode toXml() { final builder = XmlBuilder(); builder.element('S3Location', nest: () { - builder.element('AccessControlList', nest: accessControlList.toXml()); + builder.element('AccessControlList', nest: accessControlList!.toXml()); builder.element('BucketName', nest: bucketName); builder.element('CannedACL', nest: cannedACL); - builder.element('Encryption', nest: encryption.toXml()); + builder.element('Encryption', nest: encryption!.toXml()); builder.element('Prefix', nest: prefix); builder.element('StorageClass', nest: storageClass); - builder.element('Tagging', nest: tagging.toXml()); - builder.element('UserMetadata', nest: userMetadata.toXml()); + builder.element('Tagging', nest: tagging!.toXml()); + builder.element('UserMetadata', nest: userMetadata!.toXml()); }); return builder.buildDocument(); } /// A list of grants that control access to the staged results. - Grant accessControlList; + Grant? accessControlList; /// The name of the bucket where the restore results will be placed. - String bucketName; + String? bucketName; /// The canned ACL to apply to the restore results. - String cannedACL; + String? cannedACL; /// Contains the type of server-side encryption used. - Encryption encryption; + Encryption? encryption; /// The prefix that is prepended to the restore results for this request. - String prefix; + String? prefix; /// The class of storage used to store the restore results. - String storageClass; + String? storageClass; /// The tag-set that is applied to the restore results. - Tagging tagging; + Tagging? tagging; /// A list of metadata to store with the restore results in S3. - MetadataEntry userMetadata; + MetadataEntry? userMetadata; } /// Specifies the byte range of the object to get the records from. A record is processed when its first byte is contained by the range. This parameter is optional, but when specified, it must not be empty. See RFC 2616, Section 14.35.1 about how to specify the start and end of the range. @@ -3413,8 +3414,8 @@ class ScanRange { ); ScanRange.fromXml(XmlElement xml) { - end = int.tryParse(getProp(xml, 'End')?.text); - start = int.tryParse(getProp(xml, 'Start')?.text); + end = int.tryParse(getProp(xml, 'End')!.text); + start = int.tryParse(getProp(xml, 'Start')!.text); } XmlNode toXml() { @@ -3427,10 +3428,10 @@ class ScanRange { } /// Specifies the end of the byte range. This parameter is optional. Valid values: non-negative integers. The default value is one less than the size of the object being queried. If only the End parameter is supplied, it is interpreted to mean scan the last N bytes of the file. For example, <scanrange><end>50</end></scanrange> means scan the last 50 bytes. - int end; + int? end; /// Specifies the start of the byte range. This parameter is optional. Valid values: non-negative integers. The default value is 0. If only start is supplied, it means scan from that point to the end of the file.For example; <scanrange><start>50</start></scanrange> means scan from byte 50 until the end of the file. - int start; + int? start; } /// The container for selecting objects from a content event stream. @@ -3454,29 +3455,29 @@ class SelectObjectContentEventStream { XmlNode toXml() { final builder = XmlBuilder(); builder.element('SelectObjectContentEventStream', nest: () { - builder.element('Cont', nest: cont.toXml()); - builder.element('End', nest: end.toXml()); - builder.element('Progress', nest: progress.toXml()); - builder.element('Records', nest: records.toXml()); - builder.element('Stats', nest: stats.toXml()); + builder.element('Cont', nest: cont!.toXml()); + builder.element('End', nest: end!.toXml()); + builder.element('Progress', nest: progress!.toXml()); + builder.element('Records', nest: records!.toXml()); + builder.element('Stats', nest: stats!.toXml()); }); return builder.buildDocument(); } /// The Continuation Event. - ContinuationEvent cont; + ContinuationEvent? cont; /// The End Event. - EndEvent end; + EndEvent? end; /// The Progress Event. - ProgressEvent progress; + ProgressEvent? progress; /// The Records Event. - RecordsEvent records; + RecordsEvent? records; /// The Stats Event. - StatsEvent stats; + StatsEvent? stats; } /// Describes the parameters for Select job types. @@ -3488,7 +3489,7 @@ class SelectParameters { this.outputSerialization, ); - SelectParameters.fromXml(XmlElement xml) { + SelectParameters.fromXml(XmlElement? xml) { expression = getProp(xml, 'Expression')?.text; expressionType = getProp(xml, 'ExpressionType')?.text; inputSerialization = @@ -3502,23 +3503,24 @@ class SelectParameters { builder.element('SelectParameters', nest: () { builder.element('Expression', nest: expression); builder.element('ExpressionType', nest: expressionType); - builder.element('InputSerialization', nest: inputSerialization.toXml()); - builder.element('OutputSerialization', nest: outputSerialization.toXml()); + builder.element('InputSerialization', nest: inputSerialization!.toXml()); + builder.element('OutputSerialization', + nest: outputSerialization!.toXml()); }); return builder.buildDocument(); } /// The expression that is used to query the object. - String expression; + String? expression; /// The type of the provided expression (for example, SQL). - String expressionType; + String? expressionType; /// Describes the serialization format of the object. - InputSerialization inputSerialization; + InputSerialization? inputSerialization; /// Describes how the results of the Select job are serialized. - OutputSerialization outputSerialization; + OutputSerialization? outputSerialization; } /// Describes the default server-side encryption to apply to new objects in the bucket. If a PUT Object request doesn't specify any server-side encryption, this default encryption will be applied. For more information, see PUT Bucket encryption in the Amazon Simple Storage Service API Reference. @@ -3528,7 +3530,7 @@ class ServerSideEncryptionByDefault { this.sSEAlgorithm, ); - ServerSideEncryptionByDefault.fromXml(XmlElement xml) { + ServerSideEncryptionByDefault.fromXml(XmlElement? xml) { kMSMasterKeyID = getProp(xml, 'KMSMasterKeyID')?.text; sSEAlgorithm = getProp(xml, 'SSEAlgorithm')?.text; } @@ -3543,10 +3545,10 @@ class ServerSideEncryptionByDefault { } /// AWS Key Management Service (KMS) customer master key ID to use for the default encryption. This parameter is allowed if and only if SSEAlgorithm is set to aws:kms. - String kMSMasterKeyID; + String? kMSMasterKeyID; /// Server-side encryption algorithm to use for the default encryption. - String sSEAlgorithm; + String? sSEAlgorithm; } /// Specifies the default server-side-encryption configuration. @@ -3562,13 +3564,13 @@ class ServerSideEncryptionConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('ServerSideEncryptionConfiguration', nest: () { - builder.element('Rules', nest: rules.toXml()); + builder.element('Rules', nest: rules!.toXml()); }); return builder.buildDocument(); } /// Container for information about a particular server-side encryption configuration rule. - ServerSideEncryptionRule rules; + ServerSideEncryptionRule? rules; } /// Specifies the default server-side encryption configuration. @@ -3577,7 +3579,7 @@ class ServerSideEncryptionRule { this.applyServerSideEncryptionByDefault, ); - ServerSideEncryptionRule.fromXml(XmlElement xml) { + ServerSideEncryptionRule.fromXml(XmlElement? xml) { applyServerSideEncryptionByDefault = ServerSideEncryptionByDefault.fromXml( getProp(xml, 'ApplyServerSideEncryptionByDefault')); } @@ -3586,13 +3588,13 @@ class ServerSideEncryptionRule { final builder = XmlBuilder(); builder.element('ServerSideEncryptionRule', nest: () { builder.element('ApplyServerSideEncryptionByDefault', - nest: applyServerSideEncryptionByDefault.toXml()); + nest: applyServerSideEncryptionByDefault!.toXml()); }); return builder.buildDocument(); } /// Specifies the default server-side encryption to apply to new objects in the bucket. If a PUT Object request doesn't specify any server-side encryption, this default encryption will be applied. - ServerSideEncryptionByDefault applyServerSideEncryptionByDefault; + ServerSideEncryptionByDefault? applyServerSideEncryptionByDefault; } /// A container that describes additional filters for identifying the source objects that you want to replicate. You can choose to enable or disable the replication of these objects. Currently, Amazon S3 supports only the filter that you can specify for objects created with server-side encryption using a customer master key (CMK) stored in AWS Key Management Service (SSE-KMS). @@ -3601,7 +3603,7 @@ class SourceSelectionCriteria { this.sseKmsEncryptedObjects, ); - SourceSelectionCriteria.fromXml(XmlElement xml) { + SourceSelectionCriteria.fromXml(XmlElement? xml) { sseKmsEncryptedObjects = SseKmsEncryptedObjects.fromXml(getProp(xml, 'SseKmsEncryptedObjects')); } @@ -3610,13 +3612,13 @@ class SourceSelectionCriteria { final builder = XmlBuilder(); builder.element('SourceSelectionCriteria', nest: () { builder.element('SseKmsEncryptedObjects', - nest: sseKmsEncryptedObjects.toXml()); + nest: sseKmsEncryptedObjects!.toXml()); }); return builder.buildDocument(); } /// A container for filter information for the selection of Amazon S3 objects encrypted with AWS KMS. If you include SourceSelectionCriteria in the replication configuration, this element is required. - SseKmsEncryptedObjects sseKmsEncryptedObjects; + SseKmsEncryptedObjects? sseKmsEncryptedObjects; } /// Specifies the use of SSE-KMS to encrypt delivered inventory reports. @@ -3625,7 +3627,7 @@ class SSEKMS { this.keyId, ); - SSEKMS.fromXml(XmlElement xml) { + SSEKMS.fromXml(XmlElement? xml) { keyId = getProp(xml, 'KeyId')?.text; } @@ -3638,7 +3640,7 @@ class SSEKMS { } /// Specifies the ID of the AWS Key Management Service (AWS KMS) symmetric customer managed customer master key (CMK) to use for encrypting inventory reports. - String keyId; + String? keyId; } /// A container for filter information for the selection of S3 objects encrypted with AWS KMS. @@ -3647,7 +3649,7 @@ class SseKmsEncryptedObjects { this.status, ); - SseKmsEncryptedObjects.fromXml(XmlElement xml) { + SseKmsEncryptedObjects.fromXml(XmlElement? xml) { status = getProp(xml, 'Status')?.text; } @@ -3660,14 +3662,14 @@ class SseKmsEncryptedObjects { } /// Specifies whether Amazon S3 replicates objects created with server-side encryption using a customer master key (CMK) stored in AWS Key Management Service. - String status; + String? status; } /// Specifies the use of SSE-S3 to encrypt delivered inventory reports. class SSES3 { SSES3(); - SSES3.fromXml(XmlElement xml); + SSES3.fromXml(XmlElement? xml); XmlNode toXml() { final builder = XmlBuilder(); @@ -3684,10 +3686,10 @@ class Stats { this.bytesScanned, ); - Stats.fromXml(XmlElement xml) { - bytesProcessed = int.tryParse(getProp(xml, 'BytesProcessed')?.text); - bytesReturned = int.tryParse(getProp(xml, 'BytesReturned')?.text); - bytesScanned = int.tryParse(getProp(xml, 'BytesScanned')?.text); + Stats.fromXml(XmlElement? xml) { + bytesProcessed = int.tryParse(getProp(xml, 'BytesProcessed')!.text); + bytesReturned = int.tryParse(getProp(xml, 'BytesReturned')!.text); + bytesScanned = int.tryParse(getProp(xml, 'BytesScanned')!.text); } XmlNode toXml() { @@ -3701,13 +3703,13 @@ class Stats { } /// The total number of uncompressed object bytes processed. - int bytesProcessed; + int? bytesProcessed; /// The total number of bytes of records payload data returned. - int bytesReturned; + int? bytesReturned; /// The total number of object bytes scanned. - int bytesScanned; + int? bytesScanned; } /// Container for the Stats Event. @@ -3716,20 +3718,20 @@ class StatsEvent { this.details, ); - StatsEvent.fromXml(XmlElement xml) { + StatsEvent.fromXml(XmlElement? xml) { details = Stats.fromXml(getProp(xml, 'Details')); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('StatsEvent', nest: () { - builder.element('Details', nest: details.toXml()); + builder.element('Details', nest: details!.toXml()); }); return builder.buildDocument(); } /// The Stats event details. - Stats details; + Stats? details; } /// Specifies data related to access patterns to be collected and made available to analyze the tradeoffs between different storage classes for an Amazon S3 bucket. @@ -3738,7 +3740,7 @@ class StorageClassAnalysis { this.dataExport, ); - StorageClassAnalysis.fromXml(XmlElement xml) { + StorageClassAnalysis.fromXml(XmlElement? xml) { dataExport = StorageClassAnalysisDataExport.fromXml(getProp(xml, 'DataExport')); } @@ -3746,13 +3748,13 @@ class StorageClassAnalysis { XmlNode toXml() { final builder = XmlBuilder(); builder.element('StorageClassAnalysis', nest: () { - builder.element('DataExport', nest: dataExport.toXml()); + builder.element('DataExport', nest: dataExport!.toXml()); }); return builder.buildDocument(); } /// Specifies how data related to the storage class analysis for an Amazon S3 bucket should be exported. - StorageClassAnalysisDataExport dataExport; + StorageClassAnalysisDataExport? dataExport; } /// Container for data related to the storage class analysis for an Amazon S3 bucket for export. @@ -3762,7 +3764,7 @@ class StorageClassAnalysisDataExport { this.outputSchemaVersion, ); - StorageClassAnalysisDataExport.fromXml(XmlElement xml) { + StorageClassAnalysisDataExport.fromXml(XmlElement? xml) { destination = AnalyticsExportDestination.fromXml(getProp(xml, 'Destination')); outputSchemaVersion = getProp(xml, 'OutputSchemaVersion')?.text; @@ -3771,17 +3773,17 @@ class StorageClassAnalysisDataExport { XmlNode toXml() { final builder = XmlBuilder(); builder.element('StorageClassAnalysisDataExport', nest: () { - builder.element('Destination', nest: destination.toXml()); + builder.element('Destination', nest: destination!.toXml()); builder.element('OutputSchemaVersion', nest: outputSchemaVersion); }); return builder.buildDocument(); } /// The place to store the data for an analysis. - AnalyticsExportDestination destination; + AnalyticsExportDestination? destination; /// The version of the output schema to use when exporting data. Must be V_1. - String outputSchemaVersion; + String? outputSchemaVersion; } /// A container of a key value name pair. @@ -3791,7 +3793,7 @@ class Tag { this.value, ); - Tag.fromXml(XmlElement xml) { + Tag.fromXml(XmlElement? xml) { key = getProp(xml, 'Key')?.text; value = getProp(xml, 'Value')?.text; } @@ -3806,10 +3808,10 @@ class Tag { } /// Name of the tag. - String key; + String? key; /// Value of the tag. - String value; + String? value; } /// Container for TagSet elements. @@ -3818,20 +3820,20 @@ class Tagging { this.tagSet, ); - Tagging.fromXml(XmlElement xml) { + Tagging.fromXml(XmlElement? xml) { tagSet = Tag.fromXml(getProp(xml, 'TagSet')); } XmlNode toXml() { final builder = XmlBuilder(); builder.element('Tagging', nest: () { - builder.element('TagSet', nest: tagSet.toXml()); + builder.element('TagSet', nest: tagSet!.toXml()); }); return builder.buildDocument(); } /// A collection for a set of tags - Tag tagSet; + Tag? tagSet; } /// Container for granting information. @@ -3841,7 +3843,7 @@ class TargetGrant { this.permission, ); - TargetGrant.fromXml(XmlElement xml) { + TargetGrant.fromXml(XmlElement? xml) { grantee = Grantee.fromXml(getProp(xml, 'Grantee')); permission = getProp(xml, 'Permission')?.text; } @@ -3849,17 +3851,17 @@ class TargetGrant { XmlNode toXml() { final builder = XmlBuilder(); builder.element('TargetGrant', nest: () { - builder.element('Grantee', nest: grantee.toXml()); + builder.element('Grantee', nest: grantee!.toXml()); builder.element('Permission', nest: permission); }); return builder.buildDocument(); } /// Container for the person being granted permissions. - Grantee grantee; + Grantee? grantee; /// Logging permissions assigned to the Grantee for the bucket. - String permission; + String? permission; } /// A container for specifying the configuration for publication of messages to an Amazon Simple Notification Service (Amazon SNS) topic when Amazon S3 detects specified events. @@ -3871,7 +3873,7 @@ class TopicConfiguration { this.topicArn, ); - TopicConfiguration.fromXml(XmlElement xml) { + TopicConfiguration.fromXml(XmlElement? xml) { events = getProp(xml, 'Events')?.text; filter = NotificationConfigurationFilter.fromXml(getProp(xml, 'Filter')); id = getProp(xml, 'Id')?.text; @@ -3882,7 +3884,7 @@ class TopicConfiguration { final builder = XmlBuilder(); builder.element('TopicConfiguration', nest: () { builder.element('Events', nest: events); - builder.element('Filter', nest: filter.toXml()); + builder.element('Filter', nest: filter!.toXml()); builder.element('Id', nest: id); builder.element('TopicArn', nest: topicArn); }); @@ -3890,16 +3892,16 @@ class TopicConfiguration { } /// The Amazon S3 bucket event about which to send notifications. For more information, see Supported Event Types in the Amazon Simple Storage Service Developer Guide. - String events; + String? events; /// Specifies object key name filtering rules. For information about key name filtering, see Configuring Event Notifications in the Amazon Simple Storage Service Developer Guide. - NotificationConfigurationFilter filter; + NotificationConfigurationFilter? filter; /// An optional unique identifier for configurations in a notification configuration. If you don't provide one, Amazon S3 will assign an ID. - String id; + String? id; /// The Amazon Resource Name (ARN) of the Amazon SNS topic to which Amazon S3 publishes a message when it detects events of the specified type. - String topicArn; + String? topicArn; } /// A container for specifying the configuration for publication of messages to an Amazon Simple Notification Service (Amazon SNS) topic when Amazon S3 detects specified events. This data type is deprecated. Use TopicConfiguration instead. @@ -3911,7 +3913,7 @@ class TopicConfigurationDeprecated { this.topic, ); - TopicConfigurationDeprecated.fromXml(XmlElement xml) { + TopicConfigurationDeprecated.fromXml(XmlElement? xml) { event = getProp(xml, 'Event')?.text; events = getProp(xml, 'Events')?.text; id = getProp(xml, 'Id')?.text; @@ -3930,16 +3932,16 @@ class TopicConfigurationDeprecated { } /// This member has been deprecated. - String event; + String? event; /// A collection of events related to objects - String events; + String? events; /// An optional unique identifier for configurations in a notification configuration. If you don't provide one, Amazon S3 will assign an ID. - String id; + String? id; /// Amazon SNS topic to which Amazon S3 will publish a message to report the specified events for the bucket. - String topic; + String? topic; } /// Specifies when an object transitions to a specified storage class. For more information about Amazon S3 lifecycle configuration rules, see Transitioning Objects Using Amazon S3 Lifecycle in the Amazon Simple Storage Service Developer Guide. @@ -3950,16 +3952,16 @@ class Transition { this.storageClass, ); - Transition.fromXml(XmlElement xml) { - date = DateTime.parse(getProp(xml, 'Date')?.text); - days = int.tryParse(getProp(xml, 'Days')?.text); + Transition.fromXml(XmlElement? xml) { + date = DateTime.parse(getProp(xml, 'Date')!.text); + days = int.tryParse(getProp(xml, 'Days')!.text); storageClass = getProp(xml, 'StorageClass')?.text; } XmlNode toXml() { final builder = XmlBuilder(); builder.element('Transition', nest: () { - builder.element('Date', nest: date.toIso8601String()); + builder.element('Date', nest: date!.toIso8601String()); builder.element('Days', nest: days.toString()); builder.element('StorageClass', nest: storageClass); }); @@ -3967,13 +3969,13 @@ class Transition { } /// Indicates when objects are transitioned to the specified storage class. The date value must be in ISO 8601 format. The time is always midnight UTC. - DateTime date; + DateTime? date; /// Indicates the number of days after creation when objects are transitioned to the specified storage class. The value must be a positive integer. - int days; + int? days; /// The storage class to which you want the object to transition. - String storageClass; + String? storageClass; } /// Describes the versioning state of an Amazon S3 bucket. For more information, see PUT Bucket versioning in the Amazon Simple Storage Service API Reference. @@ -3998,10 +4000,10 @@ class VersioningConfiguration { } /// Specifies whether MFA delete is enabled in the bucket versioning configuration. This element is only returned if the bucket has been configured with MFA delete. If the bucket has never been so configured, this element is not returned. - String mFADelete; + String? mFADelete; /// The versioning state of the bucket. - String status; + String? status; } /// Specifies website configuration parameters for an Amazon S3 bucket. @@ -4024,24 +4026,24 @@ class WebsiteConfiguration { XmlNode toXml() { final builder = XmlBuilder(); builder.element('WebsiteConfiguration', nest: () { - builder.element('ErrorDocument', nest: errorDocument.toXml()); - builder.element('IndexDocument', nest: indexDocument.toXml()); + builder.element('ErrorDocument', nest: errorDocument!.toXml()); + builder.element('IndexDocument', nest: indexDocument!.toXml()); builder.element('RedirectAllRequestsTo', - nest: redirectAllRequestsTo.toXml()); - builder.element('RoutingRules', nest: routingRules.toXml()); + nest: redirectAllRequestsTo!.toXml()); + builder.element('RoutingRules', nest: routingRules!.toXml()); }); return builder.buildDocument(); } /// The name of the error document for the website. - ErrorDocument errorDocument; + ErrorDocument? errorDocument; /// The name of the index document for the website. - IndexDocument indexDocument; + IndexDocument? indexDocument; /// The redirect behavior for every request to this bucket's website endpoint. - RedirectAllRequestsTo redirectAllRequestsTo; + RedirectAllRequestsTo? redirectAllRequestsTo; /// Rules that define when a redirect is applied and the redirect behavior. - RoutingRule routingRules; + RoutingRule? routingRules; } diff --git a/lib/src/minio_poller.dart b/lib/src/minio_poller.dart index 381967a..1801deb 100644 --- a/lib/src/minio_poller.dart +++ b/lib/src/minio_poller.dart @@ -14,9 +14,9 @@ class NotificationPoller { final MinioClient _client; final String bucket; - final String prefix; - final String suffix; - final List<String> events; + final String? prefix; + final String? suffix; + final List<String>? events; final _eventStream = StreamController<Map<String, dynamic>>.broadcast(); Stream<Map<String, dynamic>> get stream => _eventStream.stream; diff --git a/lib/src/minio_s3.dart b/lib/src/minio_s3.dart index c93f1e3..4cd9a07 100644 --- a/lib/src/minio_s3.dart +++ b/lib/src/minio_s3.dart @@ -17,7 +17,6 @@ const awsS3Endpoint = { // getS3Endpoint get relevant endpoint for the region. String getS3Endpoint(String region) { - assert(region != null); final endpoint = awsS3Endpoint[region]; return endpoint ?? 's3.amazonaws.com'; } diff --git a/lib/src/minio_sign.dart b/lib/src/minio_sign.dart index fee400c..a1fc9fe 100644 --- a/lib/src/minio_sign.dart +++ b/lib/src/minio_sign.dart @@ -17,7 +17,7 @@ String signV4( final signedHeaders = getSignedHeaders(request.headers.keys); final hashedPayload = request.headers['x-amz-content-sha256']; final canonicalRequest = - getCanonicalRequest(request, signedHeaders, hashedPayload); + getCanonicalRequest(request, signedHeaders, hashedPayload!); final stringToSign = getStringToSign(canonicalRequest, requestDate, region); final signingKey = getSigningKey(requestDate, region, minio.secretKey); final credential = getCredential(minio.accessKey, region, requestDate); @@ -54,7 +54,7 @@ String getCanonicalRequest( final requestQuery = queryKeys.map((key) { final value = request.url.queryParameters[key]; final hasValue = value != null; - final valuePart = hasValue ? Uri.encodeQueryComponent(value) : ''; + final valuePart = hasValue ? Uri.encodeQueryComponent(value!) : ''; return Uri.encodeQueryComponent(key) + '=' + valuePart; }).join('&'); @@ -84,7 +84,7 @@ String getStringToSign( } String getScope(String region, DateTime date) { - return '${makeDateShort(date)}/${region}/s3/aws4_request'; + return '${makeDateShort(date)}/$region/s3/aws4_request'; } List<int> getSigningKey(DateTime date, String region, String secretKey) { @@ -119,7 +119,7 @@ String presignSignatureV4( final signedHeaders = getSignedHeaders(request.headers.keys); final credential = getCredential(minio.accessKey, region, requestDate); - final requestQuery = <String, String>{}; + final requestQuery = <String, String?>{}; requestQuery['X-Amz-Algorithm'] = signV4Algorithm; requestQuery['X-Amz-Credential'] = credential; requestQuery['X-Amz-Date'] = iso8601Date; @@ -142,7 +142,7 @@ String presignSignatureV4( final stringToSign = getStringToSign(canonicalRequest, requestDate, region); final signingKey = getSigningKey(requestDate, region, minio.secretKey); final signature = sha256HmacHex(stringToSign, signingKey); - final presignedUrl = request.url.toString() + '&X-Amz-Signature=${signature}'; + final presignedUrl = request.url.toString() + '&X-Amz-Signature=$signature'; return presignedUrl; } diff --git a/lib/src/minio_uploader.dart b/lib/src/minio_uploader.dart index 3dd0ffa..66a1c42 100644 --- a/lib/src/minio_uploader.dart +++ b/lib/src/minio_uploader.dart @@ -27,15 +27,15 @@ class MinioUploader implements StreamConsumer<List<int>> { final Map<String, String> metadata; var partNumber = 1; - String etag; + String? etag; List<CompletedPart> parts = []; - Map<int, Part> oldParts; - String uploadId; + Map<int?, Part>? oldParts; + String? uploadId; @override Future addStream(Stream<List<int>> stream) async { await for (var chunk in stream) { - List<int> md5digest; + List<int>? md5digest; final headers = <String, String>{}; headers.addAll(metadata); headers['Content-Length'] = chunk.length.toString(); @@ -56,7 +56,7 @@ class MinioUploader implements StreamConsumer<List<int>> { final partNumber = this.partNumber++; if (oldParts != null) { - final oldPart = oldParts[partNumber]; + final oldPart = oldParts![partNumber]; if (oldPart != null) { md5digest ??= md5.convert(chunk).bytes; if (hex.encode(md5digest) == oldPart.eTag) { @@ -67,7 +67,7 @@ class MinioUploader implements StreamConsumer<List<int>> { } } - final queries = <String, String>{ + final queries = <String, String?>{ 'partNumber': '$partNumber', 'uploadId': uploadId, }; @@ -79,9 +79,9 @@ class MinioUploader implements StreamConsumer<List<int>> { } @override - Future<String> close() async { + Future<String?> close() async { if (uploadId == null) return etag; - return minio.completeMultipartUpload(bucket, object, uploadId, parts); + return minio.completeMultipartUpload(bucket, object, uploadId!, parts); } Map<String, String> getHeaders(List<int> chunk) { @@ -95,10 +95,10 @@ class MinioUploader implements StreamConsumer<List<int>> { return headers; } - Future<String> upload( + Future<String?> upload( List<int> chunk, Map<String, String> headers, - Map<String, String> queries, + Map<String, String?>? queries, ) async { final resp = await client.request( method: 'PUT', @@ -131,7 +131,7 @@ class MinioUploader implements StreamConsumer<List<int>> { return; } - final parts = await minio.listParts(bucket, object, uploadId); + final parts = minio.listParts(bucket, object, uploadId!); final entries = await parts .asyncMap((part) => MapEntry(part.partNumber, part)) .toList(); diff --git a/lib/src/utils.dart b/lib/src/utils.dart index b37b32f..8ae8e00 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -33,12 +33,12 @@ String jsonBase64(Map<String, dynamic> jsonObject) { return base64.encode(utf8.encode(json.encode(jsonObject))); } -XmlElement getNodeProp(XmlElement xml, String name) { +XmlElement? getNodeProp(XmlElement xml, String name) { final result = xml.findElements(name); return result.isNotEmpty ? result.first : null; } -String encodeQuery(String rawKey, String rawValue) { +String encodeQuery(String rawKey, String? rawValue) { final pair = [rawKey]; if (rawValue != null) { pair.add(Uri.encodeQueryComponent(rawValue)); diff --git a/pubspec.yaml b/pubspec.yaml index f51bbe1..2a18f87 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://github.com/xtyxtyx/minio-dart issue_tracker: https://github.com/xtyxtyx/minio-dart/issues environment: - sdk: ">=2.7.0 <3.0.0" + sdk: '>=2.12.0 <3.0.0' dependencies: meta: ^1.3.0 diff --git a/test/minio_dart_test.dart b/test/minio_dart_test.dart index 266b63f..cf442c0 100644 --- a/test/minio_dart_test.dart +++ b/test/minio_dart_test.dart @@ -53,6 +53,7 @@ void main() { tearDownAll(() async { final minio = _getClient(); + await minio.removeBucket(bucketName); }); test('bucketExists() returns true for an existing bucket', () async { @@ -97,8 +98,8 @@ void main() { group('fPutObject', () { final bucketName = DateTime.now().millisecondsSinceEpoch.toString(); - Directory tempDir; - File testFile; + late Directory tempDir; + late File testFile; final objectName = 'a.jpg'; setUpAll(() async { @@ -121,7 +122,7 @@ void main() { await minio.fPutObject(bucketName, objectName, testFile.path); final stat = await minio.statObject(bucketName, objectName); - expect(stat.metaData['content-type'], equals('image/jpeg')); + expect(stat.metaData!['content-type'], equals('image/jpeg')); }); test('fPutObject() adds user-defined object metadata w/ prefix', () async { @@ -137,7 +138,7 @@ void main() { final stat = await minio.statObject(bucketName, objectName); expect( - stat.metaData[userDefinedMetadataKey.substring(prefix.length)], + stat.metaData![userDefinedMetadataKey.substring(prefix.length)], equals(userDefinedMetadataValue), ); }); @@ -153,7 +154,7 @@ void main() { await minio.fPutObject(bucketName, objectName, testFile.path, metadata); final stat = await minio.statObject(bucketName, objectName); - expect(stat.metaData[userDefinedMetadataKey], + expect(stat.metaData![userDefinedMetadataKey], equals(userDefinedMetadataValue)); }); @@ -173,8 +174,8 @@ void main() { group( 'setObjectACL', () { - String bucketName; - Directory tempDir; + late String bucketName; + late Directory tempDir; File testFile; final objectName = 'a.jpg'; @@ -205,8 +206,8 @@ void main() { group( 'getObjectACL', () { - String bucketName; - Directory tempDir; + late String bucketName; + late Directory tempDir; File testFile; final objectName = 'a.jpg'; @@ -230,7 +231,7 @@ void main() { test('getObjectACL() fetch objects acl', () async { final minio = _getClient(); var acl = await minio.getObjectACL(bucketName, objectName); - expect(acl.grants.permission, equals(null)); + expect(acl.grants!.permission, equals(null)); }); }, ); diff --git a/util/generate_models.dart b/util/generate_models.dart index 4d8d303..2f426ad 100644 --- a/util/generate_models.dart +++ b/util/generate_models.dart @@ -32,7 +32,7 @@ Future<List<String>> getAllModelUrls() async { final document = parse(page.body); final urls = document.querySelectorAll('.listitem a'); return urls - .map<String>((a) => a.attributes['href'].substring(2)) + .map<String>((a) => a.attributes['href']!.substring(2)) .map((a) => '$baseUrl/$a') .toList(); } @@ -42,16 +42,16 @@ Future<String> getModel(String url) async { final page = await http.get(Uri.parse(url)); final document = parse(page.body); - final name = document.querySelector('h1').text; + final name = document.querySelector('h1')!.text; final description = document - .querySelector('#main-col-body p') + .querySelector('#main-col-body p')! .text .replaceAll(RegExp(r'\s+'), ' '); final fields = <FieldSpec>[]; for (var dt in document.querySelectorAll('dt')) { final name = dt.text.trim(); - final spec = parseField(name, dt.nextElementSibling); + final spec = parseField(name, dt.nextElementSibling!); fields.add(spec); } @@ -136,12 +136,12 @@ Future<String> getModel(String url) async { } class FieldSpec { - String name; - String dartName; - String source; - String description; - bool isRequired; - TypeSpec type; + String? name; + String? dartName; + String? source; + String? description; + bool? isRequired; + late TypeSpec type; @override String toString() { @@ -150,8 +150,8 @@ class FieldSpec { } class TypeSpec { - String name; - String dartName; + String? name; + String? dartName; bool isObject = false; bool isArray = false; @@ -168,7 +168,7 @@ String toCamelCase(String name) { FieldSpec parseField(String name, Element dd) { final source = dd.text; final description = - dd.querySelector('p').text.replaceAll(RegExp(r'\s+'), ' '); + dd.querySelector('p')!.text.replaceAll(RegExp(r'\s+'), ' '); final isRequired = dd.text.contains('Required: Yes'); final type = parseType(source); @@ -195,13 +195,13 @@ TypeSpec parseType(String source) { 'Boolean': 'bool', }; final pattern = RegExp(r'Type: (Array of |)(\w+)( data type|)'); - final match = pattern.firstMatch(source); + final match = pattern.firstMatch(source)!; - final isArray = match.group(1).trim().isNotEmpty; - final isObject = match.group(3).trim().isNotEmpty; + final isArray = match.group(1)!.trim().isNotEmpty; + final isObject = match.group(3)!.trim().isNotEmpty; final type = match.group(2); - final dartType = isObject ? type : typeMap[type]; + final dartType = isObject ? type : typeMap[type!]; final dartName = isArray ? 'List<$dartType>' : dartType; return TypeSpec() -- GitLab