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

package tangled

// schema: sh.tangled.git.listRefs

import (
	"context"

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

const (
	GitListRefsNSID = "sh.tangled.git.listRefs"
)

// GitListRefs_DefaultBranch is a "defaultBranch" in the sh.tangled.git.listRefs schema.
type GitListRefs_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 that HEAD points at, eg. refs/heads/main.
	Ref string `json:"ref" cborgen:"ref"`
}

// GitListRefs_Output is the output of a sh.tangled.git.listRefs call.
type GitListRefs_Output struct {
	// cursor: Cursor for the next page, absent when the last page is reached
	Cursor        *string                    `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	DefaultBranch *GitListRefs_DefaultBranch `json:"defaultBranch,omitempty" cborgen:"defaultBranch,omitempty"`
	Refs          []*GitListRefs_Ref         `json:"refs" cborgen:"refs"`
}

// GitListRefs_Ref is a "ref" in the sh.tangled.git.listRefs schema.
type GitListRefs_Ref struct {
	// ref: Full ref name, eg. refs/heads/main or refs/tags/v1.0
	Ref string `json:"ref" cborgen:"ref"`
	// sha: Object SHA the ref points at. Width depends on the repo's git object-format.
	Sha string `json:"sha" cborgen:"sha"`
}

// GitListRefs calls the XRPC method "sh.tangled.git.listRefs".
//
// cursor: Pagination cursor
// limit: Maximum number of refs to return in this page
// repo: DID of the git repo as minted by the knot
func GitListRefs(ctx context.Context, c util.LexClient, cursor string, limit int64, repo string) (*GitListRefs_Output, error) {
	var out GitListRefs_Output

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

	return &out, nil
}
