// 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"
)

// DnsInboundEndpointClient provides methods for managing DnsInboundEndpoint resources of Yandex.Cloud Dns.
type DnsInboundEndpointClient interface {
	DnsInboundEndpointClientIterator
	Get(context.Context, *dns.GetDnsInboundEndpointRequest, ...grpc.CallOption) (*dns.DnsInboundEndpoint, error)
	List(context.Context, *dns.ListDnsInboundEndpointsRequest, ...grpc.CallOption) (*dns.ListDnsInboundEndpointsResponse, error)
	Create(context.Context, *dns.CreateDnsInboundEndpointRequest, ...grpc.CallOption) (*DnsInboundEndpointCreateOperation, error)
	Update(context.Context, *dns.UpdateDnsInboundEndpointRequest, ...grpc.CallOption) (*DnsInboundEndpointUpdateOperation, error)
	Delete(context.Context, *dns.DeleteDnsInboundEndpointRequest, ...grpc.CallOption) (*DnsInboundEndpointDeleteOperation, error)
	ListOperations(context.Context, *dns.ListDnsInboundEndpointOperationsRequest, ...grpc.CallOption) (*dns.ListDnsInboundEndpointOperationsResponse, error)
	ListAccessBindings(context.Context, *access.ListAccessBindingsRequest, ...grpc.CallOption) (*access.ListAccessBindingsResponse, error)
	SetAccessBindings(context.Context, *access.SetAccessBindingsRequest, ...grpc.CallOption) (*DnsInboundEndpointSetAccessBindingsOperation, error)
	UpdateAccessBindings(context.Context, *access.UpdateAccessBindingsRequest, ...grpc.CallOption) (*DnsInboundEndpointUpdateAccessBindingsOperation, error)
}

var _ DnsInboundEndpointClient = dnsInboundEndpointClient{}

type dnsInboundEndpointClient struct {
	connector transport.Connector
}

// NewDnsInboundEndpointClient returns DnsInboundEndpointClient implementation.
func NewDnsInboundEndpointClient(connector transport.Connector) DnsInboundEndpointClient {
	return dnsInboundEndpointClient{connector}
}

// Get is an operation of Yandex.Cloud Dns DnsInboundEndpoint service.
func (c dnsInboundEndpointClient) Get(ctx context.Context, in *dns.GetDnsInboundEndpointRequest, opts ...grpc.CallOption) (*dns.DnsInboundEndpoint, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointGet, opts...)
	if err != nil {
		return nil, err
	}
	return dns.NewDnsInboundEndpointServiceClient(connection).Get(ctx, in, opts...)
}

// List is an operation of Yandex.Cloud Dns DnsInboundEndpoint service.
func (c dnsInboundEndpointClient) List(ctx context.Context, in *dns.ListDnsInboundEndpointsRequest, opts ...grpc.CallOption) (*dns.ListDnsInboundEndpointsResponse, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointList, opts...)
	if err != nil {
		return nil, err
	}
	return dns.NewDnsInboundEndpointServiceClient(connection).List(ctx, in, opts...)
}

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

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

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

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

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

// Create is an operation of Yandex.Cloud Dns DnsInboundEndpoint service.
// It returns an object which should be used to monitor the operation state.
func (c dnsInboundEndpointClient) Create(ctx context.Context, in *dns.CreateDnsInboundEndpointRequest, opts ...grpc.CallOption) (*DnsInboundEndpointCreateOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointCreate, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsInboundEndpointServiceClient(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.CreateDnsInboundEndpointMetadata).GetDnsInboundEndpointId()
		},
		MetadataType: (*dns.CreateDnsInboundEndpointMetadata)(nil),
		ResponseType: (*dns.DnsInboundEndpoint)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsInboundEndpointCreateOperation{*op}, nil
}

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

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

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

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

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

