Class Metric

    • Method Detail

      • getLogging

        public Logging getLogging()
        Returns the metrics's Logging object used to issue requests.
      • delete

        public boolean delete()
        Deletes this metric.

        Example of deleting the metric.

        
         boolean deleted = metric.delete();
         if (deleted) {
           // the metric was deleted
         } else {
           // the metric was not found
         }
         
        Returns:
        true if the metric was deleted, false if it was not found
        Throws:
        LoggingException - upon failure
      • deleteAsync

        public com.google.api.core.ApiFuture<Boolean> deleteAsync()
        Sends a request for deleting this metric. This method returns a ApiFuture object to consume the result. Future.get() returns true if the metric was deleted, false if it was not found.

        Example of asynchronously deleting the metric.

        
         ApiFuture<Boolean> future = metric.deleteAsync();
         // ...
         boolean deleted = future.get();
         if (deleted) {
           // the metric was deleted
         } else {
           // the metric was not found
         }
         
        Throws:
        LoggingException - upon failure
      • reload

        public Metric reload()
        Fetches current metric's latest information. Returns null if the metric does not exist.

        Example of getting the metric's latest information.

        
         Metric latestMetric = metric.reload();
         if (latestMetric == null) {
           // the metric was not found
         }
         
        Returns:
        a Metric object with latest information or null if not found
        Throws:
        LoggingException - upon failure
      • reloadAsync

        public com.google.api.core.ApiFuture<Metric> reloadAsync()
        Sends a request to fetch current metric's latest information. This method returns a ApiFuture object to consume the result. Future.get() returns a Metric object with latest information or null if not found.

        Example of asynchronously getting the metric's latest information.

        
         ApiFuture<Metric> future = metric.reloadAsync();
         // ...
         Metric latestMetric = future.get();
         if (latestMetric == null) {
           // the metric was not found
         }
         
        Throws:
        LoggingException - upon failure
      • update

        public Metric update()
        Updates current metric. If the metric does not exist, it is created.

        Example of updating the metric's information.

        
         Metric updatedMetric = metric.toBuilder()
             .setDescription("A more detailed description")
             .build()
             .update();
         
        Returns:
        a Metric object with updated information
        Throws:
        LoggingException - upon failure
      • updateAsync

        public com.google.api.core.ApiFuture<Metric> updateAsync()
        Sends a request to update current metric. If the metric does not exist, it is created. This method returns a ApiFuture object to consume the result. Future.get() returns a Metric object with updated information.

        Example of asynchronously updating the metric's information.

        
         ApiFuture<Metric> future = metric.toBuilder()
             .setDescription("A more detailed description")
             .build()
             .updateAsync();
         // ...
         Metric updatedMetric = future.get();
         
        Throws:
        LoggingException - upon failure