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

package tangled

// schema: sh.tangled.ci.queryPipelines

import (
	"context"

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

const (
	CiQueryPipelinesNSID = "sh.tangled.ci.queryPipelines"
)

// CiQueryPipelines_Output is the output of a sh.tangled.ci.queryPipelines call.
type CiQueryPipelines_Output struct {
	Cursor    *string       `json:"cursor,omitempty" cborgen:"cursor,omitempty"`
	Pipelines []*CiPipeline `json:"pipelines" cborgen:"pipelines"`
	// total: Maximum number of pipelines
	Total int64 `json:"total" cborgen:"total"`
}

// CiQueryPipelines calls the XRPC method "sh.tangled.ci.queryPipelines".
//
// commits: Filter pipelines by commits. When provided, maximum one pipeline per commit id will be returned.
// cursor: Pagination cursor
// limit: Maximum number of pipelines to return
// repo: DID of the repository
func CiQueryPipelines(ctx context.Context, c util.LexClient, commits []string, cursor string, limit int64, repo string) (*CiQueryPipelines_Output, error) {
	var out CiQueryPipelines_Output

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

	return &out, nil
}
