// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.

package tangled

// schema: sh.tangled.sync.listRepos

import (
	"context"

	"github.com/bluesky-social/indigo/lex/util"
)

const (
	SyncListReposNSID = "sh.tangled.sync.listRepos"
)

// SyncListRepos_DefaultBranch is a "defaultBranch" in the sh.tangled.sync.listRepos schema.
type SyncListRepos_DefaultBranch struct {
	// head: Commit SHA at the tip of the default branch, for reconciling against a last-known state. Width depends on the repo's git object-format.
	Head *string `json:"head,omitempty" cborgen:"head,omitempty"`
	// ref: Default branch ref name, eg. refs/heads/main.
	Ref string `json:"ref" cborgen:"ref"`
}

// SyncListRepos_Output is the output of a sh.tangled.sync.listRepos call.
type SyncListRepos_Output struct {
	Cursor *string               `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Repos  []*SyncListRepos_Repo `json:"repos" cborgen:"repos"`
}

// SyncListRepos_Repo is a "repo" in the sh.tangled.sync.listRepos schema.
type SyncListRepos_Repo struct {
	DefaultBranch *SyncListRepos_DefaultBranch `json:"defaultBranch,omitempty" cborgen:"defaultBranch,omitempty"`
	// repo: DID of the git repo as minted by the knot
	Repo string `json:"repo" cborgen:"repo"`
	// status: Serving status of the repo according to the knot.
	Status string `json:"status" cborgen:"status"`
}

// SyncListRepos calls the XRPC method "sh.tangled.sync.listRepos".
//
// cursor: Pagination cursor
// order: Sort direction over the service's repo listing order.
func SyncListRepos(ctx context.Context, c util.LexClient, cursor string, limit int64, order string) (*SyncListRepos_Output, error) {
	var out SyncListRepos_Output

	params := map[string]interface{}{}
	if cursor != "" {
		params["cursor"] = cursor
	}
	if limit != 0 {
		params["limit"] = limit
	}
	if order != "" {
		params["order"] = order
	}
	if err := c.LexDo(ctx, util.Query, "", "sh.tangled.sync.listRepos", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
