public class QueryService extends Object
Constructor and Description |
---|
QueryService(DockerAccess docker)
Constructor which gets its dependencies as args)
|
Modifier and Type | Method and Description |
---|---|
Container |
getContainer(String containerIdOrName)
Get a container running for a given container name.
|
String |
getContainerName(String containerId)
Get name for single container when the id is given
|
List<Container> |
getContainersForImage(String image,
boolean all)
Get all containers which are build from an image.
|
String |
getImageId(String imageName)
Finds the id of an image.
|
Container |
getLatestContainerForImage(String image)
Get the id of the latest container started for an image
|
Container |
getMandatoryContainer(String containerIdOrName)
Get container by id
|
Network |
getNetworkByName(String networkName)
Get a network for a given network name.
|
Set<Network> |
getNetworks()
Get all networks.
|
boolean |
hasContainer(String containerName)
Check whether a container with the given name exists
|
boolean |
hasImage(String name)
Check whether the given Image is locally available.
|
boolean |
hasNetwork(String networkName)
Check whether a network with the given name exists
|
public QueryService(DockerAccess docker)
docker
- remote access to docker daemonpublic Container getMandatoryContainer(String containerIdOrName) throws DockerAccessException
containerIdOrName
- container id or nameDockerAccessException
- if an error occurs or no container with this id or name existspublic Container getContainer(String containerIdOrName) throws DockerAccessException
containerIdOrName
- name of container to lookupnull
if no container is available.DockerAccessException
- in case of an remote errorpublic Network getNetworkByName(String networkName) throws DockerAccessException
networkName
- name of network to lookupnull
if no network is available.DockerAccessException
- in case of an remote errorpublic Set<Network> getNetworks() throws DockerAccessException
null
if no network is available.DockerAccessException
- in case of an remote errorpublic String getContainerName(String containerId) throws DockerAccessException
containerId
- id of container to lookupDockerAccessException
- if access to the docker daemon failspublic List<Container> getContainersForImage(String image, boolean all) throws DockerAccessException
image
- for which its container are looked upall
- whether to fetch all containersContainer
objectsDockerAccessException
- if the request failspublic String getImageId(String imageName) throws DockerAccessException
imageName
- name of the image.DockerAccessException
- if the request failspublic Container getLatestContainerForImage(String image) throws DockerAccessException
image
- for which its container are looked upnull
if no container has been started for this image.DockerAccessException
- if the request failspublic boolean hasContainer(String containerName) throws DockerAccessException
containerName
- container nameDockerAccessException
- docker access exceptionpublic boolean hasNetwork(String networkName) throws DockerAccessException
networkName
- network nameDockerAccessException
- docker access exceptionpublic boolean hasImage(String name) throws DockerAccessException
name
- name of image to check, the image can contain a tag, otherwise 'latest' will be appendedDockerAccessException
- if the request failsCopyright © 2020. All rights reserved.