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

feat(iot-dev): Deprecate existing upload to blob APIs in favor of more granular APIs #808

Merged
merged 5 commits into from
Jun 15, 2020

Conversation

timtay-microsoft
Copy link
Member

@timtay-microsoft timtay-microsoft commented Jun 12, 2020

Customers should be free to use whatever version of the Azure Storage SDK that they want, and to configure it however they want. Because of that, the existing file upload API has been split into the three service calls: Get SAS uri from Iot Hub, upload to Azure Storage blob using iothub provided credentials, and then notify Iot hub that a file upload has completed.

Same as the recent effort on C# SDK that can be seen here: Azure/azure-iot-sdk-csharp#1403

…e granular APIs

Customers should be free to use whatever version of the Azure Storage SDK that they want, and to configure it however they want. Because of that, the existing file upload API has been split into the three service calls: Get SAS uri from Iot Hub, upload to Azure Storage blob using iothub provided credentials, and then notify Iot hub that a file upload has completed.
@timtay-microsoft
Copy link
Member Author

/azp run Java Prod

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@timtay-microsoft
Copy link
Member Author

/azp run Java Prod

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

}

/**
* Update the status information in the collection, and return the new json.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment says the method return the new job. Method signature does not not return anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why we had javadoc for a private method, so I'll just delete the whole thing

* @param statusDescription is the description of the status code.
* @throws IllegalArgumentException if one of the parameters is null, empty, or not valid.
*/
private void updateStatus(Boolean isSuccess, Integer statusCode, String statusDescription) throws IllegalArgumentException
Copy link
Contributor

@barustum barustum Jun 15, 2020

Choose a reason for hiding this comment

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

Nothing is thrown in this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

See above, I'll delete this javadoc

}

/**
* Convert this class in a valid json.
Copy link
Contributor

Choose a reason for hiding this comment

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

'to' a valid json.

}

/**
* @return Get the correlationId that correlates this FileUploadCompletionNotification to the earlier request to get the SAS URI
Copy link
Contributor

@barustum barustum Jun 15, 2020

Choose a reason for hiding this comment

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

Seems like this description describes the API and not the return value. Maybe remove the 'Get'?


/**
* Empty constructor: Used only to keep GSON happy.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need a @SuppressWarnings("unused") for this constructor?

Copy link
Member Author

Choose a reason for hiding this comment

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

This repo doesn't really pay much attention to warnings, so no

* @throws IllegalArgumentException if one of the parameters is null, empty, or not valid.
*/
public FileUploadCompletionNotification(String correlationId, Boolean isSuccess)
throws IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

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

is this 'throws' needed since the method doesn't throw anything?

* @throws IllegalArgumentException if one of the parameters is null, empty, or not valid.
*/
public FileUploadCompletionNotification(String correlationId, Boolean isSuccess, Integer statusCode, String statusDescription)
throws IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

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

is this 'throws' needed since the method doesn't throw anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, there is nothing thrown here anymore so I'll update the method signature and the javadocs

* @param json the json to parse.
*/
public FileUploadCompletionNotification(String json)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a throws IllegalArgumentException for thie constructor?

Copy link
Member Author

@timtay-microsoft timtay-microsoft Jun 15, 2020

Choose a reason for hiding this comment

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

No, because IllegalArgumentException is a runtime exception, so java methods don't need to declare them. https://www.tutorialspoint.com/how-to-handle-the-runtime-exception-in-java

}
}
}

/* Tests_SRS_FILE_UPLOAD_STATUS_21_004: [The toJson shall return a string with a json that represents the contend of the FileUploadStatusParser.] */
Copy link
Contributor

Choose a reason for hiding this comment

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

FileUploadStatusParser -> FileUploadCompletionNotification

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I should just delete these comments. They are a relic of an out-dated practice we used to do. They aren't worth keeping around anymore

assertFileUploadRequest(fileUploadSasUriRequest, VALID_BLOB_NAME);
}

/* Tests_SRS_FILE_UPLOAD_REQUEST_21_004: [The toJson shall return a string with a json that represents the contend of the FileUploadSasUriResponse.] */
Copy link
Contributor

Choose a reason for hiding this comment

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

contend -> content

assertFileUploadRequest(fileUploadSasUriRequest, VALID_BLOB_NAME);
}

/* Tests_SRS_FILE_UPLOAD_REQUEST_21_004: [The toJson shall return a string with a json that represents the contend of the FileUploadSasUriResponse.] */
Copy link
Contributor

Choose a reason for hiding this comment

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

FileUploadSasUriResponse -> FileUploadSasUriRequest

@timtay-microsoft
Copy link
Member Author

/azp run Java Prod

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@timtay-microsoft
Copy link
Member Author

/azp run Java Prod

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@timtay-microsoft
Copy link
Member Author

/azp run Java Prod Basic, SDL, horton-java-gate

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@timtay-microsoft timtay-microsoft merged commit 54769d2 into master Jun 15, 2020
@timtay-microsoft timtay-microsoft deleted the timtay/fileUpload branch June 15, 2020 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants