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

Add description about authorization requirements #581

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Java idiomatic client for [Cloud Logging][product-docs].
## Quickstart

If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file

```xml
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -45,17 +46,21 @@ If you are using Maven without BOM, add this to your dependencies:
```

If you are using Gradle 5.x or later, add this to your dependencies

```Groovy
implementation platform('com.google.cloud:libraries-bom:20.8.0')

compile 'com.google.cloud:google-cloud-logging'
```

If you are using Gradle without BOM, add this to your dependencies

```Groovy
compile 'com.google.cloud:google-cloud-logging:2.3.2'
```

If you are using SBT, add this to your dependencies

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-logging" % "2.3.2"
```
Expand All @@ -64,6 +69,10 @@ libraryDependencies += "com.google.cloud" % "google-cloud-logging" % "2.3.2"

See the [Authentication][authentication] section in the base directory's README.

## Authorization

Consult with [Access control guide](https://cloud.google.com/logging/docs/access-control) about IAM permissions that are required to call different Logging APIs.

## Getting Started

### Prerequisites
Expand All @@ -81,17 +90,16 @@ to add `google-cloud-logging` as a dependency in your code.

## About Cloud Logging


[Cloud Logging][product-docs] allows you to store, search, analyze, monitor, and alert on log data and events from Google Cloud and Amazon Web Services. Using the BindPlane service, you can also collect this data from over 150 common application components, on-premises systems, and hybrid cloud systems. BindPlane is included with your Google Cloud project at no additional cost.

See the [Cloud Logging client library docs][javadocs] to learn how to
use this Cloud Logging Client Library.


#### Creating an authorized service object
To make authenticated requests to Cloud Logging, you must create a service object with
credentials. You can then make API calls by calling methods on the Logging service object. The
simplest way to authenticate is to use

To make requests to Cloud Logging, you must create a service object with valid credentials.
You can then make API calls by calling methods on the Logging service object. The
simplest way to get credentials is to use
[Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
These credentials are automatically inferred from your environment, so you only need the following
code to create your service object:
Expand All @@ -106,10 +114,13 @@ try(Logging logging = options.getService()) {
}
```

For other authentication options, see the
[Authentication](https://github.com/googleapis/google-cloud-java#authentication) page.
For other options, see the [Authentication](https://github.com/googleapis/google-cloud-java#authentication) page.
The service object should be granted permissions to make API calls.
Each API call describes the permissions under Authorized Scopes section.
See [Logging API](https://cloud.google.com/logging/docs/reference/v2/rest) to find the required list of permissions or consult with [Access control guide](https://cloud.google.com/logging/docs/access-control) for predefined IAM roles that can be granted to the Logging service object.

#### Creating a metric

With Logging you can create logs-based metrics. Logs-based metrics allow to keep track of the number
of log messages associated to specific events. Add the following imports at the top of your file:

Expand Down