// Update is an operation of Yandex.Cloud Dns DnsInboundEndpoint service.
// It returns an object which should be used to monitor the operation state.
func (c dnsInboundEndpointClient) Update(ctx context.Context, in *dns.UpdateDnsInboundEndpointRequest, opts ...grpc.CallOption) (*DnsInboundEndpointUpdateOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointUpdate, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsInboundEndpointServiceClient(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.UpdateDnsInboundEndpointMetadata).GetDnsInboundEndpointId()
		},
		MetadataType: (*dns.UpdateDnsInboundEndpointMetadata)(nil),
		ResponseType: (*dns.DnsInboundEndpoint)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsInboundEndpointUpdateOperation{*op}, nil
}

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

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

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

// Wait polls the operation until it's done.
func (o *DnsInboundEndpointDeleteOperation) 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 *DnsInboundEndpointDeleteOperation) 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 DnsInboundEndpoint service.
// It returns an object which should be used to monitor the operation state.
func (c dnsInboundEndpointClient) Delete(ctx context.Context, in *dns.DeleteDnsInboundEndpointRequest, opts ...grpc.CallOption) (*DnsInboundEndpointDeleteOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointDelete, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsInboundEndpointServiceClient(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.DeleteDnsInboundEndpointMetadata).GetDnsInboundEndpointId()
		},
		MetadataType: (*dns.DeleteDnsInboundEndpointMetadata)(nil),
		ResponseType: (*emptypb.Empty)(nil),
	})
	if err != nil {
		return nil, err
	}
	return &DnsInboundEndpointDeleteOperation{*op}, nil
}

// ListOperations is an operation of Yandex.Cloud Dns DnsInboundEndpoint service.
func (c dnsInboundEndpointClient) ListOperations(ctx context.Context, in *dns.ListDnsInboundEndpointOperationsRequest, opts ...grpc.CallOption) (*dns.ListDnsInboundEndpointOperationsResponse, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointListOperations, opts...)
	if err != nil {
		return nil, err
	}
	return dns.NewDnsInboundEndpointServiceClient(connection).ListOperations(ctx, in, opts...)
}

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

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

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

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

// Wait polls the operation until it's done.
func (o *DnsInboundEndpointSetAccessBindingsOperation) 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 *DnsInboundEndpointSetAccessBindingsOperation) 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 DnsInboundEndpoint service.
// It returns an object which should be used to monitor the operation state.
func (c dnsInboundEndpointClient) SetAccessBindings(ctx context.Context, in *access.SetAccessBindingsRequest, opts ...grpc.CallOption) (*DnsInboundEndpointSetAccessBindingsOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointSetAccessBindings, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsInboundEndpointServiceClient(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 &DnsInboundEndpointSetAccessBindingsOperation{*op}, nil
}

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

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

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

// Wait polls the operation until it's done.
func (o *DnsInboundEndpointUpdateAccessBindingsOperation) 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 *DnsInboundEndpointUpdateAccessBindingsOperation) 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 DnsInboundEndpoint service.
// It returns an object which should be used to monitor the operation state.
func (c dnsInboundEndpointClient) UpdateAccessBindings(ctx context.Context, in *access.UpdateAccessBindingsRequest, opts ...grpc.CallOption) (*DnsInboundEndpointUpdateAccessBindingsOperation, error) {
	connection, err := c.connector.GetConnection(ctx, DnsInboundEndpointUpdateAccessBindings, opts...)
	if err != nil {
		return nil, err
	}
	pb, err := dns.NewDnsInboundEndpointServiceClient(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 &DnsInboundEndpointUpdateAccessBindingsOperation{*op}, nil
}

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

var (
	DnsInboundEndpointGet                  = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.Get")
	DnsInboundEndpointList                 = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.List")
	DnsInboundEndpointCreate               = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.Create")
	DnsInboundEndpointUpdate               = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.Update")
	DnsInboundEndpointDelete               = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.Delete")
	DnsInboundEndpointListOperations       = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.ListOperations")
	DnsInboundEndpointListAccessBindings   = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.ListAccessBindings")
	DnsInboundEndpointSetAccessBindings    = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.SetAccessBindings")
	DnsInboundEndpointUpdateAccessBindings = protoreflect.FullName("yandex.cloud.dns.v1.DnsInboundEndpointService.UpdateAccessBindings")
	DnsInboundEndpointOperationPoller      = protoreflect.FullName("yandex.cloud.operation.OperationService.Get")
)
