package servicemap // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( "context" "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" "github.com/Azure/go-autorest/tracing" "net/http" ) // MachinesClient is the service Map API Reference type MachinesClient struct { BaseClient } // 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 using a custom endpoint. Use this // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). func NewMachinesClientWithBaseURI(baseURI string, subscriptionID string) MachinesClient { return MachinesClient{NewWithBaseURI(baseURI, subscriptionID)} } // Get returns the specified machine. // Parameters: // resourceGroupName - resource group name within the specified subscriptionId. // workspaceName - OMS workspace containing the resources of interest. // machineName - machine resource name. // timestamp - 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(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, timestamp *date.Time) (result Machine, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.Get") defer func() { sc := -1 if result.Response.Response != nil { sc = result.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } 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.NewError("servicemap.MachinesClient", "Get", err.Error()) } req, err := client.GetPreparer(ctx, 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 } return } // GetPreparer prepares the Get request. func (client MachinesClient) GetPreparer(ctx context.Context, 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{}).WithContext(ctx)) } // 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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // 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, 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. // Parameters: // resourceGroupName - resource group name within the specified subscriptionId. // workspaceName - OMS workspace containing the resources of interest. // machineName - machine resource name. // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses // DateTime.UtcNow - 10m // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses // DateTime.UtcNow func (client MachinesClient) GetLiveness(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result Liveness, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.GetLiveness") defer func() { sc := -1 if result.Response.Response != nil { sc = result.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } 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.NewError("servicemap.MachinesClient", "GetLiveness", err.Error()) } req, err := client.GetLivenessPreparer(ctx, 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 } return } // GetLivenessPreparer prepares the GetLiveness request. func (client MachinesClient) GetLivenessPreparer(ctx context.Context, 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{}).WithContext(ctx)) } // 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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // 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, 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). // Parameters: // resourceGroupName - resource group name within the specified subscriptionId. // workspaceName - OMS workspace containing the resources of interest. // live - 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 - UTC date and time specifying the start time of an interval. When not specified the service uses // DateTime.UtcNow - 10m // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses // DateTime.UtcNow // timestamp - 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 - page size to use. When not specified, the default page size is 100 records. func (client MachinesClient) ListByWorkspace(ctx context.Context, resourceGroupName string, workspaceName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time, top *int32) (result MachineCollectionPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListByWorkspace") defer func() { sc := -1 if result.mc.Response.Response != nil { sc = result.mc.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } 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: int64(200), Chain: nil}, {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, }}}}}); err != nil { return result, validation.NewError("servicemap.MachinesClient", "ListByWorkspace", err.Error()) } result.fn = client.listByWorkspaceNextResults req, err := client.ListByWorkspacePreparer(ctx, 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.mc.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure sending request") return } result.mc, err = client.ListByWorkspaceResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure responding to request") return } if result.mc.hasNextLink() && result.mc.IsEmpty() { err = result.NextWithContext(ctx) return } return } // ListByWorkspacePreparer prepares the ListByWorkspace request. func (client MachinesClient) ListByWorkspacePreparer(ctx context.Context, 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) } else { queryParameters["live"] = autorest.Encode("query", true) } 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{}).WithContext(ctx)) } // 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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // 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, 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(ctx context.Context, lastResults MachineCollection) (result MachineCollection, err error) { req, err := lastResults.machineCollectionPreparer(ctx) if err != nil { return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listByWorkspaceNextResults", 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", "listByWorkspaceNextResults", resp, "Failure sending next results request") } result, err = client.ListByWorkspaceResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listByWorkspaceNextResults", resp, "Failure responding to next results request") } return } // ListByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required. func (client MachinesClient) ListByWorkspaceComplete(ctx context.Context, resourceGroupName string, workspaceName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time, top *int32) (result MachineCollectionIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListByWorkspace") defer func() { sc := -1 if result.Response().Response.Response != nil { sc = result.page.Response().Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } result.page, err = client.ListByWorkspace(ctx, resourceGroupName, workspaceName, live, startTime, endTime, timestamp, top) return } // ListConnections returns a collection of connections terminating or originating at the specified machine // Parameters: // resourceGroupName - resource group name within the specified subscriptionId. // workspaceName - OMS workspace containing the resources of interest. // machineName - machine resource name. // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses // DateTime.UtcNow - 10m // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses // DateTime.UtcNow func (client MachinesClient) ListConnections(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result ConnectionCollectionPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListConnections") defer func() { sc := -1 if result.cc.Response.Response != nil { sc = result.cc.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } 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.NewError("servicemap.MachinesClient", "ListConnections", err.Error()) } result.fn = client.listConnectionsNextResults req, err := client.ListConnectionsPreparer(ctx, 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.cc.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListConnections", resp, "Failure sending request") return } result.cc, err = client.ListConnectionsResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListConnections", resp, "Failure responding to request") return } if result.cc.hasNextLink() && result.cc.IsEmpty() { err = result.NextWithContext(ctx) return } return } // ListConnectionsPreparer prepares the ListConnections request. func (client MachinesClient) ListConnectionsPreparer(ctx context.Context, 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{}).WithContext(ctx)) } // 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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // 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, 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(ctx context.Context, lastResults ConnectionCollection) (result ConnectionCollection, err error) { req, err := lastResults.connectionCollectionPreparer(ctx) if err != nil { return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listConnectionsNextResults", 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", "listConnectionsNextResults", resp, "Failure sending next results request") } result, err = client.ListConnectionsResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listConnectionsNextResults", resp, "Failure responding to next results request") } return } // ListConnectionsComplete enumerates all values, automatically crossing page boundaries as required. func (client MachinesClient) ListConnectionsComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result ConnectionCollectionIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListConnections") defer func() { sc := -1 if result.Response().Response.Response != nil { sc = result.page.Response().Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } result.page, err = client.ListConnections(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime) return } // ListMachineGroupMembership returns a collection of machine groups this machine belongs to during the specified time // interval. // Parameters: // resourceGroupName - resource group name within the specified subscriptionId. // workspaceName - OMS workspace containing the resources of interest. // machineName - machine resource name. // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses // DateTime.UtcNow - 10m // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses // DateTime.UtcNow func (client MachinesClient) ListMachineGroupMembership(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result MachineGroupCollectionPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListMachineGroupMembership") defer func() { sc := -1 if result.mgc.Response.Response != nil { sc = result.mgc.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } 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.NewError("servicemap.MachinesClient", "ListMachineGroupMembership", err.Error()) } result.fn = client.listMachineGroupMembershipNextResults req, err := client.ListMachineGroupMembershipPreparer(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", nil, "Failure preparing request") return } resp, err := client.ListMachineGroupMembershipSender(req) if err != nil { result.mgc.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure sending request") return } result.mgc, err = client.ListMachineGroupMembershipResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure responding to request") return } if result.mgc.hasNextLink() && result.mgc.IsEmpty() { err = result.NextWithContext(ctx) return } return } // ListMachineGroupMembershipPreparer prepares the ListMachineGroupMembership request. func (client MachinesClient) ListMachineGroupMembershipPreparer(ctx context.Context, 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}/machineGroups", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } // 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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // 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, 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(ctx context.Context, lastResults MachineGroupCollection) (result MachineGroupCollection, err error) { req, err := lastResults.machineGroupCollectionPreparer(ctx) if err != nil { return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listMachineGroupMembershipNextResults", 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", "listMachineGroupMembershipNextResults", resp, "Failure sending next results request") } result, err = client.ListMachineGroupMembershipResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listMachineGroupMembershipNextResults", resp, "Failure responding to next results request") } return } // ListMachineGroupMembershipComplete enumerates all values, automatically crossing page boundaries as required. func (client MachinesClient) ListMachineGroupMembershipComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result MachineGroupCollectionIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListMachineGroupMembership") defer func() { sc := -1 if result.Response().Response.Response != nil { sc = result.page.Response().Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } result.page, err = client.ListMachineGroupMembership(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime) return } // ListPorts returns a collection of live ports on the specified machine during the specified time interval. // Parameters: // resourceGroupName - resource group name within the specified subscriptionId. // workspaceName - OMS workspace containing the resources of interest. // machineName - machine resource name. // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses // DateTime.UtcNow - 10m // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses // DateTime.UtcNow func (client MachinesClient) ListPorts(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result PortCollectionPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListPorts") defer func() { sc := -1 if result.pc.Response.Response != nil { sc = result.pc.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } 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.NewError("servicemap.MachinesClient", "ListPorts", err.Error()) } result.fn = client.listPortsNextResults req, err := client.ListPortsPreparer(ctx, 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.pc.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure sending request") return } result.pc, err = client.ListPortsResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure responding to request") return } if result.pc.hasNextLink() && result.pc.IsEmpty() { err = result.NextWithContext(ctx) return } return } // ListPortsPreparer prepares the ListPorts request. func (client MachinesClient) ListPortsPreparer(ctx context.Context, 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{}).WithContext(ctx)) } // 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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // 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, 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(ctx context.Context, lastResults PortCollection) (result PortCollection, err error) { req, err := lastResults.portCollectionPreparer(ctx) if err != nil { return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listPortsNextResults", 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", "listPortsNextResults", resp, "Failure sending next results request") } result, err = client.ListPortsResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listPortsNextResults", resp, "Failure responding to next results request") } return } // ListPortsComplete enumerates all values, automatically crossing page boundaries as required. func (client MachinesClient) ListPortsComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result PortCollectionIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListPorts") defer func() { sc := -1 if result.Response().Response.Response != nil { sc = result.page.Response().Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } result.page, err = client.ListPorts(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime) 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). // Parameters: // resourceGroupName - resource group name within the specified subscriptionId. // workspaceName - OMS workspace containing the resources of interest. // machineName - machine resource name. // live - 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 - UTC date and time specifying the start time of an interval. When not specified the service uses // DateTime.UtcNow - 10m // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses // DateTime.UtcNow // timestamp - 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(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time) (result ProcessCollectionPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListProcesses") defer func() { sc := -1 if result.pc.Response.Response != nil { sc = result.pc.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } 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.NewError("servicemap.MachinesClient", "ListProcesses", err.Error()) } result.fn = client.listProcessesNextResults req, err := client.ListProcessesPreparer(ctx, 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.pc.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure sending request") return } result.pc, err = client.ListProcessesResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure responding to request") return } if result.pc.hasNextLink() && result.pc.IsEmpty() { err = result.NextWithContext(ctx) return } return } // ListProcessesPreparer prepares the ListProcesses request. func (client MachinesClient) ListProcessesPreparer(ctx context.Context, 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) } else { queryParameters["live"] = autorest.Encode("query", true) } 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{}).WithContext(ctx)) } // 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 client.Send(req, azure.DoRetryWithRegistration(client.Client)) } // 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, 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(ctx context.Context, lastResults ProcessCollection) (result ProcessCollection, err error) { req, err := lastResults.processCollectionPreparer(ctx) if err != nil { return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listProcessesNextResults", 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", "listProcessesNextResults", resp, "Failure sending next results request") } result, err = client.ListProcessesResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listProcessesNextResults", resp, "Failure responding to next results request") } return } // ListProcessesComplete enumerates all values, automatically crossing page boundaries as required. func (client MachinesClient) ListProcessesComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, live *bool, startTime *date.Time, endTime *date.Time, timestamp *date.Time) (result ProcessCollectionIterator, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListProcesses") defer func() { sc := -1 if result.Response().Response.Response != nil { sc = result.page.Response().Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } result.page, err = client.ListProcesses(ctx, resourceGroupName, workspaceName, machineName, live, startTime, endTime, timestamp) return }