All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.atproto.repo.createRecord.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("DEPRECATION")

package com.atproto.repo

import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.AtIdentifier
import sh.christian.ozone.api.AtUri
import sh.christian.ozone.api.Cid
import sh.christian.ozone.api.Nsid
import sh.christian.ozone.api.model.JsonContent

/**
 * @param repo The handle or DID of the repo (aka, current account).
 * @param collection The NSID of the record collection.
 * @param rkey The Record Key.
 * @param validate Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to
 * require it, or leave unset to validate only for known Lexicons.
 * @param record The record itself. Must contain a $type field.
 * @param swapCommit Compare and swap with the previous commit by CID.
 */
@Serializable
public data class CreateRecordRequest(
  /**
   * The handle or DID of the repo (aka, current account).
   */
  public val repo: AtIdentifier,
  /**
   * The NSID of the record collection.
   */
  public val collection: Nsid,
  /**
   * The Record Key.
   */
  public val rkey: String? = null,
  /**
   * Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it,
   * or leave unset to validate only for known Lexicons.
   */
  public val validate: Boolean? = null,
  /**
   * The record itself. Must contain a $type field.
   */
  public val record: JsonContent,
  /**
   * Compare and swap with the previous commit by CID.
   */
  public val swapCommit: Cid? = null,
) {
  init {
    require(rkey == null || rkey.count() <= 512) {
      "rkey.count() must be <= 512, but was ${rkey?.count()}"
    }
  }
}

@Serializable
public data class CreateRecordResponse(
  public val uri: AtUri,
  public val cid: Cid,
  public val commit: CommitMeta? = null,
  public val validationStatus: CreateRecordValidationStatus? = null,
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy