github.com/sacloud/iaas-api-go@v1.12.0/types/auth.go (about) 1 // Copyright 2022-2023 The sacloud/iaas-api-go Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package types 16 17 import "strings" 18 19 // EAuthClass 認証クラス型 20 type EAuthClass string 21 22 // AuthClasses 認証クラス 23 var AuthClasses = struct { 24 // Unknown 不明 25 Unknown EAuthClass 26 // Account アカウント認証 27 Account EAuthClass 28 }{ 29 Unknown: EAuthClass(""), 30 Account: EAuthClass("account"), 31 } 32 33 // EAuthMethod 認証メソッド型 34 type EAuthMethod string 35 36 // AuthMethods 認証メソッド 37 var AuthMethods = struct { 38 // Unknown 不明 39 Unknown EAuthMethod 40 // APIKey APIキーによる認証 41 APIKey EAuthMethod 42 }{ 43 Unknown: EAuthMethod(""), 44 APIKey: EAuthMethod("apikey"), 45 } 46 47 // EOperationPenalty ペナルティ型 48 type EOperationPenalty string 49 50 // OperationPenalties ペナルティ 51 var OperationPenalties = struct { 52 // Unknown 不明 53 Unknown EOperationPenalty 54 // None ペナルティなし 55 None EOperationPenalty 56 }{ 57 Unknown: EOperationPenalty(""), 58 None: EOperationPenalty("none"), 59 } 60 61 // EPermission パーミッション型 62 type EPermission string 63 64 // Permissions パーミッション 65 var Permissions = struct { 66 // Unknown 不明 67 Unknown EPermission 68 // Create 作成・削除権限 69 Create EPermission 70 // Arrange 設定変更権限 71 Arrange EPermission 72 // Power 電源操作権限 73 Power EPermission 74 // View リソース閲覧権限 75 View EPermission 76 }{ 77 Unknown: EPermission(""), 78 Create: EPermission("create"), 79 Arrange: EPermission("arrange"), 80 Power: EPermission("power"), 81 View: EPermission("view"), 82 } 83 84 // ExternalPermission 他サービスへのアクセス権 85 // 86 // 各権限を表す文字列を+区切りで持つ。 87 // 例: イベントログと請求閲覧権限がある場合: eventlog+bill 88 type ExternalPermission string 89 90 // PermittedEventLog イベントログ権限を持つか 91 func (p *ExternalPermission) PermittedEventLog() bool { 92 return strings.Contains(string(*p), "eventlog") 93 } 94 95 // PermittedObjectStorage オブジェクトストレージの権限を持つか 96 func (p *ExternalPermission) PermittedObjectStorage() bool { 97 return strings.Contains(string(*p), "dstorage") 98 } 99 100 // PermittedBill 請求閲覧権限を持つか 101 func (p *ExternalPermission) PermittedBill() bool { 102 return strings.Contains(string(*p), "bill") 103 } 104 105 // PermittedWebAccel ウェブアクセラレータの権限を持つか 106 func (p *ExternalPermission) PermittedWebAccel() bool { 107 return strings.Contains(string(*p), "cdn") 108 } 109 110 // PermittedPHY PHYの権限を持つか 111 func (p *ExternalPermission) PermittedPHY() bool { 112 return strings.Contains(string(*p), "dedicatedphy") 113 }