mirror of
https://github.com/octoleo/restic.git
synced 2024-11-15 01:34:06 +00:00
946c8399e2
Exclude minio-go for now (pin to 3.x.y).
564 lines
25 KiB
Go
Executable File
564 lines
25 KiB
Go
Executable File
package servicemap
|
|
|
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
//
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
// Code generated by Microsoft (R) AutoRest Code Generator.
|
|
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
|
|
import (
|
|
"github.com/Azure/go-autorest/autorest"
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
"github.com/Azure/go-autorest/autorest/date"
|
|
"github.com/Azure/go-autorest/autorest/validation"
|
|
"net/http"
|
|
)
|
|
|
|
// ProcessesClient is the service Map API Reference
|
|
type ProcessesClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewProcessesClient creates an instance of the ProcessesClient client.
|
|
func NewProcessesClient(subscriptionID string) ProcessesClient {
|
|
return NewProcessesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
}
|
|
|
|
// NewProcessesClientWithBaseURI creates an instance of the ProcessesClient client.
|
|
func NewProcessesClientWithBaseURI(baseURI string, subscriptionID string) ProcessesClient {
|
|
return ProcessesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
}
|
|
|
|
// Get returns the specified process.
|
|
//
|
|
// resourceGroupName is resource group name within the specified subscriptionId. workspaceName is OMS workspace
|
|
// containing the resources of interest. machineName is machine resource name. processName is process resource name.
|
|
// timestamp is UTC date and time specifying a time instance relative to which to evaluate a resource. When not
|
|
// specified, the service uses DateTime.UtcNow.
|
|
func (client ProcessesClient) Get(resourceGroupName string, workspaceName string, machineName string, processName string, timestamp *date.Time) (result Process, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
|
|
{TargetValue: workspaceName,
|
|
Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
|
|
{TargetValue: machineName,
|
|
Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
|
|
{TargetValue: processName,
|
|
Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
|
|
{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.ProcessesClient", "Get")
|
|
}
|
|
|
|
req, err := client.GetPreparer(resourceGroupName, workspaceName, machineName, processName, timestamp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "Get", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client ProcessesClient) GetPreparer(resourceGroupName string, workspaceName string, machineName string, processName string, timestamp *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"processName": autorest.Encode("path", processName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"workspaceName": autorest.Encode("path", workspaceName),
|
|
}
|
|
|
|
const APIVersion = "2015-11-01-preview"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
if timestamp != nil {
|
|
queryParameters["timestamp"] = autorest.Encode("query", *timestamp)
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetSender sends the Get request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ProcessesClient) GetSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// GetResponder handles the response to the Get request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ProcessesClient) GetResponder(resp *http.Response) (result Process, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// GetLiveness obtains the liveness status of the process during the specified time interval.
|
|
//
|
|
// resourceGroupName is resource group name within the specified subscriptionId. workspaceName is OMS workspace
|
|
// containing the resources of interest. machineName is machine resource name. processName is process resource name.
|
|
// startTime is UTC date and time specifying the start time of an interval. When not specified the service uses
|
|
// DateTime.UtcNow - 10m endTime is UTC date and time specifying the end time of an interval. When not specified the
|
|
// service uses DateTime.UtcNow
|
|
func (client ProcessesClient) GetLiveness(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result Liveness, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
|
|
{TargetValue: workspaceName,
|
|
Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
|
|
{TargetValue: machineName,
|
|
Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
|
|
{TargetValue: processName,
|
|
Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
|
|
{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.ProcessesClient", "GetLiveness")
|
|
}
|
|
|
|
req, err := client.GetLivenessPreparer(resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "GetLiveness", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.GetLivenessSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "GetLiveness", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetLivenessResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "GetLiveness", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetLivenessPreparer prepares the GetLiveness request.
|
|
func (client ProcessesClient) GetLivenessPreparer(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"processName": autorest.Encode("path", processName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"workspaceName": autorest.Encode("path", workspaceName),
|
|
}
|
|
|
|
const APIVersion = "2015-11-01-preview"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
if startTime != nil {
|
|
queryParameters["startTime"] = autorest.Encode("query", *startTime)
|
|
}
|
|
if endTime != nil {
|
|
queryParameters["endTime"] = autorest.Encode("query", *endTime)
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}/liveness", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// GetLivenessSender sends the GetLiveness request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ProcessesClient) GetLivenessSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// GetLivenessResponder handles the response to the GetLiveness request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ProcessesClient) GetLivenessResponder(resp *http.Response) (result Liveness, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListAcceptingPorts returns a collection of ports on which this process is accepting
|
|
//
|
|
// resourceGroupName is resource group name within the specified subscriptionId. workspaceName is OMS workspace
|
|
// containing the resources of interest. machineName is machine resource name. processName is process resource name.
|
|
// startTime is UTC date and time specifying the start time of an interval. When not specified the service uses
|
|
// DateTime.UtcNow - 10m endTime is UTC date and time specifying the end time of an interval. When not specified the
|
|
// service uses DateTime.UtcNow
|
|
func (client ProcessesClient) ListAcceptingPorts(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result PortCollection, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
|
|
{TargetValue: workspaceName,
|
|
Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
|
|
{TargetValue: machineName,
|
|
Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
|
|
{TargetValue: processName,
|
|
Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
|
|
{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.ProcessesClient", "ListAcceptingPorts")
|
|
}
|
|
|
|
req, err := client.ListAcceptingPortsPreparer(resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListAcceptingPortsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListAcceptingPortsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListAcceptingPortsPreparer prepares the ListAcceptingPorts request.
|
|
func (client ProcessesClient) ListAcceptingPortsPreparer(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"processName": autorest.Encode("path", processName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"workspaceName": autorest.Encode("path", workspaceName),
|
|
}
|
|
|
|
const APIVersion = "2015-11-01-preview"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
if startTime != nil {
|
|
queryParameters["startTime"] = autorest.Encode("query", *startTime)
|
|
}
|
|
if endTime != nil {
|
|
queryParameters["endTime"] = autorest.Encode("query", *endTime)
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}/acceptingPorts", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListAcceptingPortsSender sends the ListAcceptingPorts request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ProcessesClient) ListAcceptingPortsSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// ListAcceptingPortsResponder handles the response to the ListAcceptingPorts request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ProcessesClient) ListAcceptingPortsResponder(resp *http.Response) (result PortCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListAcceptingPortsNextResults retrieves the next set of results, if any.
|
|
func (client ProcessesClient) ListAcceptingPortsNextResults(lastResults PortCollection) (result PortCollection, err error) {
|
|
req, err := lastResults.PortCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListAcceptingPortsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListAcceptingPortsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListAcceptingPortsComplete gets all elements from the list without paging.
|
|
func (client ProcessesClient) ListAcceptingPortsComplete(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time, cancel <-chan struct{}) (<-chan Port, <-chan error) {
|
|
resultChan := make(chan Port)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
defer func() {
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
list, err := client.ListAcceptingPorts(resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
|
|
if err != nil {
|
|
errChan <- err
|
|
return
|
|
}
|
|
if list.Value != nil {
|
|
for _, item := range *list.Value {
|
|
select {
|
|
case <-cancel:
|
|
return
|
|
case resultChan <- item:
|
|
// Intentionally left blank
|
|
}
|
|
}
|
|
}
|
|
for list.NextLink != nil {
|
|
list, err = client.ListAcceptingPortsNextResults(list)
|
|
if err != nil {
|
|
errChan <- err
|
|
return
|
|
}
|
|
if list.Value != nil {
|
|
for _, item := range *list.Value {
|
|
select {
|
|
case <-cancel:
|
|
return
|
|
case resultChan <- item:
|
|
// Intentionally left blank
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|
|
|
|
// ListConnections returns a collection of connections terminating or originating at the specified process
|
|
//
|
|
// resourceGroupName is resource group name within the specified subscriptionId. workspaceName is OMS workspace
|
|
// containing the resources of interest. machineName is machine resource name. processName is process resource name.
|
|
// startTime is UTC date and time specifying the start time of an interval. When not specified the service uses
|
|
// DateTime.UtcNow - 10m endTime is UTC date and time specifying the end time of an interval. When not specified the
|
|
// service uses DateTime.UtcNow
|
|
func (client ProcessesClient) ListConnections(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result ConnectionCollection, err error) {
|
|
if err := validation.Validate([]validation.Validation{
|
|
{TargetValue: resourceGroupName,
|
|
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
|
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
|
|
{TargetValue: workspaceName,
|
|
Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
|
|
{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
|
|
{TargetValue: machineName,
|
|
Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
|
|
{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
|
|
{TargetValue: processName,
|
|
Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
|
|
{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.ProcessesClient", "ListConnections")
|
|
}
|
|
|
|
req, err := client.ListConnectionsPreparer(resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListConnectionsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListConnectionsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListConnectionsPreparer prepares the ListConnections request.
|
|
func (client ProcessesClient) ListConnectionsPreparer(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"processName": autorest.Encode("path", processName),
|
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
|
"workspaceName": autorest.Encode("path", workspaceName),
|
|
}
|
|
|
|
const APIVersion = "2015-11-01-preview"
|
|
queryParameters := map[string]interface{}{
|
|
"api-version": APIVersion,
|
|
}
|
|
if startTime != nil {
|
|
queryParameters["startTime"] = autorest.Encode("query", *startTime)
|
|
}
|
|
if endTime != nil {
|
|
queryParameters["endTime"] = autorest.Encode("query", *endTime)
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}/connections", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListConnectionsSender sends the ListConnections request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client ProcessesClient) ListConnectionsSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client,
|
|
req,
|
|
azure.DoRetryWithRegistration(client.Client))
|
|
}
|
|
|
|
// ListConnectionsResponder handles the response to the ListConnections request. The method always
|
|
// closes the http.Response Body.
|
|
func (client ProcessesClient) ListConnectionsResponder(resp *http.Response) (result ConnectionCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListConnectionsNextResults retrieves the next set of results, if any.
|
|
func (client ProcessesClient) ListConnectionsNextResults(lastResults ConnectionCollection) (result ConnectionCollection, err error) {
|
|
req, err := lastResults.ConnectionCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListConnectionsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListConnectionsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListConnectionsComplete gets all elements from the list without paging.
|
|
func (client ProcessesClient) ListConnectionsComplete(resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time, cancel <-chan struct{}) (<-chan Connection, <-chan error) {
|
|
resultChan := make(chan Connection)
|
|
errChan := make(chan error, 1)
|
|
go func() {
|
|
defer func() {
|
|
close(resultChan)
|
|
close(errChan)
|
|
}()
|
|
list, err := client.ListConnections(resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
|
|
if err != nil {
|
|
errChan <- err
|
|
return
|
|
}
|
|
if list.Value != nil {
|
|
for _, item := range *list.Value {
|
|
select {
|
|
case <-cancel:
|
|
return
|
|
case resultChan <- item:
|
|
// Intentionally left blank
|
|
}
|
|
}
|
|
}
|
|
for list.NextLink != nil {
|
|
list, err = client.ListConnectionsNextResults(list)
|
|
if err != nil {
|
|
errChan <- err
|
|
return
|
|
}
|
|
if list.Value != nil {
|
|
for _, item := range *list.Value {
|
|
select {
|
|
case <-cancel:
|
|
return
|
|
case resultChan <- item:
|
|
// Intentionally left blank
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
return resultChan, errChan
|
|
}
|