{"modulePath":"github.com/cloudwan/gophercloud","version":"v0.0.0-20190122175118-e621b2311b07","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package groups\n\nPackage groups provides information and interaction with Security Groups for the OpenStack Networking service.\n\nExample to List Security Groups\n\n\tlistOpts := groups.ListOpts{\n\t\tTenantID: \"966b3c7d36a24facaf20b7e458bf2192\",\n\t}\n\n\tallPages, err := groups.List(networkClient, listOpts).AllPages()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tallGroups, err := groups.ExtractGroups(allPages)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, group := range allGroups {\n\t\tfmt.Printf(\"%+v\\n\", group)\n\t}\n\nExample to Create a Security Group\n\n\tcreateOpts := groups.CreateOpts{\n\t\tName:        \"group_name\",\n\t\tDescription: \"A Security Group\",\n\t}\n\n\tgroup, err := groups.Create(networkClient, createOpts).Extract()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\nExample to Update a Security Group\n\n\tgroupID := \"37d94f8a-d136-465c-ae46-144f0d8ef141\"\n\n\tupdateOpts := groups.UpdateOpts{\n\t\tName: \"new_name\",\n\t}\n\n\tgroup, err := groups.Update(networkClient, groupID, updateOpts).Extract()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\nExample to Delete a Security Group\n\n\tgroupID := \"37d94f8a-d136-465c-ae46-144f0d8ef141\"\n\terr := groups.Delete(networkClient, groupID).ExtractErr()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n## Functions\n\n```go\nfunc IDFromName(client *gophercloud.ServiceClient, name string) (string, error)\n```\nIDFromName is a convenience function that returns a security group's ID, given its name.\n\n```go\nfunc List(c *gophercloud.ServiceClient, opts ListOpts) pagination.Pager\n```\nList returns a Pager which allows you to iterate over a collection of security groups. It accepts a ListOpts struct, which allows you to filter and sort the returned collection for greater efficiency.\n\n## Types\n\n```go\ntype CreateOpts struct {\n\t// Human-readable name for the Security Group. Does not have to be unique.\n\tName string `json:\"name\" required:\"true\"`\n\n\t// TenantID is the UUID of the project who owns the Group.\n\t// Only administrative users can specify a tenant UUID other than their own.\n\tTenantID string `json:\"tenant_id,omitempty\"`\n\n\t// ProjectID is the UUID of the project who owns the Group.\n\t// Only administrative users can specify a tenant UUID other than their own.\n\tProjectID string `json:\"project_id,omitempty\"`\n\n\t// Describes the security group.\n\tDescription string `json:\"description,omitempty\"`\n}\n```\nCreateOpts contains all the values needed to create a new security group.\n\n```go\nfunc (opts CreateOpts) ToSecGroupCreateMap() (map[string]interface{}, error)\n```\nToSecGroupCreateMap builds a request body from CreateOpts.\n\n```go\ntype CreateOptsBuilder interface {\n\tToSecGroupCreateMap() (map[string]interface{}, error)\n}\n```\nCreateOptsBuilder allows extensions to add additional parameters to the Create request.\n\n```go\ntype CreateResult struct {\n\t// contains filtered or unexported fields\n}\n```\nCreateResult represents the result of a create operation. Call its Extract method to interpret it as a SecGroup.\n\n```go\nfunc Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)\n```\nCreate is an operation which provisions a new security group with default security group rules for the IPv4 and IPv6 ether types.\n\n```go\nfunc (r CreateResult) Extract() (*SecGroup, error)\n```\nExtract is a function that accepts a result and extracts a security group.\n\n```go\ntype DeleteResult struct {\n\tgophercloud.ErrResult\n}\n```\nDeleteResult represents the result of a delete operation. Call its ExtractErr method to determine if the request succeeded or failed.\n\n```go\nfunc Delete(c *gophercloud.ServiceClient, id string) (r DeleteResult)\n```\nDelete will permanently delete a particular security group based on its unique ID.\n\n```go\ntype GetResult struct {\n\t// contains filtered or unexported fields\n}\n```\nGetResult represents the result of a get operation. Call its Extract method to interpret it as a SecGroup.\n\n```go\nfunc Get(c *gophercloud.ServiceClient, id string) (r GetResult)\n```\nGet retrieves a particular security group based on its unique ID.\n\n```go\nfunc (r GetResult) Extract() (*SecGroup, error)\n```\nExtract is a function that accepts a result and extracts a security group.\n\n```go\ntype ListOpts struct {\n\tID          string `q:\"id\"`\n\tName        string `q:\"name\"`\n\tDescription string `q:\"description\"`\n\tTenantID    string `q:\"tenant_id\"`\n\tProjectID   string `q:\"project_id\"`\n\tLimit       int    `q:\"limit\"`\n\tMarker      string `q:\"marker\"`\n\tSortKey     string `q:\"sort_key\"`\n\tSortDir     string `q:\"sort_dir\"`\n\tTags        string `q:\"tags\"`\n\tTagsAny     string `q:\"tags-any\"`\n\tNotTags     string `q:\"not-tags\"`\n\tNotTagsAny  string `q:\"not-tags-any\"`\n}\n```\nListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the group attributes you want to see returned. SortKey allows you to sort by a particular network attribute. SortDir sets the direction, and is either \\`asc' or \\`desc'. Marker and Limit are used for pagination.\n\n```go\ntype SecGroup struct {\n\t// The UUID for the security group.\n\tID string\n\n\t// Human-readable name for the security group. Might not be unique.\n\t// Cannot be named \"default\" as that is automatically created for a tenant.\n\tName string\n\n\t// The security group description.\n\tDescription string\n\n\t// A slice of security group rules that dictate the permitted behaviour for\n\t// traffic entering and leaving the group.\n\tRules []rules.SecGroupRule `json:\"security_group_rules\"`\n\n\t// TenantID is the project owner of the security group.\n\tTenantID string `json:\"tenant_id\"`\n\n\t// ProjectID is the project owner of the security group.\n\tProjectID string `json:\"project_id\"`\n\n\t// Tags optionally set via extensions/attributestags\n\tTags []string `json:\"tags\"`\n}\n```\nSecGroup represents a container for security group rules.\n\n```go\nfunc ExtractGroups(r pagination.Page) ([]SecGroup, error)\n```\nExtractGroups accepts a Page struct, specifically a SecGroupPage struct, and extracts the elements into a slice of SecGroup structs. In other words, a generic collection is mapped into a relevant slice.\n\n```go\ntype SecGroupPage struct {\n\tpagination.LinkedPageBase\n}\n```\nSecGroupPage is the page returned by a pager when traversing over a collection of security groups.\n\n```go\nfunc (r SecGroupPage) IsEmpty() (bool, error)\n```\nIsEmpty checks whether a SecGroupPage struct is empty.\n\n```go\nfunc (r SecGroupPage) NextPageURL() (string, error)\n```\nNextPageURL is invoked when a paginated collection of security groups has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.\n\n```go\ntype UpdateOpts struct {\n\t// Human-readable name for the Security Group. Does not have to be unique.\n\tName string `json:\"name,omitempty\"`\n\n\t// Describes the security group.\n\tDescription *string `json:\"description,omitempty\"`\n}\n```\nUpdateOpts contains all the values needed to update an existing security group.\n\n```go\nfunc (opts UpdateOpts) ToSecGroupUpdateMap() (map[string]interface{}, error)\n```\nToSecGroupUpdateMap builds a request body from UpdateOpts.\n\n```go\ntype UpdateOptsBuilder interface {\n\tToSecGroupUpdateMap() (map[string]interface{}, error)\n}\n```\nUpdateOptsBuilder allows extensions to add additional parameters to the Update request.\n\n```go\ntype UpdateResult struct {\n\t// contains filtered or unexported fields\n}\n```\nUpdateResult represents the result of an update operation. Call its Extract method to interpret it as a SecGroup.\n\n```go\nfunc Update(c *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)\n```\nUpdate is an operation which updates an existing security group.\n\n```go\nfunc (r UpdateResult) Extract() (*SecGroup, error)\n```\nExtract is a function that accepts a result and extracts a security group.\n\n","path":"github.com/cloudwan/gophercloud/openstack/networking/v2/extensions/security/groups","name":"groups","synopsis":"Package groups provides information and interaction with Security Groups for the OpenStack Networking service.","isRedistributable":true}
