{"action":"created","comment":{"url":"https://api.github.com/repos/rackspace/gophercloud/pulls/comments/59243328","id":59243328,"diff_hunk":"@@ -0,0 +1,251 @@\n+package policies\n+\n+import (\n+\t\"errors\"\n+\n+\t\"github.com/rackspace/gophercloud\"\n+\t\"github.com/rackspace/gophercloud/pagination\"\n+)\n+\n+// Validation errors returned by create or update operations.\n+var (\n+\tErrNoName            = errors.New(\"Policy name cannot by empty.\")\n+\tErrNoArgs            = errors.New(\"Args cannot be nil for schedule policies.\")\n+\tErrInvalidAdjustment = errors.New(\"Invalid adjustment type.\")\n+)\n+\n+// List returns all scaling policies for a group.\n+func List(client *gophercloud.ServiceClient, groupID string) pagination.Pager {\n+\turl := listURL(client, groupID)\n+\n+\tcreatePageFn := func(r pagination.PageResult) pagination.Page {\n+\t\treturn PolicyPage{pagination.SinglePageBase(r)}\n+\t}\n+\n+\treturn pagination.NewPager(client, url, createPageFn)\n+}\n+\n+// CreateOptsBuilder is the interface responsible for generating the map that\n+// will be marshalled to JSON for a Create operation.\n+type CreateOptsBuilder interface {\n+\tToPolicyCreateMap() ([]map[string]interface{}, error)\n+}\n+\n+// Adjustment represents the change in capacity associated with a policy.\n+type Adjustment struct {\n+\t// The type for this adjustment.\n+\tType AdjustmentType\n+\n+\t// The value of the adjustment.  For adjustments of type Change or\n+\t// DesiredCapacity, this will be converted to an integer.\n+\tValue float64\n+}\n+\n+// AdjustmentType represents the way in which a policy will change a group.\n+type AdjustmentType string\n+\n+// Valid types of adjustments for a policy.\n+const (\n+\tChange          AdjustmentType = \"change\"\n+\tChangePercent   AdjustmentType = \"changePercent\"\n+\tDesiredCapacity AdjustmentType = \"desiredCapacity\"\n+)\n+\n+// CreateOpts is a slice of CreateOpt structs that allow the user to create\n+// multiple policies in a single operation.\n+type CreateOpts []CreateOpt\n+\n+// CreateOpt represents the options to create a policy.\n+type CreateOpt struct {\n+\t// Name [required] is a name for the policy.\n+\tName string\n+\n+\t// Type [required] of policy, i.e. either \"webhook\" or \"schedule\".\n+\tType Type\n+\n+\t// Cooldown [required] period in seconds.\n+\tCooldown int\n+\n+\t// Adjustment [requried] type and value for the policy.\n+\tAdjustment Adjustment\n+\n+\t// Additional configuration options for some types of policy.\n+\tArgs map[string]interface{}\n+}\n+\n+// ToPolicyCreateMap converts a slice of CreateOpt structs into a map for use\n+// in the request body of a Create operation.\n+func (opts CreateOpts) ToPolicyCreateMap() ([]map[string]interface{}, error) {\n+\tvar policies []map[string]interface{}\n+\n+\tfor _, o := range opts {\n+\t\tif o.Name == \"\" {\n+\t\t\treturn nil, ErrNoName","path":"rackspace/autoscale/v1/policies/requests.go","position":71,"original_position":83,"commit_id":"eedc8d932fcb100b9957c640f9f775759f7d8a5a","original_commit_id":"4d1a9a6c797895b198b3365a4c82fb52584764ae","user":{"login":"bison","id":240676,"avatar_url":"https://avatars.githubusercontent.com/u/240676?v=3","gravatar_id":"","url":"https://api.github.com/users/bison","html_url":"https://github.com/bison","followers_url":"https://api.github.com/users/bison/followers","following_url":"https://api.github.com/users/bison/following{/other_user}","gists_url":"https://api.github.com/users/bison/gists{/gist_id}","starred_url":"https://api.github.com/users/bison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bison/subscriptions","organizations_url":"https://api.github.com/users/bison/orgs","repos_url":"https://api.github.com/users/bison/repos","events_url":"https://api.github.com/users/bison/events{/privacy}","received_events_url":"https://api.github.com/users/bison/received_events","type":"User","site_admin":false},"body":"Added validation for `Type` and `Cooldown`.","created_at":"2016-04-11T17:17:06Z","updated_at":"2016-04-11T17:17:06Z","html_url":"https://github.com/rackspace/gophercloud/pull/554#discussion_r59243328","pull_request_url":"https://api.github.com/repos/rackspace/gophercloud/pulls/554","_links":{"self":{"href":"https://api.github.com/repos/rackspace/gophercloud/pulls/comments/59243328"},"html":{"href":"https://github.com/rackspace/gophercloud/pull/554#discussion_r59243328"},"pull_request":{"href":"https://api.github.com/repos/rackspace/gophercloud/pulls/554"}}},"pull_request":{"url":"https://api.github.com/repos/rackspace/gophercloud/pulls/554","id":65726569,"html_url":"https://github.com/rackspace/gophercloud/pull/554","diff_url":"https://github.com/rackspace/gophercloud/pull/554.diff","patch_url":"https://github.com/rackspace/gophercloud/pull/554.patch","issue_url":"https://api.github.com/repos/rackspace/gophercloud/issues/554","number":554,"state":"open","locked":false,"title":"[RFR] Rackspace Auto Scale: policies","user":{"login":"bison","id":240676,"avatar_url":"https://avatars.githubusercontent.com/u/240676?v=3","gravatar_id":"","url":"https://api.github.com/users/bison","html_url":"https://github.com/bison","followers_url":"https://api.github.com/users/bison/followers","following_url":"https://api.github.com/users/bison/following{/other_user}","gists_url":"https://api.github.com/users/bison/gists{/gist_id}","starred_url":"https://api.github.com/users/bison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bison/subscriptions","organizations_url":"https://api.github.com/users/bison/orgs","repos_url":"https://api.github.com/users/bison/repos","events_url":"https://api.github.com/users/bison/events{/privacy}","received_events_url":"https://api.github.com/users/bison/received_events","type":"User","site_admin":false},"body":"Adds a package for Rackspace Auto Scale [policies](https://developer.rackspace.com/docs/autoscale/v1/developer-guide/#document-api-operations/autoscale-policies).","created_at":"2016-04-08T01:51:25Z","updated_at":"2016-04-11T17:17:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2daf646e8bb3753317877bd7910eaf512d721df6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rackspace/gophercloud/pulls/554/commits","review_comments_url":"https://api.github.com/repos/rackspace/gophercloud/pulls/554/comments","review_comment_url":"https://api.github.com/repos/rackspace/gophercloud/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rackspace/gophercloud/issues/554/comments","statuses_url":"https://api.github.com/repos/rackspace/gophercloud/statuses/eedc8d932fcb100b9957c640f9f775759f7d8a5a","head":{"label":"bison:autoscale-policies","ref":"autoscale-policies","sha":"eedc8d932fcb100b9957c640f9f775759f7d8a5a","user":{"login":"bison","id":240676,"avatar_url":"https://avatars.githubusercontent.com/u/240676?v=3","gravatar_id":"","url":"https://api.github.com/users/bison","html_url":"https://github.com/bison","followers_url":"https://api.github.com/users/bison/followers","following_url":"https://api.github.com/users/bison/following{/other_user}","gists_url":"https://api.github.com/users/bison/gists{/gist_id}","starred_url":"https://api.github.com/users/bison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bison/subscriptions","organizations_url":"https://api.github.com/users/bison/orgs","repos_url":"https://api.github.com/users/bison/repos","events_url":"https://api.github.com/users/bison/events{/privacy}","received_events_url":"https://api.github.com/users/bison/received_events","type":"User","site_admin":false},"repo":{"id":54592209,"name":"gophercloud","full_name":"bison/gophercloud","owner":{"login":"bison","id":240676,"avatar_url":"https://avatars.githubusercontent.com/u/240676?v=3","gravatar_id":"","url":"https://api.github.com/users/bison","html_url":"https://github.com/bison","followers_url":"https://api.github.com/users/bison/followers","following_url":"https://api.github.com/users/bison/following{/other_user}","gists_url":"https://api.github.com/users/bison/gists{/gist_id}","starred_url":"https://api.github.com/users/bison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bison/subscriptions","organizations_url":"https://api.github.com/users/bison/orgs","repos_url":"https://api.github.com/users/bison/repos","events_url":"https://api.github.com/users/bison/events{/privacy}","received_events_url":"https://api.github.com/users/bison/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bison/gophercloud","description":"A Go SDK for OpenStack.","fork":true,"url":"https://api.github.com/repos/bison/gophercloud","forks_url":"https://api.github.com/repos/bison/gophercloud/forks","keys_url":"https://api.github.com/repos/bison/gophercloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bison/gophercloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bison/gophercloud/teams","hooks_url":"https://api.github.com/repos/bison/gophercloud/hooks","issue_events_url":"https://api.github.com/repos/bison/gophercloud/issues/events{/number}","events_url":"https://api.github.com/repos/bison/gophercloud/events","assignees_url":"https://api.github.com/repos/bison/gophercloud/assignees{/user}","branches_url":"https://api.github.com/repos/bison/gophercloud/branches{/branch}","tags_url":"https://api.github.com/repos/bison/gophercloud/tags","blobs_url":"https://api.github.com/repos/bison/gophercloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bison/gophercloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bison/gophercloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/bison/gophercloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bison/gophercloud/statuses/{sha}","languages_url":"https://api.github.com/repos/bison/gophercloud/languages","stargazers_url":"https://api.github.com/repos/bison/gophercloud/stargazers","contributors_url":"https://api.github.com/repos/bison/gophercloud/contributors","subscribers_url":"https://api.github.com/repos/bison/gophercloud/subscribers","subscription_url":"https://api.github.com/repos/bison/gophercloud/subscription","commits_url":"https://api.github.com/repos/bison/gophercloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/bison/gophercloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/bison/gophercloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/bison/gophercloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/bison/gophercloud/contents/{+path}","compare_url":"https://api.github.com/repos/bison/gophercloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bison/gophercloud/merges","archive_url":"https://api.github.com/repos/bison/gophercloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bison/gophercloud/downloads","issues_url":"https://api.github.com/repos/bison/gophercloud/issues{/number}","pulls_url":"https://api.github.com/repos/bison/gophercloud/pulls{/number}","milestones_url":"https://api.github.com/repos/bison/gophercloud/milestones{/number}","notifications_url":"https://api.github.com/repos/bison/gophercloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bison/gophercloud/labels{/name}","releases_url":"https://api.github.com/repos/bison/gophercloud/releases{/id}","deployments_url":"https://api.github.com/repos/bison/gophercloud/deployments","created_at":"2016-03-23T20:52:01Z","updated_at":"2016-03-23T20:52:03Z","pushed_at":"2016-04-11T17:15:55Z","git_url":"git://github.com/bison/gophercloud.git","ssh_url":"git@github.com:bison/gophercloud.git","clone_url":"https://github.com/bison/gophercloud.git","svn_url":"https://github.com/bison/gophercloud","homepage":"http://gophercloud.io","size":9566,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rackspace:master","ref":"master","sha":"a09b5b4eb58195b6fb3898496586b8d6aeb558e0","user":{"login":"rackspace","id":3949923,"avatar_url":"https://avatars.githubusercontent.com/u/3949923?v=3","gravatar_id":"","url":"https://api.github.com/users/rackspace","html_url":"https://github.com/rackspace","followers_url":"https://api.github.com/users/rackspace/followers","following_url":"https://api.github.com/users/rackspace/following{/other_user}","gists_url":"https://api.github.com/users/rackspace/gists{/gist_id}","starred_url":"https://api.github.com/users/rackspace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackspace/subscriptions","organizations_url":"https://api.github.com/users/rackspace/orgs","repos_url":"https://api.github.com/users/rackspace/repos","events_url":"https://api.github.com/users/rackspace/events{/privacy}","received_events_url":"https://api.github.com/users/rackspace/received_events","type":"Organization","site_admin":false},"repo":{"id":10826219,"name":"gophercloud","full_name":"rackspace/gophercloud","owner":{"login":"rackspace","id":3949923,"avatar_url":"https://avatars.githubusercontent.com/u/3949923?v=3","gravatar_id":"","url":"https://api.github.com/users/rackspace","html_url":"https://github.com/rackspace","followers_url":"https://api.github.com/users/rackspace/followers","following_url":"https://api.github.com/users/rackspace/following{/other_user}","gists_url":"https://api.github.com/users/rackspace/gists{/gist_id}","starred_url":"https://api.github.com/users/rackspace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackspace/subscriptions","organizations_url":"https://api.github.com/users/rackspace/orgs","repos_url":"https://api.github.com/users/rackspace/repos","events_url":"https://api.github.com/users/rackspace/events{/privacy}","received_events_url":"https://api.github.com/users/rackspace/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rackspace/gophercloud","description":"A Go SDK for OpenStack.","fork":false,"url":"https://api.github.com/repos/rackspace/gophercloud","forks_url":"https://api.github.com/repos/rackspace/gophercloud/forks","keys_url":"https://api.github.com/repos/rackspace/gophercloud/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rackspace/gophercloud/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rackspace/gophercloud/teams","hooks_url":"https://api.github.com/repos/rackspace/gophercloud/hooks","issue_events_url":"https://api.github.com/repos/rackspace/gophercloud/issues/events{/number}","events_url":"https://api.github.com/repos/rackspace/gophercloud/events","assignees_url":"https://api.github.com/repos/rackspace/gophercloud/assignees{/user}","branches_url":"https://api.github.com/repos/rackspace/gophercloud/branches{/branch}","tags_url":"https://api.github.com/repos/rackspace/gophercloud/tags","blobs_url":"https://api.github.com/repos/rackspace/gophercloud/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rackspace/gophercloud/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rackspace/gophercloud/git/refs{/sha}","trees_url":"https://api.github.com/repos/rackspace/gophercloud/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rackspace/gophercloud/statuses/{sha}","languages_url":"https://api.github.com/repos/rackspace/gophercloud/languages","stargazers_url":"https://api.github.com/repos/rackspace/gophercloud/stargazers","contributors_url":"https://api.github.com/repos/rackspace/gophercloud/contributors","subscribers_url":"https://api.github.com/repos/rackspace/gophercloud/subscribers","subscription_url":"https://api.github.com/repos/rackspace/gophercloud/subscription","commits_url":"https://api.github.com/repos/rackspace/gophercloud/commits{/sha}","git_commits_url":"https://api.github.com/repos/rackspace/gophercloud/git/commits{/sha}","comments_url":"https://api.github.com/repos/rackspace/gophercloud/comments{/number}","issue_comment_url":"https://api.github.com/repos/rackspace/gophercloud/issues/comments{/number}","contents_url":"https://api.github.com/repos/rackspace/gophercloud/contents/{+path}","compare_url":"https://api.github.com/repos/rackspace/gophercloud/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rackspace/gophercloud/merges","archive_url":"https://api.github.com/repos/rackspace/gophercloud/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rackspace/gophercloud/downloads","issues_url":"https://api.github.com/repos/rackspace/gophercloud/issues{/number}","pulls_url":"https://api.github.com/repos/rackspace/gophercloud/pulls{/number}","milestones_url":"https://api.github.com/repos/rackspace/gophercloud/milestones{/number}","notifications_url":"https://api.github.com/repos/rackspace/gophercloud/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rackspace/gophercloud/labels{/name}","releases_url":"https://api.github.com/repos/rackspace/gophercloud/releases{/id}","deployments_url":"https://api.github.com/repos/rackspace/gophercloud/deployments","created_at":"2013-06-20T18:10:46Z","updated_at":"2016-04-07T11:47:27Z","pushed_at":"2016-04-11T17:15:55Z","git_url":"git://github.com/rackspace/gophercloud.git","ssh_url":"git@github.com:rackspace/gophercloud.git","clone_url":"https://github.com/rackspace/gophercloud.git","svn_url":"https://github.com/rackspace/gophercloud","homepage":"http://gophercloud.io","size":9874,"stargazers_count":353,"watchers_count":353,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":125,"mirror_url":null,"open_issues_count":39,"forks":125,"open_issues":39,"watchers":353,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rackspace/gophercloud/pulls/554"},"html":{"href":"https://github.com/rackspace/gophercloud/pull/554"},"issue":{"href":"https://api.github.com/repos/rackspace/gophercloud/issues/554"},"comments":{"href":"https://api.github.com/repos/rackspace/gophercloud/issues/554/comments"},"review_comments":{"href":"https://api.github.com/repos/rackspace/gophercloud/pulls/554/comments"},"review_comment":{"href":"https://api.github.com/repos/rackspace/gophercloud/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rackspace/gophercloud/pulls/554/commits"},"statuses":{"href":"https://api.github.com/repos/rackspace/gophercloud/statuses/eedc8d932fcb100b9957c640f9f775759f7d8a5a"}}}}