~james/core

core/api/org_tangled/repocreateRepo.go -rw-r--r-- 3.3 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 14 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// 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
}