/*
* 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.
*/

    package com.ywt.gapi.base.file;

import org.apache.dubbo.common.stream.StreamObserver;
import com.google.protobuf.Message;

import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.concurrent.CompletableFuture;

public interface FileService extends org.apache.dubbo.rpc.model.DubboStub {

    String JAVA_SERVICE_NAME = "com.ywt.gapi.base.file.FileService";
    String SERVICE_NAME = "com.ywt.gapi.base.file.FileService";

        /**
         * <pre>
         * 文件名
         * </pre>
         */
    com.ywt.gapi.base.file.UploadFileResponse uploadFile(com.ywt.gapi.base.file.UploadFileRequest request);

    default CompletableFuture<com.ywt.gapi.base.file.UploadFileResponse> uploadFileAsync(com.ywt.gapi.base.file.UploadFileRequest request){
        return CompletableFuture.completedFuture(uploadFile(request));
    }

    /**
    * This server stream type unary method is <b>only</b> used for generated stub to support async unary method.
    * It will not be called if you are NOT using Dubbo3 generated triple stub and <b>DO NOT</b> implement this method.
    */
    default void uploadFile(com.ywt.gapi.base.file.UploadFileRequest request, StreamObserver<com.ywt.gapi.base.file.UploadFileResponse> responseObserver){
        uploadFileAsync(request).whenComplete((r, t) -> {
            if (t != null) {
                responseObserver.onError(t);
            } else {
                responseObserver.onNext(r);
                responseObserver.onCompleted();
            }
        });
    }

        /**
         * <pre>
         * 路径
         * </pre>
         */
    com.ywt.gapi.base.file.UploadImageResponse uploadImage(com.ywt.gapi.base.file.UploadImageRequest request);

    default CompletableFuture<com.ywt.gapi.base.file.UploadImageResponse> uploadImageAsync(com.ywt.gapi.base.file.UploadImageRequest request){
        return CompletableFuture.completedFuture(uploadImage(request));
    }

    /**
    * This server stream type unary method is <b>only</b> used for generated stub to support async unary method.
    * It will not be called if you are NOT using Dubbo3 generated triple stub and <b>DO NOT</b> implement this method.
    */
    default void uploadImage(com.ywt.gapi.base.file.UploadImageRequest request, StreamObserver<com.ywt.gapi.base.file.UploadImageResponse> responseObserver){
        uploadImageAsync(request).whenComplete((r, t) -> {
            if (t != null) {
                responseObserver.onError(t);
            } else {
                responseObserver.onNext(r);
                responseObserver.onCompleted();
            }
        });
    }

        /**
         * <pre>
         * 文件流
         * </pre>
         */
    com.ywt.gapi.base.file.ReadFileResponse readFile(com.ywt.gapi.base.file.ReadFileRequest request);

    default CompletableFuture<com.ywt.gapi.base.file.ReadFileResponse> readFileAsync(com.ywt.gapi.base.file.ReadFileRequest request){
        return CompletableFuture.completedFuture(readFile(request));
    }

    /**
    * This server stream type unary method is <b>only</b> used for generated stub to support async unary method.
    * It will not be called if you are NOT using Dubbo3 generated triple stub and <b>DO NOT</b> implement this method.
    */
    default void readFile(com.ywt.gapi.base.file.ReadFileRequest request, StreamObserver<com.ywt.gapi.base.file.ReadFileResponse> responseObserver){
        readFileAsync(request).whenComplete((r, t) -> {
            if (t != null) {
                responseObserver.onError(t);
            } else {
                responseObserver.onNext(r);
                responseObserver.onCompleted();
            }
        });
    }

        /**
         * <pre>
         * bucket，不传默认为 ywt-files
         * </pre>
         */
    com.ywt.gapi.base.file.ReadFileResponse readFileFromBucket(com.ywt.gapi.base.file.ReadFileFromBucketRequest request);

    default CompletableFuture<com.ywt.gapi.base.file.ReadFileResponse> readFileFromBucketAsync(com.ywt.gapi.base.file.ReadFileFromBucketRequest request){
        return CompletableFuture.completedFuture(readFileFromBucket(request));
    }

    /**
    * This server stream type unary method is <b>only</b> used for generated stub to support async unary method.
    * It will not be called if you are NOT using Dubbo3 generated triple stub and <b>DO NOT</b> implement this method.
    */
    default void readFileFromBucket(com.ywt.gapi.base.file.ReadFileFromBucketRequest request, StreamObserver<com.ywt.gapi.base.file.ReadFileResponse> responseObserver){
        readFileFromBucketAsync(request).whenComplete((r, t) -> {
            if (t != null) {
                responseObserver.onError(t);
            } else {
                responseObserver.onNext(r);
                responseObserver.onCompleted();
            }
        });
    }






}
