Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Key Vault Admin] Convenience layer - KeyVaultBackupClient #11009

Merged
merged 13 commits into from
Sep 9, 2020

Conversation

sadasant
Copy link
Contributor

@sadasant sadasant commented Sep 3, 2020

The Backup Client source code.

IMPORTANT:

  • The BACKUP LRO has a return type of "string" since the result of the operation is the URI of the specific backup.
  • The RESTORE LRO has a return type of "undefined" because there's no expected return value for this operation.
  • Both of the new LROs use core-lro's getOperationState to show the other values of the pending operation. This gets extended by the properties of the generated code's operation.

You can see the tests here: #11010

This PR will fail until these PRs are merged:

For: #10799

* @param sasToken The SAS token.
* @param [options] The optional parameters.
*/
public async beginBackup(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python has it as begin_full_backup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.NET guidelines specify start* but I don't see any specific guidance around naming for the other langs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In JS we favor "begin". Assuming that this prefix is fine, what I'm most concerned is of the full part.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion here, but I opted for plain backup because there is no other backup operation to contrast with.

sasToken: string;
requestOptions?: BeginBackupOptions;
intervalInMs?: number;
resumeFrom?: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more of a question, but I thought I saw a continuation_token property in some of your other poller options (or was that paging options)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The continuation token is part of the internal implementation. It's hidden from the public API here, but it's definitely there!

sdk/keyvault/keyvault-admin/src/backupClient.ts Outdated Show resolved Hide resolved
Copy link
Member

@christothes christothes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found some typos, but looks good otherwise!

sdk/keyvault/keyvault-admin/src/backupClient.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/backupClient.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/backupClient.ts Outdated Show resolved Hide resolved
* ```ts
* const client = new KeyVaultBackupClient(url, credentials);
*
* const blobStorageUri = "<blob-storage-uri>"; // <Blob storage URL>/<folder name>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the folder name is a separate argument.

Suggested change
* const blobStorageUri = "<blob-storage-uri>"; // <Blob storage URL>/<folder name>
* const blobStorageUri = "<blob-storage-uri>";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christothes I thought the same, but my tests pass with the same parameters I'm using in the others, which satisfy: <Blob storage URL>/<folder name>. Do you have different parameters for these tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you are correct, sorry!

sdk/keyvault/keyvault-admin/src/backupClient.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/backupClient.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/backupClient.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/lro/restore/operation.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/lro/backup/operation.ts Outdated Show resolved Hide resolved
Co-authored-by: Christopher Scott <chriscott@hotmail.com>
@sadasant sadasant marked this pull request as ready for review September 4, 2020 17:48
Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good to go, I left some comments but I think they're all style/preference things.

sdk/keyvault/keyvault-admin/src/lro/backup/operation.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/lro/backup/operation.ts Outdated Show resolved Hide resolved
sdk/keyvault/keyvault-admin/src/lro/backup/operation.ts Outdated Show resolved Hide resolved
/**
* Status of the restore operation.
*/
status?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this always have some kind of known status, even if it's like "started" or something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it would be nice if this was a string union, but maybe we don't have that kind of safety?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property comes from the service! And, the swagger doesn't have a set of possible values :/ I could ask though. What do you think after this information?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this property is not part of core-lro, it's part of the service we're using for this client.


let response: KeyVaultClientFullRestoreOperationResponse;
try {
response = await client.fullRestoreOperation(vaultUrl, setParentSpan(span, options));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional nit: you could do the assignment and return inside the try block if you wanted:

try {
  const response = await client.fullRestoreOperation(vaultUrl, setParentSpan(span, options));
  return response;
} finally {
   span.end();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that still allow the span.end() to run? 😮 I can also just return client.full*

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns inside a try still execute the finally, but you'll want to do an await or else the time spent inside the promise won't be tracked by the span

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh thank you

sdk/keyvault/keyvault-admin/src/lro/restore/operation.ts Outdated Show resolved Hide resolved
Copy link
Member

@bterlson bterlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the API, nice work.

@sadasant
Copy link
Contributor Author

sadasant commented Sep 9, 2020

@bterlson thank you!

@sadasant sadasant merged commit 3c5a739 into Azure:master Sep 9, 2020
@sadasant sadasant deleted the keyvault-admin/backupClient branch September 9, 2020 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants