// Code generated by protoc-gen-go-nexus. DO NOT EDIT.
// versions:
//
//	protoc-gen-go-nexus dev (latest)
//	go go1.23.6
//
// exclude service tags: disabled
//
//	protoc (unknown)
//
// source: example/nexus/v1/nexus.proto
package nexusv1nexus

import (
	"context"
	v1 "github.com/cludden/protoc-gen-go-temporal/gen/example/nexus/v1"
	nexusproto "github.com/nexus-rpc/sdk-go/contrib/nexusproto"
	nexus "github.com/nexus-rpc/sdk-go/nexus"
)

// GreetingServiceServiceName defines the fully-qualified name for the example.nexus.v1.GreetingService service.
const GreetingServiceServiceName = "example.nexus.v1.GreetingService"

// GreetingServiceHelloOperationName defines the fully-qualified name for the Hello operation.
const GreetingServiceHelloOperationName = "Hello"

var GreetingServiceHelloOperation = nexus.NewOperationReference[*v1.HelloInput, *v1.HelloOutput](GreetingServiceHelloOperationName)

type GreetingServiceNexusHandler interface {
	Hello(name string) nexus.Operation[*v1.HelloInput, *v1.HelloOutput]
}

func NewGreetingServiceNexusService(h GreetingServiceNexusHandler) (*nexus.Service, error) {
	svc := nexus.NewService(GreetingServiceServiceName)
	err := svc.Register(h.Hello(GreetingServiceHelloOperationName))
	if err != nil {
		return nil, err
	}
	return svc, nil
}

type UnimplementedGreetingServiceNexusHandler struct{}
type unimplementedGreetingServiceHello struct {
	nexus.UnimplementedOperation[*v1.HelloInput, *v1.HelloOutput]
	name string
}

func (h *unimplementedGreetingServiceHello) Name() string {
	return h.name
}
func (h *UnimplementedGreetingServiceNexusHandler) Hello(name string) nexus.Operation[*v1.HelloInput, *v1.HelloOutput] {
	return &unimplementedGreetingServiceHello{
		name: name,
	}
}

type GreetingServiceNexusHTTPClient struct {
	client nexus.HTTPClient
}

// NewGreetingServiceNexusHTTPClient initializes a new GreetingServiceNexusHTTPClient.
// options.Service is overridden with the defined proto service name.
func NewGreetingServiceNexusHTTPClient(options nexus.HTTPClientOptions) (*GreetingServiceNexusHTTPClient, error) {
	options.Service = GreetingServiceServiceName
	if options.Serializer == nil {
		options.Serializer = nexusproto.NewSerializer(nexusproto.SerializerOptions{
			Mode: nexusproto.SerializerModePreferJSON,
		})
	}
	client, err := nexus.NewHTTPClient(options)
	if err != nil {
		return nil, err
	}
	return &GreetingServiceNexusHTTPClient{
		client: *client,
	}, nil
}

type GreetingServiceHelloOperationStartResult struct {
	Successful *v1.HelloOutput
	Pending    *nexus.OperationHandle[*v1.HelloOutput]
	Links      []nexus.Link
}

func (c *GreetingServiceNexusHTTPClient) HelloAsync(ctx context.Context, input *v1.HelloInput, options nexus.StartOperationOptions) (*GreetingServiceHelloOperationStartResult, error) {
	res, err := nexus.StartOperation(ctx, &c.client, GreetingServiceHelloOperation, input, options)
	if err != nil {
		return nil, err
	}
	typed := GreetingServiceHelloOperationStartResult{
		Successful: res.Successful,
		Pending:    res.Pending,
		Links:      res.Links,
	}
	return &typed, nil
}
func (c *GreetingServiceNexusHTTPClient) Hello(ctx context.Context, input *v1.HelloInput, options nexus.ExecuteOperationOptions) (*v1.HelloOutput, error) {
	output, err := nexus.ExecuteOperation(ctx, &c.client, GreetingServiceHelloOperation, input, options)
	return output, err
}
func (c *GreetingServiceNexusHTTPClient) NewHelloHandle(id string) (*nexus.OperationHandle[*v1.HelloOutput], error) {
	return nexus.NewHandle(&c.client, GreetingServiceHelloOperation, id)
}
