|
| 1 | +--- |
| 2 | +id: "metered-consumption" |
| 3 | +url: "viewer/metered-consumption" |
| 4 | +title: "Getting metered license consumption" |
| 5 | +productName: "GroupDocs.Viewer Cloud" |
| 6 | +description: "" |
| 7 | +keywords: "" |
| 8 | +--- |
| 9 | +### Introduction ### |
| 10 | + |
| 11 | +{{< alert style="info" >}} |
| 12 | +This example related to Docker version of GroupDocs.Viewer-Cloud only |
| 13 | +{{< /alert >}} |
| 14 | + |
| 15 | +The metered license can be used in Docker version of GroupDocs.Viewer-Cloud. |
| 16 | +Here is an example how to retrieve metered license consumption. |
| 17 | + |
| 18 | +You can find more information about Docker version at [How to self-host GroupDocs.Viewer Cloud with Docker]({{< ref "viewer/getting-started/how-to-self-host-groupdocs-viewer-cloud-with-docker.md" >}}) |
| 19 | + |
| 20 | +## Resource URI ## |
| 21 | + |
| 22 | +```HTTP GET ~/viewer/consumption``` |
| 23 | + |
| 24 | +## cURL Example ## |
| 25 | + |
| 26 | +{{< tabs tabTotal="2" tabID="1" tabName1="Request" tabName2="Response" >}} {{< tab tabNum="1" >}} |
| 27 | + |
| 28 | +```html |
| 29 | + |
| 30 | +* cURL example to get metered license consumption |
| 31 | +curl -v "http://<base url>/v2.0/viewer/consumption" \ |
| 32 | +-X GET \ |
| 33 | +-H "Accept: application/json" \ |
| 34 | +-H "Authorization: Bearer <jwt token>" |
| 35 | +``` |
| 36 | + |
| 37 | +{{< /tab >}} {{< tab tabNum="2" >}} |
| 38 | + |
| 39 | +```html |
| 40 | +{ |
| 41 | + "credit": 487848, |
| 42 | + "quantity": 6061570985.37938 |
| 43 | +} |
| 44 | +{{< /tab >}} {{< /tabs >}} |
| 45 | + |
| 46 | +## Response ## |
| 47 | + |
| 48 | +The response structure contains metered license consumption information: |
| 49 | + |
| 50 | +| Name | Type | Comment |
| 51 | +|---|---|--- |
| 52 | +|Credit|decimal|Amount of used credits. |
| 53 | +|Quantity|decimal|Amount of MBs processed. |
| 54 | + |
| 55 | +## SDKs ## |
| 56 | + |
| 57 | +Our API is completely independent of your operating system, database system or development language. You can use any language and platform that supports HTTP to interact with our API. However, manually writing client code can be difficult, error-prone and time-consuming. Therefore, we have provided and support API [SDKs](https://github.com/groupdocs-viewer-cloud) in many development languages in order to make it easier to integrate with us. |
| 58 | + |
| 59 | +### SDK Examples ### |
| 60 | + |
| 61 | +{{< tabs tabTotal="6" tabID="10" tabName1="C#" tabName2="Java" tabName3="PHP" tabName4="Node.js" tabName5="Python" tabName6="Ruby" >}} {{< tab tabNum="1" >}} |
| 62 | + |
| 63 | +```csharp |
| 64 | +// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-dotnet-samples |
| 65 | +string MyClientSecret = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 66 | +string MyClientId = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 67 | + |
| 68 | +var configuration = new Configuration(MyClientId, MyClientSecret); |
| 69 | + |
| 70 | +// Create necessary API instances |
| 71 | +var apiInstance = new LicenseApi(configuration); |
| 72 | + |
| 73 | +var response = apiInstance.GetConsumptionCredit(); |
| 74 | + |
| 75 | +Console.WriteLine($"Credits: {response.Credit}"); |
| 76 | +Console.WriteLine($"Quantity: {response.Quantity}"); |
| 77 | +``` |
| 78 | + |
| 79 | +{{< /tab >}} {{< tab tabNum="2" >}} |
| 80 | + |
| 81 | +```java |
| 82 | +// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-java-samples |
| 83 | +String MyClientSecret = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 84 | +String MyClientId = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 85 | + |
| 86 | +Configuration configuration = new Configuration(MyClientId, MyClientSecret); |
| 87 | + |
| 88 | +// Create API instance |
| 89 | +LicenseApi apiInstance = new LicenseApi(configuration); |
| 90 | + |
| 91 | +ConsumptionResult response = apiInstance.getConsumptionCredit(); |
| 92 | +System.out.println("Credit: " + response.getCredit()); |
| 93 | +System.out.println("Quantity: " + response.getQuantity()); |
| 94 | +``` |
| 95 | + |
| 96 | +{{< /tab >}} {{< tab tabNum="3" >}} |
| 97 | + |
| 98 | +```php |
| 99 | +// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-php-samples |
| 100 | +use GroupDocs\Viewer\Model; |
| 101 | +use GroupDocs\Viewer\Model\Requests; |
| 102 | + |
| 103 | +$ClientId = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 104 | +$ClientSecret = ""; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 105 | + |
| 106 | +$configuration = new GroupDocs\Viewer\Configuration(); |
| 107 | +$configuration->setAppSid($ClientId); |
| 108 | +$configuration->setAppKey($ClientSecret); |
| 109 | + |
| 110 | +$apiInstance = new GroupDocs\Viewer\LicenseApi($configuration); |
| 111 | + |
| 112 | +// Prepare request |
| 113 | +$filePath = dirname(realpath(__DIR__)) . '\Resources\WordProcessing\four-pages.docx'; |
| 114 | +$request = new Requests\ConvertDocumentDirectRequest("pdf", $filePath); |
| 115 | + |
| 116 | +// Get consumption |
| 117 | +$result = $apiInstance->getConsumptionCredit(); |
| 118 | + |
| 119 | +// Done |
| 120 | +echo "Credit: " . $result->getCredit(); |
| 121 | +``` |
| 122 | + |
| 123 | +{{< /tab >}} {{< tab tabNum="4" >}} |
| 124 | + |
| 125 | +```node |
| 126 | +// For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-node-samples |
| 127 | +global.viewer_cloud = require("groupdocs-viewer-cloud"); |
| 128 | + |
| 129 | +global.clientId = "XXXX-XXXX-XXXX-XXXX"; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 130 | +global.clientSecret = "XXXXXXXXXXXXXXXX"; // Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 131 | + |
| 132 | +global.licenseApi = viewer_cloud.LicenseApi.fromKeys(clientId, clientSecret); |
| 133 | + |
| 134 | +let response = await licenseApi.getConsumptionCredit(); |
| 135 | +console.log("GetLicenseConsumption: Credit = " + response.credit); |
| 136 | +``` |
| 137 | + |
| 138 | +{{< /tab >}} {{< tab tabNum="5" >}} |
| 139 | + |
| 140 | +```python |
| 141 | +# For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-python-samples |
| 142 | +import groupdocs_viewer_cloud |
| 143 | + |
| 144 | +client_id = "XXXX-XXXX-XXXX-XXXX" # Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 145 | +client_secret = "XXXXXXXXXXXXXXXX" # Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 146 | + |
| 147 | +# Create necessary API instances |
| 148 | +apiInstance = groupdocs_viewer_cloud.LicenseApi.from_keys(Common.client_id, Common.client_secret) |
| 149 | + |
| 150 | +# Get consumption |
| 151 | +result = apiInstance.get_consumption_credit() |
| 152 | + |
| 153 | +print("Credit: " + result.credit) |
| 154 | +``` |
| 155 | + |
| 156 | +{{< /tab >}} {{< tab tabNum="6" >}} |
| 157 | + |
| 158 | +```ruby |
| 159 | +# For complete examples and data files, please go to https://github.com/groupdocs-viewer-cloud/groupdocs-viewer-cloud-ruby-samples |
| 160 | +require 'groupdocs_viewer_cloud' |
| 161 | + |
| 162 | +$client_id = "XXXX-XXXX-XXXX-XXXX" # Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 163 | +$client_secret = "XXXXXXXXXXXXXXXX" # Get ClientId and ClientSecret from https://dashboard.groupdocs.cloud |
| 164 | + |
| 165 | +# Create necessary API instances |
| 166 | +apiInstance = GroupDocsViewerCloud::LicenseApi.from_keys($client_id, $client_secret) |
| 167 | + |
| 168 | +# Get consumption |
| 169 | +result = apiInstance.get_consumption_credit() |
| 170 | + |
| 171 | +puts("Credit: " + result.credit) |
| 172 | +``` |
| 173 | + |
| 174 | +{{< /tab >}} {{< /tabs >}} |
0 commit comments