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

package tangled

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

import (
	"context"

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

const (
	GitTempListLanguagesNSID = "sh.tangled.git.temp.listLanguages"
)

// GitTempListLanguages_Language is a "language" in the sh.tangled.git.temp.listLanguages schema.
type GitTempListLanguages_Language struct {
	// name: Programming language name
	Name string `json:"name" cborgen:"name"`
	// size: Total size of files in this language (bytes)
	Size int64 `json:"size" cborgen:"size"`
}

// GitTempListLanguages_Output is the output of a sh.tangled.git.temp.listLanguages call.
type GitTempListLanguages_Output struct {
	Languages []*GitTempListLanguages_Language `json:"languages" cborgen:"languages"`
	// ref: The git reference used
	Ref string `json:"ref" cborgen:"ref"`
	// total: Total size of all analyzed files in bytes
	Total int64 `json:"total" cborgen:"total"`
}

// GitTempListLanguages calls the XRPC method "sh.tangled.git.temp.listLanguages".
//
// indexedOnly: Only serve stored languages, failing with NotIndexed rather than analyzing the commit on demand
// ref: Git reference (branch, tag, or commit SHA)
// repo: DID of the repository
func GitTempListLanguages(ctx context.Context, c util.LexClient, indexedOnly bool, ref string, repo string) (*GitTempListLanguages_Output, error) {
	var out GitTempListLanguages_Output

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

	return &out, nil
}
