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

package tangled

// schema: sh.tangled.ci.describeWorkflowDefinition

import (
	"context"

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

const (
	CiDescribeWorkflowDefinitionNSID = "sh.tangled.ci.describeWorkflowDefinition"
)

// CiDescribeWorkflowDefinition_Output is the output of a sh.tangled.ci.describeWorkflowDefinition call.
type CiDescribeWorkflowDefinition_Output struct {
	// derived: Whether the workflow definition is derived from this repository at all. When false, no commit-to-commit comparison is meaningful (e.g. definitions managed externally), and callers should not surface change warnings.
	Derived bool `json:"derived" cborgen:"derived"`
	// hash: Opaque fingerprint of the workflow definition as resolved by the spindle; for git-derived spindles this covers the workflow files at the commit, not their post-compilation expansion. Only equality is defined: identical resolved definitions MUST produce identical hashes for a given spindle deployment, and differing definitions SHOULD produce differing hashes. Absent when derived is false.
	Hash *string `json:"hash,omitempty" cborgen:"hash,omitempty"`
	// workflows: Names or paths of the effective workflow files that produced the hash, for display purposes.
	Workflows []string `json:"workflows,omitempty" cborgen:"workflows,omitempty"`
}

// CiDescribeWorkflowDefinition calls the XRPC method "sh.tangled.ci.describeWorkflowDefinition".
//
// repo: Target repository DID the workflow definition belongs to.
// sha: Commit SHA to resolve the workflow definition at
// sourceRepo: Repository DID to resolve workflow definitions from, if different from the target repo (e.g. a fork for a fork-based pull request).
func CiDescribeWorkflowDefinition(ctx context.Context, c util.LexClient, repo string, sha string, sourceRepo string) (*CiDescribeWorkflowDefinition_Output, error) {
	var out CiDescribeWorkflowDefinition_Output

	params := map[string]interface{}{}
	params["repo"] = repo
	params["sha"] = sha
	if sourceRepo != "" {
		params["sourceRepo"] = sourceRepo
	}
	if err := c.LexDo(ctx, util.Query, "", "sh.tangled.ci.describeWorkflowDefinition", params, nil, &out); err != nil {
		return nil, err
	}

	return &out, nil
}
