package com.realnet.api_registery.Controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.realnet.api_registery.Entity.Token_registery;
import com.realnet.api_registery.Services.GeneratetokenService;

@RestController
@RequestMapping(value = "/apiregistery")
public class GeneratetokenController {

	@Autowired
	private GeneratetokenService generatetokenService;

	@PostMapping("/generateToken")
	public Token_registery generatetoken(@RequestBody Token_registery reg) throws JsonProcessingException {

		String token_name = reg.getToken_name();
		Token_registery token = generatetokenService.generatetoken(token_name);

		return token;

	}

	@GetMapping("/getall")
	public List<Token_registery> getall() {

		List<Token_registery> getall = generatetokenService.getall();

		return getall;

	}

	@DeleteMapping("/delete/{id}")
	public void delete(@PathVariable Integer id) {
		generatetokenService.delete(id);

	}

}
