Skip to main content
Code42 Support

Identifying Plans That Use The Most Space Using The Code42 API

Applies to:

    Overview

    Administrators of any storage environment must be prepared to manage storage space. Use the planSummary resource in the Code42 API to help you manage storage by identifying the largest plans in your Code42 environment. This article shows you how to use the Code42 API to find out which plans are the largest, and then use the administration console to take a closer look at those plans and take appropriate action.

    Before you begin

    Considerations

    • You can also get information on the storage space utilized by plans from the administration console, although the method used in this article provides more information, as well as data that can be downloaded in JSON or CSV format.
    • The code examples use the Linux command-line utility curl utility, but these examples are applicable to any operating system and tool.
    • The example script used in this article is for demonstration purposes only. You can use it as the basis for your own solution, but your solution must be customized for your environment.
    • For assistance with creating your own custom script, contact your PRO Services representative.
    Code42 does not guarantee the suitability of the example script for any purpose other than as a way to learn about our API's capabilities. Use of this script without proper analysis, testing, modification for your environment, and validation could result in data loss.

    Steps

    Step 1: Gather necessary information

    You will need the following information in order to use the Code42 API successfully:

    • The username and password of a user with the necessary role or privileges.
    • The fully qualified domain name (FQDN), hostname, or IP address of the master server

    Step 2: Use the Code42 API with web browser

    Once you have the necessary information needed to connect to your master server with the necessary privileges, it's time to connect to your Code42 environment with the Code42 API in order to test your credentials and hostname/port information.

    The easiest method of testing the Code42 API is to simply use your web browser to submit a query and view the results.

    The following URL with query parameters will use the Code42 API to query your master server and retrieve information on the plans that are stored in your Code42 environment. The plans will be sorted by the total size of the storage space being used by each plan, and the data will be in JSON format. See the entry for the planSummary resource in the API Documentation Viewer for a complete listing of the available methods, query parameters, and output values.

    1. Enter the following URL with query parameters into your web browser's address field, replacing master-server.example.com with your master server's FQDN, hostname, or IP address:
      https://master-server.example.com:4285/api/planSummary?srtKey=totalArchiveBytes&srtDir=desc
      
    2. Your browser should ask you to enter credentials. Enter your username and password: API request for credentials
    3. The browser will display the results returned by the Code42 API in JSON format:Results with no JSON extension
    4. (Optional) Consider installing a browser extension or plug-in that formats JSON data to make it easier to read. For example:Results with JSON extension

    Step 3: Create script or curl command and save results

    Although you may find the data you need by simply using a web browser as detailed above, you may wish to save the results of your queries for further analysis. For example, you could save the results in CSV format and then view the results in a spreadsheet.

    In order to save the data, use a command-line tool such as curl to connect to your Code42 environment with the Code42 API, instead of using a web browser.

    The following command will gather the same information as the method using the web browser above, but this command saves the data to a file named results.json:

    curl -k -u 'username:password' "https://master-server.example.com:4285/api/planSummary?srtKey=totalArchiveBytes&srtDir=desc" > results.json
    

    If you would prefer to save the results in CSV format, use the following curl command, which includes an additional query parameter, export:

    curl -k -u 'username:password' "https://master-server.example.com:4285/api/planSummary?srtKey=totalArchiveBytes&srtDir=desc&export='csv'" > results.csv
    

    Step 4: Customize the command based on your needs

    Most resources in the Code42 API provide numerous options that allow you to fine-tune the results based on your need for specific information. The planSummary resource is no exception. The table below displays some of the query parameters and options that are available:

    Example Parameter API Documentation Description
    srtKey key to sort on

    Sorts the results of the planSummary request by one of several values, such as planUid, name, userCount, deviceCount, or others.

    srtDir direction of sort Sorts results in ascending or descending order.
    pgSize the max number of objects to return Specifies a maximum number of results.
    active True returns active plans; false returns deactivated plans; null returns all plans Allows the request to respond with only active or deactivated plans. If this query parameter is not included, both active and inactive plans are returned.
    export option to specify an export Instructs the planSummary request to return results in an exported format, such as a comma-separated values (CSV) file.

    For more information on the detailed options available for the planSummary resource, refer to the API Documentation Viewer.

    External resources