Class: Auth0::LogStreams::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/auth0/log_streams/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/auth0/log_streams/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#create(request_options: {}, **params) ⇒ Auth0::Types::CreateLogStreamResponseContent

Create a log stream.

Log Stream Types

The type of log stream being created determines the properties required in the sink payload.

HTTP Stream

For an http Stream, the sink properties are listed in the payload below.

Request:

{
  "name": "string",
  "type": "http",
  "sink": {
    "httpEndpoint": "string",
    "httpContentType": "string",
    "httpContentFormat": "JSONLINES|JSONARRAY",
    "httpAuthorization": "string"
  }
}

Response:

{
  "id": "string",
  "name": "string",
  "type": "http",
  "status": "active",
  "sink": {
    "httpEndpoint": "string",
    "httpContentType": "string",
    "httpContentFormat": "JSONLINES|JSONARRAY",
    "httpAuthorization": "string"
  }
}

Amazon EventBridge Stream

For an eventbridge Stream, the sink properties are listed in the payload below.

Request:

{
  "name": "string",
  "type": "eventbridge",
  "sink": {
    "awsRegion": "string",
    "awsAccountId": "string"
  }
}

The response will include an additional field awsPartnerEventSource in the sink:

Response:

{
  "id": "string",
  "name": "string",
  "type": "eventbridge",
  "status": "active",
  "sink": {
    "awsAccountId": "string",
    "awsRegion": "string",
    "awsPartnerEventSource": "string"
  }
}

Azure Event Grid Stream

For an Azure Event Grid Stream, the sink properties are listed in the payload below.

Request:

{
  "name": "string",
  "type": "eventgrid",
  "sink": {
    "azureSubscriptionId": "string",
    "azureResourceGroup": "string",
    "azureRegion": "string"
  }
}

Response:

{
  "id": "string",
  "name": "string",
  "type": "http",
  "status": "active",
  "sink": {
    "azureSubscriptionId": "string",
    "azureResourceGroup": "string",
    "azureRegion": "string",
    "azurePartnerTopic": "string"
  }
}

Datadog Stream

For a Datadog Stream, the sink properties are listed in the payload below.

Request:

{
  "name": "string",
  "type": "datadog",
  "sink": {
    "datadogRegion": "string",
    "datadogApiKey": "string"
  }
}

Response:

{
  "id": "string",
  "name": "string",
  "type": "datadog",
  "status": "active",
  "sink": {
    "datadogRegion": "string",
    "datadogApiKey": "string"
  }
}

Splunk Stream

For a Splunk Stream, the sink properties are listed in the payload below.

Request:

{
  "name": "string",
  "type": "splunk",
  "sink": {
    "splunkDomain": "string",
    "splunkToken": "string",
    "splunkPort": "string",
    "splunkSecure": "boolean"
  }
}

Response:

{
  "id": "string",
  "name": "string",
  "type": "splunk",
  "status": "active",
  "sink": {
    "splunkDomain": "string",
    "splunkToken": "string",
    "splunkPort": "string",
    "splunkSecure": "boolean"
  }
}

Sumo Logic Stream

For a Sumo Logic Stream, the sink properties are listed in the payload below.

Request:

{
  "name": "string",
  "type": "sumo",
  "sink": {
    "sumoSourceAddress": "string"
  }
}

Response:

{
  "id": "string",
  "name": "string",
  "type": "sumo",
  "status": "active",
  "sink": {
    "sumoSourceAddress": "string"
  }
}

Examples:

