1   /*
2    * Copyright 2017 LINE Corporation
3    *
4    * LINE Corporation licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package com.linecorp.centraldogma.internal.api.v1;
18  
19  import static com.linecorp.centraldogma.internal.Util.validateProjectName;
20  
21  import java.util.Set;
22  
23  import javax.annotation.Nullable;
24  
25  import com.fasterxml.jackson.annotation.JsonCreator;
26  import com.fasterxml.jackson.annotation.JsonProperty;
27  import com.google.common.base.MoreObjects;
28  import com.google.common.collect.ImmutableSet;
29  
30  /**
31   * A request to create a new project.
32   */
33  public class CreateProjectRequest {
34  
35      private final String name;
36      private final Set<String> owners;
37      private final Set<String> members;
38  
39      @JsonCreator
40      public CreateProjectRequest(@JsonProperty("name") String name,
41                                  @JsonProperty("owners") @Nullable Set<String> owners,
42                                  @JsonProperty("members") @Nullable Set<String> members) {
43          this.name = validateProjectName(name, "name");
44          this.owners = owners != null ? ImmutableSet.copyOf(owners) : ImmutableSet.of();
45          this.members = members != null ? ImmutableSet.copyOf(members) : ImmutableSet.of();
46      }
47  
48      @JsonProperty
49      public String name() {
50          return name;
51      }
52  
53      @JsonProperty
54      public Set<String> owners() {
55          return owners;
56      }
57  
58      @JsonProperty
59      public Set<String> members() {
60          return members;
61      }
62  
63      @Override
64      public String toString() {
65          return MoreObjects.toStringHelper(this)
66                            .add("name", name())
67                            .add("owners", owners())
68                            .add("members", members())
69                            .toString();
70      }
71  }