github.com/gophercloud/gophercloud@v1.11.0/openstack/identity/v3/extensions/trusts/doc.go (about) 1 /* 2 Package trusts enables management of OpenStack Identity Trusts. 3 4 Example to Create a Token with Username, Password, and Trust ID 5 6 var trustToken struct { 7 tokens.Token 8 trusts.TokenExt 9 } 10 11 authOptions := tokens.AuthOptions{ 12 UserID: "username", 13 Password: "password", 14 } 15 16 createOpts := trusts.AuthOptsExt{ 17 AuthOptionsBuilder: authOptions, 18 TrustID: "de0945a", 19 } 20 21 err := tokens.Create(identityClient, createOpts).ExtractInto(&trustToken) 22 if err != nil { 23 panic(err) 24 } 25 26 Example to Create a Trust 27 28 expiresAt := time.Date(2019, 12, 1, 14, 0, 0, 999999999, time.UTC) 29 createOpts := trusts.CreateOpts{ 30 ExpiresAt: &expiresAt, 31 Impersonation: true, 32 AllowRedelegation: true, 33 ProjectID: "9b71012f5a4a4aef9193f1995fe159b2", 34 Roles: []trusts.Role{ 35 { 36 Name: "member", 37 }, 38 }, 39 TrusteeUserID: "ecb37e88cc86431c99d0332208cb6fbf", 40 TrustorUserID: "959ed913a32c4ec88c041c98e61cbbc3", 41 } 42 43 trust, err := trusts.Create(identityClient, createOpts).Extract() 44 if err != nil { 45 panic(err) 46 } 47 48 fmt.Printf("Trust: %+v\n", trust) 49 50 Example to Delete a Trust 51 52 trustID := "3422b7c113894f5d90665e1a79655e23" 53 err := trusts.Delete(identityClient, trustID).ExtractErr() 54 if err != nil { 55 panic(err) 56 } 57 58 Example to Get a Trust 59 60 trustID := "3422b7c113894f5d90665e1a79655e23" 61 err := trusts.Get(identityClient, trustID).ExtractErr() 62 if err != nil { 63 panic(err) 64 } 65 66 Example to List a Trust 67 68 listOpts := trusts.ListOpts{ 69 TrustorUserId: "3422b7c113894f5d90665e1a79655e23", 70 } 71 72 allPages, err := trusts.List(identityClient, listOpts).AllPages() 73 if err != nil { 74 panic(err) 75 } 76 77 allTrusts, err := trusts.ExtractTrusts(allPages) 78 if err != nil { 79 panic(err) 80 } 81 82 for _, trust := range allTrusts { 83 fmt.Printf("%+v\n", region) 84 } 85 */ 86 package trusts