// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package identity

import (
	"context"

	"github.com/container-storage-interface/spec/lib/go/csi"
)

type Server struct {
	name    string
	version string

	// Embed for forward compatibility.
	csi.UnimplementedIdentityServer
}

// Server must implement the csi.IdentityServer interface.
var _ csi.IdentityServer = &Server{}

func New(name string, version string) *Server {
	return &Server{
		name:    name,
		version: version,
	}
}

func (ids *Server) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
	return &csi.GetPluginInfoResponse{
		Name:          ids.name,
		VendorVersion: ids.version,
	}, nil
}

func (ids *Server) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error) {
	return &csi.ProbeResponse{}, nil
}

func (ids *Server) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
	return &csi.GetPluginCapabilitiesResponse{
		Capabilities: []*csi.PluginCapability{
			{
				Type: &csi.PluginCapability_Service_{
					Service: &csi.PluginCapability_Service{
						Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
					},
				},
			},
			{
				Type: &csi.PluginCapability_Service_{
					Service: &csi.PluginCapability_Service{
						Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
					},
				},
			},
			// TODO(sc): volume expansion, and?
		},
	}, nil
}
