{"action":"created","comment":{"url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/comments/27248921","id":27248921,"diff_hunk":"@@ -2,67 +2,78 @@ package management\n \n import (\n \t\"encoding/xml\"\n-\t\"errors\"\n \t\"fmt\"\n \t\"time\"\n )\n \n-//operation represents an in-flight operation. Use client.getOperationStatus()\n-//to get the operation given the operation ID, or use\n-//client.waitAsyncOperation() to block until the operation has completed.\n-type operation struct {\n-\tXMLName        xml.Name `xml:\"Operation\"`\n+//  GetOperationStatusResponse  represents an in-flight operation. Use client.GetOperationStatus()\n+// to get the operation given the operation ID, or use\n+// client.WaitAsyncOperation() to block until the operation has completed.\n+// See https://msdn.microsoft.com/en-us/library/azure/ee460783.aspx\n+type GetOperationStatusResponse struct {\n+\tXMLName        xml.Name `xml:\"http://schemas.microsoft.com/windowsazure Operation\"`\n \tID             string\n-\tStatus         string\n+\tStatus         OperationStatus\n \tHttpStatusCode string\n-\tError          AzureError\n+\tError          *AzureError\n }\n \n-//getOperationStatus gets an operation given the operation ID.\n-func (client *Client) getOperationStatus(operationId string) (*operation, error) {\n+type OperationStatus string\n+\n+const (\n+\tOperationStatusInProgress OperationStatus = \"InProgress\"\n+\tOperationStatusSucceeded  OperationStatus = \"Succeeded\"\n+\tOperationStatusFailed     OperationStatus = \"Failed\"\n+)\n+\n+// OperationId is assigned by Azure API and can be used to look up the status of an operation\n+type OperationId string\n+\n+// getOperationStatus gets an operation given the operation ID.\n+func (client *Client) GetOperationStatus(operationId OperationId) (GetOperationStatusResponse, error) {\n+\toperation := GetOperationStatusResponse{}\n \tif operationId == \"\" {\n-\t\treturn nil, fmt.Errorf(errParamNotSpecified, \"operationId\")\n+\t\treturn operation, fmt.Errorf(errParamNotSpecified, \"operationId\")\n \t}\n \n-\toperation := new(operation)\n-\turl := \"operations/\" + operationId\n+\turl := fmt.Sprintf(\"operations/%s\", operationId)\n \tresponse, azureErr := client.SendAzureGetRequest(url)\n \tif azureErr != nil {\n-\t\treturn nil, azureErr\n+\t\treturn operation, azureErr\n \t}\n \n-\terr := xml.Unmarshal(response, operation)\n+\terr := xml.Unmarshal(response, &operation)\n \tif err != nil {\n-\t\treturn nil, err\n+\t\treturn operation, err\n \t}\n \n \treturn operation, nil\n }\n \n-//waitAsyncOperation blocks until the operation with the given operationId is\n-//no longer in the InProgress state. If the operation was successful, nothing is\n-//returned, otherwise an error is returned.\n-func (client *Client) WaitAsyncOperation(operationId string) error {\n-\tif operationId == \"\" {\n-\t\treturn fmt.Errorf(errParamNotSpecified, \"operationId\")\n-\t}\n+const pollInterval = 30 * time.Second\n \n-\tstatus := \"InProgress\"\n-\toperation := new(operation)\n-\terr := errors.New(\"\")\n-\tfor status == \"InProgress\" {\n-\t\ttime.Sleep(2000 * time.Millisecond)\n-\t\toperation, err = client.getOperationStatus(operationId)\n+// WaitAsyncOperation blocks until the operation with the given operationId is\n+// no longer in the InProgress state. If the operation was successful, nothing is\n+// returned, otherwise an error is returned.\n+func (client *Client) WaitAsyncOperation(operationId OperationId) error {\n+\tfor {\n+\t\toperation, err := client.GetOperationStatus(operationId)\n \t\tif err != nil {\n-\t\t\treturn err\n+\t\t\treturn fmt.Errorf(\"Failed to get operation status '%s': %v\", operationId, err)\n \t\t}\n \n-\t\tstatus = operation.Status\n-\t}\n-\n-\tif status == \"Failed\" {\n-\t\treturn fmt.Errorf(\"Azure operation %s failed. Code: %s, Message: %s\", operationId, operation.Error.Code, operation.Error.Message)\n+\t\tswitch operation.Status {\n+\t\tcase OperationStatusSucceeded:\n+\t\t\treturn nil\n+\t\tcase OperationStatusFailed:\n+\t\t\tif operation.Error != nil {\n+\t\t\t\treturn operation.Error","path":"management/operations.go","position":104,"original_position":104,"commit_id":"83ea78c145698bb27f5acfe42c40ac248c060936","original_commit_id":"83ea78c145698bb27f5acfe42c40ac248c060936","user":{"login":"ahmetalpbalkan","id":159209,"avatar_url":"https://avatars.githubusercontent.com/u/159209?v=3","gravatar_id":"","url":"https://api.github.com/users/ahmetalpbalkan","html_url":"https://github.com/ahmetalpbalkan","followers_url":"https://api.github.com/users/ahmetalpbalkan/followers","following_url":"https://api.github.com/users/ahmetalpbalkan/following{/other_user}","gists_url":"https://api.github.com/users/ahmetalpbalkan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahmetalpbalkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahmetalpbalkan/subscriptions","organizations_url":"https://api.github.com/users/ahmetalpbalkan/orgs","repos_url":"https://api.github.com/users/ahmetalpbalkan/repos","events_url":"https://api.github.com/users/ahmetalpbalkan/events{/privacy}","received_events_url":"https://api.github.com/users/ahmetalpbalkan/received_events","type":"User","site_admin":false},"body":":+1: ","created_at":"2015-03-26T19:47:29Z","updated_at":"2015-03-26T19:47:29Z","html_url":"https://github.com/MSOpenTech/azure-sdk-for-go/pull/85#discussion_r27248921","pull_request_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85","_links":{"self":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/comments/27248921"},"html":{"href":"https://github.com/MSOpenTech/azure-sdk-for-go/pull/85#discussion_r27248921"},"pull_request":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85"}}},"pull_request":{"url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85","id":31981900,"html_url":"https://github.com/MSOpenTech/azure-sdk-for-go/pull/85","diff_url":"https://github.com/MSOpenTech/azure-sdk-for-go/pull/85.diff","patch_url":"https://github.com/MSOpenTech/azure-sdk-for-go/pull/85.patch","issue_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/issues/85","number":85,"state":"open","locked":false,"title":"Introduce Azure OperationId type","user":{"login":"paulmey","id":1740197,"avatar_url":"https://avatars.githubusercontent.com/u/1740197?v=3","gravatar_id":"","url":"https://api.github.com/users/paulmey","html_url":"https://github.com/paulmey","followers_url":"https://api.github.com/users/paulmey/followers","following_url":"https://api.github.com/users/paulmey/following{/other_user}","gists_url":"https://api.github.com/users/paulmey/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmey/subscriptions","organizations_url":"https://api.github.com/users/paulmey/orgs","repos_url":"https://api.github.com/users/paulmey/repos","events_url":"https://api.github.com/users/paulmey/events{/privacy}","received_events_url":"https://api.github.com/users/paulmey/received_events","type":"User","site_admin":false},"body":"@ahmetalpbalkan Is this what you meant before in a PR? (can't find the exact comment)","created_at":"2015-03-26T01:21:26Z","updated_at":"2015-03-26T19:47:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bb0b1d6e9a743adeb94b2e0d0e78bd0a36a92f7e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85/commits","review_comments_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85/comments","review_comment_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/issues/85/comments","statuses_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/statuses/83ea78c145698bb27f5acfe42c40ac248c060936","head":{"label":"paulmey:requestid","ref":"requestid","sha":"83ea78c145698bb27f5acfe42c40ac248c060936","user":{"login":"paulmey","id":1740197,"avatar_url":"https://avatars.githubusercontent.com/u/1740197?v=3","gravatar_id":"","url":"https://api.github.com/users/paulmey","html_url":"https://github.com/paulmey","followers_url":"https://api.github.com/users/paulmey/followers","following_url":"https://api.github.com/users/paulmey/following{/other_user}","gists_url":"https://api.github.com/users/paulmey/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmey/subscriptions","organizations_url":"https://api.github.com/users/paulmey/orgs","repos_url":"https://api.github.com/users/paulmey/repos","events_url":"https://api.github.com/users/paulmey/events{/privacy}","received_events_url":"https://api.github.com/users/paulmey/received_events","type":"User","site_admin":false},"repo":{"id":31435349,"name":"azure-sdk-for-go","full_name":"paulmey/azure-sdk-for-go","owner":{"login":"paulmey","id":1740197,"avatar_url":"https://avatars.githubusercontent.com/u/1740197?v=3","gravatar_id":"","url":"https://api.github.com/users/paulmey","html_url":"https://github.com/paulmey","followers_url":"https://api.github.com/users/paulmey/followers","following_url":"https://api.github.com/users/paulmey/following{/other_user}","gists_url":"https://api.github.com/users/paulmey/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmey/subscriptions","organizations_url":"https://api.github.com/users/paulmey/orgs","repos_url":"https://api.github.com/users/paulmey/repos","events_url":"https://api.github.com/users/paulmey/events{/privacy}","received_events_url":"https://api.github.com/users/paulmey/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paulmey/azure-sdk-for-go","description":"azure-sdk-for-go","fork":true,"url":"https://api.github.com/repos/paulmey/azure-sdk-for-go","forks_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/forks","keys_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/teams","hooks_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/hooks","issue_events_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/issues/events{/number}","events_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/events","assignees_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/assignees{/user}","branches_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/branches{/branch}","tags_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/tags","blobs_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/statuses/{sha}","languages_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/languages","stargazers_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/stargazers","contributors_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/contributors","subscribers_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/subscribers","subscription_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/subscription","commits_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/contents/{+path}","compare_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/merges","archive_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/downloads","issues_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/issues{/number}","pulls_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/pulls{/number}","milestones_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/milestones{/number}","notifications_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/labels{/name}","releases_url":"https://api.github.com/repos/paulmey/azure-sdk-for-go/releases{/id}","created_at":"2015-02-27T19:26:42Z","updated_at":"2015-03-05T16:57:25Z","pushed_at":"2015-03-26T18:54:45Z","git_url":"git://github.com/paulmey/azure-sdk-for-go.git","ssh_url":"git@github.com:paulmey/azure-sdk-for-go.git","clone_url":"https://github.com/paulmey/azure-sdk-for-go.git","svn_url":"https://github.com/paulmey/azure-sdk-for-go","homepage":null,"size":962,"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":"MSOpenTech:master","ref":"master","sha":"a4d2635e7f95de1d995684c10ed95df83f2c7a39","user":{"login":"MSOpenTech","id":1638184,"avatar_url":"https://avatars.githubusercontent.com/u/1638184?v=3","gravatar_id":"","url":"https://api.github.com/users/MSOpenTech","html_url":"https://github.com/MSOpenTech","followers_url":"https://api.github.com/users/MSOpenTech/followers","following_url":"https://api.github.com/users/MSOpenTech/following{/other_user}","gists_url":"https://api.github.com/users/MSOpenTech/gists{/gist_id}","starred_url":"https://api.github.com/users/MSOpenTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MSOpenTech/subscriptions","organizations_url":"https://api.github.com/users/MSOpenTech/orgs","repos_url":"https://api.github.com/users/MSOpenTech/repos","events_url":"https://api.github.com/users/MSOpenTech/events{/privacy}","received_events_url":"https://api.github.com/users/MSOpenTech/received_events","type":"Organization","site_admin":false},"repo":{"id":22855240,"name":"azure-sdk-for-go","full_name":"MSOpenTech/azure-sdk-for-go","owner":{"login":"MSOpenTech","id":1638184,"avatar_url":"https://avatars.githubusercontent.com/u/1638184?v=3","gravatar_id":"","url":"https://api.github.com/users/MSOpenTech","html_url":"https://github.com/MSOpenTech","followers_url":"https://api.github.com/users/MSOpenTech/followers","following_url":"https://api.github.com/users/MSOpenTech/following{/other_user}","gists_url":"https://api.github.com/users/MSOpenTech/gists{/gist_id}","starred_url":"https://api.github.com/users/MSOpenTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MSOpenTech/subscriptions","organizations_url":"https://api.github.com/users/MSOpenTech/orgs","repos_url":"https://api.github.com/users/MSOpenTech/repos","events_url":"https://api.github.com/users/MSOpenTech/events{/privacy}","received_events_url":"https://api.github.com/users/MSOpenTech/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MSOpenTech/azure-sdk-for-go","description":"azure-sdk-for-go","fork":false,"url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go","forks_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/forks","keys_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/teams","hooks_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/hooks","issue_events_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/issues/events{/number}","events_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/events","assignees_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/assignees{/user}","branches_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/branches{/branch}","tags_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/tags","blobs_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/statuses/{sha}","languages_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/languages","stargazers_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/stargazers","contributors_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/contributors","subscribers_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/subscribers","subscription_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/subscription","commits_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/contents/{+path}","compare_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/merges","archive_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/downloads","issues_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/issues{/number}","pulls_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls{/number}","milestones_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/milestones{/number}","notifications_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/labels{/name}","releases_url":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/releases{/id}","created_at":"2014-08-11T21:18:43Z","updated_at":"2015-03-26T17:07:08Z","pushed_at":"2015-03-26T18:54:46Z","git_url":"git://github.com/MSOpenTech/azure-sdk-for-go.git","ssh_url":"git@github.com:MSOpenTech/azure-sdk-for-go.git","clone_url":"https://github.com/MSOpenTech/azure-sdk-for-go.git","svn_url":"https://github.com/MSOpenTech/azure-sdk-for-go","homepage":null,"size":2138,"stargazers_count":37,"watchers_count":37,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":15,"forks":20,"open_issues":15,"watchers":37,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85"},"html":{"href":"https://github.com/MSOpenTech/azure-sdk-for-go/pull/85"},"issue":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/issues/85"},"comments":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/MSOpenTech/azure-sdk-for-go/statuses/83ea78c145698bb27f5acfe42c40ac248c060936"}}}}