// Code generated by sdkgen-v2. DO NOT EDIT.
package dnssdk

import (
	"context"

	access "github.com/yandex-cloud/go-genproto/yandex/cloud/access"
	dns "github.com/yandex-cloud/go-genproto/yandex/cloud/dns/v1"
	operation "github.com/yandex-cloud/go-genproto/yandex/cloud/operation"
	sdkop "github.com/yandex-cloud/go-sdk/v2/pkg/operation"
	"github.com/yandex-cloud/go-sdk/v2/pkg/transport"
	"google.golang.org/grpc"
	proto "google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/reflect/protoreflect"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
)

// DnsFirewallClient provides methods for managing DnsFirewall resources of Yandex.Cloud Dns.
type DnsFirewallClient interface {
	DnsFirewallClientIterator
	Get(context.Context, *dns.GetDnsFirewallRequest, ...grpc.CallOption) (*dns.DnsFirewall, error)
	List(context.Context, *dns.ListDnsFirewallsRequest, ...grpc.CallOption) (*dns.ListDnsFirewallsResponse, error)
	Create(context.Context, *dns.CreateDnsFirewallRequest, ...grpc.CallOption) (*DnsFirewallCreateOperation, error)
	Update(context.Context, *dns.UpdateDnsFirewallRequest, ...grpc.CallOption) (*DnsFirewallUpdateOperation, error)
	Move(context.Context, *dns.MoveDnsFirewallRequest, ...grpc.CallOption) (*DnsFirewallMoveOperation, error)
	Delete(context.Context, *dns.DeleteDnsFirewallRequest, ...grpc.CallOption) (*DnsFirewallDeleteOperation, error)
	ListOperations(context.Context, *dns.ListDnsFirewallOperationsRequest, ...grpc.CallOption) (*dns.ListDnsFirewallOperationsResponse, error)
	ListAccessBindings(context.Context, *access.ListAccessBindingsRequest, ...grpc.CallOption) (*access.ListAccessBindingsResponse, error)
	SetAccessBindings(context.Context, *access.SetAccessBindingsRequest, ...grpc.CallOption) (*DnsFirewallSetAccessBindingsOperation, error)
	UpdateAccessBindings(context.Context, *access.UpdateAccessBindingsRequest, ...grpc.CallOption) (*DnsFirewallUpdateAccessBindingsOperation, error)
}

var _ DnsFirewallClient = dnsFirewallClient{}

type dnsFirewallClient struct {
	connector transport.Connector
}

// NewDnsFirewallClient returns DnsFirewallClient implementation.
func NewDnsFirewallClient(connector transport.Connector) DnsFirewallClient {
	return dnsFirewallClient{connector}
}

// Get is an operation of Yandex.Cloud Dns DnsFirewall service.
func (c dnsFirewallClient) Get(ctx context.Context, in *dns.GetDnsFirewallRequest, opts ...grpc.CallOption) (*dns.DnsFirewall, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallGet, opts...)
	if err != nil {
		return nil, err
	}
	return dns.NewDnsFirewallServiceClient(connection).Get(ctx, in, opts...)
}

// List is an operation of Yandex.Cloud Dns DnsFirewall service.
func (c dnsFirewallClient) List(ctx context.Context, in *dns.ListDnsFirewallsRequest, opts ...grpc.CallOption) (*dns.ListDnsFirewallsResponse, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallList, opts...)
	if err != nil {
		return nil, err
	}
	return dns.NewDnsFirewallServiceClient(connection).List(ctx, in, opts...)
}

// DnsFirewallCreateOperation is used to monitor the state of Create operations.
type DnsFirewallCreateOperation struct {
	sdkop.Operation
}

// Metadata retrieves the operation metadata.
func (o *DnsFirewallCreateOperation) Metadata() *dns.CreateDnsFirewallMetadata {
	return o.Operation.Metadata().(*dns.CreateDnsFirewallMetadata)
}

// Response retrieves the operation response.
func (o *DnsFirewallCreateOperation) Response() *dns.DnsFirewall {
	return o.Operation.Response().(*dns.DnsFirewall)
}

// Wait polls the operation until it's done.
func (o *DnsFirewallCreateOperation) Wait(ctx context.Context, opts ...grpc.CallOption) (*dns.DnsFirewall, error) {
	abstract, err := o.Operation.Wait(ctx, opts...)
	response, _ := abstract.(*dns.DnsFirewall)
	return response, err
}

// WaitInterval polls the operation until it's done with custom interval.
func (o *DnsFirewallCreateOperation) WaitInterval(ctx context.Context, pollInterval sdkop.PollIntervalFunc, opts ...grpc.CallOption) (*dns.DnsFirewall, error) {
	abstract, err := o.Operation.WaitInterval(ctx, pollInterval, opts...)
	response, _ := abstract.(*dns.DnsFirewall)
	return response, err
}

