This page shows how to get started with the Cloud Client Libraries for the Google Security Operations API. Client libraries make it easier to access Google Cloud APIs from a supported language. Although you can use Google Cloud APIs directly by making raw requests to the server, client libraries provide simplifications that significantly reduce the amount of code you need to write.
Read more about the Cloud Client Libraries and the older Google API Client Libraries in Client libraries explained .
Install the client library
C++
Follow the Quickstart
.
C#
Install the Google.Cloud.Chronicle.V1
package from NuGet.
For more information, see Setting Up a C# Development Environment .
Go
go get cloud.google.com/go/chronicle/apiv1
For more information, see Setting Up a Go Development Environment .
Java
If you are using Maven
, add
the following to your pom.xml
file. For more information about
BOMs, see The Google Cloud Platform Libraries BOM
.
If you are using Gradle , add the following to your dependencies:
If you are using sbt , add the following to your dependencies:
For more information, see Setting Up a Java Development Environment .
Node.js
npm install @google-cloud/chronicle
For more information, see Setting Up a Node.js Development Environment .
PHP
composer require google/cloud-chronicle
For more information, see Using PHP on Google Cloud .
Python
pip install --upgrade google-cloud-chronicle
For more information, see Setting Up a Python Development Environment .
Ruby
gem install google-cloud-chronicle-v1
For more information, see Setting Up a Ruby Development Environment .
Set up authentication
To authenticate calls to Google Cloud APIs, client libraries support Application Default Credentials (ADC) ; the libraries look for credentials in a set of defined locations and use those credentials to authenticate requests to the API. With ADC, you can make credentials available to your application in a variety of environments, such as local development or production, without needing to modify your application code.For production environments, the way you set up ADC depends on the service and context. For more information, see Set up Application Default Credentials .
For a local development environment, you can set up ADC with the credentials that are associated with your Google Account:
-
Install the Google Cloud CLI. After installation, initialize the Google Cloud CLI by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity .
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity .
A sign-in screen appears. After you sign in, your credentials are stored in the local credential file used by ADC .
Use the client library
The following example shows how to use the client library to list reference list.
C++
# include
"google/cloud/chronicle/v1/chronicle_client.h"
# include
"google/cloud/common_options.h"
# include
< iostream
>
# include
< string
> int
main
(
int
argc
,
char
*
argv
[])
{
// TODO(developer): Replace these variables before running the sample.
std
::
string
const
project_id
=
""
;
std
::
string
const
instance_id
=
""
;
std
::
string
const
location
=
"us"
;
std
::
string
const
endpoint
=
"us-chronicle.googleapis.com"
;
namespace
chronicle
=
::
google
::
cloud
::
chronicle_v1
;
auto
options
=
google
::
cloud
::
Options
{}.
set<google
::
cloud
::
EndpointOption
> (
endpoint
);
auto
client
=
chronicle
::
ChronicleClient
(
chronicle
::
MakeChronicleConnection
(
options
));
// Construct the parent resource name
// Format: projects/{project}/locations/{location}/instances/{instance}
std
::
string
parent
=
"projects/"
+
project_id
+
"/locations/"
+
location
+
"/instances/"
+
instance_id
;
google
::
cloud
::
chronicle
::
v1
::
ListReferenceListsRequest
request
;
request
.
set_parent
(
parent
);
std
::
cout
<<
"Listing reference lists for parent: "
<<
parent
<<
std
::
endl
;
for
(
auto
const
&
reference_list
:
client
.
ListReferenceLists
(
request
))
{
if
(
!
reference_list
)
{
std
::
cerr
<<
"Error listing reference lists: "
<<
reference_list
.
status
().
message
()
<<
std
::
endl
;
return
1
;
}
std
::
cout
<<
"Name: "
<<
reference_list
-
> name
()
<< std
::
endl
;
std
::
cout
<<
"Display Name: "
<<
reference_list
-
> display_name
()
<<
std
::
endl
;
}
return
0
;
}
C#
using
Google.Cloud.Chronicle.V1
;
// TODO(developer): Replace these variables before running the sample.
const
string
project
=
""
;
const
string
location
=
"us"
;
const
string
instance
=
""
;
const
string
endpoint
=
"us-chronicle.googleapis.com"
;
ReferenceListServiceClient
client
=
new
ReferenceListServiceClientBuilder
{
Endpoint
=
endpoint
,
}.
Build
();
string
parent
=
InstanceName
.
FromProjectLocationInstance
(
project
,
location
,
instance
).
ToString
();
foreach
(
ReferenceList
referenceList
in
client
.
ListReferenceLists
(
parent
))
{
Console
.
WriteLine
(
$"Name: {referenceList.Name}"
);
Console
.
WriteLine
(
$"Description: {referenceList.Description}"
);
}
Go
package
main
import
(
"context"
"fmt"
"log"
chronicle
"cloud.google.com/go/chronicle/apiv1"
chroniclepb
"cloud.google.com/go/chronicle/apiv1/chroniclepb"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
)
// TODO(developer): Replace these variables before running the sample.
const
(
project
=
""
location
=
"us"
instance
=
""
apiEndpoint
=
"us-chronicle.googleapis.com:443"
)
func
main
()
{
ctx
:=
context
.
Background
()
client
,
err
:=
chronicle
.
NewReferenceListClient
(
ctx
,
option
.
WithEndpoint
(
apiEndpoint
),)
if
err
!=
nil
{
log
.
Fatalf
(
"failed to create client: %v"
,
err
)
}
defer
client
.
Close
()
parent
:=
fmt
.
Sprintf
(
"projects/%s/locations/%s/instances/%s"
,
project
,
location
,
instance
)
req
:=
& chroniclepb
.
ListReferenceListsRequest
{
Parent
:
parent
,
}
it
:=
client
.
ListReferenceLists
(
ctx
,
req
)
for
{
resp
,
err
:=
it
.
Next
()
if
err
==
iterator
.
Done
{
break
}
if
err
!=
nil
{
log
.
Fatalf
(
"error listing reference lists: %v"
,
err
)
}
fmt
.
Printf
(
"Name: %s\n"
,
resp
.
GetName
())
fmt
.
Printf
(
"Description: %s\n"
,
resp
.
GetDescription
())
fmt
.
Printf
(
"---\n"
)
}
}
Java
package
com.example
;
import
com.google.cloud.chronicle.v1. InstanceName
;
import
com.google.cloud.chronicle.v1. ReferenceList
;
import
com.google.cloud.chronicle.v1. ReferenceListServiceClient
;
import
com.google.cloud.chronicle.v1. ReferenceListServiceSettings
;
public
class
ListReferenceLists
{
// TODO(developer): Replace these variables before running the sample.
private
static
final
String
PROJECT
=
""
;
private
static
final
String
LOCATION
=
"us"
;
private
static
final
String
INSTANCE
=
""
;
private
static
final
String
ENDPOINT
=
"us-chronicle.googleapis.com:443"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ReferenceListServiceSettings
settings
=
ReferenceListServiceSettings
.
newBuilder
().
setEndpoint
(
ENDPOINT
).
build
();
try
(
ReferenceListServiceClient
client
=
ReferenceListServiceClient
.
create
(
settings
))
{
String
parent
=
InstanceName
.
of
(
PROJECT
,
LOCATION
,
INSTANCE
).
toString
();
for
(
ReferenceList
referenceList
:
client
.
listReferenceLists
(
parent
).
iterateAll
())
{
System
.
out
.
println
(
"Name: "
+
referenceList
.
getName
());
System
.
out
.
println
(
"Description: "
+
referenceList
.
getDescription
());
System
.
out
.
println
(
"---"
);
}
}
}
}
Node.js
'use strict'
;
function
main
(
parent
)
{
const
{
ReferenceListServiceClient
}
=
require
(
' @google-cloud/chronicle
'
).
v1
;
const
chronicleClient
=
new
ReferenceListServiceClient
({
apiEndpoint
:
'us-chronicle.googleapis.com'
,
});
async
function
callListReferenceLists
()
{
// TODO(developer): Replace these variables before running the sample.
const
request
=
{
parent
:
'projects/<project-number>/locations/us/instances/<instance-id>'
};
const
iterable
=
chronicleClient
.
listReferenceListsAsync
(
request
);
for
await
(
const
response
of
iterable
)
{
console
.
log
(
response
);
}
}
callListReferenceLists
();
}
process
.
on
(
'unhandledRejection'
,
err
=
>
{
console
.
error
(
err
.
message
);
process
.
exitCode
=
1
;
});
main
(...
process
.
argv
.
slice
(
2
));
PHP
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Chronicle\V1\Client\ReferenceListServiceClient;
use Google\Cloud\Chronicle\V1\ListReferenceListsRequest;
use Google\Cloud\Chronicle\V1\ReferenceList;
// TODO(developer): Replace these variables before running the sample.
const PROJECT = '';
const LOCATION = 'us';
const INSTANCE = '';
const ENDPOINT = 'us-chronicle.googleapis.com';
$client = new ReferenceListServiceClient([
'apiEndpoint' => ENDPOINT,
]);
$parent = ReferenceListServiceClient::instanceName(PROJECT, LOCATION, INSTANCE);
$request = (new ListReferenceListsRequest())->setParent($parent);
try {
/** @var PagedListResponse $response /
$response = $client->listReferenceLists($request);
/* @var ReferenceList $referenceList */
foreach ($response as $referenceList) {
printf('Name: %s' . PHP_EOL, $referenceList->getName());
printf('Description: %s' . PHP_EOL, $referenceList->getDescription());
printf('---' . PHP_EOL);
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
Python
from
google.cloud
import
chronicle_v1
# TODO
(
developer
):
Replace
these
variables
before
running
the
sample
.
PROJECT_ID
=
""
LOCATION
=
"us"
INSTANCE_ID
=
""
def
list_reference_lists
():
client
=
chronicle_v1
.
ReferenceListServiceClient
(
client_options
=
{
"api_endpoint"
:
"us-chronicle.googleapis.com"
})
parent
=
f
"projects/
{
PROJECT_ID
}
/locations/
{
LOCATION
}
/instances/
{
INSTANCE_ID
}
"
response
=
client
.
list_reference_lists
(
parent
=
parent
)
for
reference_list
in
response
:
print
(
f
"Name:
{
reference_list
.
name
}
"
)
print
(
f
"Display Name:
{
reference_list
.
display_name
}
"
)
if
__ name
__ ==
"__main__"
:
list_reference_lists
()
Ruby
require
"google/cloud/chronicle/v1"
#
TODO
(
developer
):
Replace
these
variables
before
running
the
sample
.
PROJECT_ID
=
""
LOCATION
=
"us"
INSTANCE_ID
=
""
ENDPOINT
=
"us-chronicle.googleapis.com"
client
=
Google
::
Cloud
::
Chronicle
::
V1
::
ReferenceListService
::
Client
.
new
do
|
config
|
config
.
endpoint
=
ENDPOINT
end
parent
=
"projects/
#{
PROJECT_ID
}
/locations/
#{
LOCATION
}
/instances/
#{
INSTANCE_ID
}
"
request
=
Google
::
Cloud
::
Chronicle
::
V1
::
ListReferenceListsRequest
.
new
(
parent
:
parent
)
begin
response
=
client
.
list_reference_lists
request
response
.
each
do
|
reference_list
|
puts
"Name:
#{
reference_list
.
name
}
"
puts
"Description:
#{
reference_list
.
description
}
"
end
rescue
Google
::
Cloud
::
Error
=
>
e
puts
"API call failed:
#{
e
.
message
}
"
end
Additional resources
C++
The following list contains links to more resources related to the client library for C++:
C#
The following list contains links to more resources related to the client library for C#:
Go
The following list contains links to more resources related to the client library for Go:
Java
The following list contains links to more resources related to the client library for Java:
Node.js
The following list contains links to more resources related to the client library for Node.js:
PHP
The following list contains links to more resources related to the client library for PHP:
Python
The following list contains links to more resources related to the client library for Python:
Ruby
The following list contains links to more resources related to the client library for Ruby:

