// Code generated by github.com/Khan/genqlient, DO NOT EDIT.

package api

import (
	"context"
	"encoding/json"
	"fmt"

	"github.com/Khan/genqlient/graphql"
)

// Build includes the GraphQL fields of Build requested by the fragment Build.
// The GraphQL type's documentation follows.
//
// A build from a pipeline
type Build struct {
	// The UUID for the build
	Uuid string `json:"uuid"`
	Id   string `json:"id"`
	// The number of the build
	Number int `json:"number"`
	// The current state of the build
	State BuildStates            `json:"state"`
	Jobs  BuildJobsJobConnection `json:"jobs"`
}

// GetUuid returns Build.Uuid, and is useful for accessing the field via an interface.
func (v *Build) GetUuid() string { return v.Uuid }

// GetId returns Build.Id, and is useful for accessing the field via an interface.
func (v *Build) GetId() string { return v.Id }

// GetNumber returns Build.Number, and is useful for accessing the field via an interface.
func (v *Build) GetNumber() int { return v.Number }

// GetState returns Build.State, and is useful for accessing the field via an interface.
func (v *Build) GetState() BuildStates { return v.State }

// GetJobs returns Build.Jobs, and is useful for accessing the field via an interface.
func (v *Build) GetJobs() BuildJobsJobConnection { return v.Jobs }

// Author for a build
type BuildAuthorInput struct {
	// The email for the build author
	Email string `json:"email"`
	// The name for the build author
	Name string `json:"name"`
}

// GetEmail returns BuildAuthorInput.Email, and is useful for accessing the field via an interface.
func (v *BuildAuthorInput) GetEmail() string { return v.Email }

// GetName returns BuildAuthorInput.Name, and is useful for accessing the field via an interface.
func (v *BuildAuthorInput) GetName() string { return v.Name }

// BuildCancelBuildCancelBuildCancelPayload includes the requested fields of the GraphQL type BuildCancelPayload.
// The GraphQL type's documentation follows.
//
// Autogenerated return type of BuildCancel.
type BuildCancelBuildCancelBuildCancelPayload struct {
	// A unique identifier for the client performing the mutation.
	ClientMutationId string `json:"clientMutationId"`
}

// GetClientMutationId returns BuildCancelBuildCancelBuildCancelPayload.ClientMutationId, and is useful for accessing the field via an interface.
func (v *BuildCancelBuildCancelBuildCancelPayload) GetClientMutationId() string {
	return v.ClientMutationId
}

// Autogenerated input type of BuildCancel
type BuildCancelInput struct {
	// A unique identifier for the client performing the mutation.
	ClientMutationId string `json:"clientMutationId"`
	Id               string `json:"id"`
}

// GetClientMutationId returns BuildCancelInput.ClientMutationId, and is useful for accessing the field via an interface.
func (v *BuildCancelInput) GetClientMutationId() string { return v.ClientMutationId }

// GetId returns BuildCancelInput.Id, and is useful for accessing the field via an interface.
func (v *BuildCancelInput) GetId() string { return v.Id }

// BuildCancelResponse is returned by BuildCancel on success.
type BuildCancelResponse struct {
	// Cancel a build.
	BuildCancel BuildCancelBuildCancelBuildCancelPayload `json:"buildCancel"`
}

// GetBuildCancel returns BuildCancelResponse.BuildCancel, and is useful for accessing the field via an interface.
func (v *BuildCancelResponse) GetBuildCancel() BuildCancelBuildCancelBuildCancelPayload {
	return v.BuildCancel
}

// BuildCreateBuildCreateBuildCreatePayload includes the requested fields of the GraphQL type BuildCreatePayload.
// The GraphQL type's documentation follows.
//
// Autogenerated return type of BuildCreate.
type BuildCreateBuildCreateBuildCreatePayload struct {
	Build BuildCreateBuildCreateBuildCreatePayloadBuild `json:"build"`
}

// GetBuild returns BuildCreateBuildCreateBuildCreatePayload.Build, and is useful for accessing the field via an interface.
func (v *BuildCreateBuildCreateBuildCreatePayload) GetBuild() BuildCreateBuildCreateBuildCreatePayloadBuild {
	return v.Build
}

// BuildCreateBuildCreateBuildCreatePayloadBuild includes the requested fields of the GraphQL type Build.
// The GraphQL type's documentation follows.
//
// A build from a pipeline
type BuildCreateBuildCreateBuildCreatePayloadBuild struct {
	Build `json:"-"`
}

// GetUuid returns BuildCreateBuildCreateBuildCreatePayloadBuild.Uuid, and is useful for accessing the field via an interface.
func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) GetUuid() string { return v.Build.Uuid }

// GetId returns BuildCreateBuildCreateBuildCreatePayloadBuild.Id, and is useful for accessing the field via an interface.
func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) GetId() string { return v.Build.Id }

// GetNumber returns BuildCreateBuildCreateBuildCreatePayloadBuild.Number, and is useful for accessing the field via an interface.
func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) GetNumber() int { return v.Build.Number }

// GetState returns BuildCreateBuildCreateBuildCreatePayloadBuild.State, and is useful for accessing the field via an interface.
func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) GetState() BuildStates { return v.Build.State }

// GetJobs returns BuildCreateBuildCreateBuildCreatePayloadBuild.Jobs, and is useful for accessing the field via an interface.
func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) GetJobs() BuildJobsJobConnection {
	return v.Build.Jobs
}

func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) UnmarshalJSON(b []byte) error {

	if string(b) == "null" {
		return nil
	}

	var firstPass struct {
		*BuildCreateBuildCreateBuildCreatePayloadBuild
		graphql.NoUnmarshalJSON
	}
	firstPass.BuildCreateBuildCreateBuildCreatePayloadBuild = v

	err := json.Unmarshal(b, &firstPass)
	if err != nil {
		return err
	}

	err = json.Unmarshal(
		b, &v.Build)
	if err != nil {
		return err
	}
	return nil
}

type __premarshalBuildCreateBuildCreateBuildCreatePayloadBuild struct {
	Uuid string `json:"uuid"`

	Id string `json:"id"`

	Number int `json:"number"`

	State BuildStates `json:"state"`

	Jobs BuildJobsJobConnection `json:"jobs"`
}

func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) MarshalJSON() ([]byte, error) {
	premarshaled, err := v.__premarshalJSON()
	if err != nil {
		return nil, err
	}
	return json.Marshal(premarshaled)
}

func (v *BuildCreateBuildCreateBuildCreatePayloadBuild) __premarshalJSON() (*__premarshalBuildCreateBuildCreateBuildCreatePayloadBuild, error) {
	var retval __premarshalBuildCreateBuildCreateBuildCreatePayloadBuild

	retval.Uuid = v.Build.Uuid
	retval.Id = v.Build.Id
	retval.Number = v.Build.Number
	retval.State = v.Build.State
	retval.Jobs = v.Build.Jobs
	return &retval, nil
}

// Autogenerated input type of BuildCreate
type BuildCreateInput struct {
	Author BuildAuthorInput `json:"author"`
	// The branch for the build
	Branch string `json:"branch"`
	// A unique identifier for the client performing the mutation.
	ClientMutationId string `json:"clientMutationId"`
	// The commit for the build
	Commit string `json:"commit"`
	// Environment variables used for the build
	Env []string `json:"env"`
	// The message that is displayed on the build
	Message  string               `json:"message"`
	MetaData []BuildMetaDataInput `json:"metaData"`
	// The GraphQL ID of the pipeline you want to create a build on
	PipelineID string `json:"pipelineID"`
}

// GetAuthor returns BuildCreateInput.Author, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetAuthor() BuildAuthorInput { return v.Author }

// GetBranch returns BuildCreateInput.Branch, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetBranch() string { return v.Branch }

// GetClientMutationId returns BuildCreateInput.ClientMutationId, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetClientMutationId() string { return v.ClientMutationId }

// GetCommit returns BuildCreateInput.Commit, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetCommit() string { return v.Commit }

// GetEnv returns BuildCreateInput.Env, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetEnv() []string { return v.Env }

// GetMessage returns BuildCreateInput.Message, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetMessage() string { return v.Message }

// GetMetaData returns BuildCreateInput.MetaData, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetMetaData() []BuildMetaDataInput { return v.MetaData }

// GetPipelineID returns BuildCreateInput.PipelineID, and is useful for accessing the field via an interface.
func (v *BuildCreateInput) GetPipelineID() string { return v.PipelineID }

// BuildCreateResponse is returned by BuildCreate on success.
type BuildCreateResponse struct {
	// Create a build.
	BuildCreate BuildCreateBuildCreateBuildCreatePayload `json:"buildCreate"`
}

// GetBuildCreate returns BuildCreateResponse.BuildCreate, and is useful for accessing the field via an interface.
func (v *BuildCreateResponse) GetBuildCreate() BuildCreateBuildCreateBuildCreatePayload {
	return v.BuildCreate
}

// BuildJobsJobConnection includes the requested fields of the GraphQL type JobConnection.
type BuildJobsJobConnection struct {
	Edges []BuildJobsJobConnectionEdgesJobEdge `json:"edges"`
}

// GetEdges returns BuildJobsJobConnection.Edges, and is useful for accessing the field via an interface.
func (v *BuildJobsJobConnection) GetEdges() []BuildJobsJobConnectionEdgesJobEdge { return v.Edges }

// BuildJobsJobConnectionEdgesJobEdge includes the requested fields of the GraphQL type JobEdge.
type BuildJobsJobConnectionEdgesJobEdge struct {
	Node Job `json:"-"`
}

// GetNode returns BuildJobsJobConnectionEdgesJobEdge.Node, and is useful for accessing the field via an interface.
func (v *BuildJobsJobConnectionEdgesJobEdge) GetNode() Job { return v.Node }

func (v *BuildJobsJobConnectionEdgesJobEdge) UnmarshalJSON(b []byte) error {

	if string(b) == "null" {
		return nil
	}

	var firstPass struct {
		*BuildJobsJobConnectionEdgesJobEdge
		Node json.RawMessage `json:"node"`
		graphql.NoUnmarshalJSON
	}
	firstPass.BuildJobsJobConnectionEdgesJobEdge = v

	err := json.Unmarshal(b, &firstPass)
	if err != nil {
		return err
	}

	{
		dst := &v.Node
		src := firstPass.Node
		if len(src) != 0 && string(src) != "null" {
			err = __unmarshalJob(
				src, dst)
			if err != nil {
				return fmt.Errorf(
					"unable to unmarshal BuildJobsJobConnectionEdgesJobEdge.Node: %w", err)
			}
		}
	}
	return nil
}

type __premarshalBuildJobsJobConnectionEdgesJobEdge struct {
	Node json.RawMessage `json:"node"`
}

func (v *BuildJobsJobConnectionEdgesJobEdge) MarshalJSON() ([]byte, error) {
	premarshaled, err := v.__premarshalJSON()
	if err != nil {
		return nil, err
	}
	return json.Marshal(premarshaled)
}

func (v *BuildJobsJobConnectionEdgesJobEdge) __premarshalJSON() (*__premarshalBuildJobsJobConnectionEdgesJobEdge, error) {
	var retval __premarshalBuildJobsJobConnectionEdgesJobEdge

	{

		dst := &retval.Node
		src := v.Node
		var err error
		*dst, err = __marshalJob(
			&src)
		if err != nil {
			return nil, fmt.Errorf(
				"unable to marshal BuildJobsJobConnectionEdgesJobEdge.Node: %w", err)
		}
	}
	return &retval, nil
}

// Meta-data key/value pairs for a build
type BuildMetaDataInput struct {
	// The key for this meta-data item
	Key string `json:"key"`
	// The value for this meta-data item
	Value string `json:"value"`
}

// GetKey returns BuildMetaDataInput.Key, and is useful for accessing the field via an interface.
func (v *BuildMetaDataInput) GetKey() string { return v.Key }

// GetValue returns BuildMetaDataInput.Value, and is useful for accessing the field via an interface.
func (v *BuildMetaDataInput) GetValue() string { return v.Value }

// All the possible states a build can be in
type BuildStates string

const (
	// The build is blocked
	BuildStatesBlocked BuildStates = "BLOCKED"
	// The build was canceled
	BuildStatesCanceled BuildStates = "CANCELED"
	// The build is currently being canceled
	BuildStatesCanceling BuildStates = "CANCELING"
	// The build is currently being created
	BuildStatesCreating BuildStates = "CREATING"
	// The build failed
	BuildStatesFailed BuildStates = "FAILED"
	// The build is failing
	BuildStatesFailing BuildStates = "FAILING"
	// The build wasn't run
	BuildStatesNotRun BuildStates = "NOT_RUN"
	// The build passed
	BuildStatesPassed BuildStates = "PASSED"
	// The build is currently running jobs
	BuildStatesRunning BuildStates = "RUNNING"
	// The build has yet to start running jobs
	BuildStatesScheduled BuildStates = "SCHEDULED"
	// The build was skipped
	BuildStatesSkipped BuildStates = "SKIPPED"
)

var AllBuildStates = []BuildStates{
	BuildStatesBlocked,
	BuildStatesCanceled,
	BuildStatesCanceling,
	BuildStatesCreating,
	BuildStatesFailed,
	BuildStatesFailing,
	BuildStatesNotRun,
	BuildStatesPassed,
	BuildStatesRunning,
	BuildStatesScheduled,
	BuildStatesSkipped,
}

// CommandJob includes the GraphQL fields of JobTypeCommand requested by the fragment CommandJob.
// The GraphQL type's documentation follows.
//
// A type of job that runs a command on an agent
type CommandJob struct {
	// The UUID for this job
	Uuid string `json:"uuid"`
}

// GetUuid returns CommandJob.Uuid, and is useful for accessing the field via an interface.
func (v *CommandJob) GetUuid() string { return v.Uuid }

// GetBuildBuild includes the requested fields of the GraphQL type Build.
// The GraphQL type's documentation follows.
//
// A build from a pipeline
type GetBuildBuild struct {
	Build `json:"-"`
}

// GetUuid returns GetBuildBuild.Uuid, and is useful for accessing the field via an interface.
func (v *GetBuildBuild) GetUuid() string { return v.Build.Uuid }

// GetId returns GetBuildBuild.Id, and is useful for accessing the field via an interface.
func (v *GetBuildBuild) GetId() string { return v.Build.Id }

// GetNumber returns GetBuildBuild.Number, and is useful for accessing the field via an interface.
func (v *GetBuildBuild) GetNumber() int { return v.Build.Number }

// GetState returns GetBuildBuild.State, and is useful for accessing the field via an interface.
func (v *GetBuildBuild) GetState() BuildStates { return v.Build.State }

// GetJobs returns GetBuildBuild.Jobs, and is useful for accessing the field via an interface.
func (v *GetBuildBuild) GetJobs() BuildJobsJobConnection { return v.Build.Jobs }

func (v *GetBuildBuild) UnmarshalJSON(b []byte) error {

	if string(b) == "null" {
		return nil
	}

	var firstPass struct {
		*GetBuildBuild
		graphql.NoUnmarshalJSON
	}
	firstPass.GetBuildBuild = v

	err := json.Unmarshal(b, &firstPass)
	if err != nil {
		return err
	}

	err = json.Unmarshal(
		b, &v.Build)
	if err != nil {
		return err
	}
	return nil
}

type __premarshalGetBuildBuild struct {
	Uuid string `json:"uuid"`

	Id string `json:"id"`

	Number int `json:"number"`

	State BuildStates `json:"state"`

	Jobs BuildJobsJobConnection `json:"jobs"`
}

func (v *GetBuildBuild) MarshalJSON() ([]byte, error) {
	premarshaled, err := v.__premarshalJSON()
	if err != nil {
		return nil, err
	}
	return json.Marshal(premarshaled)
}

func (v *GetBuildBuild) __premarshalJSON() (*__premarshalGetBuildBuild, error) {
	var retval __premarshalGetBuildBuild

	retval.Uuid = v.Build.Uuid
	retval.Id = v.Build.Id
	retval.Number = v.Build.Number
	retval.State = v.Build.State
	retval.Jobs = v.Build.Jobs
	return &retval, nil
}

// GetBuildResponse is returned by GetBuild on success.
type GetBuildResponse struct {
	// Find a build
	Build GetBuildBuild `json:"build"`
}

// GetBuild returns GetBuildResponse.Build, and is useful for accessing the field via an interface.
func (v *GetBuildResponse) GetBuild() GetBuildBuild { return v.Build }

// GetBuildsPipeline includes the requested fields of the GraphQL type Pipeline.
// The GraphQL type's documentation follows.
//
// A pipeline
type GetBuildsPipeline struct {
	// Returns the builds for this pipeline
	Builds GetBuildsPipelineBuildsBuildConnection `json:"builds"`
}

// GetBuilds returns GetBuildsPipeline.Builds, and is useful for accessing the field via an interface.
func (v *GetBuildsPipeline) GetBuilds() GetBuildsPipelineBuildsBuildConnection { return v.Builds }

// GetBuildsPipelineBuildsBuildConnection includes the requested fields of the GraphQL type BuildConnection.
type GetBuildsPipelineBuildsBuildConnection struct {
	Edges []GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdge `json:"edges"`
}

// GetEdges returns GetBuildsPipelineBuildsBuildConnection.Edges, and is useful for accessing the field via an interface.
func (v *GetBuildsPipelineBuildsBuildConnection) GetEdges() []GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdge {
	return v.Edges
}

// GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdge includes the requested fields of the GraphQL type BuildEdge.
type GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdge struct {
	Node GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild `json:"node"`
}

// GetNode returns GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdge.Node, and is useful for accessing the field via an interface.
func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdge) GetNode() GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild {
	return v.Node
}

// GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild includes the requested fields of the GraphQL type Build.
// The GraphQL type's documentation follows.
//
// A build from a pipeline
type GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild struct {
	Build `json:"-"`
}

// GetUuid returns GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild.Uuid, and is useful for accessing the field via an interface.
func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) GetUuid() string {
	return v.Build.Uuid
}

// GetId returns GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild.Id, and is useful for accessing the field via an interface.
func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) GetId() string {
	return v.Build.Id
}

// GetNumber returns GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild.Number, and is useful for accessing the field via an interface.
func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) GetNumber() int {
	return v.Build.Number
}

// GetState returns GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild.State, and is useful for accessing the field via an interface.
func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) GetState() BuildStates {
	return v.Build.State
}

// GetJobs returns GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild.Jobs, and is useful for accessing the field via an interface.
func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) GetJobs() BuildJobsJobConnection {
	return v.Build.Jobs
}

func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) UnmarshalJSON(b []byte) error {

	if string(b) == "null" {
		return nil
	}

	var firstPass struct {
		*GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild
		graphql.NoUnmarshalJSON
	}
	firstPass.GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild = v

	err := json.Unmarshal(b, &firstPass)
	if err != nil {
		return err
	}

	err = json.Unmarshal(
		b, &v.Build)
	if err != nil {
		return err
	}
	return nil
}

type __premarshalGetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild struct {
	Uuid string `json:"uuid"`

	Id string `json:"id"`

	Number int `json:"number"`

	State BuildStates `json:"state"`

	Jobs BuildJobsJobConnection `json:"jobs"`
}

func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) MarshalJSON() ([]byte, error) {
	premarshaled, err := v.__premarshalJSON()
	if err != nil {
		return nil, err
	}
	return json.Marshal(premarshaled)
}

func (v *GetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild) __premarshalJSON() (*__premarshalGetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild, error) {
	var retval __premarshalGetBuildsPipelineBuildsBuildConnectionEdgesBuildEdgeNodeBuild

	retval.Uuid = v.Build.Uuid
	retval.Id = v.Build.Id
	retval.Number = v.Build.Number
	retval.State = v.Build.State
	retval.Jobs = v.Build.Jobs
	return &retval, nil
}

// GetBuildsResponse is returned by GetBuilds on success.
type GetBuildsResponse struct {
	// Find a pipeline
	Pipeline GetBuildsPipeline `json:"pipeline"`
}

// GetPipeline returns GetBuildsResponse.Pipeline, and is useful for accessing the field via an interface.
func (v *GetBuildsResponse) GetPipeline() GetBuildsPipeline { return v.Pipeline }

// Job includes the GraphQL fields of Job requested by the fragment Job.
// The GraphQL type's documentation follows.
//
// # Kinds of jobs that can exist on a build
//
// Job is implemented by the following types:
// JobJobTypeBlock
// JobJobTypeCommand
// JobJobTypeTrigger
// JobJobTypeWait
type Job interface {
	implementsGraphQLInterfaceJob()
}

func (v *JobJobTypeBlock) implementsGraphQLInterfaceJob()   {}
func (v *JobJobTypeCommand) implementsGraphQLInterfaceJob() {}
func (v *JobJobTypeTrigger) implementsGraphQLInterfaceJob() {}
func (v *JobJobTypeWait) implementsGraphQLInterfaceJob()    {}

func __unmarshalJob(b []byte, v *Job) error {
	if string(b) == "null" {
		return nil
	}

	var tn struct {
		TypeName string `json:"__typename"`
	}
	err := json.Unmarshal(b, &tn)
	if err != nil {
		return err
	}

	switch tn.TypeName {
	case "JobTypeBlock":
		*v = new(JobJobTypeBlock)
		return json.Unmarshal(b, *v)
	case "JobTypeCommand":
		*v = new(JobJobTypeCommand)
		return json.Unmarshal(b, *v)
	case "JobTypeTrigger":
		*v = new(JobJobTypeTrigger)
		return json.Unmarshal(b, *v)
	case "JobTypeWait":
		*v = new(JobJobTypeWait)
		return json.Unmarshal(b, *v)
	case "":
		return fmt.Errorf(
			"response was missing Job.__typename")
	default:
		return fmt.Errorf(
			`unexpected concrete type for Job: "%v"`, tn.TypeName)
	}
}

func __marshalJob(v *Job) ([]byte, error) {

	var typename string
	switch v := (*v).(type) {
	case *JobJobTypeBlock:
		typename = "JobTypeBlock"

		result := struct {
			TypeName string `json:"__typename"`
			*JobJobTypeBlock
		}{typename, v}
		return json.Marshal(result)
	case *JobJobTypeCommand:
		typename = "JobTypeCommand"

		premarshaled, err := v.__premarshalJSON()
		if err != nil {
			return nil, err
		}
		result := struct {
			TypeName string `json:"__typename"`
			*__premarshalJobJobTypeCommand
		}{typename, premarshaled}
		return json.Marshal(result)
	case *JobJobTypeTrigger:
		typename = "JobTypeTrigger"

		result := struct {
			TypeName string `json:"__typename"`
			*JobJobTypeTrigger
		}{typename, v}
		return json.Marshal(result)
	case *JobJobTypeWait:
		typename = "JobTypeWait"

		result := struct {
			TypeName string `json:"__typename"`
			*JobJobTypeWait
		}{typename, v}
		return json.Marshal(result)
	case nil:
		return []byte("null"), nil
	default:
		return nil, fmt.Errorf(
			`unexpected concrete type for Job: "%T"`, v)
	}
}

// Job includes the GraphQL fields of JobTypeBlock requested by the fragment Job.
// The GraphQL type's documentation follows.
//
// Kinds of jobs that can exist on a build
type JobJobTypeBlock struct {
}

// Job includes the GraphQL fields of JobTypeCommand requested by the fragment Job.
// The GraphQL type's documentation follows.
//
// Kinds of jobs that can exist on a build
type JobJobTypeCommand struct {
	CommandJob `json:"-"`
}

// GetUuid returns JobJobTypeCommand.Uuid, and is useful for accessing the field via an interface.
func (v *JobJobTypeCommand) GetUuid() string { return v.CommandJob.Uuid }

