Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from Nike-Inc/feature/meta_data_endpoint
Browse files Browse the repository at this point in the history
Add new metadata endpoint
  • Loading branch information
fieldju authored Jan 6, 2017
2 parents 632cb8a + af37054 commit 9b2528a
Show file tree
Hide file tree
Showing 17 changed files with 1,032 additions and 119 deletions.
77 changes: 77 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,4 +474,81 @@ Returns basic stats about each safe deposit box (name, owner, last updated ts).
}
],
"safe_deposit_box_total": 2
}

# Group Metadata

## SDB Metadata [/v1/metadata?limit={limit}&offset={offset}]

### Get metadata [GET]

Returns pageable metadata for all SDBs
You can use has_next and next_offset from the response to paginate through all records

+ Parameters
+ limit (number) - OPTIONAL: The number of records to include in the metadata result. Defaults to 100
+ offset (number) - OPTIONAL: The offset to use when paginating records. Defaults to 0

+ Response 200 (application/json)

+ Headers

X-Vault-Token: 7f6808f1-ede3-2177-aa9d-45f507391310

+ Body

{
"has_next": false,
"next_offset": 0,
"limit": 10,
"offset": 0,
"sdb_count_in_result": 3,
"total_sdbcount": 3,
"safe_deposit_box_meta_data": [
{
"name": "dev demo",
"path": "app/dev-demo/",
"category": "Applications",
"owner": "Lst-Squad.Carebears",
"description": "test",
"created_ts": "2017-01-04T23:18:40-08:00",
"created_by": "[email protected]",
"last_updated_ts": "2017-01-04T23:18:40-08:00",
"last_updated_by": "[email protected]",
"user_group_permissions": {
"Application.FOO.User": "read"
},
"iam_role_permissions": {
"arn:aws:iam::265866363820:role/asdf": "write"
}
},
{
"name": "nike dev foo bar",
"path": "app/nike-dev-foo-bar/",
"category": "Applications",
"owner": "Lst-Squad.Carebears",
"description": "adsfasdfadsfasdf",
"created_ts": "2017-01-04T23:19:03-08:00",
"created_by": "[email protected]",
"last_updated_ts": "2017-01-04T23:19:03-08:00",
"last_updated_by": "[email protected]",
"user_group_permissions": {
"Lst-FOO-bar": "read"
},
"iam_role_permissions": {}
},
{
"name": "IaM W d WASD",
"path": "shared/iam-w-d-wasd/",
"category": "Shared",
"owner": "Lst-Squad.Carebears",
"description": "CAREBERS",
"created_ts": "2017-01-04T23:19:19-08:00",
"created_by": "[email protected]",
"last_updated_ts": "2017-01-04T23:19:19-08:00",
"last_updated_by": "[email protected]",
"user_group_permissions": {},
"iam_role_permissions": {}
}
]
}
8 changes: 6 additions & 2 deletions src/main/java/com/nike/cerberus/dao/SafeDepositBoxDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ public List<SafeDepositBoxRecord> getUserAssociatedSafeDepositBoxes(final Set<St
return safeDepositBoxMapper.getUserAssociatedSafeDepositBoxes(userGroups);
}

public List<SafeDepositBoxRecord> getSafeDepositBoxes() {
return safeDepositBoxMapper.getSafeDepositBoxes();
public List<SafeDepositBoxRecord> getSafeDepositBoxes(final int limit, final int offset) {
return safeDepositBoxMapper.getSafeDepositBoxes(limit, offset);
}

public Integer getSafeDepositBoxCount() {
return safeDepositBoxMapper.count();
}

public Optional<SafeDepositBoxRecord> getSafeDepositBox(final String id) {
Expand Down
124 changes: 124 additions & 0 deletions src/main/java/com/nike/cerberus/domain/SDBMetaData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* 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.nike.cerberus.domain;

import java.time.OffsetDateTime;
import java.util.Date;
import java.util.Map;

public class SDBMetaData {

private String name;
private String path;
private String category;
private String owner;
private String description;
private OffsetDateTime createdTs;
private String createdBy;
private OffsetDateTime lastUpdatedTs;
private String lastUpdatedBy;
private Map<String, String> userGroupPermissions;
private Map<String, String> iamRolePermissions;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public String getCategory() {
return category;
}

public void setCategory(String category) {
this.category = category;
}

public String getOwner() {
return owner;
}

public void setOwner(String owner) {
this.owner = owner;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public OffsetDateTime getCreatedTs() {
return createdTs;
}

public void setCreatedTs(OffsetDateTime createdTs) {
this.createdTs = createdTs;
}

public String getCreatedBy() {
return createdBy;
}

public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}

public OffsetDateTime getLastUpdatedTs() {
return lastUpdatedTs;
}

public void setLastUpdatedTs(OffsetDateTime lastUpdatedTs) {
this.lastUpdatedTs = lastUpdatedTs;
}

public String getLastUpdatedBy() {
return lastUpdatedBy;
}

public void setLastUpdatedBy(String lastUpdatedBy) {
this.lastUpdatedBy = lastUpdatedBy;
}

public Map<String, String> getUserGroupPermissions() {
return userGroupPermissions;
}

public void setUserGroupPermissions(Map<String, String> userGroupPermissions) {
this.userGroupPermissions = userGroupPermissions;
}

public Map<String, String> getIamRolePermissions() {
return iamRolePermissions;
}

public void setIamRolePermissions(Map<String, String> iamRolePermissions) {
this.iamRolePermissions = iamRolePermissions;
}
}
86 changes: 86 additions & 0 deletions src/main/java/com/nike/cerberus/domain/SDBMetaDataResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* 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.nike.cerberus.domain;

import java.util.List;

public class SDBMetaDataResult {

private boolean hasNext = false;
private int nextOffset = 0;
private int limit = 0;
private int offset = 0;
private int sdbCountInResult;
private int totalSDBCount;
private List<SDBMetaData> safeDepositBoxMetaData;

public boolean isHasNext() {
return hasNext;
}

public void setHasNext(boolean hasNext) {
this.hasNext = hasNext;
}

public int getNextOffset() {
return nextOffset;
}

public void setNextOffset(int nextOffset) {
this.nextOffset = nextOffset;
}

public int getLimit() {
return limit;
}

public void setLimit(int limit) {
this.limit = limit;
}

public int getOffset() {
return offset;
}

public void setOffset(int offset) {
this.offset = offset;
}

public int getSdbCountInResult() {
return sdbCountInResult;
}

public void setSdbCountInResult(int sdbCountInResult) {
this.sdbCountInResult = sdbCountInResult;
}

public int getTotalSDBCount() {
return totalSDBCount;
}

public void setTotalSDBCount(int totalSDBCount) {
this.totalSDBCount = totalSDBCount;
}

public List<SDBMetaData> getSafeDepositBoxMetaData() {
return safeDepositBoxMetaData;
}

public void setSafeDepositBoxMetaData(List<SDBMetaData> safeDepositBoxMetaData) {
this.safeDepositBoxMetaData = safeDepositBoxMetaData;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 9b2528a

Please sign in to comment.