// Copyright IBM Corp. 2014, 2026
// SPDX-License-Identifier: BUSL-1.1

// Code generated by ./generator. DO NOT EDIT.
package dynrpcserver

import (
	"context"
	"sync"

	"google.golang.org/grpc"

	stacks "github.com/hashicorp/terraform/internal/rpcapi/terraform1/stacks"
)

type Stacks struct {
	impl stacks.StacksServer
	mu   sync.RWMutex
	stacks.UnimplementedStacksServer
}

var _ stacks.StacksServer = (*Stacks)(nil)

func NewStacksStub() *Stacks {
	return &Stacks{}
}

func (s *Stacks) ApplyStackChanges(a0 *stacks.ApplyStackChanges_Request, a1 grpc.ServerStreamingServer[stacks.ApplyStackChanges_Event]) error {
	impl, err := s.realRPCServer()
	if err != nil {
		return err
	}
	return impl.ApplyStackChanges(a0, a1)
}

func (s *Stacks) ClosePlan(a0 context.Context, a1 *stacks.CloseStackPlan_Request) (*stacks.CloseStackPlan_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.ClosePlan(a0, a1)
}

func (s *Stacks) CloseStackConfiguration(a0 context.Context, a1 *stacks.CloseStackConfiguration_Request) (*stacks.CloseStackConfiguration_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.CloseStackConfiguration(a0, a1)
}

func (s *Stacks) CloseState(a0 context.Context, a1 *stacks.CloseStackState_Request) (*stacks.CloseStackState_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.CloseState(a0, a1)
}

func (s *Stacks) CloseTerraformState(a0 context.Context, a1 *stacks.CloseTerraformState_Request) (*stacks.CloseTerraformState_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.CloseTerraformState(a0, a1)
}

func (s *Stacks) FindStackConfigurationComponents(a0 context.Context, a1 *stacks.FindStackConfigurationComponents_Request) (*stacks.FindStackConfigurationComponents_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.FindStackConfigurationComponents(a0, a1)
}

func (s *Stacks) InspectExpressionResult(a0 context.Context, a1 *stacks.InspectExpressionResult_Request) (*stacks.InspectExpressionResult_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.InspectExpressionResult(a0, a1)
}

func (s *Stacks) ListResourceIdentities(a0 context.Context, a1 *stacks.ListResourceIdentities_Request) (*stacks.ListResourceIdentities_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.ListResourceIdentities(a0, a1)
}

func (s *Stacks) MigrateTerraformState(a0 *stacks.MigrateTerraformState_Request, a1 grpc.ServerStreamingServer[stacks.MigrateTerraformState_Event]) error {
	impl, err := s.realRPCServer()
	if err != nil {
		return err
	}
	return impl.MigrateTerraformState(a0, a1)
}

func (s *Stacks) OpenPlan(a0 grpc.ClientStreamingServer[stacks.OpenStackPlan_RequestItem, stacks.OpenStackPlan_Response]) error {
	impl, err := s.realRPCServer()
	if err != nil {
		return err
	}
	return impl.OpenPlan(a0)
}

func (s *Stacks) OpenStackConfiguration(a0 context.Context, a1 *stacks.OpenStackConfiguration_Request) (*stacks.OpenStackConfiguration_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.OpenStackConfiguration(a0, a1)
}

func (s *Stacks) OpenStackInspector(a0 context.Context, a1 *stacks.OpenStackInspector_Request) (*stacks.OpenStackInspector_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.OpenStackInspector(a0, a1)
}

func (s *Stacks) OpenState(a0 grpc.ClientStreamingServer[stacks.OpenStackState_RequestItem, stacks.OpenStackState_Response]) error {
	impl, err := s.realRPCServer()
	if err != nil {
		return err
	}
	return impl.OpenState(a0)
}

func (s *Stacks) OpenTerraformState(a0 context.Context, a1 *stacks.OpenTerraformState_Request) (*stacks.OpenTerraformState_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.OpenTerraformState(a0, a1)
}

func (s *Stacks) PlanStackChanges(a0 *stacks.PlanStackChanges_Request, a1 grpc.ServerStreamingServer[stacks.PlanStackChanges_Event]) error {
	impl, err := s.realRPCServer()
	if err != nil {
		return err
	}
	return impl.PlanStackChanges(a0, a1)
}

func (s *Stacks) ValidateStackConfiguration(a0 context.Context, a1 *stacks.ValidateStackConfiguration_Request) (*stacks.ValidateStackConfiguration_Response, error) {
	impl, err := s.realRPCServer()
	if err != nil {
		return nil, err
	}
	return impl.ValidateStackConfiguration(a0, a1)
}

func (s *Stacks) ActivateRPCServer(impl stacks.StacksServer) {
	s.mu.Lock()
	s.impl = impl
	s.mu.Unlock()
}

func (s *Stacks) realRPCServer() (stacks.StacksServer, error) {
	s.mu.RLock()
	impl := s.impl
	s.mu.RUnlock()
	if impl == nil {
		return nil, unavailableErr
	}
	return impl, nil
}