client.log_streams.create(
  type: "http",
  sink: {
    http_endpoint: "httpEndpoint"
  }
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/auth0/log_streams/client.rb', line 333

def create(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "log-streams",
    body: Auth0::Types::CreateLogStreamRequestContent.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::CreateLogStreamResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#delete(request_options: {}, **params) ⇒ untyped

Delete a log stream.

Examples:

client.log_streams.delete(id: "id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:

  • (untyped)

Raises:

  • (error_class)


559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
# File 'lib/auth0/log_streams/client.rb', line 559

def delete(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "DELETE",
    path: "log-streams/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#get(request_options: {}, **params) ⇒ Auth0::Types::GetLogStreamResponseContent

Retrieve a log stream configuration and status.

Sample responses

Amazon EventBridge Log Stream

{
  "id": "string",
  "name": "string",
  "type": "eventbridge",
  "status": "active|paused|suspended",
  "sink": {
    "awsAccountId": "string",
    "awsRegion": "string",
    "awsPartnerEventSource": "string"
  }
}

HTTP Log Stream

{
  "id": "string",
  "name": "string",
  "type": "http",
  "status": "active|paused|suspended",
  "sink": {
    "httpContentFormat": "JSONLINES|JSONARRAY",
    "httpContentType": "string",
    "httpEndpoint": "string",
    "httpAuthorization": "string"
  }
}

Datadog Log Stream

{
  "id": "string",
  "name": "string",
  "type": "datadog",
  "status": "active|paused|suspended",
  "sink": {
    "datadogRegion": "string",
    "datadogApiKey": "string"
  }
}

Mixpanel

Request:

{
  "name": "string",
  "type": "mixpanel",
  "sink": {
    "mixpanelRegion": "string",
    "mixpanelProjectId": "string",
    "mixpanelServiceAccountUsername": "string",
    "mixpanelServiceAccountPassword": "string"
  }
}

Response:

{
  "id": "string",
  "name": "string",
  "type": "mixpanel",
  "status": "active",
  "sink": {
    "mixpanelRegion": "string",
    "mixpanelProjectId": "string",
    "mixpanelServiceAccountUsername": "string",
    "mixpanelServiceAccountPassword": "string"
  }
}

Segment

Request:

{
  "name": "string",
  "type": "segment",
  "sink": {
    "segmentWriteKey": "string"
  }
}

Response:

{
  "id": "string",
  "name": "string",
  "type": "segment",
  "status": "active",
  "sink": {
    "segmentWriteKey": "string"
  }
}

Splunk Log Stream

{
  "id": "string",
  "name": "string",
  "type": "splunk",
  "status": "active|paused|suspended",
  "sink": {
    "splunkDomain": "string",
    "splunkToken": "string",
    "splunkPort": "string",
    "splunkSecure": "boolean"
  }
}

Sumo Logic Log Stream

{
  "id": "string",
  "name": "string",
  "type": "sumo",
  "status": "active|paused|suspended",
  "sink": {
    "sumoSourceAddress": "string"
  }
}

Status

The status of a log stream maybe any of the following:

  1. active - Stream is currently enabled.
  2. paused - Stream is currently user disabled and will not attempt log delivery.
  3. suspended - Stream is currently disabled because of errors and will not attempt log delivery.

Examples:

client.log_streams.get(id: "id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/auth0/log_streams/client.rb', line 522

def get(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "log-streams/#{URI.encode_uri_component(params[:id].to_s)}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::GetLogStreamResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#list(request_options: {}, **_params) ⇒ Array[Auth0::Types::LogStreamResponseSchema]

Retrieve details on log streams.

Sample Response

[{
  "id": "string",
  "name": "string",
  "type": "eventbridge",
  "status": "active|paused|suspended",
  "sink": {
    "awsAccountId": "string",
    "awsRegion": "string",
    "awsPartnerEventSource": "string"
  }
}, {
  "id": "string",
  "name": "string",
  "type": "http",
  "status": "active|paused|suspended",
  "sink": {
    "httpContentFormat": "JSONLINES|JSONARRAY",
    "httpContentType": "string",
    "httpEndpoint": "string",
    "httpAuthorization": "string"
  }
},
{
  "id": "string",
  "name": "string",
  "type": "eventgrid",
  "status": "active|paused|suspended",
  "sink": {
    "azureSubscriptionId": "string",
    "azureResourceGroup": "string",
    "azureRegion": "string",
    "azurePartnerTopic": "string"
  }
},
{
  "id": "string",
  "name": "string",
  "type": "splunk",
  "status": "active|paused|suspended",
  "sink": {
    "splunkDomain": "string",
    "splunkToken": "string",
    "splunkPort": "string",
    "splunkSecure": "boolean"
  }
},
{
  "id": "string",
  "name": "string",
  "type": "sumo",
  "status": "active|paused|suspended",
  "sink": {
    "sumoSourceAddress": "string"
  }
},
{
  "id": "string",
  "name": "string",
  "type": "datadog",
  "status": "active|paused|suspended",
  "sink": {
    "datadogRegion": "string",
    "datadogApiKey": "string"
  }
}]

Examples:

client.log_streams.list

Parameters:

  • request_options (Hash) (defaults to: {})
  • _params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/auth0/log_streams/client.rb', line 97

def list(request_options: {}, **_params)
  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "log-streams",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Auth0::Internal::Types::Utils.coerce(Internal::Types::Array[Auth0::Types::LogStreamResponseSchema], (response.body.to_s.empty? ? nil : JSON.parse(response.body, symbolize_names: true)))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update(request_options: {}, **params) ⇒ Auth0::Types::UpdateLogStreamResponseContent

Update a log stream.

Examples of how to use the PATCH endpoint.

The following fields may be updated in a PATCH operation:

  • name
  • status
  • sink

Note: For log streams of type eventbridge and eventgrid, updating the sink is not permitted.

Update the status of a log stream

{
  "status": "active|paused"
}

Update the name of a log stream

{
  "name": "string"
}

Update the sink properties of a stream of type http

{
  "sink": {
    "httpEndpoint": "string",
    "httpContentType": "string",
    "httpContentFormat": "JSONARRAY|JSONLINES",
    "httpAuthorization": "string"
  }
}

Update the sink properties of a stream of type datadog

{
  "sink": {
    "datadogRegion": "string",
    "datadogApiKey": "string"
  }
}

Update the sink properties of a stream of type splunk

{
  "sink": {
    "splunkDomain": "string",
    "splunkToken": "string",
    "splunkPort": "string",
    "splunkSecure": "boolean"
  }
}

Update the sink properties of a stream of type sumo

{
  "sink": {
    "sumoSourceAddress": "string"
  }
}

Examples:

client.log_streams.update(id: "id")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :id (String)

Returns:



667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
# File 'lib/auth0/log_streams/client.rb', line 667

def update(request_options: {}, **params)
  params = Auth0::Internal::Types::Utils.normalize_keys(params)
  request_data = Auth0::LogStreams::Types::UpdateLogStreamRequestContent.new(params).to_h
  non_body_param_names = %w[id]
  body = request_data.except(*non_body_param_names)

  request = Auth0::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PATCH",
    path: "log-streams/#{URI.encode_uri_component(params[:id].to_s)}",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Auth0::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    (response.body.to_s.empty? ? nil : Auth0::Types::UpdateLogStreamResponseContent.load(response.body))
  else
    error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end