/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.api.machine.server.spi;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.api.core.model.machine.MachineSource;
import org.eclipse.che.api.core.model.machine.Recipe;
import org.eclipse.che.api.core.util.LineConsumer;
import org.eclipse.che.api.machine.server.exception.InvalidRecipeException;
import org.eclipse.che.api.machine.server.exception.MachineException;
import org.eclipse.che.api.machine.server.exception.SnapshotException;
import org.eclipse.che.api.machine.server.exception.SourceNotFoundException;
import org.eclipse.che.api.machine.server.exception.UnsupportedRecipeException;
import java.util.Set;
/**
* Provides instances of {@link Instance} in implementation specific way.
*
* @author gazarenkov
* @author Alexander Garagatyi
*/
public interface InstanceProvider {
/**
* Gets type of instance that this provider supports. Must be unique per system.
*
* @return type of instance that this provider supports
*/
String getType();
/**
* Gets supported recipe types.
*
* @return supported recipe types
* @see Recipe#getType()
*/
Set<String> getRecipeTypes();
/**
* Creates instance from scratch or by reusing a previously one by using specified {@link org.eclipse.che.api.core.model.machine.MachineSource}
* data in {@link org.eclipse.che.api.core.model.machine.MachineConfig}.
*
* @param machine
* machine description
* @param creationLogsOutput
* output for instance creation logs
* @return newly created {@link Instance}
* @throws UnsupportedRecipeException
* if specified {@code recipe} is not supported
* @throws InvalidRecipeException
* if {@code recipe} is invalid
* @throws NotFoundException
* if instance described by {@link org.eclipse.che.api.core.model.machine.MachineSource} doesn't exists
* @throws MachineException
* if other error occurs
*/
Instance createInstance(Machine machine,
LineConsumer creationLogsOutput) throws UnsupportedRecipeException,
InvalidRecipeException,
SourceNotFoundException,
NotFoundException,
MachineException;
/**
* Removes snapshot of the instance in implementation specific way.
*
* @param machineSource
* contains implementation specific key of the snapshot of the instance that should be removed
* @throws SnapshotException
* if exception occurs on instance snapshot removal
*/
void removeInstanceSnapshot(MachineSource machineSource) throws SnapshotException;
}