...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/operationalinsights/mgmt/2015-11-01-preview/servicemap/processes.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  // ProcessesClient is the service Map API Reference
    20  type ProcessesClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewProcessesClient creates an instance of the ProcessesClient client.
    25  func NewProcessesClient(subscriptionID string) ProcessesClient {
    26  	return NewProcessesClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewProcessesClientWithBaseURI creates an instance of the ProcessesClient 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 NewProcessesClientWithBaseURI(baseURI string, subscriptionID string) ProcessesClient {
    32  	return ProcessesClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // Get returns the specified process.
    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  // processName - process resource name.
    41  // timestamp - UTC date and time specifying a time instance relative to which to evaluate a resource. When not
    42  // specified, the service uses DateTime.UtcNow.
    43  func (client ProcessesClient) Get(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, timestamp *date.Time) (result Process, err error) {
    44  	if tracing.IsEnabled() {
    45  		ctx = tracing.StartSpan(ctx, fqdn+"/ProcessesClient.Get")
    46  		defer func() {
    47  			sc := -1
    48  			if result.Response.Response != nil {
    49  				sc = result.Response.Response.StatusCode
    50  			}
    51  			tracing.EndSpan(ctx, sc, err)
    52  		}()
    53  	}
    54  	if err := validation.Validate([]validation.Validation{
    55  		{TargetValue: resourceGroupName,
    56  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
    57  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
    58  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
    59  		{TargetValue: workspaceName,
    60  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
    61  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
    62  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
    63  		{TargetValue: machineName,
    64  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
    65  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
    66  		{TargetValue: processName,
    67  			Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
    68  				{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
    69  		return result, validation.NewError("servicemap.ProcessesClient", "Get", err.Error())
    70  	}
    71  
    72  	req, err := client.GetPreparer(ctx, resourceGroupName, workspaceName, machineName, processName, timestamp)
    73  	if err != nil {
    74  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "Get", nil, "Failure preparing request")
    75  		return
    76  	}
    77  
    78  	resp, err := client.GetSender(req)
    79  	if err != nil {
    80  		result.Response = autorest.Response{Response: resp}
    81  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "Get", resp, "Failure sending request")
    82  		return
    83  	}
    84  
    85  	result, err = client.GetResponder(resp)
    86  	if err != nil {
    87  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "Get", resp, "Failure responding to request")
    88  		return
    89  	}
    90  
    91  	return
    92  }
    93  
    94  // GetPreparer prepares the Get request.
    95  func (client ProcessesClient) GetPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, timestamp *date.Time) (*http.Request, error) {
    96  	pathParameters := map[string]interface{}{
    97  		"machineName":       autorest.Encode("path", machineName),
    98  		"processName":       autorest.Encode("path", processName),
    99  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   100  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   101  		"workspaceName":     autorest.Encode("path", workspaceName),
   102  	}
   103  
   104  	const APIVersion = "2015-11-01-preview"
   105  	queryParameters := map[string]interface{}{
   106  		"api-version": APIVersion,
   107  	}
   108  	if timestamp != nil {
   109  		queryParameters["timestamp"] = autorest.Encode("query", *timestamp)
   110  	}
   111  
   112  	preparer := autorest.CreatePreparer(
   113  		autorest.AsGet(),
   114  		autorest.WithBaseURL(client.BaseURI),
   115  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}", pathParameters),
   116  		autorest.WithQueryParameters(queryParameters))
   117  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   118  }
   119  
   120  // GetSender sends the Get request. The method will close the
   121  // http.Response Body if it receives an error.
   122  func (client ProcessesClient) GetSender(req *http.Request) (*http.Response, error) {
   123  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   124  }
   125  
   126  // GetResponder handles the response to the Get request. The method always
   127  // closes the http.Response Body.
   128  func (client ProcessesClient) GetResponder(resp *http.Response) (result Process, err error) {
   129  	err = autorest.Respond(
   130  		resp,
   131  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   132  		autorest.ByUnmarshallingJSON(&result),
   133  		autorest.ByClosing())
   134  	result.Response = autorest.Response{Response: resp}
   135  	return
   136  }
   137  
   138  // GetLiveness obtains the liveness status of the process during the specified time interval.
   139  // Parameters:
   140  // resourceGroupName - resource group name within the specified subscriptionId.
   141  // workspaceName - OMS workspace containing the resources of interest.
   142  // machineName - machine resource name.
   143  // processName - process resource name.
   144  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   145  // DateTime.UtcNow - 10m
   146  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   147  // DateTime.UtcNow
   148  func (client ProcessesClient) GetLiveness(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result Liveness, err error) {
   149  	if tracing.IsEnabled() {
   150  		ctx = tracing.StartSpan(ctx, fqdn+"/ProcessesClient.GetLiveness")
   151  		defer func() {
   152  			sc := -1
   153  			if result.Response.Response != nil {
   154  				sc = result.Response.Response.StatusCode
   155  			}
   156  			tracing.EndSpan(ctx, sc, err)
   157  		}()
   158  	}
   159  	if err := validation.Validate([]validation.Validation{
   160  		{TargetValue: resourceGroupName,
   161  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   162  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   163  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   164  		{TargetValue: workspaceName,
   165  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   166  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   167  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   168  		{TargetValue: machineName,
   169  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   170  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
   171  		{TargetValue: processName,
   172  			Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
   173  				{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   174  		return result, validation.NewError("servicemap.ProcessesClient", "GetLiveness", err.Error())
   175  	}
   176  
   177  	req, err := client.GetLivenessPreparer(ctx, resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
   178  	if err != nil {
   179  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "GetLiveness", nil, "Failure preparing request")
   180  		return
   181  	}
   182  
   183  	resp, err := client.GetLivenessSender(req)
   184  	if err != nil {
   185  		result.Response = autorest.Response{Response: resp}
   186  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "GetLiveness", resp, "Failure sending request")
   187  		return
   188  	}
   189  
   190  	result, err = client.GetLivenessResponder(resp)
   191  	if err != nil {
   192  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "GetLiveness", resp, "Failure responding to request")
   193  		return
   194  	}
   195  
   196  	return
   197  }
   198  
   199  // GetLivenessPreparer prepares the GetLiveness request.
   200  func (client ProcessesClient) GetLivenessPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
   201  	pathParameters := map[string]interface{}{
   202  		"machineName":       autorest.Encode("path", machineName),
   203  		"processName":       autorest.Encode("path", processName),
   204  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   205  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   206  		"workspaceName":     autorest.Encode("path", workspaceName),
   207  	}
   208  
   209  	const APIVersion = "2015-11-01-preview"
   210  	queryParameters := map[string]interface{}{
   211  		"api-version": APIVersion,
   212  	}
   213  	if startTime != nil {
   214  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   215  	}
   216  	if endTime != nil {
   217  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   218  	}
   219  
   220  	preparer := autorest.CreatePreparer(
   221  		autorest.AsGet(),
   222  		autorest.WithBaseURL(client.BaseURI),
   223  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}/liveness", pathParameters),
   224  		autorest.WithQueryParameters(queryParameters))
   225  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   226  }
   227  
   228  // GetLivenessSender sends the GetLiveness request. The method will close the
   229  // http.Response Body if it receives an error.
   230  func (client ProcessesClient) GetLivenessSender(req *http.Request) (*http.Response, error) {
   231  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   232  }
   233  
   234  // GetLivenessResponder handles the response to the GetLiveness request. The method always
   235  // closes the http.Response Body.
   236  func (client ProcessesClient) GetLivenessResponder(resp *http.Response) (result Liveness, err error) {
   237  	err = autorest.Respond(
   238  		resp,
   239  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   240  		autorest.ByUnmarshallingJSON(&result),
   241  		autorest.ByClosing())
   242  	result.Response = autorest.Response{Response: resp}
   243  	return
   244  }
   245  
   246  // ListAcceptingPorts returns a collection of ports on which this process is accepting
   247  // Parameters:
   248  // resourceGroupName - resource group name within the specified subscriptionId.
   249  // workspaceName - OMS workspace containing the resources of interest.
   250  // machineName - machine resource name.
   251  // processName - process resource name.
   252  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   253  // DateTime.UtcNow - 10m
   254  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   255  // DateTime.UtcNow
   256  func (client ProcessesClient) ListAcceptingPorts(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result PortCollectionPage, err error) {
   257  	if tracing.IsEnabled() {
   258  		ctx = tracing.StartSpan(ctx, fqdn+"/ProcessesClient.ListAcceptingPorts")
   259  		defer func() {
   260  			sc := -1
   261  			if result.pc.Response.Response != nil {
   262  				sc = result.pc.Response.Response.StatusCode
   263  			}
   264  			tracing.EndSpan(ctx, sc, err)
   265  		}()
   266  	}
   267  	if err := validation.Validate([]validation.Validation{
   268  		{TargetValue: resourceGroupName,
   269  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   270  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   271  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   272  		{TargetValue: workspaceName,
   273  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   274  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   275  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   276  		{TargetValue: machineName,
   277  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   278  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
   279  		{TargetValue: processName,
   280  			Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
   281  				{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   282  		return result, validation.NewError("servicemap.ProcessesClient", "ListAcceptingPorts", err.Error())
   283  	}
   284  
   285  	result.fn = client.listAcceptingPortsNextResults
   286  	req, err := client.ListAcceptingPortsPreparer(ctx, resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
   287  	if err != nil {
   288  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", nil, "Failure preparing request")
   289  		return
   290  	}
   291  
   292  	resp, err := client.ListAcceptingPortsSender(req)
   293  	if err != nil {
   294  		result.pc.Response = autorest.Response{Response: resp}
   295  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", resp, "Failure sending request")
   296  		return
   297  	}
   298  
   299  	result.pc, err = client.ListAcceptingPortsResponder(resp)
   300  	if err != nil {
   301  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListAcceptingPorts", resp, "Failure responding to request")
   302  		return
   303  	}
   304  	if result.pc.hasNextLink() && result.pc.IsEmpty() {
   305  		err = result.NextWithContext(ctx)
   306  		return
   307  	}
   308  
   309  	return
   310  }
   311  
   312  // ListAcceptingPortsPreparer prepares the ListAcceptingPorts request.
   313  func (client ProcessesClient) ListAcceptingPortsPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
   314  	pathParameters := map[string]interface{}{
   315  		"machineName":       autorest.Encode("path", machineName),
   316  		"processName":       autorest.Encode("path", processName),
   317  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   318  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   319  		"workspaceName":     autorest.Encode("path", workspaceName),
   320  	}
   321  
   322  	const APIVersion = "2015-11-01-preview"
   323  	queryParameters := map[string]interface{}{
   324  		"api-version": APIVersion,
   325  	}
   326  	if startTime != nil {
   327  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   328  	}
   329  	if endTime != nil {
   330  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   331  	}
   332  
   333  	preparer := autorest.CreatePreparer(
   334  		autorest.AsGet(),
   335  		autorest.WithBaseURL(client.BaseURI),
   336  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}/acceptingPorts", pathParameters),
   337  		autorest.WithQueryParameters(queryParameters))
   338  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   339  }
   340  
   341  // ListAcceptingPortsSender sends the ListAcceptingPorts request. The method will close the
   342  // http.Response Body if it receives an error.
   343  func (client ProcessesClient) ListAcceptingPortsSender(req *http.Request) (*http.Response, error) {
   344  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   345  }
   346  
   347  // ListAcceptingPortsResponder handles the response to the ListAcceptingPorts request. The method always
   348  // closes the http.Response Body.
   349  func (client ProcessesClient) ListAcceptingPortsResponder(resp *http.Response) (result PortCollection, err error) {
   350  	err = autorest.Respond(
   351  		resp,
   352  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   353  		autorest.ByUnmarshallingJSON(&result),
   354  		autorest.ByClosing())
   355  	result.Response = autorest.Response{Response: resp}
   356  	return
   357  }
   358  
   359  // listAcceptingPortsNextResults retrieves the next set of results, if any.
   360  func (client ProcessesClient) listAcceptingPortsNextResults(ctx context.Context, lastResults PortCollection) (result PortCollection, err error) {
   361  	req, err := lastResults.portCollectionPreparer(ctx)
   362  	if err != nil {
   363  		return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "listAcceptingPortsNextResults", nil, "Failure preparing next results request")
   364  	}
   365  	if req == nil {
   366  		return
   367  	}
   368  	resp, err := client.ListAcceptingPortsSender(req)
   369  	if err != nil {
   370  		result.Response = autorest.Response{Response: resp}
   371  		return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "listAcceptingPortsNextResults", resp, "Failure sending next results request")
   372  	}
   373  	result, err = client.ListAcceptingPortsResponder(resp)
   374  	if err != nil {
   375  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "listAcceptingPortsNextResults", resp, "Failure responding to next results request")
   376  	}
   377  	return
   378  }
   379  
   380  // ListAcceptingPortsComplete enumerates all values, automatically crossing page boundaries as required.
   381  func (client ProcessesClient) ListAcceptingPortsComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result PortCollectionIterator, err error) {
   382  	if tracing.IsEnabled() {
   383  		ctx = tracing.StartSpan(ctx, fqdn+"/ProcessesClient.ListAcceptingPorts")
   384  		defer func() {
   385  			sc := -1
   386  			if result.Response().Response.Response != nil {
   387  				sc = result.page.Response().Response.Response.StatusCode
   388  			}
   389  			tracing.EndSpan(ctx, sc, err)
   390  		}()
   391  	}
   392  	result.page, err = client.ListAcceptingPorts(ctx, resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
   393  	return
   394  }
   395  
   396  // ListConnections returns a collection of connections terminating or originating at the specified process
   397  // Parameters:
   398  // resourceGroupName - resource group name within the specified subscriptionId.
   399  // workspaceName - OMS workspace containing the resources of interest.
   400  // machineName - machine resource name.
   401  // processName - process resource name.
   402  // startTime - UTC date and time specifying the start time of an interval. When not specified the service uses
   403  // DateTime.UtcNow - 10m
   404  // endTime - UTC date and time specifying the end time of an interval. When not specified the service uses
   405  // DateTime.UtcNow
   406  func (client ProcessesClient) ListConnections(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result ConnectionCollectionPage, err error) {
   407  	if tracing.IsEnabled() {
   408  		ctx = tracing.StartSpan(ctx, fqdn+"/ProcessesClient.ListConnections")
   409  		defer func() {
   410  			sc := -1
   411  			if result.cc.Response.Response != nil {
   412  				sc = result.cc.Response.Response.StatusCode
   413  			}
   414  			tracing.EndSpan(ctx, sc, err)
   415  		}()
   416  	}
   417  	if err := validation.Validate([]validation.Validation{
   418  		{TargetValue: resourceGroupName,
   419  			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   420  				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
   421  				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_-]+`, Chain: nil}}},
   422  		{TargetValue: workspaceName,
   423  			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 63, Chain: nil},
   424  				{Target: "workspaceName", Name: validation.MinLength, Rule: 3, Chain: nil},
   425  				{Target: "workspaceName", Name: validation.Pattern, Rule: `[a-zA-Z0-9_][a-zA-Z0-9_-]+[a-zA-Z0-9_]`, Chain: nil}}},
   426  		{TargetValue: machineName,
   427  			Constraints: []validation.Constraint{{Target: "machineName", Name: validation.MaxLength, Rule: 64, Chain: nil},
   428  				{Target: "machineName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
   429  		{TargetValue: processName,
   430  			Constraints: []validation.Constraint{{Target: "processName", Name: validation.MaxLength, Rule: 128, Chain: nil},
   431  				{Target: "processName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
   432  		return result, validation.NewError("servicemap.ProcessesClient", "ListConnections", err.Error())
   433  	}
   434  
   435  	result.fn = client.listConnectionsNextResults
   436  	req, err := client.ListConnectionsPreparer(ctx, resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
   437  	if err != nil {
   438  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", nil, "Failure preparing request")
   439  		return
   440  	}
   441  
   442  	resp, err := client.ListConnectionsSender(req)
   443  	if err != nil {
   444  		result.cc.Response = autorest.Response{Response: resp}
   445  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", resp, "Failure sending request")
   446  		return
   447  	}
   448  
   449  	result.cc, err = client.ListConnectionsResponder(resp)
   450  	if err != nil {
   451  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "ListConnections", resp, "Failure responding to request")
   452  		return
   453  	}
   454  	if result.cc.hasNextLink() && result.cc.IsEmpty() {
   455  		err = result.NextWithContext(ctx)
   456  		return
   457  	}
   458  
   459  	return
   460  }
   461  
   462  // ListConnectionsPreparer prepares the ListConnections request.
   463  func (client ProcessesClient) ListConnectionsPreparer(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (*http.Request, error) {
   464  	pathParameters := map[string]interface{}{
   465  		"machineName":       autorest.Encode("path", machineName),
   466  		"processName":       autorest.Encode("path", processName),
   467  		"resourceGroupName": autorest.Encode("path", resourceGroupName),
   468  		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
   469  		"workspaceName":     autorest.Encode("path", workspaceName),
   470  	}
   471  
   472  	const APIVersion = "2015-11-01-preview"
   473  	queryParameters := map[string]interface{}{
   474  		"api-version": APIVersion,
   475  	}
   476  	if startTime != nil {
   477  		queryParameters["startTime"] = autorest.Encode("query", *startTime)
   478  	}
   479  	if endTime != nil {
   480  		queryParameters["endTime"] = autorest.Encode("query", *endTime)
   481  	}
   482  
   483  	preparer := autorest.CreatePreparer(
   484  		autorest.AsGet(),
   485  		autorest.WithBaseURL(client.BaseURI),
   486  		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}/features/serviceMap/machines/{machineName}/processes/{processName}/connections", pathParameters),
   487  		autorest.WithQueryParameters(queryParameters))
   488  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   489  }
   490  
   491  // ListConnectionsSender sends the ListConnections request. The method will close the
   492  // http.Response Body if it receives an error.
   493  func (client ProcessesClient) ListConnectionsSender(req *http.Request) (*http.Response, error) {
   494  	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
   495  }
   496  
   497  // ListConnectionsResponder handles the response to the ListConnections request. The method always
   498  // closes the http.Response Body.
   499  func (client ProcessesClient) ListConnectionsResponder(resp *http.Response) (result ConnectionCollection, err error) {
   500  	err = autorest.Respond(
   501  		resp,
   502  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   503  		autorest.ByUnmarshallingJSON(&result),
   504  		autorest.ByClosing())
   505  	result.Response = autorest.Response{Response: resp}
   506  	return
   507  }
   508  
   509  // listConnectionsNextResults retrieves the next set of results, if any.
   510  func (client ProcessesClient) listConnectionsNextResults(ctx context.Context, lastResults ConnectionCollection) (result ConnectionCollection, err error) {
   511  	req, err := lastResults.connectionCollectionPreparer(ctx)
   512  	if err != nil {
   513  		return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "listConnectionsNextResults", nil, "Failure preparing next results request")
   514  	}
   515  	if req == nil {
   516  		return
   517  	}
   518  	resp, err := client.ListConnectionsSender(req)
   519  	if err != nil {
   520  		result.Response = autorest.Response{Response: resp}
   521  		return result, autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "listConnectionsNextResults", resp, "Failure sending next results request")
   522  	}
   523  	result, err = client.ListConnectionsResponder(resp)
   524  	if err != nil {
   525  		err = autorest.NewErrorWithError(err, "servicemap.ProcessesClient", "listConnectionsNextResults", resp, "Failure responding to next results request")
   526  	}
   527  	return
   528  }
   529  
   530  // ListConnectionsComplete enumerates all values, automatically crossing page boundaries as required.
   531  func (client ProcessesClient) ListConnectionsComplete(ctx context.Context, resourceGroupName string, workspaceName string, machineName string, processName string, startTime *date.Time, endTime *date.Time) (result ConnectionCollectionIterator, err error) {
   532  	if tracing.IsEnabled() {
   533  		ctx = tracing.StartSpan(ctx, fqdn+"/ProcessesClient.ListConnections")
   534  		defer func() {
   535  			sc := -1
   536  			if result.Response().Response.Response != nil {
   537  				sc = result.page.Response().Response.Response.StatusCode
   538  			}
   539  			tracing.EndSpan(ctx, sc, err)
   540  		}()
   541  	}
   542  	result.page, err = client.ListConnections(ctx, resourceGroupName, workspaceName, machineName, processName, startTime, endTime)
   543  	return
   544  }
   545  

View as plain text