github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/sfs/v2/shares/doc.go (about)

     1  /*
     2  Package shares enables management and retrieval of shares
     3  Share service.
     4  Example to List Shares
     5  	listshares := shares.ListOpts{}
     6  	allshares, err := shares.List(client,listshares)
     7  	if err != nil {
     8  		panic(err)
     9  	}
    10  	fmt.Println(allshares)
    11  
    12  Example to Create a share
    13  	share:=shares.CreateOpts{
    14  			Name:"sfs-test",
    15  			ShareProto:"NFS",
    16  			Size:1,
    17  		}
    18  	outshare,err:=shares.Create(client,share).Extract()
    19  	if err != nil {
    20  				panic(err)
    21  			}
    22  	fmt.Println(outshare)
    23  
    24  Example to Update a share
    25  	updateshare:=shares.UpdateOpts{DisplayName:"sfs-test-1",DisplayDescription:"test sfs"}
    26  	out,err:=shares.Update(client,"6149e448-dcac-4691-96d9-041e09ef617f",updateshare).Extract()
    27  	if err != nil {
    28  			panic(err)
    29  		}
    30  	fmt.Println(out)
    31  
    32  Example to Delete a share
    33  	out:=shares.Delete(client,"6149e448-dcac-4691-96d9-041e09ef617f")
    34  	fmt.Println(out)
    35  	if err != nil {
    36  		panic(err)
    37  	}
    38  
    39  Example to Get share
    40  	getshare,err:=shares.Get(client, "6149e448-dcac-4691-96d9-041e09ef617f").Extract()
    41  	fmt.Println(getshare)
    42  	if err != nil {
    43  			panic(err)
    44  		}
    45  Example to Allow Access
    46  createSet:=shares.GrantAccessOpts{AccessLevel:"rw",AccessTo:"5232f396-d6cc-4a81-8de3-afd7a7ecdfd8",AccessType:"cert"}
    47  	access,err:=shares.GrantAccess(client,"dff2df5f-00e7-4517-ac32-1d0ab8dc0d68",createSet).Extract()
    48  	fmt.Println(access)
    49  	if err != nil {
    50  			panic(err)
    51  		}
    52  
    53  Example to Deny Access
    54  	deleteSet := shares.DeleteAccessOpts{AccessID:"fc32500f-fa78-4f06-8caf-06ad7fb9726c"}
    55  	remove:=shares.DeleteAccess(client,"1b8facf8-b822-4349-a033-e078b2a84b7f",deleteSet)
    56  	fmt.Println(remove)
    57  	if err != nil {
    58  			panic(err)
    59  		}
    60  
    61  Example to Get Access Rule Detail
    62  	rule_list,err:= shares.ListAccessRights(client,"42381b5b-f8cb-445e-9465-89a718e071a7").ExtractAccessRights()
    63  	if err != nil {
    64  			panic(err)
    65  		}
    66  	fmt.Println(rule_list)
    67  
    68  Example to Get Mount Location Details
    69  	mount, err := shares.GetExportLocations(client, "dff2df5f-00e7-4517-ac32-1d0ab8dc0d68").ExtractExportLocations()
    70  	fmt.Println(mount)
    71  	if err != nil {
    72  			panic(err)
    73  		}
    74  
    75  Example to Extend share
    76  	extendsfs:=shares.ExpandOpts{OSExtend: shares.OSExtendOpts{NewSize: 512}}
    77  	shares.Expand(client,"45a3af18-8ab0-405c-9ead-06c51a415f79",extendsfs)
    78  
    79  Example to Shrink share
    80  	shrinksfs:=shares.ShrinkOpts{OSShrink: shares.OSShrinkOpts{NewSize: 8}}
    81  	shares.Shrink(client,"45a3af18-8ab0-405c-9ead-06c51a415f79",shrinksfs)
    82  */
    83  package shares