...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap/machines.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap

     1  package servicemap
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/date"
    14  	"github.com/Azure/go-autorest/autorest/validation"
    15  	"github.com/Azure/go-autorest/tracing"
    16  	"net/http"
    17  )
    18  
    19  // MachinesClient is the service Map API Reference
    20  type MachinesClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewMachinesClient creates an instance of the MachinesClient client.
    25  func NewMachinesClient(subscriptionID string) MachinesClient {
    26  	return NewMachinesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewMachinesClientWithBaseURI creates an instance of the MachinesClient client using a custom endpoint.  Use this
    30  // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    31  func NewMachinesClientWithBaseURI(baseURI string, subscriptionID string) MachinesClient {
    32  	return MachinesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Get returns the specified machine.
    36  // Parameters:
    37  // resourceGroupName - resource group name within the specified subscriptionId.
    38  // workspaceName - OMS workspace containing the resources of interest.
    39  // machineName - machine resource name.
    40  // timestamp - UTC date and time specifying a time instance relative to which to evaluate the machine resource.
    41  // When not specified, the service uses DateTime.UtcNow.
    42  func (client MachinesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, timestamp *date.Time) (result Machine, err error) {
    43  	if tracing.IsEnabled() {
    44  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.Get")
    45  		defer func() {
    46  			sc := -1
    47  			if result.Response.Response != nil {
    48  				sc = result.Response.Response.StatusCode
    49  			}
    50  			tracing.EndSpan(ctx, sc, err)
    51  		}()
    52  	}
    53  	if err := validation.Validate([]validation.Validation{
    54  		{TargetValue: resourceGroupName,
    55  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
    56  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    57  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
    58  		{TargetValue: workspaceName,
    59  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
    60  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
    61  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
    62  		{TargetValue: machineName,
    63  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
    64  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
    65  		return result, validation.NewError("servicemap.MachinesClient", "Get", err.Error())
    66  	}
    67  
    68  	req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, machineName, timestamp)
    69  	if err != nil {
    70  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "Get", nil, "Failure preparing request")
    71  		return
    72  	}
    73  
    74  	resp, err := client.GetSender(req)
    75  	if err != nil {
    76  		result.Response = autorest.Response{Response: resp}
    77  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "Get", resp, "Failure sending request")
    78  		return
    79  	}
    80  
    81  	result, err = client.GetResponder(resp)
    82  	if err != nil {
    83  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "Get", resp, "Failure responding to request")
    84  		return
    85  	}
    86  
    87  	return
    88  }
    89  
    90  // GetPreparer prepares the Get request.
    91  func (client MachinesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, timestamp *date.Time) (*http.Request, error) {
    92  	pathParameters := map[string]interface{}{
    93  		"machineName":       autorest.Encode("path", machineName),
    94  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
    95  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
    96  		"workspaceName":     autorest.Encode("path", workspaceName),
    97  	}
    98  
    99  	const APIVersion = "2015-11-01-preview"
   100  	queryParameters := map[string]interface{}{
   101  		"api-version": APIVersion,
   102  	}
   103  	if timestamp != nil {
   104  		queryParameters["timestamp"] = autorest.Encode("query", *timestamp)
   105  	}
   106  
   107  	preparer := autorest.CreatePreparer(
   108  		autorest.AsGet(),
   109  		autorest.WithBaseURL(client.BaseURI),
   110  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}", pathParameters),
   111  		autorest.WithQueryParameters(queryParameters))
   112  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   113  }
   114  
   115  // GetSender sends the Get request. The method will close the
   116  // http.Response Body if it receives an error.
   117  func (client MachinesClient) GetSender(req *http.Request) (*http.Response, error) {
   118  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   119  }
   120  
   121  // GetResponder handles the response to the Get request. The method always
   122  // closes the http.Response Body.
   123  func (client MachinesClient) GetResponder(resp *http.Response) (result Machine, err error) {
   124  	err = autorest.Respond(
   125  		resp,
   126  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   127  		autorest.ByUnmarshallingJSON(&result),
   128  		autorest.ByClosing())
   129  	result.Response = autorest.Response{Response: resp}
   130  	return
   131  }
   132  
   133  // GetLiveness obtains the liveness status of the machine during the specified time interval.
   134  // Parameters:
   135  // resourceGroupName - resource group name within the specified subscriptionId.
   136  // workspaceName - OMS workspace containing the resources of interest.
   137  // machineName - machine resource name.
   138  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   139  // DateTime.UtcNow - 10m
   140  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   141  // DateTime.UtcNow
   142  func (client MachinesClient) GetLiveness(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result Liveness, err error) {
   143  	if tracing.IsEnabled() {
   144  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.GetLiveness")
   145  		defer func() {
   146  			sc := -1
   147  			if result.Response.Response != nil {
   148  				sc = result.Response.Response.StatusCode
   149  			}
   150  			tracing.EndSpan(ctx, sc, err)
   151  		}()
   152  	}
   153  	if err := validation.Validate([]validation.Validation{
   154  		{TargetValue: resourceGroupName,
   155  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   156  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   157  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   158  		{TargetValue: workspaceName,
   159  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   160  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   161  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   162  		{TargetValue: machineName,
   163  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   164  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   165  		return result, validation.NewError("servicemap.MachinesClient", "GetLiveness", err.Error())
   166  	}
   167  
   168  	req, err := client.GetLivenessPreparer(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime)
   169  	if err != nil {
   170  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "GetLiveness", nil, "Failure preparing request")
   171  		return
   172  	}
   173  
   174  	resp, err := client.GetLivenessSender(req)
   175  	if err != nil {
   176  		result.Response = autorest.Response{Response: resp}
   177  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "GetLiveness", resp, "Failure sending request")
   178  		return
   179  	}
   180  
   181  	result, err = client.GetLivenessResponder(resp)
   182  	if err != nil {
   183  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "GetLiveness", resp, "Failure responding to request")
   184  		return
   185  	}
   186  
   187  	return
   188  }
   189  
   190  // GetLivenessPreparer prepares the GetLiveness request.
   191  func (client MachinesClient) GetLivenessPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
   192  	pathParameters := map[string]interface{}{
   193  		"machineName":       autorest.Encode("path", machineName),
   194  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   195  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   196  		"workspaceName":     autorest.Encode("path", workspaceName),
   197  	}
   198  
   199  	const APIVersion = "2015-11-01-preview"
   200  	queryParameters := map[string]interface{}{
   201  		"api-version": APIVersion,
   202  	}
   203  	if startTime != nil {
   204  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   205  	}
   206  	if endTime != nil {
   207  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   208  	}
   209  
   210  	preparer := autorest.CreatePreparer(
   211  		autorest.AsGet(),
   212  		autorest.WithBaseURL(client.BaseURI),
   213  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/liveness", pathParameters),
   214  		autorest.WithQueryParameters(queryParameters))
   215  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   216  }
   217  
   218  // GetLivenessSender sends the GetLiveness request. The method will close the
   219  // http.Response Body if it receives an error.
   220  func (client MachinesClient) GetLivenessSender(req *http.Request) (*http.Response, error) {
   221  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   222  }
   223  
   224  // GetLivenessResponder handles the response to the GetLiveness request. The method always
   225  // closes the http.Response Body.
   226  func (client MachinesClient) GetLivenessResponder(resp *http.Response) (result Liveness, err error) {
   227  	err = autorest.Respond(
   228  		resp,
   229  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   230  		autorest.ByUnmarshallingJSON(&result),
   231  		autorest.ByClosing())
   232  	result.Response = autorest.Response{Response: resp}
   233  	return
   234  }
   235  
   236  // ListByWorkspace returns a collection of machines matching the specified conditions.  The returned collection
   237  // represents either machines that are active/live during the specified interval  of time (`live=true` and
   238  // `startTime`/`endTime` are specified) or that are known to have existed at or  some time prior to the specified point
   239  // in time (`live=false` and `timestamp` is specified).
   240  // Parameters:
   241  // resourceGroupName - resource group name within the specified subscriptionId.
   242  // workspaceName - OMS workspace containing the resources of interest.
   243  // live - specifies whether to return live resources (true) or inventory resources (false). Defaults to
   244  // **true**. When retrieving live resources, the start time (`startTime`) and end time (`endTime`) of the
   245  // desired interval should be included. When retrieving inventory resources, an optional timestamp
   246  // (`timestamp`) parameter can be specified to return the version of each resource closest (not-after) that
   247  // timestamp.
   248  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   249  // DateTime.UtcNow - 10m
   250  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   251  // DateTime.UtcNow
   252  // timestamp - UTC date and time specifying a time instance relative to which to evaluate each machine
   253  // resource. Only applies when `live=false`. When not specified, the service uses DateTime.UtcNow.
   254  // top - page size to use. When not specified, the default page size is 100 records.
   255  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) {
   256  	if tracing.IsEnabled() {
   257  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListByWorkspace")
   258  		defer func() {
   259  			sc := -1
   260  			if result.mc.Response.Response != nil {
   261  				sc = result.mc.Response.Response.StatusCode
   262  			}
   263  			tracing.EndSpan(ctx, sc, err)
   264  		}()
   265  	}
   266  	if err := validation.Validate([]validation.Validation{
   267  		{TargetValue: resourceGroupName,
   268  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   269  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   270  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   271  		{TargetValue: workspaceName,
   272  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   273  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   274  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   275  		{TargetValue: top,
   276  			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
   277  				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(200), Chain: nil},
   278  					{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil},
   279  				}}}}}); err != nil {
   280  		return result, validation.NewError("servicemap.MachinesClient", "ListByWorkspace", err.Error())
   281  	}
   282  
   283  	result.fn = client.listByWorkspaceNextResults
   284  	req, err := client.ListByWorkspacePreparer(ctx, resourceGroupName, workspaceName, live, startTime, endTime, timestamp, top)
   285  	if err != nil {
   286  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", nil, "Failure preparing request")
   287  		return
   288  	}
   289  
   290  	resp, err := client.ListByWorkspaceSender(req)
   291  	if err != nil {
   292  		result.mc.Response = autorest.Response{Response: resp}
   293  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure sending request")
   294  		return
   295  	}
   296  
   297  	result.mc, err = client.ListByWorkspaceResponder(resp)
   298  	if err != nil {
   299  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListByWorkspace", resp, "Failure responding to request")
   300  		return
   301  	}
   302  	if result.mc.hasNextLink() && result.mc.IsEmpty() {
   303  		err = result.NextWithContext(ctx)
   304  		return
   305  	}
   306  
   307  	return
   308  }
   309  
   310  // ListByWorkspacePreparer prepares the ListByWorkspace request.
   311  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) {
   312  	pathParameters := map[string]interface{}{
   313  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   314  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   315  		"workspaceName":     autorest.Encode("path", workspaceName),
   316  	}
   317  
   318  	const APIVersion = "2015-11-01-preview"
   319  	queryParameters := map[string]interface{}{
   320  		"api-version": APIVersion,
   321  	}
   322  	if live != nil {
   323  		queryParameters["live"] = autorest.Encode("query", *live)
   324  	} else {
   325  		queryParameters["live"] = autorest.Encode("query", true)
   326  	}
   327  	if startTime != nil {
   328  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   329  	}
   330  	if endTime != nil {
   331  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   332  	}
   333  	if timestamp != nil {
   334  		queryParameters["timestamp"] = autorest.Encode("query", *timestamp)
   335  	}
   336  	if top != nil {
   337  		queryParameters["$top"] = autorest.Encode("query", *top)
   338  	}
   339  
   340  	preparer := autorest.CreatePreparer(
   341  		autorest.AsGet(),
   342  		autorest.WithBaseURL(client.BaseURI),
   343  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines", pathParameters),
   344  		autorest.WithQueryParameters(queryParameters))
   345  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   346  }
   347  
   348  // ListByWorkspaceSender sends the ListByWorkspace request. The method will close the
   349  // http.Response Body if it receives an error.
   350  func (client MachinesClient) ListByWorkspaceSender(req *http.Request) (*http.Response, error) {
   351  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   352  }
   353  
   354  // ListByWorkspaceResponder handles the response to the ListByWorkspace request. The method always
   355  // closes the http.Response Body.
   356  func (client MachinesClient) ListByWorkspaceResponder(resp *http.Response) (result MachineCollection, err error) {
   357  	err = autorest.Respond(
   358  		resp,
   359  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   360  		autorest.ByUnmarshallingJSON(&result),
   361  		autorest.ByClosing())
   362  	result.Response = autorest.Response{Response: resp}
   363  	return
   364  }
   365  
   366  // listByWorkspaceNextResults retrieves the next set of results, if any.
   367  func (client MachinesClient) listByWorkspaceNextResults(ctx context.Context, lastResults MachineCollection) (result MachineCollection, err error) {
   368  	req, err := lastResults.machineCollectionPreparer(ctx)
   369  	if err != nil {
   370  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listByWorkspaceNextResults", nil, "Failure preparing next results request")
   371  	}
   372  	if req == nil {
   373  		return
   374  	}
   375  	resp, err := client.ListByWorkspaceSender(req)
   376  	if err != nil {
   377  		result.Response = autorest.Response{Response: resp}
   378  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listByWorkspaceNextResults", resp, "Failure sending next results request")
   379  	}
   380  	result, err = client.ListByWorkspaceResponder(resp)
   381  	if err != nil {
   382  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listByWorkspaceNextResults", resp, "Failure responding to next results request")
   383  	}
   384  	return
   385  }
   386  
   387  // ListByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required.
   388  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) {
   389  	if tracing.IsEnabled() {
   390  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListByWorkspace")
   391  		defer func() {
   392  			sc := -1
   393  			if result.Response().Response.Response != nil {
   394  				sc = result.page.Response().Response.Response.StatusCode
   395  			}
   396  			tracing.EndSpan(ctx, sc, err)
   397  		}()
   398  	}
   399  	result.page, err = client.ListByWorkspace(ctx, resourceGroupName, workspaceName, live, startTime, endTime, timestamp, top)
   400  	return
   401  }
   402  
   403  // ListConnections returns a collection of connections terminating or originating at the specified machine
   404  // Parameters:
   405  // resourceGroupName - resource group name within the specified subscriptionId.
   406  // workspaceName - OMS workspace containing the resources of interest.
   407  // machineName - machine resource name.
   408  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   409  // DateTime.UtcNow - 10m
   410  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   411  // DateTime.UtcNow
   412  func (client MachinesClient) ListConnections(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result ConnectionCollectionPage, err error) {
   413  	if tracing.IsEnabled() {
   414  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListConnections")
   415  		defer func() {
   416  			sc := -1
   417  			if result.cc.Response.Response != nil {
   418  				sc = result.cc.Response.Response.StatusCode
   419  			}
   420  			tracing.EndSpan(ctx, sc, err)
   421  		}()
   422  	}
   423  	if err := validation.Validate([]validation.Validation{
   424  		{TargetValue: resourceGroupName,
   425  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   426  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   427  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   428  		{TargetValue: workspaceName,
   429  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   430  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   431  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   432  		{TargetValue: machineName,
   433  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   434  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   435  		return result, validation.NewError("servicemap.MachinesClient", "ListConnections", err.Error())
   436  	}
   437  
   438  	result.fn = client.listConnectionsNextResults
   439  	req, err := client.ListConnectionsPreparer(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime)
   440  	if err != nil {
   441  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListConnections", nil, "Failure preparing request")
   442  		return
   443  	}
   444  
   445  	resp, err := client.ListConnectionsSender(req)
   446  	if err != nil {
   447  		result.cc.Response = autorest.Response{Response: resp}
   448  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListConnections", resp, "Failure sending request")
   449  		return
   450  	}
   451  
   452  	result.cc, err = client.ListConnectionsResponder(resp)
   453  	if err != nil {
   454  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListConnections", resp, "Failure responding to request")
   455  		return
   456  	}
   457  	if result.cc.hasNextLink() && result.cc.IsEmpty() {
   458  		err = result.NextWithContext(ctx)
   459  		return
   460  	}
   461  
   462  	return
   463  }
   464  
   465  // ListConnectionsPreparer prepares the ListConnections request.
   466  func (client MachinesClient) ListConnectionsPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
   467  	pathParameters := map[string]interface{}{
   468  		"machineName":       autorest.Encode("path", machineName),
   469  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   470  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   471  		"workspaceName":     autorest.Encode("path", workspaceName),
   472  	}
   473  
   474  	const APIVersion = "2015-11-01-preview"
   475  	queryParameters := map[string]interface{}{
   476  		"api-version": APIVersion,
   477  	}
   478  	if startTime != nil {
   479  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   480  	}
   481  	if endTime != nil {
   482  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   483  	}
   484  
   485  	preparer := autorest.CreatePreparer(
   486  		autorest.AsGet(),
   487  		autorest.WithBaseURL(client.BaseURI),
   488  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/connections", pathParameters),
   489  		autorest.WithQueryParameters(queryParameters))
   490  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   491  }
   492  
   493  // ListConnectionsSender sends the ListConnections request. The method will close the
   494  // http.Response Body if it receives an error.
   495  func (client MachinesClient) ListConnectionsSender(req *http.Request) (*http.Response, error) {
   496  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   497  }
   498  
   499  // ListConnectionsResponder handles the response to the ListConnections request. The method always
   500  // closes the http.Response Body.
   501  func (client MachinesClient) ListConnectionsResponder(resp *http.Response) (result ConnectionCollection, err error) {
   502  	err = autorest.Respond(
   503  		resp,
   504  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   505  		autorest.ByUnmarshallingJSON(&result),
   506  		autorest.ByClosing())
   507  	result.Response = autorest.Response{Response: resp}
   508  	return
   509  }
   510  
   511  // listConnectionsNextResults retrieves the next set of results, if any.
   512  func (client MachinesClient) listConnectionsNextResults(ctx context.Context, lastResults ConnectionCollection) (result ConnectionCollection, err error) {
   513  	req, err := lastResults.connectionCollectionPreparer(ctx)
   514  	if err != nil {
   515  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listConnectionsNextResults", nil, "Failure preparing next results request")
   516  	}
   517  	if req == nil {
   518  		return
   519  	}
   520  	resp, err := client.ListConnectionsSender(req)
   521  	if err != nil {
   522  		result.Response = autorest.Response{Response: resp}
   523  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listConnectionsNextResults", resp, "Failure sending next results request")
   524  	}
   525  	result, err = client.ListConnectionsResponder(resp)
   526  	if err != nil {
   527  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listConnectionsNextResults", resp, "Failure responding to next results request")
   528  	}
   529  	return
   530  }
   531  
   532  // ListConnectionsComplete enumerates all values, automatically crossing page boundaries as required.
   533  func (client MachinesClient) ListConnectionsComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result ConnectionCollectionIterator, err error) {
   534  	if tracing.IsEnabled() {
   535  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListConnections")
   536  		defer func() {
   537  			sc := -1
   538  			if result.Response().Response.Response != nil {
   539  				sc = result.page.Response().Response.Response.StatusCode
   540  			}
   541  			tracing.EndSpan(ctx, sc, err)
   542  		}()
   543  	}
   544  	result.page, err = client.ListConnections(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime)
   545  	return
   546  }
   547  
   548  // ListMachineGroupMembership returns a collection of machine groups this machine belongs to during the specified time
   549  // interval.
   550  // Parameters:
   551  // resourceGroupName - resource group name within the specified subscriptionId.
   552  // workspaceName - OMS workspace containing the resources of interest.
   553  // machineName - machine resource name.
   554  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   555  // DateTime.UtcNow - 10m
   556  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   557  // DateTime.UtcNow
   558  func (client MachinesClient) ListMachineGroupMembership(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result MachineGroupCollectionPage, err error) {
   559  	if tracing.IsEnabled() {
   560  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListMachineGroupMembership")
   561  		defer func() {
   562  			sc := -1
   563  			if result.mgc.Response.Response != nil {
   564  				sc = result.mgc.Response.Response.StatusCode
   565  			}
   566  			tracing.EndSpan(ctx, sc, err)
   567  		}()
   568  	}
   569  	if err := validation.Validate([]validation.Validation{
   570  		{TargetValue: resourceGroupName,
   571  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   572  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   573  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   574  		{TargetValue: workspaceName,
   575  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   576  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   577  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   578  		{TargetValue: machineName,
   579  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   580  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   581  		return result, validation.NewError("servicemap.MachinesClient", "ListMachineGroupMembership", err.Error())
   582  	}
   583  
   584  	result.fn = client.listMachineGroupMembershipNextResults
   585  	req, err := client.ListMachineGroupMembershipPreparer(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime)
   586  	if err != nil {
   587  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", nil, "Failure preparing request")
   588  		return
   589  	}
   590  
   591  	resp, err := client.ListMachineGroupMembershipSender(req)
   592  	if err != nil {
   593  		result.mgc.Response = autorest.Response{Response: resp}
   594  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure sending request")
   595  		return
   596  	}
   597  
   598  	result.mgc, err = client.ListMachineGroupMembershipResponder(resp)
   599  	if err != nil {
   600  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListMachineGroupMembership", resp, "Failure responding to request")
   601  		return
   602  	}
   603  	if result.mgc.hasNextLink() && result.mgc.IsEmpty() {
   604  		err = result.NextWithContext(ctx)
   605  		return
   606  	}
   607  
   608  	return
   609  }
   610  
   611  // ListMachineGroupMembershipPreparer prepares the ListMachineGroupMembership request.
   612  func (client MachinesClient) ListMachineGroupMembershipPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
   613  	pathParameters := map[string]interface{}{
   614  		"machineName":       autorest.Encode("path", machineName),
   615  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   616  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   617  		"workspaceName":     autorest.Encode("path", workspaceName),
   618  	}
   619  
   620  	const APIVersion = "2015-11-01-preview"
   621  	queryParameters := map[string]interface{}{
   622  		"api-version": APIVersion,
   623  	}
   624  	if startTime != nil {
   625  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   626  	}
   627  	if endTime != nil {
   628  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   629  	}
   630  
   631  	preparer := autorest.CreatePreparer(
   632  		autorest.AsGet(),
   633  		autorest.WithBaseURL(client.BaseURI),
   634  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/machineGroups", pathParameters),
   635  		autorest.WithQueryParameters(queryParameters))
   636  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   637  }
   638  
   639  // ListMachineGroupMembershipSender sends the ListMachineGroupMembership request. The method will close the
   640  // http.Response Body if it receives an error.
   641  func (client MachinesClient) ListMachineGroupMembershipSender(req *http.Request) (*http.Response, error) {
   642  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   643  }
   644  
   645  // ListMachineGroupMembershipResponder handles the response to the ListMachineGroupMembership request. The method always
   646  // closes the http.Response Body.
   647  func (client MachinesClient) ListMachineGroupMembershipResponder(resp *http.Response) (result MachineGroupCollection, err error) {
   648  	err = autorest.Respond(
   649  		resp,
   650  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   651  		autorest.ByUnmarshallingJSON(&result),
   652  		autorest.ByClosing())
   653  	result.Response = autorest.Response{Response: resp}
   654  	return
   655  }
   656  
   657  // listMachineGroupMembershipNextResults retrieves the next set of results, if any.
   658  func (client MachinesClient) listMachineGroupMembershipNextResults(ctx context.Context, lastResults MachineGroupCollection) (result MachineGroupCollection, err error) {
   659  	req, err := lastResults.machineGroupCollectionPreparer(ctx)
   660  	if err != nil {
   661  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listMachineGroupMembershipNextResults", nil, "Failure preparing next results request")
   662  	}
   663  	if req == nil {
   664  		return
   665  	}
   666  	resp, err := client.ListMachineGroupMembershipSender(req)
   667  	if err != nil {
   668  		result.Response = autorest.Response{Response: resp}
   669  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listMachineGroupMembershipNextResults", resp, "Failure sending next results request")
   670  	}
   671  	result, err = client.ListMachineGroupMembershipResponder(resp)
   672  	if err != nil {
   673  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listMachineGroupMembershipNextResults", resp, "Failure responding to next results request")
   674  	}
   675  	return
   676  }
   677  
   678  // ListMachineGroupMembershipComplete enumerates all values, automatically crossing page boundaries as required.
   679  func (client MachinesClient) ListMachineGroupMembershipComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result MachineGroupCollectionIterator, err error) {
   680  	if tracing.IsEnabled() {
   681  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListMachineGroupMembership")
   682  		defer func() {
   683  			sc := -1
   684  			if result.Response().Response.Response != nil {
   685  				sc = result.page.Response().Response.Response.StatusCode
   686  			}
   687  			tracing.EndSpan(ctx, sc, err)
   688  		}()
   689  	}
   690  	result.page, err = client.ListMachineGroupMembership(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime)
   691  	return
   692  }
   693  
   694  // ListPorts returns a collection of live ports on the specified machine during the specified time interval.
   695  // Parameters:
   696  // resourceGroupName - resource group name within the specified subscriptionId.
   697  // workspaceName - OMS workspace containing the resources of interest.
   698  // machineName - machine resource name.
   699  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   700  // DateTime.UtcNow - 10m
   701  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   702  // DateTime.UtcNow
   703  func (client MachinesClient) ListPorts(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result PortCollectionPage, err error) {
   704  	if tracing.IsEnabled() {
   705  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListPorts")
   706  		defer func() {
   707  			sc := -1
   708  			if result.pc.Response.Response != nil {
   709  				sc = result.pc.Response.Response.StatusCode
   710  			}
   711  			tracing.EndSpan(ctx, sc, err)
   712  		}()
   713  	}
   714  	if err := validation.Validate([]validation.Validation{
   715  		{TargetValue: resourceGroupName,
   716  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   717  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   718  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   719  		{TargetValue: workspaceName,
   720  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   721  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   722  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   723  		{TargetValue: machineName,
   724  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   725  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   726  		return result, validation.NewError("servicemap.MachinesClient", "ListPorts", err.Error())
   727  	}
   728  
   729  	result.fn = client.listPortsNextResults
   730  	req, err := client.ListPortsPreparer(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime)
   731  	if err != nil {
   732  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", nil, "Failure preparing request")
   733  		return
   734  	}
   735  
   736  	resp, err := client.ListPortsSender(req)
   737  	if err != nil {
   738  		result.pc.Response = autorest.Response{Response: resp}
   739  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure sending request")
   740  		return
   741  	}
   742  
   743  	result.pc, err = client.ListPortsResponder(resp)
   744  	if err != nil {
   745  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListPorts", resp, "Failure responding to request")
   746  		return
   747  	}
   748  	if result.pc.hasNextLink() && result.pc.IsEmpty() {
   749  		err = result.NextWithContext(ctx)
   750  		return
   751  	}
   752  
   753  	return
   754  }
   755  
   756  // ListPortsPreparer prepares the ListPorts request.
   757  func (client MachinesClient) ListPortsPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
   758  	pathParameters := map[string]interface{}{
   759  		"machineName":       autorest.Encode("path", machineName),
   760  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   761  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   762  		"workspaceName":     autorest.Encode("path", workspaceName),
   763  	}
   764  
   765  	const APIVersion = "2015-11-01-preview"
   766  	queryParameters := map[string]interface{}{
   767  		"api-version": APIVersion,
   768  	}
   769  	if startTime != nil {
   770  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   771  	}
   772  	if endTime != nil {
   773  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   774  	}
   775  
   776  	preparer := autorest.CreatePreparer(
   777  		autorest.AsGet(),
   778  		autorest.WithBaseURL(client.BaseURI),
   779  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/ports", pathParameters),
   780  		autorest.WithQueryParameters(queryParameters))
   781  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   782  }
   783  
   784  // ListPortsSender sends the ListPorts request. The method will close the
   785  // http.Response Body if it receives an error.
   786  func (client MachinesClient) ListPortsSender(req *http.Request) (*http.Response, error) {
   787  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   788  }
   789  
   790  // ListPortsResponder handles the response to the ListPorts request. The method always
   791  // closes the http.Response Body.
   792  func (client MachinesClient) ListPortsResponder(resp *http.Response) (result PortCollection, err error) {
   793  	err = autorest.Respond(
   794  		resp,
   795  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   796  		autorest.ByUnmarshallingJSON(&result),
   797  		autorest.ByClosing())
   798  	result.Response = autorest.Response{Response: resp}
   799  	return
   800  }
   801  
   802  // listPortsNextResults retrieves the next set of results, if any.
   803  func (client MachinesClient) listPortsNextResults(ctx context.Context, lastResults PortCollection) (result PortCollection, err error) {
   804  	req, err := lastResults.portCollectionPreparer(ctx)
   805  	if err != nil {
   806  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listPortsNextResults", nil, "Failure preparing next results request")
   807  	}
   808  	if req == nil {
   809  		return
   810  	}
   811  	resp, err := client.ListPortsSender(req)
   812  	if err != nil {
   813  		result.Response = autorest.Response{Response: resp}
   814  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listPortsNextResults", resp, "Failure sending next results request")
   815  	}
   816  	result, err = client.ListPortsResponder(resp)
   817  	if err != nil {
   818  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listPortsNextResults", resp, "Failure responding to next results request")
   819  	}
   820  	return
   821  }
   822  
   823  // ListPortsComplete enumerates all values, automatically crossing page boundaries as required.
   824  func (client MachinesClient) ListPortsComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, startTime *date.Time, endTime *date.Time) (result PortCollectionIterator, err error) {
   825  	if tracing.IsEnabled() {
   826  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListPorts")
   827  		defer func() {
   828  			sc := -1
   829  			if result.Response().Response.Response != nil {
   830  				sc = result.page.Response().Response.Response.StatusCode
   831  			}
   832  			tracing.EndSpan(ctx, sc, err)
   833  		}()
   834  	}
   835  	result.page, err = client.ListPorts(ctx, resourceGroupName, workspaceName, machineName, startTime, endTime)
   836  	return
   837  }
   838  
   839  // ListProcesses returns a collection of processes on the specified machine matching the specified conditions. The
   840  // returned collection represents either processes that are active/live during the specified interval  of time
   841  // (`live=true` and `startTime`/`endTime` are specified) or that are known to have existed at or  some time prior to
   842  // the specified point in time (`live=false` and `timestamp` is specified).
   843  // Parameters:
   844  // resourceGroupName - resource group name within the specified subscriptionId.
   845  // workspaceName - OMS workspace containing the resources of interest.
   846  // machineName - machine resource name.
   847  // live - specifies whether to return live resources (true) or inventory resources (false). Defaults to
   848  // **true**. When retrieving live resources, the start time (`startTime`) and end time (`endTime`) of the
   849  // desired interval should be included. When retrieving inventory resources, an optional timestamp
   850  // (`timestamp`) parameter can be specified to return the version of each resource closest (not-after) that
   851  // timestamp.
   852  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   853  // DateTime.UtcNow - 10m
   854  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   855  // DateTime.UtcNow
   856  // timestamp - UTC date and time specifying a time instance relative to which to evaluate all process resource.
   857  // Only applies when `live=false`. When not specified, the service uses DateTime.UtcNow.
   858  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) {
   859  	if tracing.IsEnabled() {
   860  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListProcesses")
   861  		defer func() {
   862  			sc := -1
   863  			if result.pc.Response.Response != nil {
   864  				sc = result.pc.Response.Response.StatusCode
   865  			}
   866  			tracing.EndSpan(ctx, sc, err)
   867  		}()
   868  	}
   869  	if err := validation.Validate([]validation.Validation{
   870  		{TargetValue: resourceGroupName,
   871  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   872  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   873  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   874  		{TargetValue: workspaceName,
   875  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   876  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   877  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   878  		{TargetValue: machineName,
   879  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   880  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   881  		return result, validation.NewError("servicemap.MachinesClient", "ListProcesses", err.Error())
   882  	}
   883  
   884  	result.fn = client.listProcessesNextResults
   885  	req, err := client.ListProcessesPreparer(ctx, resourceGroupName, workspaceName, machineName, live, startTime, endTime, timestamp)
   886  	if err != nil {
   887  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", nil, "Failure preparing request")
   888  		return
   889  	}
   890  
   891  	resp, err := client.ListProcessesSender(req)
   892  	if err != nil {
   893  		result.pc.Response = autorest.Response{Response: resp}
   894  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure sending request")
   895  		return
   896  	}
   897  
   898  	result.pc, err = client.ListProcessesResponder(resp)
   899  	if err != nil {
   900  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "ListProcesses", resp, "Failure responding to request")
   901  		return
   902  	}
   903  	if result.pc.hasNextLink() && result.pc.IsEmpty() {
   904  		err = result.NextWithContext(ctx)
   905  		return
   906  	}
   907  
   908  	return
   909  }
   910  
   911  // ListProcessesPreparer prepares the ListProcesses request.
   912  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) {
   913  	pathParameters := map[string]interface{}{
   914  		"machineName":       autorest.Encode("path", machineName),
   915  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   916  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   917  		"workspaceName":     autorest.Encode("path", workspaceName),
   918  	}
   919  
   920  	const APIVersion = "2015-11-01-preview"
   921  	queryParameters := map[string]interface{}{
   922  		"api-version": APIVersion,
   923  	}
   924  	if live != nil {
   925  		queryParameters["live"] = autorest.Encode("query", *live)
   926  	} else {
   927  		queryParameters["live"] = autorest.Encode("query", true)
   928  	}
   929  	if startTime != nil {
   930  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   931  	}
   932  	if endTime != nil {
   933  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   934  	}
   935  	if timestamp != nil {
   936  		queryParameters["timestamp"] = autorest.Encode("query", *timestamp)
   937  	}
   938  
   939  	preparer := autorest.CreatePreparer(
   940  		autorest.AsGet(),
   941  		autorest.WithBaseURL(client.BaseURI),
   942  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes", pathParameters),
   943  		autorest.WithQueryParameters(queryParameters))
   944  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   945  }
   946  
   947  // ListProcessesSender sends the ListProcesses request. The method will close the
   948  // http.Response Body if it receives an error.
   949  func (client MachinesClient) ListProcessesSender(req *http.Request) (*http.Response, error) {
   950  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   951  }
   952  
   953  // ListProcessesResponder handles the response to the ListProcesses request. The method always
   954  // closes the http.Response Body.
   955  func (client MachinesClient) ListProcessesResponder(resp *http.Response) (result ProcessCollection, err error) {
   956  	err = autorest.Respond(
   957  		resp,
   958  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   959  		autorest.ByUnmarshallingJSON(&result),
   960  		autorest.ByClosing())
   961  	result.Response = autorest.Response{Response: resp}
   962  	return
   963  }
   964  
   965  // listProcessesNextResults retrieves the next set of results, if any.
   966  func (client MachinesClient) listProcessesNextResults(ctx context.Context, lastResults ProcessCollection) (result ProcessCollection, err error) {
   967  	req, err := lastResults.processCollectionPreparer(ctx)
   968  	if err != nil {
   969  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listProcessesNextResults", nil, "Failure preparing next results request")
   970  	}
   971  	if req == nil {
   972  		return
   973  	}
   974  	resp, err := client.ListProcessesSender(req)
   975  	if err != nil {
   976  		result.Response = autorest.Response{Response: resp}
   977  		return result, autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listProcessesNextResults", resp, "Failure sending next results request")
   978  	}
   979  	result, err = client.ListProcessesResponder(resp)
   980  	if err != nil {
   981  		err = autorest.NewErrorWithError(err, "servicemap.MachinesClient", "listProcessesNextResults", resp, "Failure responding to next results request")
   982  	}
   983  	return
   984  }
   985  
   986  // ListProcessesComplete enumerates all values, automatically crossing page boundaries as required.
   987  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) {
   988  	if tracing.IsEnabled() {
   989  		ctx = tracing.StartSpan(ctx, fqdn+"/MachinesClient.ListProcesses")
   990  		defer func() {
   991  			sc := -1
   992  			if result.Response().Response.Response != nil {
   993  				sc = result.page.Response().Response.Response.StatusCode
   994  			}
   995  			tracing.EndSpan(ctx, sc, err)
   996  		}()
   997  	}
   998  	result.page, err = client.ListProcesses(ctx, resourceGroupName, workspaceName, machineName, live, startTime, endTime, timestamp)
   999  	return
  1000  }
  1001  

View as plain text