Skip to content

Commit

Permalink
Merge branch 'master' into activity-tracker-events-update
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanstjohn authored Mar 14, 2023
2 parents e0b9ccd + 20d727b commit a473753
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 59 deletions.
4 changes: 2 additions & 2 deletions app/apollo/resolvers/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ const subscriptionResolvers = {
}
catch( error ) {
logger.error(error, `There was an error resolving ${queryName}`);
logger.info({org_id, req_id, user, cluster_id}, `${queryName} There was an error resolving subscriptions: ${error.message}`);
// Continue and return as many as possible -- e.g. SystemSubscriptions like primaryOrgKey should be returned so they can be applied even if there was an error retrieving 'normal' subscriptions.
logger.error({org_id, req_id, user, cluster_id}, `${queryName} There was an error resolving subscriptions: ${error.message}`);
throw error;
}
logger.info({org_id, req_id, user, cluster_id, subs, clusterGroupNames}, `${queryName} returning ${subs.length} subscriptions for cluster ${cluster_id}`);
return subs;
Expand Down
2 changes: 1 addition & 1 deletion app/routes/v3/gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const getChannel = async (req, res) => {
const operationName = 'channel';
const query = `
query ${operationName}($orgId: String!, $uuid: String!) {
clusterByClusterId(orgId: $orgId, uuid: $uuid) {
channel(orgId: $orgId, uuid: $uuid) {
uuid
orgId
name
Expand Down
10 changes: 5 additions & 5 deletions app/routes/v3/gql.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ describe('gql', () => {
{ name: 'getChannel', method: 'GET', url: '/channels/testUuid', params: { uuid: 'testUuid' } },
{ name: 'postChannelVersion', method: 'POST', url: '/channels/testId/versions', params: { channelUuid: 'testUuid' }, body: { name: 'testName', type: 'application/json', content: 'testContent' } },
{ name: 'getChannelVersion', method: 'GET', url: '/channels/testUuid/versions/testUuid', params: { channelUuid: 'testUuid', versionUuid: 'testUuid' } },
{ name: 'getClusters', method: 'GET', url: '/channels' },
{ name: 'getCluster', method: 'GET', url: '/channels/testUuid', params: { clusterId: 'testUuid' } },
{ name: 'getClusters', method: 'GET', url: '/clusters' },
{ name: 'getCluster', method: 'GET', url: '/clusters/testUuid', params: { clusterId: 'testUuid' } },
{ name: 'postGroups', method: 'POST', url: '/groups', body: { name: 'testName' } },
{ name: 'putGroup', method: 'PUT', url: '/groups/testUuid', params: { uuid: 'testUuid' }, body: { clusters: [] } },
{ name: 'getGroups', method: 'GET', url: '/groups' },
{ name: 'getGroup', method: 'GET', url: '/groups/testUuid', params: { uuid: 'testUuid' } },
{ name: 'postSubscriptions', method: 'POST', url: '/channels', body: { name: 'testName', groups: ['testUuid'], channelUuid: 'testUuid', versionUuid: 'testUuid' } },
{ name: 'getSubscriptions', method: 'GET', url: '/channels' },
{ name: 'getSubscription', method: 'GET', url: '/channels/testUuid', params: { uuid: 'testUuid' } },
{ name: 'postSubscriptions', method: 'POST', url: '/subscriptions', body: { name: 'testName', groups: ['testUuid'], channelUuid: 'testUuid', versionUuid: 'testUuid' } },
{ name: 'getSubscriptions', method: 'GET', url: '/subscriptions' },
{ name: 'getSubscription', method: 'GET', url: '/subscriptions/testUuid', params: { uuid: 'testUuid' } },
];

restFunctions.forEach( f => {
Expand Down
63 changes: 41 additions & 22 deletions app/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Create a channel",
"description": "",
"consumes": [
"application/json"
Expand Down Expand Up @@ -656,8 +656,8 @@
"schema": {
"type": "object",
"properties": {
"orgId": {
"example": "any"
"name": {
"example": "sample-channel-name"
}
}
}
Expand Down Expand Up @@ -710,7 +710,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Gets a channel",
"description": "",
"produces": [
"application/json"
Expand Down Expand Up @@ -753,7 +753,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Create a channel version",
"description": "",
"consumes": [
"application/json"
Expand Down Expand Up @@ -787,8 +787,14 @@
"schema": {
"type": "object",
"properties": {
"orgId": {
"example": "any"
"name": {
"example": "sample-version-name"
},
"type": {
"example": "application/yaml"
},
"content": {
"example": "sample kube resource yaml"
}
}
}
Expand All @@ -809,7 +815,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Gets a channel version",
"description": "",
"produces": [
"application/json"
Expand Down Expand Up @@ -892,7 +898,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Gets a cluster",
"description": "",
"produces": [
"application/json"
Expand Down Expand Up @@ -935,7 +941,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Create a group",
"description": "",
"consumes": [
"application/json"
Expand Down Expand Up @@ -963,8 +969,8 @@
"schema": {
"type": "object",
"properties": {
"orgId": {
"example": "any"
"name": {
"example": "sample-group-name"
}
}
}
Expand All @@ -983,7 +989,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Gets all groups",
"description": "",
"produces": [
"application/json"
Expand Down Expand Up @@ -1017,7 +1023,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Set clusters as group members",
"description": "",
"consumes": [
"application/json"
Expand Down Expand Up @@ -1051,8 +1057,11 @@
"schema": {
"type": "object",
"properties": {
"orgId": {
"example": "any"
"clusters": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
Expand All @@ -1071,7 +1080,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Gets a group",
"description": "",
"produces": [
"application/json"
Expand Down Expand Up @@ -1111,7 +1120,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Create a subscription",
"description": "",
"consumes": [
"application/json"
Expand Down Expand Up @@ -1139,8 +1148,18 @@
"schema": {
"type": "object",
"properties": {
"orgId": {
"example": "any"
"name": {
"example": "sample-subscription-name"
},
"groups": {
"type": "array",
"items": "string"
},
"channelUuid": {
"example": "12345678-1234-1234-1234567890ab"
},
"versionUuid": {
"example": "12345678-1234-1234-1234567890ab"
}
}
}
Expand All @@ -1159,7 +1178,7 @@
"tags": [
"channels"
],
"summary": "Gets all channels",
"summary": "Gets all subscriptions",
"description": "",
"produces": [
"application/json"
Expand Down Expand Up @@ -1193,7 +1212,7 @@
"tags": [
"channels"
],
"summary": "Gets a specified subscription",
"summary": "Gets a subscription",
"description": "",
"produces": [
"application/json"
Expand Down
2 changes: 2 additions & 0 deletions local-dev/api/cloudLogin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ ibmcloud login -a ${CLOUDPREFIX}cloud.ibm.com --sso

export RAZEE_USER_TOKEN=$(ibmcloud iam oauth-tokens --output json | jq --raw-output '.iam_token' | sed 's/^Bearer //')
export RAZEE_URL=https://config.${CLOUDREGION}satellite.${CLOUDPREFIX}cloud.ibm.com/graphql
export RAZEE_REST_URL=https://config.${CLOUDREGION}satellite.${CLOUDPREFIX}cloud.ibm.com/api/v3
export RAZEE_V2_URL=https://config.${CLOUDREGION}satellite.${CLOUDPREFIX}cloud.ibm.com/api/v2
export RAZEE_ORG_ID=$(ibmcloud target --output json | jq --raw-output '.account.guid')

echo "RAZEE_URL: $RAZEE_URL"
Expand Down
9 changes: 5 additions & 4 deletions local-dev/api/restGet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ TYPE=${1:-cluster}
ID=/${2}
RAZEE_ORG_ID=${3:-${RAZEE_ORG_ID}}

echo "Getting ${TYPE}s${ID} in orgId ${RAZEE_ORG_ID}"
RAZEE_URL=${RAZEE_URL:-http://localhost:3333/api/v3/${TYPE}s${ID}}
RAZEE_REST_URL=${RAZEE_REST_URL:-http://localhost:3333/api/v3}

echo "Getting ${TYPE}s${ID} in orgId ${RAZEE_ORG_ID} by GET to ${RAZEE_REST_URL}"

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"

curl \
-X GET \
-H "${AUTH_HEADER}" \
-H "Content-Type: application/json" \
-H "xorg-id: ${RAZEE_ORG_ID}" \
-H "org-id: ${RAZEE_ORG_ID}" \
-w "HTTP: %{http_code}" \
${RAZEE_URL}?orgId=${RAZEE_ORG_ID}
${RAZEE_REST_URL}/${TYPE}s${ID}?orgId=${RAZEE_ORG_ID}

retVal=$?

Expand Down
9 changes: 5 additions & 4 deletions local-dev/api/restGetChild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

TYPE=${1:-channel}
ID=/${2:-pChannelId}
ID=${2:-pChannelId}
CHILD_TYPE=${3:-version}
CHILD_ID=/${4:-pVersionId}
RAZEE_ORG_ID=${5:-${RAZEE_ORG_ID}}

echo "Getting ${TYPE}s${ID}/${CHILD_TYPE}s${CHILD_ID} in orgId ${RAZEE_ORG_ID}"
RAZEE_URL=${RAZEE_URL:-http://localhost:3333/api/v3/${TYPE}s${ID}/${CHILD_TYPE}s${CHILD_ID}}
RAZEE_REST_URL=${RAZEE_REST_URL:-http://localhost:3333/api/v3}

echo "Getting ${TYPE}s/${ID}/${CHILD_TYPE}s${CHILD_ID} in orgId ${RAZEE_ORG_ID} by GET to ${RAZEE_REST_URL}"

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"

Expand All @@ -19,7 +20,7 @@ curl \
-H "Content-Type: application/json" \
-H "org-id: ${RAZEE_ORG_ID}" \
-w "HTTP: %{http_code}" \
${RAZEE_URL}
${RAZEE_REST_URL}/${TYPE}s/${ID}/${CHILD_TYPE}s${CHILD_ID}

retVal=$?

Expand Down
9 changes: 4 additions & 5 deletions local-dev/api/restPostChannelByName.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
CHANNEL_NAME=${1:-pChannel}
RAZEE_ORG_ID=${2:-${RAZEE_ORG_ID}}

echo "Creating CHANNEL ${CHANNEL_NAME} in orgId ${RAZEE_ORG_ID}"
RAZEE_URL=${RAZEE_URL:-http://localhost:3333/api/v3/channels}
RAZEE_REST_URL=${RAZEE_REST_URL:-http://localhost:3333/api/v3}

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"
echo "Creating CHANNEL ${CHANNEL_NAME} in orgId ${RAZEE_ORG_ID} by POST to ${RAZEE_REST_URL}"

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"

curl \
-i \
-X POST \
-H "${AUTH_HEADER}" \
-H "Content-Type: application/json" \
-H "org-id: ${RAZEE_ORG_ID}" \
-w "HTTP: %{http_code}" \
--data '{ "name": "'"${CHANNEL_NAME}"'" }' \
${RAZEE_URL}
${RAZEE_REST_URL}/channels

retVal=$?

Expand Down
8 changes: 4 additions & 4 deletions local-dev/api/restPostGroupByName.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
GROUP_NAME=${1:-pGroup}
RAZEE_ORG_ID=${2:-${RAZEE_ORG_ID}}

echo "Creating GROUP ${GROUP_NAME} in orgId ${RAZEE_ORG_ID}"
RAZEE_URL=${RAZEE_URL:-http://localhost:3333/api/v3/groups}
RAZEE_REST_URL=${RAZEE_REST_URL:-http://localhost:3333/api/v3}

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"
echo "Creating GROUP ${GROUP_NAME} in orgId ${RAZEE_ORG_ID} by POST to ${RAZEE_REST_URL}"

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"

curl \
-i \
Expand All @@ -19,7 +19,7 @@ curl \
-H "org-id: ${RAZEE_ORG_ID}" \
-w "HTTP: %{http_code}" \
--data '{ "name": "'"${GROUP_NAME}"'" }' \
${RAZEE_URL}
${RAZEE_REST_URL}/groups

retVal=$?

Expand Down
9 changes: 5 additions & 4 deletions local-dev/api/restPostGroupByNameWithClusterIds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ GROUP_NAME=${1:-pGroup}
RAZEE_CLUSTER_UUID=${2:-${RAZEE_CLUSTER_UUID:-pClusterUuid}}
RAZEE_ORG_ID=${3:-${RAZEE_ORG_ID}}

echo "Creating GROUP ${GROUP_NAME} in orgId ${RAZEE_ORG_ID} with Clusters"
RAZEE_REST_URL=${RAZEE_REST_URL:-http://localhost:3333/api/v3}

echo "Creating GROUP ${GROUP_NAME} in orgId ${RAZEE_ORG_ID} with Clusters by POST to ${RAZEE_REST_URL}"

echo "***********"
echo "THIS DOES NOT WORK AT THIS TIME! clusters ignored?"
echo "***********"
RAZEE_URL=${RAZEE_URL:-http://localhost:3333/api/v3/groups}

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"


curl \
-i \
-X POST \
Expand All @@ -23,7 +24,7 @@ curl \
-H "org-id: ${RAZEE_ORG_ID}" \
-w "HTTP: %{http_code}" \
--data '{ "name": "'"${GROUP_NAME}"'", "clusters": [ "'"${RAZEE_CLUSTER_UUID}"'" ] }' \
${RAZEE_URL}
${RAZEE_REST_URL}/groups

retVal=$?

Expand Down
9 changes: 4 additions & 5 deletions local-dev/api/restPostVersionByName.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,20 @@ CHANNEL_UUID=${1:-pChannelId}
VER_NAME=${2:-pVerName}
RAZEE_ORG_ID=${3:-${RAZEE_ORG_ID}}

echo "Creating VERSION ${VER_NAME} on channel ${CHANNEL_UUID} in orgId ${RAZEE_ORG_ID}"
RAZEE_URL=${RAZEE_URL:-http://localhost:3333/api/v3/channels/${CHANNEL_UUID}/versions}
RAZEE_REST_URL=${RAZEE_REST_URL:-http://localhost:3333/api/v3}

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"
echo "Creating VERSION ${VER_NAME} on channel ${CHANNEL_UUID} in orgId ${RAZEE_ORG_ID} by POST to ${RAZEE_REST_URL}"

[ ! -z "${RAZEE_USER_TOKEN}" ] && AUTH_HEADER="Authorization: Bearer ${RAZEE_USER_TOKEN}" || AUTH_HEADER="no-auth-available: asdf"

curl \
-i \
-X POST \
-H "${AUTH_HEADER}" \
-H "Content-Type: application/json" \
-H "org-id: ${RAZEE_ORG_ID}" \
-w "HTTP: %{http_code}" \
--data '{ "name": "'"${VER_NAME}"'", "type": "'"application/yaml"'", "content": "'"dummycontent"'" }' \
${RAZEE_URL}
${RAZEE_REST_URL}/channels/${CHANNEL_UUID}/versions

retVal=$?

Expand Down
Loading

0 comments on commit a473753

Please sign in to comment.