this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add agnostic version of repo applyWrites

+189
+189
api/agnostic/repoapplyWrites.go
··· 1 + // Copied from indigo:api/atproto/repoapplyWrites.go 2 + 3 + package agnostic 4 + 5 + // schema: com.atproto.repo.applyWrites 6 + 7 + import ( 8 + "context" 9 + "encoding/json" 10 + "fmt" 11 + 12 + "github.com/bluesky-social/indigo/lex/util" 13 + "github.com/bluesky-social/indigo/xrpc" 14 + ) 15 + 16 + // RepoApplyWrites_Create is a "create" in the com.atproto.repo.applyWrites schema. 17 + // 18 + // Operation which creates a new record. 19 + // 20 + // RECORDTYPE: RepoApplyWrites_Create 21 + type RepoApplyWrites_Create struct { 22 + LexiconTypeID string `json:"$type,const=com.atproto.repo.applyWrites#create" cborgen:"$type,const=com.atproto.repo.applyWrites#create"` 23 + Collection string `json:"collection" cborgen:"collection"` 24 + Rkey *string `json:"rkey,omitempty" cborgen:"rkey,omitempty"` 25 + Value *json.RawMessage `json:"value" cborgen:"value"` 26 + } 27 + 28 + // RepoApplyWrites_CreateResult is a "createResult" in the com.atproto.repo.applyWrites schema. 29 + // 30 + // RECORDTYPE: RepoApplyWrites_CreateResult 31 + type RepoApplyWrites_CreateResult struct { 32 + LexiconTypeID string `json:"$type,const=com.atproto.repo.applyWrites#createResult" cborgen:"$type,const=com.atproto.repo.applyWrites#createResult"` 33 + Cid string `json:"cid" cborgen:"cid"` 34 + Uri string `json:"uri" cborgen:"uri"` 35 + ValidationStatus *string `json:"validationStatus,omitempty" cborgen:"validationStatus,omitempty"` 36 + } 37 + 38 + // RepoApplyWrites_Delete is a "delete" in the com.atproto.repo.applyWrites schema. 39 + // 40 + // Operation which deletes an existing record. 41 + // 42 + // RECORDTYPE: RepoApplyWrites_Delete 43 + type RepoApplyWrites_Delete struct { 44 + LexiconTypeID string `json:"$type,const=com.atproto.repo.applyWrites#delete" cborgen:"$type,const=com.atproto.repo.applyWrites#delete"` 45 + Collection string `json:"collection" cborgen:"collection"` 46 + Rkey string `json:"rkey" cborgen:"rkey"` 47 + } 48 + 49 + // RepoApplyWrites_DeleteResult is a "deleteResult" in the com.atproto.repo.applyWrites schema. 50 + // 51 + // RECORDTYPE: RepoApplyWrites_DeleteResult 52 + type RepoApplyWrites_DeleteResult struct { 53 + LexiconTypeID string `json:"$type,const=com.atproto.repo.applyWrites#deleteResult" cborgen:"$type,const=com.atproto.repo.applyWrites#deleteResult"` 54 + } 55 + 56 + // RepoApplyWrites_Input is the input argument to a com.atproto.repo.applyWrites call. 57 + type RepoApplyWrites_Input struct { 58 + // repo: The handle or DID of the repo (aka, current account). 59 + Repo string `json:"repo" cborgen:"repo"` 60 + // swapCommit: If provided, the entire operation will fail if the current repo commit CID does not match this value. Used to prevent conflicting repo mutations. 61 + SwapCommit *string `json:"swapCommit,omitempty" cborgen:"swapCommit,omitempty"` 62 + // validate: Can be set to 'false' to skip Lexicon schema validation of record data across all operations, 'true' to require it, or leave unset to validate only for known Lexicons. 63 + Validate *bool `json:"validate,omitempty" cborgen:"validate,omitempty"` 64 + Writes []*RepoApplyWrites_Input_Writes_Elem `json:"writes" cborgen:"writes"` 65 + } 66 + 67 + type RepoApplyWrites_Input_Writes_Elem struct { 68 + RepoApplyWrites_Create *RepoApplyWrites_Create 69 + RepoApplyWrites_Update *RepoApplyWrites_Update 70 + RepoApplyWrites_Delete *RepoApplyWrites_Delete 71 + } 72 + 73 + func (t *RepoApplyWrites_Input_Writes_Elem) MarshalJSON() ([]byte, error) { 74 + if t.RepoApplyWrites_Create != nil { 75 + t.RepoApplyWrites_Create.LexiconTypeID = "com.atproto.repo.applyWrites#create" 76 + return json.Marshal(t.RepoApplyWrites_Create) 77 + } 78 + if t.RepoApplyWrites_Update != nil { 79 + t.RepoApplyWrites_Update.LexiconTypeID = "com.atproto.repo.applyWrites#update" 80 + return json.Marshal(t.RepoApplyWrites_Update) 81 + } 82 + if t.RepoApplyWrites_Delete != nil { 83 + t.RepoApplyWrites_Delete.LexiconTypeID = "com.atproto.repo.applyWrites#delete" 84 + return json.Marshal(t.RepoApplyWrites_Delete) 85 + } 86 + return nil, fmt.Errorf("cannot marshal empty enum") 87 + } 88 + func (t *RepoApplyWrites_Input_Writes_Elem) UnmarshalJSON(b []byte) error { 89 + typ, err := util.TypeExtract(b) 90 + if err != nil { 91 + return err 92 + } 93 + 94 + switch typ { 95 + case "com.atproto.repo.applyWrites#create": 96 + t.RepoApplyWrites_Create = new(RepoApplyWrites_Create) 97 + return json.Unmarshal(b, t.RepoApplyWrites_Create) 98 + case "com.atproto.repo.applyWrites#update": 99 + t.RepoApplyWrites_Update = new(RepoApplyWrites_Update) 100 + return json.Unmarshal(b, t.RepoApplyWrites_Update) 101 + case "com.atproto.repo.applyWrites#delete": 102 + t.RepoApplyWrites_Delete = new(RepoApplyWrites_Delete) 103 + return json.Unmarshal(b, t.RepoApplyWrites_Delete) 104 + 105 + default: 106 + return fmt.Errorf("closed enums must have a matching value") 107 + } 108 + } 109 + 110 + // RepoApplyWrites_Output is the output of a com.atproto.repo.applyWrites call. 111 + type RepoApplyWrites_Output struct { 112 + Commit *RepoDefs_CommitMeta `json:"commit,omitempty" cborgen:"commit,omitempty"` 113 + Results []*RepoApplyWrites_Output_Results_Elem `json:"results,omitempty" cborgen:"results,omitempty"` 114 + } 115 + 116 + type RepoApplyWrites_Output_Results_Elem struct { 117 + RepoApplyWrites_CreateResult *RepoApplyWrites_CreateResult 118 + RepoApplyWrites_UpdateResult *RepoApplyWrites_UpdateResult 119 + RepoApplyWrites_DeleteResult *RepoApplyWrites_DeleteResult 120 + } 121 + 122 + func (t *RepoApplyWrites_Output_Results_Elem) MarshalJSON() ([]byte, error) { 123 + if t.RepoApplyWrites_CreateResult != nil { 124 + t.RepoApplyWrites_CreateResult.LexiconTypeID = "com.atproto.repo.applyWrites#createResult" 125 + return json.Marshal(t.RepoApplyWrites_CreateResult) 126 + } 127 + if t.RepoApplyWrites_UpdateResult != nil { 128 + t.RepoApplyWrites_UpdateResult.LexiconTypeID = "com.atproto.repo.applyWrites#updateResult" 129 + return json.Marshal(t.RepoApplyWrites_UpdateResult) 130 + } 131 + if t.RepoApplyWrites_DeleteResult != nil { 132 + t.RepoApplyWrites_DeleteResult.LexiconTypeID = "com.atproto.repo.applyWrites#deleteResult" 133 + return json.Marshal(t.RepoApplyWrites_DeleteResult) 134 + } 135 + return nil, fmt.Errorf("cannot marshal empty enum") 136 + } 137 + func (t *RepoApplyWrites_Output_Results_Elem) UnmarshalJSON(b []byte) error { 138 + typ, err := util.TypeExtract(b) 139 + if err != nil { 140 + return err 141 + } 142 + 143 + switch typ { 144 + case "com.atproto.repo.applyWrites#createResult": 145 + t.RepoApplyWrites_CreateResult = new(RepoApplyWrites_CreateResult) 146 + return json.Unmarshal(b, t.RepoApplyWrites_CreateResult) 147 + case "com.atproto.repo.applyWrites#updateResult": 148 + t.RepoApplyWrites_UpdateResult = new(RepoApplyWrites_UpdateResult) 149 + return json.Unmarshal(b, t.RepoApplyWrites_UpdateResult) 150 + case "com.atproto.repo.applyWrites#deleteResult": 151 + t.RepoApplyWrites_DeleteResult = new(RepoApplyWrites_DeleteResult) 152 + return json.Unmarshal(b, t.RepoApplyWrites_DeleteResult) 153 + 154 + default: 155 + return fmt.Errorf("closed enums must have a matching value") 156 + } 157 + } 158 + 159 + // RepoApplyWrites_Update is a "update" in the com.atproto.repo.applyWrites schema. 160 + // 161 + // Operation which updates an existing record. 162 + // 163 + // RECORDTYPE: RepoApplyWrites_Update 164 + type RepoApplyWrites_Update struct { 165 + LexiconTypeID string `json:"$type,const=com.atproto.repo.applyWrites#update" cborgen:"$type,const=com.atproto.repo.applyWrites#update"` 166 + Collection string `json:"collection" cborgen:"collection"` 167 + Rkey string `json:"rkey" cborgen:"rkey"` 168 + Value *json.RawMessage `json:"value" cborgen:"value"` 169 + } 170 + 171 + // RepoApplyWrites_UpdateResult is a "updateResult" in the com.atproto.repo.applyWrites schema. 172 + // 173 + // RECORDTYPE: RepoApplyWrites_UpdateResult 174 + type RepoApplyWrites_UpdateResult struct { 175 + LexiconTypeID string `json:"$type,const=com.atproto.repo.applyWrites#updateResult" cborgen:"$type,const=com.atproto.repo.applyWrites#updateResult"` 176 + Cid string `json:"cid" cborgen:"cid"` 177 + Uri string `json:"uri" cborgen:"uri"` 178 + ValidationStatus *string `json:"validationStatus,omitempty" cborgen:"validationStatus,omitempty"` 179 + } 180 + 181 + // RepoApplyWrites calls the XRPC method "com.atproto.repo.applyWrites". 182 + func RepoApplyWrites(ctx context.Context, c *xrpc.Client, input *RepoApplyWrites_Input) (*RepoApplyWrites_Output, error) { 183 + var out RepoApplyWrites_Output 184 + if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.repo.applyWrites", nil, input, &out); err != nil { 185 + return nil, err 186 + } 187 + 188 + return &out, nil 189 + }