github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/identity/v3/trusts/doc.go (about)

     1  /*
     2  Package trusts enables management of OpenStack Identity Trusts.
     3  
     4  Example to Create a Trust
     5  
     6  	expiresAt := time.Date(2019, 12, 1, 14, 0, 0, 999999999, time.UTC)
     7  	createOpts := trusts.CreateOpts{
     8  	    ExpiresAt:         &expiresAt,
     9  	    Impersonation:     true,
    10  	    AllowRedelegation: true,
    11  	    ProjectID:         "9b71012f5a4a4aef9193f1995fe159b2",
    12  	    Roles: []trusts.Role{
    13  	        {
    14  	            Name: "member",
    15  	        },
    16  	    },
    17  	    TrusteeUserID: "ecb37e88cc86431c99d0332208cb6fbf",
    18  	    TrustorUserID: "959ed913a32c4ec88c041c98e61cbbc3",
    19  	}
    20  
    21  	trust, err := trusts.Create(context.TODO(), identityClient, createOpts).Extract()
    22  	if err != nil {
    23  	    panic(err)
    24  	}
    25  
    26  	fmt.Printf("Trust: %+v\n", trust)
    27  
    28  Example to Delete a Trust
    29  
    30  	trustID := "3422b7c113894f5d90665e1a79655e23"
    31  	err := trusts.Delete(context.TODO(), identityClient, trustID).ExtractErr()
    32  	if err != nil {
    33  	    panic(err)
    34  	}
    35  
    36  Example to Get a Trust
    37  
    38  	trustID := "3422b7c113894f5d90665e1a79655e23"
    39  	err := trusts.Get(context.TODO(), identityClient, trustID).ExtractErr()
    40  	if err != nil {
    41  	    panic(err)
    42  	}
    43  
    44  Example to List a Trust
    45  
    46  	listOpts := trusts.ListOpts{
    47  		TrustorUserId: "3422b7c113894f5d90665e1a79655e23",
    48  	}
    49  
    50  	allPages, err := trusts.List(identityClient, listOpts).AllPages(context.TODO())
    51  	if err != nil {
    52  		panic(err)
    53  	}
    54  
    55  	allTrusts, err := trusts.ExtractTrusts(allPages)
    56  	if err != nil {
    57  		panic(err)
    58  	}
    59  
    60  	for _, trust := range allTrusts {
    61  		fmt.Printf("%+v\n", region)
    62  	}
    63  */
    64  package trusts