Revert a File

Reverts a file by releasing the lock that is placed on the file by a Check Out a File operation. After the Revert command runs, the file is again available to be checked out.

Note: For more information about this command, including descriptions of any path and request parameters, request body schema, response codes and schemas, and payload examples, refer to the online API reference for this command at the following web page:

Revert a file

URI

https://bartendercloud.com/api/librarian/files/{fileId}/revert

Note: The bartendercloud.com domain that is referenced in the URI and in the code example that follows must be replaced with the contents of the DataCenterURI claim that is extracted from your access token. For more information, refer to Extracting the DataCenterURI Claim.

Path Parameters

fileId

Type: String

Specifies the ID of the file to revert. This command clears the exclusive lock that is set during the checkout operation. Required.

Query Parameters

None.

Example

Request body: See FileUpdateRequest.

Response: A FileChange object is returned that provides details about the file.

Copy
// Assume that fileId is the ID of the file to revert.
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

var updateRequest = new FileUpdateRequest() {
    Comment = "Release lock on SQL Script file"
};
HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("PATCH"), new Uri($"https://bartendercloud.com/api/librarian/files/{fileId}/revert"))
{
   Content = new StringContent(JsonConvert.SerializeObject(updateRequest), Encoding.UTF8, "application/json")
};

HttpResponseMessage msg = await client.SendAsync(request);
if (msg.IsSuccessStatusCode)
{
   return JsonConvert.DeserializeObject<FileChange>(await msg.Content.ReadAsStringAsync());
}