Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional data_location for addChannel, SatCon #1155 #890

Merged
merged 3 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/apollo/models/channel.schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const ChannelSchema = new mongoose.Schema({
uuid: {
type: String,
},
data_location: {
type: String,
},
ownerId: {
type: String,
},
Expand Down
7 changes: 4 additions & 3 deletions app/apollo/resolvers/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const channelResolvers = {
}
},
Mutation: {
addChannel: async (parent, { orgId: org_id, name, tags=[] }, context)=>{
addChannel: async (parent, { orgId: org_id, name, data_location, tags=[] }, context)=>{
const { models, me, req_id, logger } = context;
const queryName = 'addChannel';
logger.debug({ req_id, user: whoIs(me), org_id, name }, `${queryName} enter`);
Expand All @@ -211,6 +211,7 @@ const channelResolvers = {
_id: UUID(),
uuid, org_id, name, versions: [],
tags,
data_location,
ownerId: me._id,
kubeOwnerName,
});
Expand All @@ -225,7 +226,7 @@ const channelResolvers = {
throw new RazeeQueryError(context.req.t('Query {{queryName}} error. MessageID: {{req_id}}.', {'queryName':queryName, 'req_id':req_id}), context);
}
},
editChannel: async (parent, { orgId: org_id, uuid, name, tags=[] }, context)=>{
editChannel: async (parent, { orgId: org_id, uuid, name, data_location, tags=[] }, context)=>{
const { models, me, req_id, logger } = context;
const queryName = 'editChannel';
logger.debug({ req_id, user: whoIs(me), org_id, uuid, name }, `${queryName} enter`);
Expand All @@ -236,7 +237,7 @@ const channelResolvers = {
throw new NotFoundError(context.req.t('channel uuid "{{uuid}}" not found', {'uuid':uuid}), context);
}
await validAuth(me, org_id, ACTIONS.UPDATE, TYPES.CHANNEL, queryName, context, [channel.uuid, channel.name]);
await models.Channel.updateOne({ org_id, uuid }, { $set: { name, tags } });
await models.Channel.updateOne({ org_id, uuid }, { $set: { name, tags, data_location } }, {omitUndefined:true});

// find any subscriptions for this configuration channel and update channelName in those subs
await models.Subscription.updateMany(
Expand Down
4 changes: 2 additions & 2 deletions app/apollo/schema/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ const channelSchema = gql`
"""
Adds a channel
"""
addChannel(orgId: String! @sv, name: String! @sv, tags: [String!]): AddChannelReply!
addChannel(orgId: String! @sv, name: String! @sv, data_location: String, tags: [String!]): AddChannelReply!

"""
Edits a channel
"""
editChannel(orgId: String! @sv, uuid: String! @sv, name: String! @sv, tags: [String!]): EditChannelReply!
editChannel(orgId: String! @sv, uuid: String! @sv, name: String! @sv, data_location: String, tags: [String!]): EditChannelReply!

"""
Adds a yaml version to this channel
Expand Down
4 changes: 4 additions & 0 deletions app/apollo/test/channel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,14 @@ describe('channel graphql test suite', () => {
} = await channelApi.addChannel(adminToken, {
orgId: org01._id,
name: 'a_random_name',
data_location: 'dal'
});

expect(addChannel.uuid).to.be.an('string');

const channel1 = await models.Channel.findOne({uuid: addChannel.uuid});
expect(channel1.data_location).to.equal('dal');

const addChannel2 = await channelApi.addChannel(adminToken, {
orgId: org01._id,
name: 'a_random_name2',
Expand Down
4 changes: 2 additions & 2 deletions app/apollo/test/channelApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ const channelFunc = grahqlUrl => {
grahqlUrl,
{
query: `
mutation($orgId: String!,$name: String!) {
addChannel(orgId: $orgId name: $name) {
mutation($orgId: String!,$name: String!, $data_location: String) {
addChannel(orgId: $orgId name: $name, data_location: $data_location) {
uuid
}
}
Expand Down