// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
package org_tangled
// schema: org.tangled.repo.createRepo
import (
"context"
"encoding/json"
"fmt"
"github.com/bluesky-social/indigo/lex/util"
)
const (
RepoCreateRepoNSID = "org.tangled.repo.createRepo"
)
// RepoCreateRepo_Input is the input argument to a org.tangled.repo.createRepo call.
type RepoCreateRepo_Input struct {
CreatedAt *string `json:"createdAt,omitempty" cborgen:"createdAt,omitempty"`
// defaultBranch: Default branch of the repository.
DefaultBranch *string `json:"defaultBranch,omitempty" cborgen:"defaultBranch,omitempty"`
Description *string `json:"description,omitempty" cborgen:"description,omitempty"`
// did: Optional user-provided DID to use as the repo identity instead of minting one.
Did *string `json:"did,omitempty" cborgen:"did,omitempty"`
// name: Name of the repository.
Name string `json:"name" cborgen:"name"`
// source: A source to clone from, populate this when forking or importing a repository.
Source *RepoCreateRepo_Input_Source `json:"source,omitempty" cborgen:"source,omitempty"`
Spindle *string `json:"spindle,omitempty" cborgen:"spindle,omitempty"`
// topics: Topics related to the repo
Topics []string `json:"topics,omitempty" cborgen:"topics,omitempty"`
// website: Any URI related to the repo
Website *string `json:"website,omitempty" cborgen:"website,omitempty"`
}
// A source to clone from, populate this when forking or importing a repository.
type RepoCreateRepo_Input_Source struct {
RepoDefs_SourceTangled *RepoDefs_SourceTangled
RepoDefs_SourceExternal *RepoDefs_SourceExternal
}
func (t *RepoCreateRepo_Input_Source) MarshalJSON() ([]byte, error) {
if t.RepoDefs_SourceTangled != nil {
t.RepoDefs_SourceTangled.LexiconTypeID = "org.tangled.repo.defs#sourceTangled"
return json.Marshal(t.RepoDefs_SourceTangled)
}
if t.RepoDefs_SourceExternal != nil {
t.RepoDefs_SourceExternal.LexiconTypeID = "org.tangled.repo.defs#sourceExternal"
return json.Marshal(t.RepoDefs_SourceExternal)
}
return nil, fmt.Errorf("cannot marshal empty enum")
}
func (t *RepoCreateRepo_Input_Source) UnmarshalJSON(b []byte) error {
typ, err := util.TypeExtract(b)
if err != nil {
return err
}
switch typ {
case "org.tangled.repo.defs#sourceTangled":
t.RepoDefs_SourceTangled = new(RepoDefs_SourceTangled)
return json.Unmarshal(b, t.RepoDefs_SourceTangled)
case "org.tangled.repo.defs#sourceExternal":
t.RepoDefs_SourceExternal = new(RepoDefs_SourceExternal)
return json.Unmarshal(b, t.RepoDefs_SourceExternal)
default:
return nil
}
}
// RepoCreateRepo_Output is the output of a org.tangled.repo.createRepo call.
type RepoCreateRepo_Output struct {
Did *string `json:"did,omitempty" cborgen:"did,omitempty"`
// key: Multibase-encoded public signing key the knot holds for this repository
Key *string `json:"key,omitempty" cborgen:"key,omitempty"`
}
// RepoCreateRepo calls the XRPC method "org.tangled.repo.createRepo".
func RepoCreateRepo(ctx context.Context, c util.LexClient, input *RepoCreateRepo_Input) (*RepoCreateRepo_Output, error) {
var out RepoCreateRepo_Output
if err := c.LexDo(ctx, util.Procedure, "application/json", "org.tangled.repo.createRepo", nil, input, &out); err != nil {
return nil, err
}
return &out, nil
}