class LeaderController {

	private final String host;

	@Value("${spring.cloud.kubernetes.leader.role}")
	private String role;

	private Context context;

	public LeaderController() throws UnknownHostException {
		this.host = InetAddress.getLocalHost().getHostName();
	}

	/**
	 * Return a message whether this instance is a leader or not.
	 * @return info
	 */
	@GetMapping("/")
	public String getInfo() {
		if (this.context == null) {
			return String.format("I am '%s' but I am not a leader of the '%s'", this.host, this.role);
		}

		return String.format("I am '%s' and I am the leader of the '%s'", this.host, this.role);
	}

	/**
	 * PUT request to try and revoke a leadership of this instance. If the instance is not
	 * a leader, leadership cannot be revoked. Thus "HTTP Bad Request" response. If the
	 * instance is a leader, it must have a leadership context instance which can be used
	 * to give up the leadership.
	 * @return info about leadership
	 */
	@PutMapping("/")
	public ResponseEntity<String> revokeLeadership() {<FILL_FUNCTION_BODY>}

	/**
	 * Handle a notification that this instance has become a leader.
	 * @param event on granted event
	 */
	@EventListener
	public void handleEvent(OnGrantedEvent event) {
		System.out.println(String.format("'%s' leadership granted", event.getRole()));
		this.context = event.getContext();
	}

	/**
	 * Handle a notification that this instance's leadership has been revoked.
	 * @param event on revoked event
	 */
	@EventListener
	public void handleEvent(OnRevokedEvent event) {
		System.out.println(String.format("'%s' leadership revoked", event.getRole()));
		this.context = null;
	}

}

		if (this.context == null) {
			String message = String.format("Cannot revoke leadership because '%s' is not a leader", this.host);
			return ResponseEntity.badRequest().body(message);
		}

		this.context.yield();

		String message = String.format("Leadership revoked for '%s'", this.host);
		return ResponseEntity.ok(message);
	
<no_super_class>