Skip to content
This repository was archived by the owner on Mar 21, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*-
* -\-\-
* docker-client
* --
* Copyright (C) 2016 Spotify AB
* --
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -/-/-
*/

package com.spotify.docker.client.messages;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import java.util.List;
import java.util.Map;

import javax.annotation.Nullable;

@AutoValue
@JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE)
public abstract class DeviceRequest {

@Nullable
@JsonProperty("Driver")
public abstract String driver();

@Nullable
@JsonProperty("Count")
public abstract Integer count();

@Nullable
@JsonProperty("DeviceIDs")
public abstract ImmutableList<String> deviceIDs();

@Nullable
@JsonProperty("Capabilities")
public abstract ImmutableList<List<String>> capabilities();

@Nullable
@JsonProperty("Options")
public abstract ImmutableMap<String, String> options();

@AutoValue.Builder
public abstract static class Builder {

public abstract Builder driver(String driver);

public abstract Builder count(Integer count);

public abstract Builder deviceIDs(List<String> deviceIDs);

public abstract Builder capabilities(List<List<String>> capabilities);

public abstract Builder options(Map<String, String> options);

public abstract DeviceRequest build();
}

public static DeviceRequest.Builder builder() {
return new AutoValue_DeviceRequest.Builder();
}

@JsonCreator
static DeviceRequest create(
@JsonProperty("Driver") final String driver,
@JsonProperty("Count") final Integer count,
@JsonProperty("DeviceIDs") final List<String> deviceIDs,
@JsonProperty("Capabilities") final List<List<String>> capabilities,
@JsonProperty("Options") final Map<String, String> options) {
return builder()
.driver(driver)
.count(count)
.deviceIDs(deviceIDs)
.capabilities(capabilities)
.options(options)
.build();
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/spotify/docker/client/messages/HostConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public abstract class HostConfig {
@JsonProperty("Devices")
public abstract ImmutableList<Device> devices();

@Nullable
@JsonProperty("DeviceRequests")
public abstract ImmutableList<DeviceRequest> deviceRequests();

@Nullable
@JsonProperty("Memory")
public abstract Long memory();
Expand Down Expand Up @@ -279,6 +283,7 @@ static HostConfig create(
@JsonProperty("NetworkMode") final String networkMode,
@JsonProperty("SecurityOpt") final List<String> securityOpt,
@JsonProperty("Devices") final List<Device> devices,
@JsonProperty("DeviceRequests") final List<DeviceRequest> deviceRequests,
@JsonProperty("Memory") final Long memory,
@JsonProperty("MemorySwap") final Long memorySwap,
@JsonProperty("MemorySwappiness") final Integer memorySwappiness,
Expand Down Expand Up @@ -330,6 +335,7 @@ static HostConfig create(
.networkMode(networkMode)
.securityOpt(securityOpt)
.devices(devices)
.deviceRequests(deviceRequests)
.memory(memory)
.memorySwap(memorySwap)
.memorySwappiness(memorySwappiness)
Expand Down Expand Up @@ -581,6 +587,10 @@ private static <T> ImmutableList<T> copyWithoutDuplicates(final List<T> input) {

public abstract Builder devices(Device... devices);

public abstract Builder deviceRequests(List<DeviceRequest> deviceRequests);

public abstract Builder deviceRequests(DeviceRequest... deviceRequests);

public abstract Builder memory(Long memory);

public abstract Builder memorySwap(Long memorySwap);
Expand Down