func (v *JobJobTypeCommand) UnmarshalJSON(b []byte) error {

	if string(b) == "null" {
		return nil
	}

	var firstPass struct {
		*JobJobTypeCommand
		graphql.NoUnmarshalJSON
	}
	firstPass.JobJobTypeCommand = v

	err := json.Unmarshal(b, &firstPass)
	if err != nil {
		return err
	}

	err = json.Unmarshal(
		b, &v.CommandJob)
	if err != nil {
		return err
	}
	return nil
}

type __premarshalJobJobTypeCommand struct {
	Uuid string `json:"uuid"`
}

func (v *JobJobTypeCommand) MarshalJSON() ([]byte, error) {
	premarshaled, err := v.__premarshalJSON()
	if err != nil {
		return nil, err
	}
	return json.Marshal(premarshaled)
}

func (v *JobJobTypeCommand) __premarshalJSON() (*__premarshalJobJobTypeCommand, error) {
	var retval __premarshalJobJobTypeCommand

	retval.Uuid = v.CommandJob.Uuid
	return &retval, nil
}

// Job includes the GraphQL fields of JobTypeTrigger requested by the fragment Job.
// The GraphQL type's documentation follows.
//
// Kinds of jobs that can exist on a build
type JobJobTypeTrigger struct {
}

// Job includes the GraphQL fields of JobTypeWait requested by the fragment Job.
// The GraphQL type's documentation follows.
//
// Kinds of jobs that can exist on a build
type JobJobTypeWait struct {
}

// Autogenerated input type of PipelineDelete
type PipelineDeleteInput struct {
	// A unique identifier for the client performing the mutation.
	ClientMutationId string `json:"clientMutationId"`
	Id               string `json:"id"`
}

// GetClientMutationId returns PipelineDeleteInput.ClientMutationId, and is useful for accessing the field via an interface.
func (v *PipelineDeleteInput) GetClientMutationId() string { return v.ClientMutationId }

// GetId returns PipelineDeleteInput.Id, and is useful for accessing the field via an interface.
func (v *PipelineDeleteInput) GetId() string { return v.Id }

// PipelineDeletePipelineDeletePipelineDeletePayload includes the requested fields of the GraphQL type PipelineDeletePayload.
// The GraphQL type's documentation follows.
//
// Autogenerated return type of PipelineDelete.
type PipelineDeletePipelineDeletePipelineDeletePayload struct {
	// A unique identifier for the client performing the mutation.
	ClientMutationId string `json:"clientMutationId"`
}

// GetClientMutationId returns PipelineDeletePipelineDeletePipelineDeletePayload.ClientMutationId, and is useful for accessing the field via an interface.
func (v *PipelineDeletePipelineDeletePipelineDeletePayload) GetClientMutationId() string {
	return v.ClientMutationId
}

// PipelineDeleteResponse is returned by PipelineDelete on success.
type PipelineDeleteResponse struct {
	// Delete a pipeline.
	PipelineDelete PipelineDeletePipelineDeletePipelineDeletePayload `json:"pipelineDelete"`
}

// GetPipelineDelete returns PipelineDeleteResponse.PipelineDelete, and is useful for accessing the field via an interface.
func (v *PipelineDeleteResponse) GetPipelineDelete() PipelineDeletePipelineDeletePipelineDeletePayload {
	return v.PipelineDelete
}

// SearchPipelinesOrganization includes the requested fields of the GraphQL type Organization.
// The GraphQL type's documentation follows.
//
// An organization
type SearchPipelinesOrganization struct {
	// Return all the pipelines the current user has access to for this organization
	Pipelines SearchPipelinesOrganizationPipelinesPipelineConnection `json:"pipelines"`
}

// GetPipelines returns SearchPipelinesOrganization.Pipelines, and is useful for accessing the field via an interface.
func (v *SearchPipelinesOrganization) GetPipelines() SearchPipelinesOrganizationPipelinesPipelineConnection {
	return v.Pipelines
}

// SearchPipelinesOrganizationPipelinesPipelineConnection includes the requested fields of the GraphQL type PipelineConnection.
type SearchPipelinesOrganizationPipelinesPipelineConnection struct {
	Edges []SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdge `json:"edges"`
}

// GetEdges returns SearchPipelinesOrganizationPipelinesPipelineConnection.Edges, and is useful for accessing the field via an interface.
func (v *SearchPipelinesOrganizationPipelinesPipelineConnection) GetEdges() []SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdge {
	return v.Edges
}

// SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdge includes the requested fields of the GraphQL type PipelineEdge.
type SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdge struct {
	Node SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline `json:"node"`
}

// GetNode returns SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdge.Node, and is useful for accessing the field via an interface.
func (v *SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdge) GetNode() SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline {
	return v.Node
}

// SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline includes the requested fields of the GraphQL type Pipeline.
// The GraphQL type's documentation follows.
//
// A pipeline
type SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline struct {
	Id string `json:"id"`
	// The name of the pipeline
	Name string `json:"name"`
}

// GetId returns SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline.Id, and is useful for accessing the field via an interface.
func (v *SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline) GetId() string {
	return v.Id
}

// GetName returns SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline.Name, and is useful for accessing the field via an interface.
func (v *SearchPipelinesOrganizationPipelinesPipelineConnectionEdgesPipelineEdgeNodePipeline) GetName() string {
	return v.Name
}

// SearchPipelinesResponse is returned by SearchPipelines on success.
type SearchPipelinesResponse struct {
	// Find an organization
	Organization SearchPipelinesOrganization `json:"organization"`
}

// GetOrganization returns SearchPipelinesResponse.Organization, and is useful for accessing the field via an interface.
func (v *SearchPipelinesResponse) GetOrganization() SearchPipelinesOrganization {
	return v.Organization
}

// __BuildCancelInput is used internally by genqlient
type __BuildCancelInput struct {
	Input BuildCancelInput `json:"input"`
}

// GetInput returns __BuildCancelInput.Input, and is useful for accessing the field via an interface.
func (v *__BuildCancelInput) GetInput() BuildCancelInput { return v.Input }

// __BuildCreateInput is used internally by genqlient
type __BuildCreateInput struct {
	Input BuildCreateInput `json:"input"`
}

// GetInput returns __BuildCreateInput.Input, and is useful for accessing the field via an interface.
func (v *__BuildCreateInput) GetInput() BuildCreateInput { return v.Input }

// __GetBuildInput is used internally by genqlient
type __GetBuildInput struct {
	Uuid string `json:"uuid"`
}

// GetUuid returns __GetBuildInput.Uuid, and is useful for accessing the field via an interface.
func (v *__GetBuildInput) GetUuid() string { return v.Uuid }

// __GetBuildsInput is used internally by genqlient
type __GetBuildsInput struct {
	Slug  string        `json:"slug"`
	State []BuildStates `json:"state"`
	First int           `json:"first"`
}

// GetSlug returns __GetBuildsInput.Slug, and is useful for accessing the field via an interface.
func (v *__GetBuildsInput) GetSlug() string { return v.Slug }

// GetState returns __GetBuildsInput.State, and is useful for accessing the field via an interface.
func (v *__GetBuildsInput) GetState() []BuildStates { return v.State }

// GetFirst returns __GetBuildsInput.First, and is useful for accessing the field via an interface.
func (v *__GetBuildsInput) GetFirst() int { return v.First }

// __PipelineDeleteInput is used internally by genqlient
type __PipelineDeleteInput struct {
	Input PipelineDeleteInput `json:"input"`
}

// GetInput returns __PipelineDeleteInput.Input, and is useful for accessing the field via an interface.
func (v *__PipelineDeleteInput) GetInput() PipelineDeleteInput { return v.Input }

// __SearchPipelinesInput is used internally by genqlient
type __SearchPipelinesInput struct {
	Slug   string `json:"slug"`
	Search string `json:"search"`
	First  int    `json:"first"`
}

// GetSlug returns __SearchPipelinesInput.Slug, and is useful for accessing the field via an interface.
func (v *__SearchPipelinesInput) GetSlug() string { return v.Slug }

// GetSearch returns __SearchPipelinesInput.Search, and is useful for accessing the field via an interface.
func (v *__SearchPipelinesInput) GetSearch() string { return v.Search }

// GetFirst returns __SearchPipelinesInput.First, and is useful for accessing the field via an interface.
func (v *__SearchPipelinesInput) GetFirst() int { return v.First }

// The mutation executed by BuildCancel.
const BuildCancel_Operation = `
mutation BuildCancel ($input: BuildCancelInput!) {
	buildCancel(input: $input) {
		clientMutationId
	}
}
`

func BuildCancel(
	ctx_ context.Context,
	client_ graphql.Client,
	input BuildCancelInput,
) (data_ *BuildCancelResponse, err_ error) {
	req_ := &graphql.Request{
		OpName: "BuildCancel",
		Query:  BuildCancel_Operation,
		Variables: &__BuildCancelInput{
			Input: input,
		},
	}

	data_ = &BuildCancelResponse{}
	resp_ := &graphql.Response{Data: data_}

	err_ = client_.MakeRequest(
		ctx_,
		req_,
		resp_,
	)

	return data_, err_
}

// The mutation executed by BuildCreate.
const BuildCreate_Operation = `
mutation BuildCreate ($input: BuildCreateInput!) {
	buildCreate(input: $input) {
		build {
			... Build
		}
	}
}
fragment Build on Build {
	uuid
	id
	number
	state
	jobs(first: 100) {
		edges {
			node {
				__typename
				... Job
			}
		}
	}
}
fragment Job on Job {
	... on JobTypeCommand {
		... CommandJob
	}
}
fragment CommandJob on JobTypeCommand {
	uuid
}
`

