From e453a6e3fdb6f7bb929ba43030a27c7ca062535e Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Mon, 24 Apr 2017 16:19:23 +0200 Subject: SONAR-9091 add visibility flag to api/components/create --- .../sonarqube/ws/client/project/CreateRequest.java | 19 +++++++++++++++++++ sonar-ws/src/main/protobuf/ws-projects.proto | 1 + 2 files changed, 20 insertions(+) (limited to 'sonar-ws') diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java index 962e04f2150..8a03fff7c13 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/project/CreateRequest.java @@ -19,10 +19,14 @@ */ package org.sonarqube.ws.client.project; +import java.util.Optional; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Arrays.asList; + @Immutable public class CreateRequest { @@ -30,12 +34,15 @@ public class CreateRequest { private final String key; private final String name; private final String branch; + @CheckForNull + private final String visibility; private CreateRequest(Builder builder) { this.organization = builder.organization; this.key = builder.key; this.name = builder.name; this.branch = builder.branch; + this.visibility = builder.visibility; } @CheckForNull @@ -56,6 +63,10 @@ public class CreateRequest { return branch; } + public Optional getVisibility() { + return Optional.ofNullable(visibility); + } + public static Builder builder() { return new Builder(); } @@ -65,6 +76,8 @@ public class CreateRequest { private String key; private String name; private String branch; + @CheckForNull + private String visibility; private Builder() { } @@ -89,6 +102,12 @@ public class CreateRequest { return this; } + public Builder setVisibility(@Nullable String visibility) { + checkArgument(visibility == null || asList("private", "public").contains(visibility), "Unexpected visibility '" + visibility + "'"); + this.visibility = visibility; + return this; + } + public CreateRequest build() { return new CreateRequest(this); } diff --git a/sonar-ws/src/main/protobuf/ws-projects.proto b/sonar-ws/src/main/protobuf/ws-projects.proto index 86ed442a8d6..2836db8c48c 100644 --- a/sonar-ws/src/main/protobuf/ws-projects.proto +++ b/sonar-ws/src/main/protobuf/ws-projects.proto @@ -54,6 +54,7 @@ message CreateWsResponse { optional string key = 1; optional string name = 2; optional string qualifier = 3; + optional string visibility = 4; } } -- cgit v1.2.3