sardell commented on code in PR #9855:
URL: https://github.com/apache/nifi/pull/9855#discussion_r2214380743


##########
nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/service/droplets.service.ts:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
+
+@Injectable({ providedIn: 'root' })
+export class DropletsService {
+    private static readonly API: string = '../nifi-registry-api';
+
+    constructor(private httpClient: HttpClient) {}
+
+    getDroplets(bucketId?: string): Observable<any> {
+        if (bucketId) {
+            return 
this.httpClient.get(`${DropletsService.API}/items/${bucketId}`);
+        }
+        return this.httpClient.get(`${DropletsService.API}/items`);
+    }
+
+    deleteDroplet(href: string): Observable<any> {
+        return 
this.httpClient.delete(`${DropletsService.API}/${href}?version=0`);
+    }
+
+    createNewFlow(bucketUri: string, name: string, description: string): 
Observable<any> {
+        return 
this.httpClient.post(`${DropletsService.API}/${bucketUri}/flows`, {
+            name: name,
+            description: description
+        });
+    }
+
+    uploadFlow(flowUri: string, file: File, description: string): 
Observable<any> {
+        return 
this.httpClient.post(`${DropletsService.API}/${flowUri}/versions/import`, file, 
{
+            headers: { Comments: description }
+        });
+    }
+
+    exportDropletVersionedSnapshot(dropletUri: string, versionNumber: number): 
Observable<any> {
+        const headers = new HttpHeaders({ 'Content-Type': 'application/json' 
});
+        return 
this.httpClient.get(`${DropletsService.API}/${dropletUri}/versions/${versionNumber}/export`,
 {
+            headers,
+            observe: 'response',
+            responseType: 'text'
+        });
+    }
+
+    getDropletSnapshotMetadata(dropletUri: string): Observable<any> {

Review Comment:
   I can manually type out all of these response interfaces in this PR, but we 
use `Observable<any>` for most of the http response types in NiFi. I think if 
we want to have stronger typing for our API responses it would be much better 
to leverage a package that generates Typescript interfaces from backend 
schemas. Not only would it save us a ton of time doing manual work but we also 
get the big advantage of ensuring the contract between the frontend and the 
backend isn't broken at build time.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to