mirror of
https://github.com/octoleo/restic.git
synced 2024-11-27 15:26:37 +00:00
847 lines
39 KiB
Go
Executable File
847 lines
39 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 1.0.1.0
|
|
// 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"
|
|
)
|
|
|
|
// MachinesClient is the service Map API Reference
|
|
type MachinesClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewMachinesClient creates an instance of the MachinesClient client.
|
|
func NewMachinesClient(subscriptionID string) MachinesClient {
|
|
return NewMachinesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
}
|
|
|
|
// NewMachinesClientWithBaseURI creates an instance of the MachinesClient
|
|
// client.
|
|
func NewMachinesClientWithBaseURI(baseURI string, subscriptionID string) MachinesClient {
|
|
return MachinesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
}
|
|
|
|
// Get returns the specified machine.
|
|
//
|
|
// resourceGroupName is resource group name within the specified
|
|
// subscriptionId. workspaceName is oMS workspace containing the resources of
|
|
// interest. machineName is machine resource name. timestamp is uTC date and
|
|
// time specifying a time instance relative to which to evaluate the machine
|
|
// resource. When not specified, the service uses DateTime.UtcNow.
|
|
func (client MachinesClient) Get(resourceGroupName string, workspaceName string, machineName string, timestamp *date.Time) (result Machine, 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}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.MachinesClient", "Get")
|
|
}
|
|
|
|
req, err := client.GetPreparer(resourceGroupName, workspaceName, machineName, timestamp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "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.MachinesClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client MachinesClient) GetPreparer(resourceGroupName string, workspaceName string, machineName string, timestamp *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"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}", 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 MachinesClient) GetSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// GetResponder handles the response to the Get request. The method always
|
|
// closes the http.Response Body.
|
|
func (client MachinesClient) GetResponder(resp *http.Response) (result Machine, 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 machine 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. 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 MachinesClient) GetLiveness(resourceGroupName string, workspaceName string, machineName 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}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.MachinesClient", "GetLiveness")
|
|
}
|
|
|
|
req, err := client.GetLivenessPreparer(resourceGroupName, workspaceName, machineName, startTime, endTime)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "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.MachinesClient", "GetLiveness", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetLivenessResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "GetLiveness", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetLivenessPreparer prepares the GetLiveness request.
|
|
func (client MachinesClient) GetLivenessPreparer(resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"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}/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 MachinesClient) GetLivenessSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// GetLivenessResponder handles the response to the GetLiveness request. The method always
|
|
// closes the http.Response Body.
|
|
func (client MachinesClient) 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
|
|
}
|
|
|
|
// ListByWorkspace returns a collection of machines matching the specified
|
|
// conditions. The returned collection represents either machines that are
|
|
// active/live during the specified interval of time (`live=true` and
|
|
// `startTime`/`endTime` are specified) or that are known to have existed at or
|
|
// some time prior to the specified point in time (`live=false` and `timestamp`
|
|
// is specified).
|
|
//
|
|
// resourceGroupName is resource group name within the specified
|
|
// subscriptionId. workspaceName is oMS workspace containing the resources of
|
|
// interest. live is specifies whether to return live resources (true) or
|
|
// inventory resources (false). Defaults to **true**. When retrieving live
|
|
// resources, the start time (`startTime`) and end time (`endTime`) of the
|
|
// desired interval should be included. When retrieving inventory resources, an
|
|
// optional timestamp (`timestamp`) parameter can be specified to return the
|
|
// version of each resource closest (not-after) that timestamp. 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 timestamp is uTC date and time specifying a time
|
|
// instance relative to which to evaluate each machine resource. Only applies
|
|
// when `live=false`. When not specified, the service uses DateTime.UtcNow. top
|
|
// is page size to use. When not specified, the default page size is 100
|
|
// records.
|
|
func (client MachinesClient) ListByWorkspace(resourceGroupName string, workspaceName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time, top *int32) (result MachineCollection, 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: top,
|
|
Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
|
|
Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: 200, Chain: nil},
|
|
{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
|
|
}}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.MachinesClient", "ListByWorkspace")
|
|
}
|
|
|
|
req, err := client.ListByWorkspacePreparer(resourceGroupName, workspaceName, live, startTime, endTime, timestamp, top)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByWorkspaceSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListByWorkspaceResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByWorkspacePreparer prepares the ListByWorkspace request.
|
|
func (client MachinesClient) ListByWorkspacePreparer(resourceGroupName string, workspaceName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time, top *int32) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"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 live != nil {
|
|
queryParameters["live"] = autorest.Encode("query", *live)
|
|
}
|
|
if startTime != nil {
|
|
queryParameters["startTime"] = autorest.Encode("query", *startTime)
|
|
}
|
|
if endTime != nil {
|
|
queryParameters["endTime"] = autorest.Encode("query", *endTime)
|
|
}
|
|
if timestamp != nil {
|
|
queryParameters["timestamp"] = autorest.Encode("query", *timestamp)
|
|
}
|
|
if top != nil {
|
|
queryParameters["$top"] = autorest.Encode("query", *top)
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListByWorkspaceSender sends the ListByWorkspace request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client MachinesClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always
|
|
// closes the http.Response Body.
|
|
func (client MachinesClient) ListByWorkspaceResponder(resp *http.Response) (result MachineCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListByWorkspaceNextResults retrieves the next set of results, if any.
|
|
func (client MachinesClient) ListByWorkspaceNextResults(lastResults MachineCollection) (result MachineCollection, err error) {
|
|
req, err := lastResults.MachineCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByWorkspaceSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListByWorkspaceResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListConnections returns a collection of connections terminating or
|
|
// originating at the specified machine
|
|
//
|
|
// resourceGroupName is resource group name within the specified
|
|
// subscriptionId. workspaceName is oMS workspace containing the resources of
|
|
// interest. machineName is machine 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 MachinesClient) ListConnections(resourceGroupName string, workspaceName string, machineName 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}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.MachinesClient", "ListConnections")
|
|
}
|
|
|
|
req, err := client.ListConnectionsPreparer(resourceGroupName, workspaceName, machineName, startTime, endTime)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "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.MachinesClient", "ListConnections", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListConnectionsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListConnections", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListConnectionsPreparer prepares the ListConnections request.
|
|
func (client MachinesClient) ListConnectionsPreparer(resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"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}/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 MachinesClient) ListConnectionsSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListConnectionsResponder handles the response to the ListConnections request. The method always
|
|
// closes the http.Response Body.
|
|
func (client MachinesClient) 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 MachinesClient) ListConnectionsNextResults(lastResults ConnectionCollection) (result ConnectionCollection, err error) {
|
|
req, err := lastResults.ConnectionCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "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.MachinesClient", "ListConnections", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListConnectionsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListConnections", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListMachineGroupMembership returns a collection of machine groups this
|
|
// machine belongs to.
|
|
//
|
|
// resourceGroupName is resource group name within the specified
|
|
// subscriptionId. workspaceName is oMS workspace containing the resources of
|
|
// interest. machineName is machine resource name.
|
|
func (client MachinesClient) ListMachineGroupMembership(resourceGroupName string, workspaceName string, machineName string) (result MachineGroupCollection, 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}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.MachinesClient", "ListMachineGroupMembership")
|
|
}
|
|
|
|
req, err := client.ListMachineGroupMembershipPreparer(resourceGroupName, workspaceName, machineName)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListMachineGroupMembershipSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListMachineGroupMembershipResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListMachineGroupMembershipPreparer prepares the ListMachineGroupMembership request.
|
|
func (client MachinesClient) ListMachineGroupMembershipPreparer(resourceGroupName string, workspaceName string, machineName string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"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,
|
|
}
|
|
|
|
preparer := autorest.CreatePreparer(
|
|
autorest.AsGet(),
|
|
autorest.WithBaseURL(client.BaseURI),
|
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/machineGroups", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListMachineGroupMembershipSender sends the ListMachineGroupMembership request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client MachinesClient) ListMachineGroupMembershipSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListMachineGroupMembershipResponder handles the response to the ListMachineGroupMembership request. The method always
|
|
// closes the http.Response Body.
|
|
func (client MachinesClient) ListMachineGroupMembershipResponder(resp *http.Response) (result MachineGroupCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListMachineGroupMembershipNextResults retrieves the next set of results, if any.
|
|
func (client MachinesClient) ListMachineGroupMembershipNextResults(lastResults MachineGroupCollection) (result MachineGroupCollection, err error) {
|
|
req, err := lastResults.MachineGroupCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListMachineGroupMembershipSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListMachineGroupMembershipResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListPorts returns a collection of live ports on the specified machine 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. 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 MachinesClient) ListPorts(resourceGroupName string, workspaceName string, machineName 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}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.MachinesClient", "ListPorts")
|
|
}
|
|
|
|
req, err := client.ListPortsPreparer(resourceGroupName, workspaceName, machineName, startTime, endTime)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListPortsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListPortsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListPortsPreparer prepares the ListPorts request.
|
|
func (client MachinesClient) ListPortsPreparer(resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"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}/ports", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListPortsSender sends the ListPorts request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client MachinesClient) ListPortsSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListPortsResponder handles the response to the ListPorts request. The method always
|
|
// closes the http.Response Body.
|
|
func (client MachinesClient) ListPortsResponder(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
|
|
}
|
|
|
|
// ListPortsNextResults retrieves the next set of results, if any.
|
|
func (client MachinesClient) ListPortsNextResults(lastResults PortCollection) (result PortCollection, err error) {
|
|
req, err := lastResults.PortCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListPortsSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListPortsResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListProcesses returns a collection of processes on the specified machine
|
|
// matching the specified conditions. The returned collection represents either
|
|
// processes that are active/live during the specified interval of time
|
|
// (`live=true` and `startTime`/`endTime` are specified) or that are known to
|
|
// have existed at or some time prior to the specified point in time
|
|
// (`live=false` and `timestamp` is specified).
|
|
//
|
|
// resourceGroupName is resource group name within the specified
|
|
// subscriptionId. workspaceName is oMS workspace containing the resources of
|
|
// interest. machineName is machine resource name. live is specifies whether to
|
|
// return live resources (true) or inventory resources (false). Defaults to
|
|
// **true**. When retrieving live resources, the start time (`startTime`) and
|
|
// end time (`endTime`) of the desired interval should be included. When
|
|
// retrieving inventory resources, an optional timestamp (`timestamp`)
|
|
// parameter can be specified to return the version of each resource closest
|
|
// (not-after) that timestamp. 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
|
|
// timestamp is uTC date and time specifying a time instance relative to which
|
|
// to evaluate all process resource. Only applies when `live=false`. When not
|
|
// specified, the service uses DateTime.UtcNow.
|
|
func (client MachinesClient) ListProcesses(resourceGroupName string, workspaceName string, machineName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time) (result ProcessCollection, 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}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "servicemap.MachinesClient", "ListProcesses")
|
|
}
|
|
|
|
req, err := client.ListProcessesPreparer(resourceGroupName, workspaceName, machineName, live, startTime, endTime, timestamp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListProcessesSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListProcessesResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListProcessesPreparer prepares the ListProcesses request.
|
|
func (client MachinesClient) ListProcessesPreparer(resourceGroupName string, workspaceName string, machineName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"machineName": autorest.Encode("path", machineName),
|
|
"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 live != nil {
|
|
queryParameters["live"] = autorest.Encode("query", *live)
|
|
}
|
|
if startTime != nil {
|
|
queryParameters["startTime"] = autorest.Encode("query", *startTime)
|
|
}
|
|
if endTime != nil {
|
|
queryParameters["endTime"] = autorest.Encode("query", *endTime)
|
|
}
|
|
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", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListProcessesSender sends the ListProcesses request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client MachinesClient) ListProcessesSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListProcessesResponder handles the response to the ListProcesses request. The method always
|
|
// closes the http.Response Body.
|
|
func (client MachinesClient) ListProcessesResponder(resp *http.Response) (result ProcessCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListProcessesNextResults retrieves the next set of results, if any.
|
|
func (client MachinesClient) ListProcessesNextResults(lastResults ProcessCollection) (result ProcessCollection, err error) {
|
|
req, err := lastResults.ProcessCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListProcessesSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListProcessesResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|