@@ -47,13 +47,7 @@ func HandleCreate(req *handler.Request, client *util.MongoDBClient, model *Model
4747 )
4848 }
4949
50- workspaceOrInstanceName , err := GetWorkspaceOrInstanceName (model )
51- if err != nil {
52- return handler.ProgressEvent {
53- OperationStatus : handler .Failed ,
54- Message : err .Error (),
55- }
56- }
50+ workspaceName := util .SafeString (model .WorkspaceName )
5751
5852 ctx := context .Background ()
5953 projectID := util .SafeString (model .ProjectId )
@@ -83,7 +77,7 @@ func HandleCreate(req *handler.Request, client *util.MongoDBClient, model *Model
8377 }
8478 }
8579
86- _ , apiResp , err := client .AtlasSDK .StreamsApi .CreateStreamProcessor (ctx , projectID , workspaceOrInstanceName , streamProcessorReq ).Execute ()
80+ _ , apiResp , err := client .AtlasSDK .StreamsApi .CreateStreamProcessor (ctx , projectID , workspaceName , streamProcessorReq ).Execute ()
8781 if err != nil {
8882 return handleError (apiResp , constants .CREATE , err )
8983 }
@@ -110,7 +104,7 @@ func HandleCreate(req *handler.Request, client *util.MongoDBClient, model *Model
110104 Message : constants .Pending ,
111105 ResourceModel : inProgressModel ,
112106 CallbackDelaySeconds : defaultCallbackDelaySeconds ,
113- CallbackContext : buildCallbackContext (projectID , workspaceOrInstanceName , processorName , map [string ]any {
107+ CallbackContext : buildCallbackContext (projectID , workspaceName , processorName , map [string ]any {
114108 "needsStarting" : needsStarting ,
115109 "startTime" : time .Now ().Format (time .RFC3339 ),
116110 "timeoutDuration" : timeoutStr ,
@@ -120,21 +114,14 @@ func HandleCreate(req *handler.Request, client *util.MongoDBClient, model *Model
120114}
121115
122116func HandleRead (req * handler.Request , client * util.MongoDBClient , model * Model ) handler.ProgressEvent {
123- workspaceOrInstanceName , err := GetWorkspaceOrInstanceName (model )
124- if err != nil {
125- return handler.ProgressEvent {
126- OperationStatus : handler .Failed ,
127- Message : err .Error (),
128- }
129- }
130-
117+ workspaceName := util .SafeString (model .WorkspaceName )
131118 projectID := util .SafeString (model .ProjectId )
132119 processorName := util .SafeString (model .ProcessorName )
133120
134121 streamProcessor , apiResp , err := client .AtlasSDK .StreamsApi .GetStreamProcessorWithParams (context .Background (),
135122 & admin.GetStreamProcessorApiParams {
136123 GroupId : projectID ,
137- TenantName : workspaceOrInstanceName ,
124+ TenantName : workspaceName ,
138125 ProcessorName : processorName ,
139126 }).Execute ()
140127 if err != nil {
@@ -179,21 +166,15 @@ func HandleUpdate(req *handler.Request, client *util.MongoDBClient, prevModel *M
179166 )
180167 }
181168
182- workspaceOrInstanceName , err := GetWorkspaceOrInstanceName (model )
183- if err != nil {
184- return handler.ProgressEvent {
185- OperationStatus : handler .Failed ,
186- Message : err .Error (),
187- }
188- }
169+ workspaceName := util .SafeString (model .WorkspaceName )
189170
190171 ctx := context .Background ()
191172 projectID := util .SafeString (model .ProjectId )
192173 processorName := util .SafeString (model .ProcessorName )
193174
194175 requestParams := & admin.GetStreamProcessorApiParams {
195176 GroupId : projectID ,
196- TenantName : workspaceOrInstanceName ,
177+ TenantName : workspaceName ,
197178 ProcessorName : processorName ,
198179 }
199180
@@ -229,7 +210,7 @@ func HandleUpdate(req *handler.Request, client *util.MongoDBClient, prevModel *M
229210 _ , err := client .AtlasSDK .StreamsApi .StopStreamProcessorWithParams (ctx ,
230211 & admin.StopStreamProcessorApiParams {
231212 GroupId : projectID ,
232- TenantName : workspaceOrInstanceName ,
213+ TenantName : workspaceName ,
233214 ProcessorName : processorName ,
234215 },
235216 ).Execute ()
@@ -252,7 +233,7 @@ func HandleUpdate(req *handler.Request, client *util.MongoDBClient, prevModel *M
252233 Message : constants .Pending ,
253234 ResourceModel : inProgressModel ,
254235 CallbackDelaySeconds : defaultCallbackDelaySeconds ,
255- CallbackContext : buildCallbackContext (projectID , workspaceOrInstanceName , processorName , map [string ]any {
236+ CallbackContext : buildCallbackContext (projectID , workspaceName , processorName , map [string ]any {
256237 "desiredState" : desiredState ,
257238 }),
258239 }
@@ -275,7 +256,7 @@ func HandleUpdate(req *handler.Request, client *util.MongoDBClient, prevModel *M
275256 _ , err := client .AtlasSDK .StreamsApi .StartStreamProcessorWithParams (ctx ,
276257 & admin.StartStreamProcessorApiParams {
277258 GroupId : projectID ,
278- TenantName : workspaceOrInstanceName ,
259+ TenantName : workspaceName ,
279260 ProcessorName : processorName ,
280261 },
281262 ).Execute ()
@@ -298,7 +279,7 @@ func HandleUpdate(req *handler.Request, client *util.MongoDBClient, prevModel *M
298279 Message : constants .Pending ,
299280 ResourceModel : inProgressModel ,
300281 CallbackDelaySeconds : defaultCallbackDelaySeconds ,
301- CallbackContext : buildCallbackContext (projectID , workspaceOrInstanceName , processorName , map [string ]any {
282+ CallbackContext : buildCallbackContext (projectID , workspaceName , processorName , map [string ]any {
302283 "desiredState" : desiredState ,
303284 }),
304285 }
@@ -308,19 +289,13 @@ func HandleUpdate(req *handler.Request, client *util.MongoDBClient, prevModel *M
308289}
309290
310291func HandleDelete (req * handler.Request , client * util.MongoDBClient , model * Model ) handler.ProgressEvent {
311- workspaceOrInstanceName , err := GetWorkspaceOrInstanceName (model )
312- if err != nil {
313- return handler.ProgressEvent {
314- OperationStatus : handler .Failed ,
315- Message : err .Error (),
316- }
317- }
292+ workspaceName := util .SafeString (model .WorkspaceName )
318293
319294 ctx := context .Background ()
320295 projectID := util .SafeString (model .ProjectId )
321296 processorName := util .SafeString (model .ProcessorName )
322297
323- apiResp , err := client .AtlasSDK .StreamsApi .DeleteStreamProcessor (ctx , projectID , workspaceOrInstanceName , processorName ).Execute ()
298+ apiResp , err := client .AtlasSDK .StreamsApi .DeleteStreamProcessor (ctx , projectID , workspaceName , processorName ).Execute ()
324299 if err != nil {
325300 if apiResp != nil && apiResp .StatusCode == http .StatusNotFound {
326301 return handler.ProgressEvent {
@@ -342,18 +317,12 @@ func HandleDelete(req *handler.Request, client *util.MongoDBClient, model *Model
342317}
343318
344319func HandleList (req * handler.Request , client * util.MongoDBClient , model * Model ) handler.ProgressEvent {
345- workspaceOrInstanceName , err := GetWorkspaceOrInstanceName (model )
346- if err != nil {
347- return handler.ProgressEvent {
348- OperationStatus : handler .Failed ,
349- Message : err .Error (),
350- }
351- }
320+ workspaceName := util .SafeString (model .WorkspaceName )
352321
353322 ctx := context .Background ()
354323 projectID := util .SafeString (model .ProjectId )
355324
356- accumulatedProcessors , apiResp , err := getAllStreamProcessors (ctx , client .AtlasSDK , projectID , workspaceOrInstanceName )
325+ accumulatedProcessors , apiResp , err := getAllStreamProcessors (ctx , client .AtlasSDK , projectID , workspaceName )
357326 if err != nil {
358327 return handleError (apiResp , constants .LIST , err )
359328 }
0 commit comments