Create a new metadata. The metadata will be henceforth identified by account/container/filepath which must be unique or this function will throw an exception. This function will also create a new version of the metadata in the versions collection. Parameters ---------- met
(metadata: Metadata)
| 89 | |
| 90 | |
| 91 | async def create(metadata: Metadata): |
| 92 | """ |
| 93 | Create a new metadata. The metadata will be henceforth identified by account/container/filepath which |
| 94 | must be unique or this function will throw an exception. |
| 95 | |
| 96 | This function will also create a new version of the metadata in the versions collection. |
| 97 | |
| 98 | Parameters |
| 99 | ---------- |
| 100 | metadata : Metadata |
| 101 | The metadata to create. |
| 102 | |
| 103 | Returns |
| 104 | ------- |
| 105 | None |
| 106 | """ |
| 107 | if metadata.globalMetadata.traceability_origin is None: |
| 108 | raise Exception("Metadata must have origin") |
| 109 | |
| 110 | if await exists( |
| 111 | metadata.globalMetadata.traceability_origin.account, |
| 112 | metadata.globalMetadata.traceability_origin.container, |
| 113 | metadata.globalMetadata.traceability_origin.file_path, |
| 114 | ): |
| 115 | raise Exception("Metadata Already Exists") |
| 116 | |
| 117 | metadata_collection: AgnosticCollection = collection() |
| 118 | versions: AgnosticCollection = versions_collection() |
| 119 | |
| 120 | await metadata_collection.insert_one( |
| 121 | metadata.dict(by_alias=True, exclude_unset=True) |
| 122 | ) |
| 123 | await versions.insert_one(metadata.dict(by_alias=True, exclude_unset=True)) |
| 124 | |
| 125 | |
| 126 | class InvalidGeolocationFormat(Exception): |
nothing calls this directly
no test coverage detected