// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // NOTE: This file is generated and may not follow lint rules defined in your app // Generated files can be excluded from analysis in analysis_options.yaml // For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis // ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'package:amplify_core/amplify_core.dart'; import 'package:meta/meta.dart'; /// This is an auto generated class representing the PostWithAuthRules type in your schema. @immutable class PostWithAuthRules extends Model { static const classType = _PostWithAuthRulesModelType(); final String id; final String? _title; final String? _owner; final TemporalDateTime? _createdAt; final TemporalDateTime? _updatedAt; @override getInstanceType() => classType; @Deprecated( '[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.') @override String getId() => id; PostWithAuthRulesModelIdentifier get modelIdentifier { return PostWithAuthRulesModelIdentifier(id: id); } String get title { try { return _title!; } catch (e) { throw AmplifyCodeGenModelException( AmplifyExceptionMessages .codeGenRequiredFieldForceCastExceptionMessage, recoverySuggestion: AmplifyExceptionMessages .codeGenRequiredFieldForceCastRecoverySuggestion, underlyingException: e.toString()); } } String? get owner { return _owner; } TemporalDateTime? get createdAt { return _createdAt; } TemporalDateTime? get updatedAt { return _updatedAt; } const PostWithAuthRules._internal( {required this.id, required title, owner, createdAt, updatedAt}) : _title = title, _owner = owner, _createdAt = createdAt, _updatedAt = updatedAt; factory PostWithAuthRules( {String? id, required String title, String? owner}) { return PostWithAuthRules._internal( id: id == null ? UUID.getUUID() : id, title: title, owner: owner); } bool equals(Object other) { return this == other; } @override bool operator ==(Object other) { if (identical(other, this)) return true; return other is PostWithAuthRules && id == other.id && _title == other._title && _owner == other._owner; } @override int get hashCode => toString().hashCode; @override String toString() { var buffer = StringBuffer(); buffer.write("PostWithAuthRules {"); buffer.write("id=" + "$id" + ", "); buffer.write("title=" + "$_title" + ", "); buffer.write("owner=" + "$_owner" + ", "); buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", "); buffer.write( "updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null")); buffer.write("}"); return buffer.toString(); } PostWithAuthRules copyWith({String? title, String? owner}) { return PostWithAuthRules._internal( id: id, title: title ?? this.title, owner: owner ?? this.owner); } PostWithAuthRules.fromJson(Map json) : id = json['id'], _title = json['title'], _owner = json['owner'], _createdAt = json['createdAt'] != null ? TemporalDateTime.fromString(json['createdAt']) : null, _updatedAt = json['updatedAt'] != null ? TemporalDateTime.fromString(json['updatedAt']) : null; Map toJson() => { 'id': id, 'title': _title, 'owner': _owner, 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format() }; Map toMap() => { 'id': id, 'title': _title, 'owner': _owner, 'createdAt': _createdAt, 'updatedAt': _updatedAt }; static final QueryModelIdentifier MODEL_IDENTIFIER = QueryModelIdentifier(); static final QueryField ID = QueryField(fieldName: "id"); static final QueryField TITLE = QueryField(fieldName: "title"); static final QueryField OWNER = QueryField(fieldName: "owner"); static var schema = Model.defineSchema(define: (ModelSchemaDefinition modelSchemaDefinition) { modelSchemaDefinition.name = "PostWithAuthRules"; modelSchemaDefinition.pluralName = "PostWithAuthRules"; modelSchemaDefinition.authRules = [ AuthRule( authStrategy: AuthStrategy.OWNER, ownerField: "owner", identityClaim: "cognito:username", provider: AuthRuleProvider.USERPOOLS, operations: [ ModelOperation.CREATE, ModelOperation.UPDATE, ModelOperation.DELETE, ModelOperation.READ ]) ]; modelSchemaDefinition.addField(ModelFieldDefinition.id()); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: PostWithAuthRules.TITLE, isRequired: true, ofType: ModelFieldType(ModelFieldTypeEnum.string))); modelSchemaDefinition.addField(ModelFieldDefinition.field( key: PostWithAuthRules.OWNER, isRequired: false, ofType: ModelFieldType(ModelFieldTypeEnum.string))); modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( fieldName: 'createdAt', isRequired: false, isReadOnly: true, ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); modelSchemaDefinition.addField(ModelFieldDefinition.nonQueryField( fieldName: 'updatedAt', isRequired: false, isReadOnly: true, ofType: ModelFieldType(ModelFieldTypeEnum.dateTime))); }); } class _PostWithAuthRulesModelType extends ModelType { const _PostWithAuthRulesModelType(); @override PostWithAuthRules fromJson(Map jsonData) { return PostWithAuthRules.fromJson(jsonData); } @override String modelName() { return 'PostWithAuthRules'; } } /// This is an auto generated class representing the model identifier /// of [PostWithAuthRules] in your schema. @immutable class PostWithAuthRulesModelIdentifier implements ModelIdentifier { final String id; /// Create an instance of PostWithAuthRulesModelIdentifier using [id] the primary key. const PostWithAuthRulesModelIdentifier({required this.id}); @override Map serializeAsMap() => ({'id': id}); @override List> serializeAsList() => serializeAsMap() .entries .map((entry) => ({entry.key: entry.value})) .toList(); @override String serializeAsString() => serializeAsMap().values.join('#'); @override String toString() => 'PostWithAuthRulesModelIdentifier(id: $id)'; @override bool operator ==(Object other) { if (identical(this, other)) { return true; } return other is PostWithAuthRulesModelIdentifier && id == other.id; } @override int get hashCode => id.hashCode; }