Added /projects/name/access as REST endpoint. Implemented GET.
We currently use RPC to view and edit access for projects. In an effort to migrate to polygerrit this has to be ported to REST. While the current /access endpoint is purely intended for listing access rights for multiple (or a single) projects, what we want to accomplish here is to have an API in place to change the access rights for one project. As a first step I have implemented the /projects/name/access endpoint as a way of GETing access rights for a project. I'm currently writing logic to POST/change access rights under the same endpoint in a different change set. Having the GET implemented here is just a matter of consistency. Change-Id: I5cc621ba28dc14bea15ae8e7a78a5ad3d0846c43
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// 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.google.gerrit.extensions.api.access;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AccessSectionInfo {
|
||||
public Map<String, PermissionInfo> permissions;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// 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.google.gerrit.extensions.api.access;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PermissionInfo {
|
||||
public String label;
|
||||
public Boolean exclusive;
|
||||
public Map<String, PermissionRuleInfo> rules;
|
||||
|
||||
public PermissionInfo(String label, Boolean exclusive) {
|
||||
this.label = label;
|
||||
this.exclusive = exclusive;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// 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.google.gerrit.extensions.api.access;
|
||||
|
||||
public class PermissionRuleInfo {
|
||||
public enum Action {
|
||||
ALLOW,
|
||||
DENY,
|
||||
BLOCK,
|
||||
INTERACTIVE,
|
||||
BATCH
|
||||
}
|
||||
|
||||
public Action action;
|
||||
public Boolean force;
|
||||
public Integer min;
|
||||
public Integer max;
|
||||
|
||||
public PermissionRuleInfo(Action action, Boolean force) {
|
||||
this.action = action;
|
||||
this.force = force;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// 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.google.gerrit.extensions.api.access;
|
||||
|
||||
import com.google.gerrit.extensions.common.ProjectInfo;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ProjectAccessInfo {
|
||||
public String revision;
|
||||
public ProjectInfo inheritsFrom;
|
||||
public Map<String, AccessSectionInfo> local;
|
||||
public Boolean isOwner;
|
||||
public Set<String> ownerOf;
|
||||
public Boolean canUpload;
|
||||
public Boolean canAdd;
|
||||
public Boolean configVisible;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// 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.google.gerrit.extensions.api.projects;
|
||||
|
||||
import com.google.gerrit.extensions.api.access.ProjectAccessInfo;
|
||||
import com.google.gerrit.extensions.restapi.NotImplementedException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
|
||||
public interface AccessApi {
|
||||
ProjectAccessInfo get() throws RestApiException;
|
||||
|
||||
/**
|
||||
* A default implementation which allows source compatibility
|
||||
* when adding new methods to the interface.
|
||||
**/
|
||||
class NotImplemented implements AccessApi {
|
||||
@Override
|
||||
public ProjectAccessInfo get() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,12 @@
|
||||
|
||||
package com.google.gerrit.extensions.api.projects;
|
||||
|
||||
import com.google.gerrit.extensions.api.access.ProjectAccessInfo;
|
||||
import com.google.gerrit.extensions.common.ProjectInfo;
|
||||
import com.google.gerrit.extensions.restapi.NotImplementedException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface ProjectApi {
|
||||
@@ -28,6 +30,8 @@ public interface ProjectApi {
|
||||
String description() throws RestApiException;
|
||||
void description(PutDescriptionInput in) throws RestApiException;
|
||||
|
||||
ProjectAccessInfo access() throws RestApiException;
|
||||
|
||||
ListRefsRequest<BranchInfo> branches();
|
||||
ListRefsRequest<TagInfo> tags();
|
||||
|
||||
@@ -129,6 +133,11 @@ public interface ProjectApi {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectAccessInfo access() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void description(PutDescriptionInput in)
|
||||
throws RestApiException {
|
||||
|
||||
Reference in New Issue
Block a user