Skip to content

Commit da0e9e2

Browse files
Merge pull request #890 from razee-io/optional-data_location
optional data_location for addChannel, SatCon #1155
2 parents 5581646 + 8be22ca commit da0e9e2

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

app/apollo/models/channel.schema.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const ChannelSchema = new mongoose.Schema({
3030
uuid: {
3131
type: String,
3232
},
33+
data_location: {
34+
type: String,
35+
},
3336
ownerId: {
3437
type: String,
3538
},

app/apollo/resolvers/channel.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ const channelResolvers = {
187187
}
188188
},
189189
Mutation: {
190-
addChannel: async (parent, { orgId: org_id, name, tags=[] }, context)=>{
190+
addChannel: async (parent, { orgId: org_id, name, data_location, tags=[] }, context)=>{
191191
const { models, me, req_id, logger } = context;
192192
const queryName = 'addChannel';
193193
logger.debug({ req_id, user: whoIs(me), org_id, name }, `${queryName} enter`);
@@ -211,6 +211,7 @@ const channelResolvers = {
211211
_id: UUID(),
212212
uuid, org_id, name, versions: [],
213213
tags,
214+
data_location,
214215
ownerId: me._id,
215216
kubeOwnerName,
216217
});
@@ -225,7 +226,7 @@ const channelResolvers = {
225226
throw new RazeeQueryError(context.req.t('Query {{queryName}} error. MessageID: {{req_id}}.', {'queryName':queryName, 'req_id':req_id}), context);
226227
}
227228
},
228-
editChannel: async (parent, { orgId: org_id, uuid, name, tags=[] }, context)=>{
229+
editChannel: async (parent, { orgId: org_id, uuid, name, data_location, tags=[] }, context)=>{
229230
const { models, me, req_id, logger } = context;
230231
const queryName = 'editChannel';
231232
logger.debug({ req_id, user: whoIs(me), org_id, uuid, name }, `${queryName} enter`);
@@ -236,7 +237,7 @@ const channelResolvers = {
236237
throw new NotFoundError(context.req.t('channel uuid "{{uuid}}" not found', {'uuid':uuid}), context);
237238
}
238239
await validAuth(me, org_id, ACTIONS.UPDATE, TYPES.CHANNEL, queryName, context, [channel.uuid, channel.name]);
239-
await models.Channel.updateOne({ org_id, uuid }, { $set: { name, tags } });
240+
await models.Channel.updateOne({ org_id, uuid }, { $set: { name, tags, data_location } }, {omitUndefined:true});
240241

241242
// find any subscriptions for this configuration channel and update channelName in those subs
242243
await models.Subscription.updateMany(

app/apollo/schema/channel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ const channelSchema = gql`
107107
"""
108108
Adds a channel
109109
"""
110-
addChannel(orgId: String! @sv, name: String! @sv, tags: [String!]): AddChannelReply!
110+
addChannel(orgId: String! @sv, name: String! @sv, data_location: String, tags: [String!]): AddChannelReply!
111111
112112
"""
113113
Edits a channel
114114
"""
115-
editChannel(orgId: String! @sv, uuid: String! @sv, name: String! @sv, tags: [String!]): EditChannelReply!
115+
editChannel(orgId: String! @sv, uuid: String! @sv, name: String! @sv, data_location: String, tags: [String!]): EditChannelReply!
116116
117117
"""
118118
Adds a yaml version to this channel

app/apollo/test/channel.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,14 @@ describe('channel graphql test suite', () => {
290290
} = await channelApi.addChannel(adminToken, {
291291
orgId: org01._id,
292292
name: 'a_random_name',
293+
data_location: 'dal'
293294
});
294295

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

298+
const channel1 = await models.Channel.findOne({uuid: addChannel.uuid});
299+
expect(channel1.data_location).to.equal('dal');
300+
297301
const addChannel2 = await channelApi.addChannel(adminToken, {
298302
orgId: org01._id,
299303
name: 'a_random_name2',

app/apollo/test/channelApi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ const channelFunc = grahqlUrl => {
207207
grahqlUrl,
208208
{
209209
query: `
210-
mutation($orgId: String!,$name: String!) {
211-
addChannel(orgId: $orgId name: $name) {
210+
mutation($orgId: String!,$name: String!, $data_location: String) {
211+
addChannel(orgId: $orgId name: $name, data_location: $data_location) {
212212
uuid
213213
}
214214
}

0 commit comments

Comments
 (0)