github.com/polarismesh/polaris@v1.17.8/common/model/operation.go (about) 1 /** 2 * Tencent is pleased to support the open source community by making Polaris available. 3 * 4 * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 * 6 * Licensed under the BSD 3-Clause License (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * https://opensource.org/licenses/BSD-3-Clause 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed 13 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 * specific language governing permissions and limitations under the License. 16 */ 17 18 package model 19 20 import ( 21 "fmt" 22 "time" 23 24 commontime "github.com/polarismesh/polaris/common/time" 25 ) 26 27 // OperationType Operating type 28 type OperationType string 29 30 // Define the type of operation containing 31 const ( 32 // OCreate create 33 OCreate OperationType = "Create" 34 // ODelete delete 35 ODelete OperationType = "Delete" 36 // OUpdate update 37 OUpdate OperationType = "Update" 38 // OUpdateIsolate Update isolation state 39 OUpdateIsolate OperationType = "UpdateIsolate" 40 // OUpdateToken Update token 41 OUpdateToken OperationType = "UpdateToken" 42 // OUpdateGroup Update user-user group association relationship 43 OUpdateGroup OperationType = "UpdateGroup" 44 // OEnableRateLimit Update enable state 45 OUpdateEnable OperationType = "UpdateEnable" 46 // ORollback Rollback resource 47 ORollback OperationType = "Rollback" 48 ) 49 50 // Resource Operating resources 51 type Resource string 52 53 // Define the type of resource type 54 const ( 55 RNamespace Resource = "Namespace" 56 RService Resource = "Service" 57 RRouting Resource = "Routing" 58 RCircuitBreaker Resource = "CircuitBreaker" 59 RInstance Resource = "Instance" 60 RRateLimit Resource = "RateLimit" 61 RUser Resource = "User" 62 RUserGroup Resource = "UserGroup" 63 RUserGroupRelation Resource = "UserGroupRelation" 64 RAuthStrategy Resource = "AuthStrategy" 65 RConfigGroup Resource = "ConfigGroup" 66 RConfigFile Resource = "ConfigFile" 67 RConfigFileRelease Resource = "ConfigFileRelease" 68 RCircuitBreakerRule Resource = "CircuitBreakerRule" 69 RFaultDetectRule Resource = "FaultDetectRule" 70 ) 71 72 // RecordEntry Operation records 73 type RecordEntry struct { 74 ResourceType Resource 75 ResourceName string 76 Namespace string 77 Operator string 78 OperationType OperationType 79 Detail string 80 Server string 81 HappenTime time.Time 82 } 83 84 func (r *RecordEntry) String() string { 85 return fmt.Sprintf("%s|%s|%s|%s|%s|%s|%s|%s", 86 commontime.Time2String(r.HappenTime), 87 r.ResourceType, 88 r.ResourceName, 89 r.Namespace, 90 r.OperationType, 91 r.Operator, 92 r.Detail, 93 r.Server, 94 ) 95 }