Skip to content
Snippets Groups Projects
minio_models_generated.dart 136.92 KiB
import 'package:xml/xml.dart';

XmlElement? getProp(XmlElement? xml, String name) {
  if (xml == null) return null;
  final result = xml.findElements(name);
  return result.isNotEmpty ? result.first : null;
}

/// 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.
class AbortIncompleteMultipartUpload {
  AbortIncompleteMultipartUpload(
    this.daysAfterInitiation,
  );

  AbortIncompleteMultipartUpload.fromXml(XmlElement? xml) {
    daysAfterInitiation =
        int.tryParse(getProp(xml, 'DaysAfterInitiation')!.text);
  }

  XmlNode toXml() {
    final builder = XmlBuilder();
    builder.element('AbortIncompleteMultipartUpload', nest: () {
      builder.element('DaysAfterInitiation',
          nest: daysAfterInitiation.toString());
    });
    return builder.buildDocument();
  }

  /// Specifies the number of days after which Amazon S3 aborts an incomplete multipart upload.
  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.
class AccelerateConfiguration {
  AccelerateConfiguration(
    this.status,
  );

  AccelerateConfiguration.fromXml(XmlElement xml) {
    status = getProp(xml, 'Status')?.text;
  }

  XmlNode toXml() {
    final builder = XmlBuilder();
    builder.element('AccelerateConfiguration', nest: () {
      builder.element('Status', nest: status);
    });
    return builder.buildDocument();
  }

  /// Specifies the transfer acceleration status of the bucket.
  String? status;
}

/// Contains the elements that set the ACL permissions for an object per grantee.
class AccessControlPolicy {
  AccessControlPolicy(
    this.grants,
    this.owner,
  );

  AccessControlPolicy.fromXml(XmlElement? xml) {
    grants = Grant.fromXml(getProp(xml, 'Grants'));
    owner = Owner.fromXml(getProp(xml, 'Owner'));
  }

  XmlNode toXml() {
    final builder = XmlBuilder();
    builder.element('AccessControlPolicy', nest: () {
      builder.element('Grants', nest: grants!.toXml());