aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-api/src/main/java/ai/vespa/hosted/api/Deployment.java
blob: 77cc116b41391b81a62758e2a557558bb19c87c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.api;

import java.nio.file.Path;
import java.util.Optional;

/**
 * A deployment intended for hosted Vespa, containing an application package and some meta data.
 */
public class Deployment {

    private final Optional<String> version;
    private final Path applicationZip;
    private final boolean dryRun;

    private Deployment(Optional<String> version, Path applicationZip, boolean dryRun) {
        this.version = version;
        this.applicationZip = applicationZip;
        this.dryRun = dryRun;
    }

    /** Returns a deployment which will use the provided application package. */
    public static Deployment ofPackage(Path applicationZipFile) {
        return new Deployment(Optional.empty(), applicationZipFile, false);
    }

    /** Returns a copy of this which will have the specified Vespa version on its nodes. */
    public Deployment atVersion(String vespaVersion) {
        return new Deployment(Optional.of(vespaVersion), applicationZip, false);
    }

    /** Returns a copy of this which will do a dry-run deployment. */
    public Deployment withDryRun() {
        return new Deployment(version, applicationZip, true);
    }

    public Optional<String> version() { return version; }
    public Path applicationZip() { return applicationZip; }
    public boolean isDryRun() { return dryRun; }

}