Skip to content

Commit

Permalink
Merge branch 'master' into docs-cross-account-sns
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinemoore authored Dec 24, 2023
2 parents dd49b0a + a351cb1 commit f641d2f
Show file tree
Hide file tree
Showing 102 changed files with 9,193 additions and 1,497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
- [ ] Automated tests (e.g. Preflight)
- [ ] Confirm that this change meets security best practices and does not violate the security model
- [ ] Documentation
- [ ] [Python: Run `build.py`](../gendocs/build.py) for new docstrings
- [ ] [Python: Run `build.py`](../tree/master/gendocs/build.py) for new docstrings
- [ ] JavaScript: basic explanation and screenshot of new features
- [ ] Markdown somewhere in docs/**/*.md that explains the feature to end users (said .md files should be linked from SUMMARY.md so they appear on https://docs.quiltdata.com)
- [ ] Markdown docs for developers
- [ ] [Changelog](CHANGELOG.md) entry (skip if change is not significant to end users, e.g. docs only)
- [ ] [Changelog](../tree/master/docs/CHANGELOG.md) entry (skip if change is not significant to end users, e.g. docs only)
4 changes: 2 additions & 2 deletions .github/workflows/js-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16.11'
cache: 'npm'
Expand All @@ -40,7 +40,7 @@ jobs:
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16.11'
- run: npx --package=markdownlint-cli markdownlint --ignore node_modules **/*.md
16 changes: 8 additions & 8 deletions .github/workflows/py-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: Install dependencies
Expand All @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: Install dependencies
Expand All @@ -46,7 +46,7 @@ jobs:
QUILT_DISABLE_USAGE_METRICS: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: install deps
Expand All @@ -66,7 +66,7 @@ jobs:
QUILT_DISABLE_USAGE_METRICS: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: install poetry
Expand All @@ -80,13 +80,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
env:
QUILT_DISABLE_USAGE_METRICS: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
working-directory: api/python
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: verify git tag vs. version
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
JUPYTER_PATH: deps/share/jupyter # Jupyter is not smart enough to handle custom Python paths
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion api/python/quilt3/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.1
5.4.0
119 changes: 29 additions & 90 deletions api/python/quilt3/admin.py
Original file line number Diff line number Diff line change
@@ -1,117 +1,56 @@
"""Provides admin-only functions for Quilt."""
"""APIs for Quilt administrators. 'Registry' refers to Quilt stack backend services, including identity management."""
import typing as T

from .session import get_registry_url, get_session


def create_role(name, arn):
def create_user(*, username: str, email: str):
"""
Create a new role in your registry. Admins only.
Create a new user in the registry.
Required Parameters:
name(string): name of role to create
arn(string): ARN of IAM role to associate with the Quilt role you are creating
Required parameters:
username (str): Username of user to create.
email (str): Email of user to create.
"""
session = get_session()
response = session.post(
"{url}/api/roles".format(
url=get_registry_url()
),
get_registry_url() + "/api/users/create",
json={
'name': name,
'arn': arn
}
"username": username,
"email": email,
},
)

return response.json()


def edit_role(role_id, new_name=None, new_arn=None):
def delete_user(*, username: str):
"""
Edit an existing role in your registry. Admins only.
Delete user from the registry.
Required parameters:
role_id(string): ID of role you want to operate on.
Optional paramters:
new_name(string): new name for role
new_arn(string): new ARN for IAM role attached to Quilt role
username (str): Username of user to delete.
"""
session = get_session()
old_data = get_role(role_id)
data = {}
data['name'] = new_name or old_data['name']
data['arn'] = new_arn or old_data['arn']

response = session.put(
"{url}/api/roles/{role_id}".format(
url=get_registry_url(),
role_id=role_id
),
json=data
response = session.post(
get_registry_url() + "/api/users/delete",
json={
"username": username,
},
)

return response.json()


def delete_role(role_id):
"""
Delete a role in your registry. Admins only.
Required parameters:
role_id(string): ID of role you want to delete.
"""
session = get_session()
session.delete(
"{url}/api/roles/{role_id}".format(
url=get_registry_url(),
role_id=role_id
)
)


def get_role(role_id):
def set_role(*, username: str, role_name: T.Optional[str]):
"""
Get info on a role based on its ID. Admins only.
Set the named Quilt role for a user.
Required parameters:
role_id(string): ID of role you want to get details on.
"""
session = get_session()
response = session.get(
"{url}/api/roles/{role_id}".format(
url=get_registry_url(),
role_id=role_id
)
)

return response.json()


def list_roles():
"""
List configured roles. Admins only.
username (str): Username of user to update.
role_name (str): Quilt role name assign to the user. Set a `None` value to unassign the role.
"""
session = get_session()
response = session.get(
"{url}/api/roles".format(
url=get_registry_url()
))

return response.json()['results']


def set_role(username, role_name=''):
"""
Set which role is associated with a user.
Admins only.
"""
session = get_session()
data = {
'username': username,
'role': role_name
}
session.post(
"{url}/api/users/set_role".format(
url=get_registry_url()
),
json=data
get_registry_url() + "/api/users/set_role",
json={
"username": username,
"role": role_name or "",
},
)
63 changes: 2 additions & 61 deletions api/python/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,65 +43,6 @@ def test_config_invalid_host(self):
with pytest.raises(util.QuiltException, match='Port must be a number'):
he.config('https://fliff:fluff')

def test_empty_list_role(self):
empty_list_response = {'results': []}
self.requests_mock.add(responses.GET, DEFAULT_URL + '/api/roles',
json=empty_list_response, status=200)
assert he.admin.list_roles() == []

def test_list_role(self):
result = {
'name': 'test',
'arn': 'asdf123',
'id': '1234-1234'
}
list_response = {'results': [result]}
self.requests_mock.add(responses.GET, DEFAULT_URL + '/api/roles',
json=list_response, status=200)
assert he.admin.list_roles() == [result]

def test_get_role(self):
result = {
'name': 'test',
'arn': 'asdf123',
'id': '1234-1234'
}
self.requests_mock.add(responses.GET, DEFAULT_URL + '/api/roles/1234-1234',
json=result, status=200)
assert he.admin.get_role('1234-1234') == result

def test_create_role(self):
result = {
'name': 'test',
'arn': 'asdf123',
'id': '1234-1234'
}
self.requests_mock.add(responses.POST, DEFAULT_URL + '/api/roles',
json=result, status=200)
assert he.admin.create_role('test', 'asdf123') == result

def test_edit_role(self):
get_result = {
'name': 'test',
'arn': 'asdf123',
'id': '1234-1234'
}
result = {
'name': 'test_new_name',
'arn': 'qwer456',
'id': '1234-1234'
}
self.requests_mock.add(responses.GET, DEFAULT_URL + '/api/roles/1234-1234',
json=get_result, status=200)
self.requests_mock.add(responses.PUT, DEFAULT_URL + '/api/roles/1234-1234',
json=result, status=200)
assert he.admin.edit_role('1234-1234', 'test_new_name', 'qwer456') == result

def test_delete_role(self):
self.requests_mock.add(responses.DELETE, DEFAULT_URL + '/api/roles/1234-1234',
status=200)
he.admin.delete_role('1234-1234')

def test_set_role(self):
self.requests_mock.add(responses.POST, DEFAULT_URL + '/api/users/set_role',
json={}, status=200)
Expand All @@ -112,7 +53,7 @@ def test_set_role(self):
self.requests_mock.add(responses.POST, DEFAULT_URL + '/api/users/set_role',
json=not_found_result, status=400)

he.admin.set_role('test_user', 'test_role')
he.admin.set_role(username='test_user', role_name='test_role')

with pytest.raises(util.QuiltException):
he.admin.set_role('not_found', 'test_role')
he.admin.set_role(username='not_found', role_name='test_role')
2 changes: 1 addition & 1 deletion catalog/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
'max-classes-per-file': 0,
'no-console': 2,
'no-nested-ternary': 1,
'no-underscore-dangle': [2, { allow: ['_', '__', '__typename'] }],
'no-underscore-dangle': [2, { allow: ['_', '__', '__typename', '_tag'] }],
'prefer-arrow-callback': [2, { allowNamedFunctions: true }],
'prefer-template': 2,
'react-hooks/exhaustive-deps': 2,
Expand Down
2 changes: 1 addition & 1 deletion catalog/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM amazonlinux:2023.2.20230920.1
FROM amazonlinux:2023.3.20231218.0
MAINTAINER Quilt Data, Inc. [email protected]

ENV LC_ALL=C.UTF-8
Expand Down
26 changes: 16 additions & 10 deletions catalog/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createBrowserHistory as createHistory } from 'history'
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { Router } from 'react-router-dom'
import { createSelector } from 'reselect'
import * as M from '@material-ui/core'

// initialize config from window.QUILT_CATALOG_CONFIG
Expand Down Expand Up @@ -38,6 +39,7 @@ import * as APIConnector from 'utils/APIConnector'
import * as GraphQL from 'utils/GraphQL'
import { BucketCacheProvider } from 'utils/BucketCache'
import GlobalAPI from 'utils/GlobalAPI'
import log from 'utils/Logging'
import * as NamedRoutes from 'utils/NamedRoutes'
import * as Cache from 'utils/ResourceCache'
import * as Store from 'utils/Store'
Expand All @@ -57,26 +59,30 @@ globalApi.attach(window)
const GlobalAPIProvider = globalApi.getProvider()

// listen for Roboto fonts
fontLoader('Roboto', 'Roboto Mono').then(() => {
// reload doc when we have all custom fonts
document.body.classList.add('fontLoaded')
})
fontLoader('Roboto', 'Roboto Mono')
.then(() => {
// reload doc when we have all custom fonts
document.body.classList.add('fontLoaded')
})
.catch((error) => {
log.log('Failed to load fonts')
log.error(error)
})

const MOUNT_NODE = document.getElementById('app')

// TODO: make storage injectable
const storage = mkStorage({ user: 'USER', tokens: 'TOKENS' })

const intercomUserSelector = (state: $TSFixMe) => {
const { user: u } = Auth.selectors.domain(state)
return (
const intercomUserSelector = createSelector(
Auth.selectors.domain,
({ user: u }) =>
u && {
user_id: u.current_user,
name: u.current_user,
email: u.email,
}
)
}
},
)

const render = () => {
ReactDOM.render(
Expand Down
Loading

0 comments on commit f641d2f

Please sign in to comment.