1// Copied from indigo:api/atproto/repocreateRecords.go
2
3package agnostic
4
5// schema: com.atproto.repo.createRecord
6
7import (
8 "context"
9
10 "github.com/bluesky-social/indigo/lex/util"
11)
12
13// RepoDefs_CommitMeta is a "commitMeta" in the com.atproto.repo.defs schema.
14type RepoDefs_CommitMeta struct {
15 Cid string `json:"cid" cborgen:"cid"`
16 Rev string `json:"rev" cborgen:"rev"`
17}
18
19// RepoCreateRecord_Input is the input argument to a com.atproto.repo.createRecord call.
20type RepoCreateRecord_Input struct {
21 // collection: The NSID of the record collection.
22 Collection string `json:"collection" cborgen:"collection"`
23 // record: The record itself. Must contain a $type field.
24 Record map[string]any `json:"record" cborgen:"record"`
25 // repo: The handle or DID of the repo (aka, current account).
26 Repo string `json:"repo" cborgen:"repo"`
27 // rkey: The Record Key.
28 Rkey *string `json:"rkey,omitempty" cborgen:"rkey,omitempty"`
29 // swapCommit: Compare and swap with the previous commit by CID.
30 SwapCommit *string `json:"swapCommit,omitempty" cborgen:"swapCommit,omitempty"`
31 // 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.
32 Validate *bool `json:"validate,omitempty" cborgen:"validate,omitempty"`
33}
34
35// RepoCreateRecord_Output is the output of a com.atproto.repo.createRecord call.
36type RepoCreateRecord_Output struct {
37 Cid string `json:"cid" cborgen:"cid"`
38 Commit *RepoDefs_CommitMeta `json:"commit,omitempty" cborgen:"commit,omitempty"`
39 Uri string `json:"uri" cborgen:"uri"`
40 ValidationStatus *string `json:"validationStatus,omitempty" cborgen:"validationStatus,omitempty"`
41}
42
43// RepoCreateRecord calls the XRPC method "com.atproto.repo.createRecord".
44func RepoCreateRecord(ctx context.Context, c util.LexClient, input *RepoCreateRecord_Input) (*RepoCreateRecord_Output, error) {
45 var out RepoCreateRecord_Output
46 if err := c.LexDo(ctx, util.Procedure, "application/json", "com.atproto.repo.createRecord", nil, input, &out); err != nil {
47 return nil, err
48 }
49
50 return &out, nil
51}