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

package tangled

// schema: sh.tangled.git.temp.getTree

import (
	"context"

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

const (
	GitTempGetTreeNSID = "sh.tangled.git.temp.getTree"
)

// GitTempGetTree_LastCommit is a "lastCommit" in the sh.tangled.git.temp.getTree schema.
type GitTempGetTree_LastCommit struct {
	Author *GitTempGetTree_Signature `json:"author,omitempty" cborgen:"author,omitempty"`
	// hash: Commit hash
	Hash string `json:"hash" cborgen:"hash"`
	// message: Commit message
	Message string `json:"message" cborgen:"message"`
	// when: Commit timestamp
	When string `json:"when" cborgen:"when"`
}

// GitTempGetTree_Output is the output of a sh.tangled.git.temp.getTree call.
type GitTempGetTree_Output struct {
	// dotdot: Parent directory path
	Dotdot     *string                     `json:"dotdot,omitempty" cborgen:"dotdot,omitempty"`
	Files      []*GitTempGetTree_TreeEntry `json:"files" cborgen:"files"`
	LastCommit *GitTempGetTree_LastCommit  `json:"lastCommit,omitempty" cborgen:"lastCommit,omitempty"`
	// parent: The parent path in the tree
	Parent *string `json:"parent,omitempty" cborgen:"parent,omitempty"`
	// readme: Readme for this file tree
	Readme *GitTempGetTree_Readme `json:"readme,omitempty" cborgen:"readme,omitempty"`
	// ref: The git reference used
	Ref string `json:"ref" cborgen:"ref"`
}

// GitTempGetTree_Readme is a "readme" in the sh.tangled.git.temp.getTree schema.
type GitTempGetTree_Readme struct {
	// contents: Contents of the readme file
	Contents string `json:"contents" cborgen:"contents"`
	// filename: Name of the readme file
	Filename string `json:"filename" cborgen:"filename"`
}

// GitTempGetTree_Signature is a "signature" in the sh.tangled.git.temp.getTree schema.
type GitTempGetTree_Signature struct {
	// email: Author email
	Email string `json:"email" cborgen:"email"`
	// name: Author name
	Name string `json:"name" cborgen:"name"`
	// when: Author timestamp
	When string `json:"when" cborgen:"when"`
}

// GitTempGetTree_TreeEntry is a "treeEntry" in the sh.tangled.git.temp.getTree schema.
type GitTempGetTree_TreeEntry struct {
	Last_commit *GitTempGetTree_LastCommit `json:"last_commit,omitempty" cborgen:"last_commit,omitempty"`
	// mode: File mode
	Mode string `json:"mode" cborgen:"mode"`
	// name: Relative file or directory name
	Name string `json:"name" cborgen:"name"`
	// size: File size in bytes
	Size int64 `json:"size" cborgen:"size"`
}

// GitTempGetTree calls the XRPC method "sh.tangled.git.temp.getTree".
//
// path: Path within the repository tree
// ref: Git reference (branch, tag, or commit SHA)
// repo: AT-URI of the repository
func GitTempGetTree(ctx context.Context, c util.LexClient, path string, ref string, repo string) (*GitTempGetTree_Output, error) {
	var out GitTempGetTree_Output

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

	return &out, nil
}