// Create is an operation of Yandex.Cloud Dns DnsFirewall service.
// It returns an object which should be used to monitor the operation state.
func (c dnsFirewallClient) Create(ctx context.Context, in *dns.CreateDnsFirewallRequest, opts ...grpc.CallOption) (*DnsFirewallCreateOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallCreate, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsFirewallServiceClient(connection).Create(ctx, in, opts...)
	if err != nil {
		return nil, err
	}
	op, err := sdkop.NewOperation(pb, &sdkop.Concretization{
		Poll: c.pollOperation,
		GetResourceID: func(metadata proto.Message) string {
			return metadata.(*dns.CreateDnsFirewallMetadata).GetDnsFirewallId()
		},
		MetadataType: (*dns.CreateDnsFirewallMetadata)(nil),
		ResponseType: (*dns.DnsFirewall)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsFirewallCreateOperation{*op}, nil
}

// DnsFirewallUpdateOperation is used to monitor the state of Update operations.
type DnsFirewallUpdateOperation struct {
	sdkop.Operation
}

// Metadata retrieves the operation metadata.
func (o *DnsFirewallUpdateOperation) Metadata() *dns.UpdateDnsFirewallMetadata {
	return o.Operation.Metadata().(*dns.UpdateDnsFirewallMetadata)
}

// Response retrieves the operation response.
func (o *DnsFirewallUpdateOperation) Response() *dns.DnsFirewall {
	return o.Operation.Response().(*dns.DnsFirewall)
}

// Wait polls the operation until it's done.
func (o *DnsFirewallUpdateOperation) Wait(ctx context.Context, opts ...grpc.CallOption) (*dns.DnsFirewall, error) {
	abstract, err := o.Operation.Wait(ctx, opts...)
	response, _ := abstract.(*dns.DnsFirewall)
	return response, err
}

// WaitInterval polls the operation until it's done with custom interval.
func (o *DnsFirewallUpdateOperation) WaitInterval(ctx context.Context, pollInterval sdkop.PollIntervalFunc, opts ...grpc.CallOption) (*dns.DnsFirewall, error) {
	abstract, err := o.Operation.WaitInterval(ctx, pollInterval, opts...)
	response, _ := abstract.(*dns.DnsFirewall)
	return response, err
}

// Update is an operation of Yandex.Cloud Dns DnsFirewall service.
// It returns an object which should be used to monitor the operation state.
func (c dnsFirewallClient) Update(ctx context.Context, in *dns.UpdateDnsFirewallRequest, opts ...grpc.CallOption) (*DnsFirewallUpdateOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallUpdate, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsFirewallServiceClient(connection).Update(ctx, in, opts...)
	if err != nil {
		return nil, err
	}
	op, err := sdkop.NewOperation(pb, &sdkop.Concretization{
		Poll: c.pollOperation,
		GetResourceID: func(metadata proto.Message) string {
			return metadata.(*dns.UpdateDnsFirewallMetadata).GetDnsFirewallId()
		},
		MetadataType: (*dns.UpdateDnsFirewallMetadata)(nil),
		ResponseType: (*dns.DnsFirewall)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsFirewallUpdateOperation{*op}, nil
}

// DnsFirewallMoveOperation is used to monitor the state of Move operations.
type DnsFirewallMoveOperation struct {
	sdkop.Operation
}

// Metadata retrieves the operation metadata.
func (o *DnsFirewallMoveOperation) Metadata() *dns.MoveDnsFirewallMetadata {
	return o.Operation.Metadata().(*dns.MoveDnsFirewallMetadata)
}

// Response retrieves the operation response.
func (o *DnsFirewallMoveOperation) Response() *dns.DnsFirewall {
	return o.Operation.Response().(*dns.DnsFirewall)
}

// Wait polls the operation until it's done.
func (o *DnsFirewallMoveOperation) Wait(ctx context.Context, opts ...grpc.CallOption) (*dns.DnsFirewall, error) {
	abstract, err := o.Operation.Wait(ctx, opts...)
	response, _ := abstract.(*dns.DnsFirewall)
	return response, err
}

// WaitInterval polls the operation until it's done with custom interval.
func (o *DnsFirewallMoveOperation) WaitInterval(ctx context.Context, pollInterval sdkop.PollIntervalFunc, opts ...grpc.CallOption) (*dns.DnsFirewall, error) {
	abstract, err := o.Operation.WaitInterval(ctx, pollInterval, opts...)
	response, _ := abstract.(*dns.DnsFirewall)
	return response, err
}

// Move is an operation of Yandex.Cloud Dns DnsFirewall service.
// It returns an object which should be used to monitor the operation state.
func (c dnsFirewallClient) Move(ctx context.Context, in *dns.MoveDnsFirewallRequest, opts ...grpc.CallOption) (*DnsFirewallMoveOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallMove, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsFirewallServiceClient(connection).Move(ctx, in, opts...)
	if err != nil {
		return nil, err
	}
	op, err := sdkop.NewOperation(pb, &sdkop.Concretization{
		Poll: c.pollOperation,
		GetResourceID: func(metadata proto.Message) string {
			return metadata.(*dns.MoveDnsFirewallMetadata).GetDnsFirewallId()
		},
		MetadataType: (*dns.MoveDnsFirewallMetadata)(nil),
		ResponseType: (*dns.DnsFirewall)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsFirewallMoveOperation{*op}, nil
}

// DnsFirewallDeleteOperation is used to monitor the state of Delete operations.
type DnsFirewallDeleteOperation struct {
	sdkop.Operation
}

// Metadata retrieves the operation metadata.
func (o *DnsFirewallDeleteOperation) Metadata() *dns.DeleteDnsFirewallMetadata {
	return o.Operation.Metadata().(*dns.DeleteDnsFirewallMetadata)
}

// Response retrieves the operation response.
func (o *DnsFirewallDeleteOperation) Response() *emptypb.Empty {
	return o.Operation.Response().(*emptypb.Empty)
}

// Wait polls the operation until it's done.
func (o *DnsFirewallDeleteOperation) Wait(ctx context.Context, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	abstract, err := o.Operation.Wait(ctx, opts...)
	response, _ := abstract.(*emptypb.Empty)
	return response, err
}

// WaitInterval polls the operation until it's done with custom interval.
func (o *DnsFirewallDeleteOperation) WaitInterval(ctx context.Context, pollInterval sdkop.PollIntervalFunc, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	abstract, err := o.Operation.WaitInterval(ctx, pollInterval, opts...)
	response, _ := abstract.(*emptypb.Empty)
	return response, err
}

// Delete is an operation of Yandex.Cloud Dns DnsFirewall service.
// It returns an object which should be used to monitor the operation state.
func (c dnsFirewallClient) Delete(ctx context.Context, in *dns.DeleteDnsFirewallRequest, opts ...grpc.CallOption) (*DnsFirewallDeleteOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallDelete, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsFirewallServiceClient(connection).Delete(ctx, in, opts...)
	if err != nil {
		return nil, err
	}
	op, err := sdkop.NewOperation(pb, &sdkop.Concretization{
		Poll: c.pollOperation,
		GetResourceID: func(metadata proto.Message) string {
			return metadata.(*dns.DeleteDnsFirewallMetadata).GetDnsFirewallId()
		},
		MetadataType: (*dns.DeleteDnsFirewallMetadata)(nil),
		ResponseType: (*emptypb.Empty)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsFirewallDeleteOperation{*op}, nil
}

// ListOperations is an operation of Yandex.Cloud Dns DnsFirewall service.
func (c dnsFirewallClient) ListOperations(ctx context.Context, in *dns.ListDnsFirewallOperationsRequest, opts ...grpc.CallOption) (*dns.ListDnsFirewallOperationsResponse, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallListOperations, opts...)
	if err != nil {
		return nil, err
	}
	return dns.NewDnsFirewallServiceClient(connection).ListOperations(ctx, in, opts...)
}

// ListAccessBindings is an operation of Yandex.Cloud Dns DnsFirewall service.
func (c dnsFirewallClient) ListAccessBindings(ctx context.Context, in *access.ListAccessBindingsRequest, opts ...grpc.CallOption) (*access.ListAccessBindingsResponse, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallListAccessBindings, opts...)
	if err != nil {
		return nil, err
	}
	return dns.NewDnsFirewallServiceClient(connection).ListAccessBindings(ctx, in, opts...)
}

// DnsFirewallSetAccessBindingsOperation is used to monitor the state of SetAccessBindings operations.
type DnsFirewallSetAccessBindingsOperation struct {
	sdkop.Operation
}

// Metadata retrieves the operation metadata.
func (o *DnsFirewallSetAccessBindingsOperation) Metadata() *access.SetAccessBindingsMetadata {
	return o.Operation.Metadata().(*access.SetAccessBindingsMetadata)
}

// Response retrieves the operation response.
func (o *DnsFirewallSetAccessBindingsOperation) Response() *emptypb.Empty {
	return o.Operation.Response().(*emptypb.Empty)
}

// Wait polls the operation until it's done.
func (o *DnsFirewallSetAccessBindingsOperation) Wait(ctx context.Context, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	abstract, err := o.Operation.Wait(ctx, opts...)
	response, _ := abstract.(*emptypb.Empty)
	return response, err
}

// WaitInterval polls the operation until it's done with custom interval.
func (o *DnsFirewallSetAccessBindingsOperation) WaitInterval(ctx context.Context, pollInterval sdkop.PollIntervalFunc, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	abstract, err := o.Operation.WaitInterval(ctx, pollInterval, opts...)
	response, _ := abstract.(*emptypb.Empty)
	return response, err
}

// SetAccessBindings is an operation of Yandex.Cloud Dns DnsFirewall service.
// It returns an object which should be used to monitor the operation state.
func (c dnsFirewallClient) SetAccessBindings(ctx context.Context, in *access.SetAccessBindingsRequest, opts ...grpc.CallOption) (*DnsFirewallSetAccessBindingsOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallSetAccessBindings, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsFirewallServiceClient(connection).SetAccessBindings(ctx, in, opts...)
	if err != nil {
		return nil, err
	}
	op, err := sdkop.NewOperation(pb, &sdkop.Concretization{
		Poll:         c.pollOperation,
		MetadataType: (*access.SetAccessBindingsMetadata)(nil),
		ResponseType: (*emptypb.Empty)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsFirewallSetAccessBindingsOperation{*op}, nil
}

// DnsFirewallUpdateAccessBindingsOperation is used to monitor the state of UpdateAccessBindings operations.
type DnsFirewallUpdateAccessBindingsOperation struct {
	sdkop.Operation
}

// Metadata retrieves the operation metadata.
func (o *DnsFirewallUpdateAccessBindingsOperation) Metadata() *access.UpdateAccessBindingsMetadata {
	return o.Operation.Metadata().(*access.UpdateAccessBindingsMetadata)
}

// Response retrieves the operation response.
func (o *DnsFirewallUpdateAccessBindingsOperation) Response() *emptypb.Empty {
	return o.Operation.Response().(*emptypb.Empty)
}

// Wait polls the operation until it's done.
func (o *DnsFirewallUpdateAccessBindingsOperation) Wait(ctx context.Context, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	abstract, err := o.Operation.Wait(ctx, opts...)
	response, _ := abstract.(*emptypb.Empty)
	return response, err
}

// WaitInterval polls the operation until it's done with custom interval.
func (o *DnsFirewallUpdateAccessBindingsOperation) WaitInterval(ctx context.Context, pollInterval sdkop.PollIntervalFunc, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	abstract, err := o.Operation.WaitInterval(ctx, pollInterval, opts...)
	response, _ := abstract.(*emptypb.Empty)
	return response, err
}

// UpdateAccessBindings is an operation of Yandex.Cloud Dns DnsFirewall service.
// It returns an object which should be used to monitor the operation state.
func (c dnsFirewallClient) UpdateAccessBindings(ctx context.Context, in *access.UpdateAccessBindingsRequest, opts ...grpc.CallOption) (*DnsFirewallUpdateAccessBindingsOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallUpdateAccessBindings, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsFirewallServiceClient(connection).UpdateAccessBindings(ctx, in, opts...)
	if err != nil {
		return nil, err
	}
	op, err := sdkop.NewOperation(pb, &sdkop.Concretization{
		Poll:         c.pollOperation,
		MetadataType: (*access.UpdateAccessBindingsMetadata)(nil),
		ResponseType: (*emptypb.Empty)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsFirewallUpdateAccessBindingsOperation{*op}, nil
}

// pollOperation returns the current state of the polled operation.
func (c dnsFirewallClient) pollOperation(ctx context.Context, operationId string, opts ...grpc.CallOption) (sdkop.YCOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsFirewallOperationPoller, opts...)
	if err != nil {
		return nil, err
	}
	return operation.NewOperationServiceClient(connection).Get(ctx, &operation.GetOperationRequest{OperationId: operationId}, opts...)
}

var (
	DnsFirewallGet                  = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.Get")
	DnsFirewallList                 = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.List")
	DnsFirewallCreate               = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.Create")
	DnsFirewallUpdate               = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.Update")
	DnsFirewallMove                 = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.Move")
	DnsFirewallDelete               = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.Delete")
	DnsFirewallListOperations       = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.ListOperations")
	DnsFirewallListAccessBindings   = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.ListAccessBindings")
	DnsFirewallSetAccessBindings    = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.SetAccessBindings")
	DnsFirewallUpdateAccessBindings = protoreflect.FullName("yandex.cloud.dns.v1.DnsFirewallService.UpdateAccessBindings")
	DnsFirewallOperationPoller      = protoreflect.FullName("yandex.cloud.operation.OperationService.Get")
)