func BuildCreate(
	ctx_ context.Context,
	client_ graphql.Client,
	input BuildCreateInput,
) (data_ *BuildCreateResponse, err_ error) {
	req_ := &graphql.Request{
		OpName: "BuildCreate",
		Query:  BuildCreate_Operation,
		Variables: &__BuildCreateInput{
			Input: input,
		},
	}

	data_ = &BuildCreateResponse{}
	resp_ := &graphql.Response{Data: data_}

	err_ = client_.MakeRequest(
		ctx_,
		req_,
		resp_,
	)

	return data_, err_
}

// The query executed by GetBuild.
const GetBuild_Operation = `
query GetBuild ($uuid: ID!) {
	build(uuid: $uuid) {
		... Build
	}
}
fragment Build on Build {
	uuid
	id
	number
	state
	jobs(first: 100) {
		edges {
			node {
				__typename
				... Job
			}
		}
	}
}
fragment Job on Job {
	... on JobTypeCommand {
		... CommandJob
	}
}
fragment CommandJob on JobTypeCommand {
	uuid
}
`

func GetBuild(
	ctx_ context.Context,
	client_ graphql.Client,
	uuid string,
) (data_ *GetBuildResponse, err_ error) {
	req_ := &graphql.Request{
		OpName: "GetBuild",
		Query:  GetBuild_Operation,
		Variables: &__GetBuildInput{
			Uuid: uuid,
		},
	}

	data_ = &GetBuildResponse{}
	resp_ := &graphql.Response{Data: data_}

	err_ = client_.MakeRequest(
		ctx_,
		req_,
		resp_,
	)

	return data_, err_
}

// The query executed by GetBuilds.
const GetBuilds_Operation = `
query GetBuilds ($slug: ID!, $state: [BuildStates!], $first: Int) {
	pipeline(slug: $slug) {
		builds(state: $state, first: $first) {
			edges {
				node {
					... Build
				}
			}
		}
	}
}
fragment Build on Build {
	uuid
	id
	number
	state
	jobs(first: 100) {
		edges {
			node {
				__typename
				... Job
			}
		}
	}
}
fragment Job on Job {
	... on JobTypeCommand {
		... CommandJob
	}
}
fragment CommandJob on JobTypeCommand {
	uuid
}
`

func GetBuilds(
	ctx_ context.Context,
	client_ graphql.Client,
	slug string,
	state []BuildStates,
	first int,
) (data_ *GetBuildsResponse, err_ error) {
	req_ := &graphql.Request{
		OpName: "GetBuilds",
		Query:  GetBuilds_Operation,
		Variables: &__GetBuildsInput{
			Slug:  slug,
			State: state,
			First: first,
		},
	}

	data_ = &GetBuildsResponse{}
	resp_ := &graphql.Response{Data: data_}

	err_ = client_.MakeRequest(
		ctx_,
		req_,
		resp_,
	)

	return data_, err_
}

// The mutation executed by PipelineDelete.
const PipelineDelete_Operation = `
mutation PipelineDelete ($input: PipelineDeleteInput!) {
	pipelineDelete(input: $input) {
		clientMutationId
	}
}
`

// ## The following are used in the cleanup integration "test"
func PipelineDelete(
	ctx_ context.Context,
	client_ graphql.Client,
	input PipelineDeleteInput,
) (data_ *PipelineDeleteResponse, err_ error) {
	req_ := &graphql.Request{
		OpName: "PipelineDelete",
		Query:  PipelineDelete_Operation,
		Variables: &__PipelineDeleteInput{
			Input: input,
		},
	}

	data_ = &PipelineDeleteResponse{}
	resp_ := &graphql.Response{Data: data_}

	err_ = client_.MakeRequest(
		ctx_,
		req_,
		resp_,
	)

	return data_, err_
}

// The query executed by SearchPipelines.
const SearchPipelines_Operation = `
query SearchPipelines ($slug: ID!, $search: String!, $first: Int!) {
	organization(slug: $slug) {
		pipelines(search: $search, first: $first) {
			edges {
				node {
					id
					name
				}
			}
		}
	}
}
`

func SearchPipelines(
	ctx_ context.Context,
	client_ graphql.Client,
	slug string,
	search string,
	first int,
) (data_ *SearchPipelinesResponse, err_ error) {
	req_ := &graphql.Request{
		OpName: "SearchPipelines",
		Query:  SearchPipelines_Operation,
		Variables: &__SearchPipelinesInput{
			Slug:   slug,
			Search: search,
			First:  first,
		},
	}

	data_ = &SearchPipelinesResponse{}
	resp_ := &graphql.Response{Data: data_}

	err_ = client_.MakeRequest(
		ctx_,
		req_,
		resp_,
	)

	return data_, err_
}
