/*
 * 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 { BulletinEntity, DocumentedType, Permissions, Revision } from '../../../../state/shared';

export const registryClientsFeatureKey = 'registryClients';

export interface CreateRegistryClientDialogRequest {
    registryClientTypes: DocumentedType[];
}

export interface LoadRegistryClientsResponse {
    registryClients: RegistryClientEntity[];
    loadedTimestamp: string;
}

export interface CreateRegistryClientRequest {
    revision: Revision;
    component: {
        name: string;
        type: string;
        description?: string;
    };
}

export interface CreateRegistryClientSuccess {
    registryClient: RegistryClientEntity;
}

export interface EditRegistryClientDialogRequest {
    registryClient: RegistryClientEntity;
}

export interface EditRegistryClientRequest {
    id: string;
    uri: string;
    payload: any;
    postUpdateNavigation?: string[];
}

export interface EditRegistryClientRequestSuccess {
    id: string;
    registryClient: RegistryClientEntity;
    postUpdateNavigation?: string[];
}

export interface DeleteRegistryClientRequest {
    registryClient: RegistryClientEntity;
}

export interface DeleteRegistryClientSuccess {
    registryClient: RegistryClientEntity;
}

export interface SelectRegistryClientRequest {
    id: string;
}

export interface RegistryClientEntity {
    permissions: Permissions;
    operatePermissions?: Permissions;
    revision: Revision;
    bulletins?: BulletinEntity[];
    id: string;
    uri: string;
    component: any;
}

export interface RegistryClientsState {
    registryClients: RegistryClientEntity[];
    saving: boolean;
    loadedTimestamp: string;
    error: string | null;
    status: 'pending' | 'loading' | 'error' | 'success';
}
