yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/hcso/shell/saml_provider.go (about) 1 // Copyright 2019 Yunion 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 shell 16 17 import ( 18 huawei "yunion.io/x/cloudmux/pkg/multicloud/hcso" 19 "yunion.io/x/onecloud/pkg/util/shellutils" 20 ) 21 22 func init() { 23 type SAMLProviderListOptions struct { 24 } 25 shellutils.R(&SAMLProviderListOptions{}, "saml-provider-list", "List saml provider", func(cli *huawei.SRegion, args *SAMLProviderListOptions) error { 26 result, err := cli.GetClient().ListSAMLProviders() 27 if err != nil { 28 return err 29 } 30 printList(result, 0, 0, 0, nil) 31 return nil 32 }) 33 34 type SAMLProviderIdOptions struct { 35 ID string 36 } 37 38 shellutils.R(&SAMLProviderIdOptions{}, "saml-provider-delete", "Delete saml provider", func(cli *huawei.SRegion, args *SAMLProviderIdOptions) error { 39 return cli.GetClient().DeleteSAMLProvider(args.ID) 40 }) 41 42 shellutils.R(&SAMLProviderIdOptions{}, "saml-provider-protocol-list", "List saml provider protocol", func(cli *huawei.SRegion, args *SAMLProviderIdOptions) error { 43 result, err := cli.GetClient().GetSAMLProviderProtocols(args.ID) 44 if err != nil { 45 return err 46 } 47 printList(result, 0, 0, 0, nil) 48 return nil 49 }) 50 51 type SAMLProviderProtocolDeleteOptions struct { 52 SAML_PROVIDER string 53 PROTOCOL string 54 } 55 56 shellutils.R(&SAMLProviderProtocolDeleteOptions{}, "saml-provider-protocol-delete", "Delete saml provider protocol", func(cli *huawei.SRegion, args *SAMLProviderProtocolDeleteOptions) error { 57 return cli.GetClient().DeleteSAMLProviderProtocol(args.SAML_PROVIDER, args.PROTOCOL) 58 }) 59 60 shellutils.R(&SAMLProviderIdOptions{}, "saml-provider-metadata-show", "Show saml provider metadata", func(cli *huawei.SRegion, args *SAMLProviderIdOptions) error { 61 result, err := cli.GetClient().GetSAMLProviderMetadata(args.ID) 62 if err != nil { 63 return err 64 } 65 printObject(result) 66 return nil 67 }) 68 69 type SAMLProviderMetadataOptions struct { 70 ID string 71 METADATA string 72 } 73 74 shellutils.R(&SAMLProviderMetadataOptions{}, "saml-provider-metadata-update", "Update saml provider metadata", func(cli *huawei.SRegion, args *SAMLProviderMetadataOptions) error { 75 return cli.GetClient().UpdateSAMLProviderMetadata(args.ID, args.METADATA) 76 }) 77 78 type MappingListOptions struct { 79 } 80 81 shellutils.R(&MappingListOptions{}, "saml-provider-mapping-list", "List saml provider mapping", func(cli *huawei.SRegion, args *MappingListOptions) error { 82 mappings, err := cli.GetClient().ListSAMLProviderMappings() 83 if err != nil { 84 return err 85 } 86 printList(mappings, 0, 0, 0, nil) 87 return nil 88 }) 89 90 type MappingInitOptions struct { 91 SAML_PROVIDER string 92 } 93 94 shellutils.R(&MappingInitOptions{}, "saml-provider-mapping-init", "Init saml provider mapping", func(cli *huawei.SRegion, args *MappingInitOptions) error { 95 return cli.GetClient().InitSAMLProviderMapping(args.SAML_PROVIDER) 96 }) 97 98 type MappingDeleteOptions struct { 99 ID string 100 } 101 102 shellutils.R(&MappingDeleteOptions{}, "saml-provider-mapping-delete", "Delete saml provider mapping", func(cli *huawei.SRegion, args *MappingDeleteOptions) error { 103 return cli.GetClient().DeleteSAMLProviderMapping(args.ID) 104 }) 105 106 }