syntax = "proto3";

package com.wixpress.authorization.abac.attributes;

import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
import "wix/api/permissions.proto";
import "wix/api/validations.proto";
import "com/wixpress/authorization/abac/attributes/AbacAttributeEvents.proto";
import "com/wixpress/authorization/abac/Context.proto";
import "wix/api/entity.proto";
import "wix/api/annotations.proto";

service AbacAttributesService {
    option (wix.api.service_entity).message = "com.wixpress.authorization.abac.Attribute";
    option (wix.api.service_exposure) = INTERNAL;

    rpc UpdateResourceAttribute(ResourceAttributeUpdate) returns (google.protobuf.Empty) {
        option (wix.api.permission).name = "AUTH_ATTRIBUTES.UPDATE_ATTRIBUTES";
        option (google.api.http).put = "/v1/attributes";
    }

    rpc BulkUpdateResourceAttribute(BulkResourceAttributeUpdateRequest) returns (BulkResourceAttributeUpdateResponse) {
        option (wix.api.permission).name = "AUTH_ATTRIBUTES.BULK_UPDATE_ATTRIBUTES";
        option (wix.api.required) = "BulkResourceAttributeUpdateRequest.full_name_resources";
        option (wix.api.required) = "BulkResourceAttributeUpdateRequest.update_event";
        option (google.api.http).put = "/v1/attributes/bulk";
    }

    rpc GetAttributes(GetAttributesRequest) returns (GetAttributesResponse) {
        option (wix.api.permission).name = "AUTH_ATTRIBUTES.GET_ATTRIBUTES";
        option (google.api.http).get = "/v1/attributes";
    }

    rpc UpdateResourcesWithAttribute(UpdateResourcesWithAttributeMessage) returns (google.protobuf.Empty) {
        option (wix.api.permission).name = "AUTH_ATTRIBUTES.UPDATE_ATTRIBUTES";
        option (google.api.http).put = "/v1/attributes/resources";
    }

    rpc BulkUpdateResourcesWithAttribute(BulkUpdateResourcesWithAttributeRequest) returns (BulkUpdateResourcesWithAttributeResponse) {
        option (wix.api.permission).name = "AUTH_ATTRIBUTES.BULK_UPDATE_ATTRIBUTES";
        option (wix.api.required) = "BulkUpdateResourcesWithAttributeRequest.operators";
        option (google.api.http).put = "/v1/attributes/resources/bulk";
    }

    rpc DeleteAttributesByTenant(DeleteAttributesByTenantRequest) returns (google.protobuf.Empty) {
        option (wix.api.permission).name = "AUTH_ATTRIBUTES.DELETE_ATTRIBUTES_BY_TENANT";
        option (wix.api.required) = "DeleteAttributesByTenantRequest.tenant";
        option (wix.api.required) = "DeleteAttributesByTenantRequest.attribute_type";
        option (google.api.http).delete = "/v1/attributes/{tenant}";
    }
}

message GetAttributesRequest {
    FullNameResource full_name_resource = 1;
    string attribute_type = 2;
}

message GetAttributesResponse {
    repeated Attribute attributes = 1;
}

message DeleteAttributesByTenantRequest {
    string tenant = 1;
    string attribute_type = 2;
}
