1package securityinsight
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
9import (
10	"context"
11	"github.com/Azure/go-autorest/autorest"
12	"github.com/Azure/go-autorest/autorest/azure"
13	"github.com/Azure/go-autorest/autorest/validation"
14	"github.com/Azure/go-autorest/tracing"
15	"net/http"
16)
17
18// EntitiesClient is the API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider
19type EntitiesClient struct {
20	BaseClient
21}
22
23// NewEntitiesClient creates an instance of the EntitiesClient client.
24func NewEntitiesClient(subscriptionID string) EntitiesClient {
25	return NewEntitiesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewEntitiesClientWithBaseURI creates an instance of the EntitiesClient client using a custom endpoint.  Use this
29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewEntitiesClientWithBaseURI(baseURI string, subscriptionID string) EntitiesClient {
31	return EntitiesClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// Expand expands an entity.
35// Parameters:
36// resourceGroupName - the name of the resource group within the user's subscription. The name is case
37// insensitive.
38// operationalInsightsResourceProvider - the namespace of workspaces resource provider-
39// Microsoft.OperationalInsights.
40// workspaceName - the name of the workspace.
41// entityID - entity ID
42// parameters - the parameters required to execute an expand operation on the given entity.
43func (client EntitiesClient) Expand(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string, parameters EntityExpandParameters) (result EntityExpandResponse, err error) {
44	if tracing.IsEnabled() {
45		ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.Expand")
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: client.SubscriptionID,
56			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
57		{TargetValue: resourceGroupName,
58			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
59				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
60				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
61		{TargetValue: workspaceName,
62			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil},
63				{Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
64		return result, validation.NewError("securityinsight.EntitiesClient", "Expand", err.Error())
65	}
66
67	req, err := client.ExpandPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, entityID, parameters)
68	if err != nil {
69		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Expand", nil, "Failure preparing request")
70		return
71	}
72
73	resp, err := client.ExpandSender(req)
74	if err != nil {
75		result.Response = autorest.Response{Response: resp}
76		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Expand", resp, "Failure sending request")
77		return
78	}
79
80	result, err = client.ExpandResponder(resp)
81	if err != nil {
82		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Expand", resp, "Failure responding to request")
83		return
84	}
85
86	return
87}
88
89// ExpandPreparer prepares the Expand request.
90func (client EntitiesClient) ExpandPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string, parameters EntityExpandParameters) (*http.Request, error) {
91	pathParameters := map[string]interface{}{
92		"entityId":                            autorest.Encode("path", entityID),
93		"operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider),
94		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
95		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
96		"workspaceName":                       autorest.Encode("path", workspaceName),
97	}
98
99	const APIVersion = "2019-01-01-preview"
100	queryParameters := map[string]interface{}{
101		"api-version": APIVersion,
102	}
103
104	preparer := autorest.CreatePreparer(
105		autorest.AsContentType("application/json; charset=utf-8"),
106		autorest.AsPost(),
107		autorest.WithBaseURL(client.BaseURI),
108		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entities/{entityId}/expand", pathParameters),
109		autorest.WithJSON(parameters),
110		autorest.WithQueryParameters(queryParameters))
111	return preparer.Prepare((&http.Request{}).WithContext(ctx))
112}
113
114// ExpandSender sends the Expand request. The method will close the
115// http.Response Body if it receives an error.
116func (client EntitiesClient) ExpandSender(req *http.Request) (*http.Response, error) {
117	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
118}
119
120// ExpandResponder handles the response to the Expand request. The method always
121// closes the http.Response Body.
122func (client EntitiesClient) ExpandResponder(resp *http.Response) (result EntityExpandResponse, err error) {
123	err = autorest.Respond(
124		resp,
125		azure.WithErrorUnlessStatusCode(http.StatusOK),
126		autorest.ByUnmarshallingJSON(&result),
127		autorest.ByClosing())
128	result.Response = autorest.Response{Response: resp}
129	return
130}
131
132// Get gets an entity.
133// Parameters:
134// resourceGroupName - the name of the resource group within the user's subscription. The name is case
135// insensitive.
136// operationalInsightsResourceProvider - the namespace of workspaces resource provider-
137// Microsoft.OperationalInsights.
138// workspaceName - the name of the workspace.
139// entityID - entity ID
140func (client EntitiesClient) Get(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string) (result EntityModel, err error) {
141	if tracing.IsEnabled() {
142		ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.Get")
143		defer func() {
144			sc := -1
145			if result.Response.Response != nil {
146				sc = result.Response.Response.StatusCode
147			}
148			tracing.EndSpan(ctx, sc, err)
149		}()
150	}
151	if err := validation.Validate([]validation.Validation{
152		{TargetValue: client.SubscriptionID,
153			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
154		{TargetValue: resourceGroupName,
155			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
156				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
157				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
158		{TargetValue: workspaceName,
159			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil},
160				{Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
161		return result, validation.NewError("securityinsight.EntitiesClient", "Get", err.Error())
162	}
163
164	req, err := client.GetPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, entityID)
165	if err != nil {
166		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Get", nil, "Failure preparing request")
167		return
168	}
169
170	resp, err := client.GetSender(req)
171	if err != nil {
172		result.Response = autorest.Response{Response: resp}
173		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Get", resp, "Failure sending request")
174		return
175	}
176
177	result, err = client.GetResponder(resp)
178	if err != nil {
179		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Get", resp, "Failure responding to request")
180		return
181	}
182
183	return
184}
185
186// GetPreparer prepares the Get request.
187func (client EntitiesClient) GetPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string) (*http.Request, error) {
188	pathParameters := map[string]interface{}{
189		"entityId":                            autorest.Encode("path", entityID),
190		"operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider),
191		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
192		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
193		"workspaceName":                       autorest.Encode("path", workspaceName),
194	}
195
196	const APIVersion = "2019-01-01-preview"
197	queryParameters := map[string]interface{}{
198		"api-version": APIVersion,
199	}
200
201	preparer := autorest.CreatePreparer(
202		autorest.AsGet(),
203		autorest.WithBaseURL(client.BaseURI),
204		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entities/{entityId}", pathParameters),
205		autorest.WithQueryParameters(queryParameters))
206	return preparer.Prepare((&http.Request{}).WithContext(ctx))
207}
208
209// GetSender sends the Get request. The method will close the
210// http.Response Body if it receives an error.
211func (client EntitiesClient) GetSender(req *http.Request) (*http.Response, error) {
212	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
213}
214
215// GetResponder handles the response to the Get request. The method always
216// closes the http.Response Body.
217func (client EntitiesClient) GetResponder(resp *http.Response) (result EntityModel, err error) {
218	err = autorest.Respond(
219		resp,
220		azure.WithErrorUnlessStatusCode(http.StatusOK),
221		autorest.ByUnmarshallingJSON(&result),
222		autorest.ByClosing())
223	result.Response = autorest.Response{Response: resp}
224	return
225}
226
227// GetInsights execute Insights for an entity.
228// Parameters:
229// resourceGroupName - the name of the resource group within the user's subscription. The name is case
230// insensitive.
231// operationalInsightsResourceProvider - the namespace of workspaces resource provider-
232// Microsoft.OperationalInsights.
233// workspaceName - the name of the workspace.
234// entityID - entity ID
235// parameters - the parameters required to execute insights on the given entity.
236func (client EntitiesClient) GetInsights(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string, parameters EntityGetInsightsParameters) (result EntityGetInsightsResponse, err error) {
237	if tracing.IsEnabled() {
238		ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.GetInsights")
239		defer func() {
240			sc := -1
241			if result.Response.Response != nil {
242				sc = result.Response.Response.StatusCode
243			}
244			tracing.EndSpan(ctx, sc, err)
245		}()
246	}
247	if err := validation.Validate([]validation.Validation{
248		{TargetValue: client.SubscriptionID,
249			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
250		{TargetValue: resourceGroupName,
251			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
252				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
253				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
254		{TargetValue: workspaceName,
255			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil},
256				{Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
257		{TargetValue: parameters,
258			Constraints: []validation.Constraint{{Target: "parameters.StartTime", Name: validation.Null, Rule: true, Chain: nil},
259				{Target: "parameters.EndTime", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
260		return result, validation.NewError("securityinsight.EntitiesClient", "GetInsights", err.Error())
261	}
262
263	req, err := client.GetInsightsPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, entityID, parameters)
264	if err != nil {
265		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "GetInsights", nil, "Failure preparing request")
266		return
267	}
268
269	resp, err := client.GetInsightsSender(req)
270	if err != nil {
271		result.Response = autorest.Response{Response: resp}
272		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "GetInsights", resp, "Failure sending request")
273		return
274	}
275
276	result, err = client.GetInsightsResponder(resp)
277	if err != nil {
278		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "GetInsights", resp, "Failure responding to request")
279		return
280	}
281
282	return
283}
284
285// GetInsightsPreparer prepares the GetInsights request.
286func (client EntitiesClient) GetInsightsPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string, parameters EntityGetInsightsParameters) (*http.Request, error) {
287	pathParameters := map[string]interface{}{
288		"entityId":                            autorest.Encode("path", entityID),
289		"operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider),
290		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
291		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
292		"workspaceName":                       autorest.Encode("path", workspaceName),
293	}
294
295	const APIVersion = "2019-01-01-preview"
296	queryParameters := map[string]interface{}{
297		"api-version": APIVersion,
298	}
299
300	preparer := autorest.CreatePreparer(
301		autorest.AsContentType("application/json; charset=utf-8"),
302		autorest.AsPost(),
303		autorest.WithBaseURL(client.BaseURI),
304		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entities/{entityId}/getInsights", pathParameters),
305		autorest.WithJSON(parameters),
306		autorest.WithQueryParameters(queryParameters))
307	return preparer.Prepare((&http.Request{}).WithContext(ctx))
308}
309
310// GetInsightsSender sends the GetInsights request. The method will close the
311// http.Response Body if it receives an error.
312func (client EntitiesClient) GetInsightsSender(req *http.Request) (*http.Response, error) {
313	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
314}
315
316// GetInsightsResponder handles the response to the GetInsights request. The method always
317// closes the http.Response Body.
318func (client EntitiesClient) GetInsightsResponder(resp *http.Response) (result EntityGetInsightsResponse, err error) {
319	err = autorest.Respond(
320		resp,
321		azure.WithErrorUnlessStatusCode(http.StatusOK),
322		autorest.ByUnmarshallingJSON(&result),
323		autorest.ByClosing())
324	result.Response = autorest.Response{Response: resp}
325	return
326}
327
328// List gets all entities.
329// Parameters:
330// resourceGroupName - the name of the resource group within the user's subscription. The name is case
331// insensitive.
332// operationalInsightsResourceProvider - the namespace of workspaces resource provider-
333// Microsoft.OperationalInsights.
334// workspaceName - the name of the workspace.
335func (client EntitiesClient) List(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result EntityListPage, err error) {
336	if tracing.IsEnabled() {
337		ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.List")
338		defer func() {
339			sc := -1
340			if result.el.Response.Response != nil {
341				sc = result.el.Response.Response.StatusCode
342			}
343			tracing.EndSpan(ctx, sc, err)
344		}()
345	}
346	if err := validation.Validate([]validation.Validation{
347		{TargetValue: client.SubscriptionID,
348			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
349		{TargetValue: resourceGroupName,
350			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
351				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
352				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
353		{TargetValue: workspaceName,
354			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil},
355				{Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
356		return result, validation.NewError("securityinsight.EntitiesClient", "List", err.Error())
357	}
358
359	result.fn = client.listNextResults
360	req, err := client.ListPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName)
361	if err != nil {
362		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "List", nil, "Failure preparing request")
363		return
364	}
365
366	resp, err := client.ListSender(req)
367	if err != nil {
368		result.el.Response = autorest.Response{Response: resp}
369		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "List", resp, "Failure sending request")
370		return
371	}
372
373	result.el, err = client.ListResponder(resp)
374	if err != nil {
375		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "List", resp, "Failure responding to request")
376		return
377	}
378	if result.el.hasNextLink() && result.el.IsEmpty() {
379		err = result.NextWithContext(ctx)
380		return
381	}
382
383	return
384}
385
386// ListPreparer prepares the List request.
387func (client EntitiesClient) ListPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (*http.Request, error) {
388	pathParameters := map[string]interface{}{
389		"operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider),
390		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
391		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
392		"workspaceName":                       autorest.Encode("path", workspaceName),
393	}
394
395	const APIVersion = "2019-01-01-preview"
396	queryParameters := map[string]interface{}{
397		"api-version": APIVersion,
398	}
399
400	preparer := autorest.CreatePreparer(
401		autorest.AsGet(),
402		autorest.WithBaseURL(client.BaseURI),
403		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entities", pathParameters),
404		autorest.WithQueryParameters(queryParameters))
405	return preparer.Prepare((&http.Request{}).WithContext(ctx))
406}
407
408// ListSender sends the List request. The method will close the
409// http.Response Body if it receives an error.
410func (client EntitiesClient) ListSender(req *http.Request) (*http.Response, error) {
411	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
412}
413
414// ListResponder handles the response to the List request. The method always
415// closes the http.Response Body.
416func (client EntitiesClient) ListResponder(resp *http.Response) (result EntityList, err error) {
417	err = autorest.Respond(
418		resp,
419		azure.WithErrorUnlessStatusCode(http.StatusOK),
420		autorest.ByUnmarshallingJSON(&result),
421		autorest.ByClosing())
422	result.Response = autorest.Response{Response: resp}
423	return
424}
425
426// listNextResults retrieves the next set of results, if any.
427func (client EntitiesClient) listNextResults(ctx context.Context, lastResults EntityList) (result EntityList, err error) {
428	req, err := lastResults.entityListPreparer(ctx)
429	if err != nil {
430		return result, autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "listNextResults", nil, "Failure preparing next results request")
431	}
432	if req == nil {
433		return
434	}
435	resp, err := client.ListSender(req)
436	if err != nil {
437		result.Response = autorest.Response{Response: resp}
438		return result, autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "listNextResults", resp, "Failure sending next results request")
439	}
440	result, err = client.ListResponder(resp)
441	if err != nil {
442		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "listNextResults", resp, "Failure responding to next results request")
443	}
444	return
445}
446
447// ListComplete enumerates all values, automatically crossing page boundaries as required.
448func (client EntitiesClient) ListComplete(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string) (result EntityListIterator, err error) {
449	if tracing.IsEnabled() {
450		ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.List")
451		defer func() {
452			sc := -1
453			if result.Response().Response.Response != nil {
454				sc = result.page.Response().Response.Response.StatusCode
455			}
456			tracing.EndSpan(ctx, sc, err)
457		}()
458	}
459	result.page, err = client.List(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName)
460	return
461}
462
463// Queries get Insights and Activities for an entity.
464// Parameters:
465// resourceGroupName - the name of the resource group within the user's subscription. The name is case
466// insensitive.
467// operationalInsightsResourceProvider - the namespace of workspaces resource provider-
468// Microsoft.OperationalInsights.
469// workspaceName - the name of the workspace.
470// entityID - entity ID
471func (client EntitiesClient) Queries(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string) (result GetQueriesResponse, err error) {
472	if tracing.IsEnabled() {
473		ctx = tracing.StartSpan(ctx, fqdn+"/EntitiesClient.Queries")
474		defer func() {
475			sc := -1
476			if result.Response.Response != nil {
477				sc = result.Response.Response.StatusCode
478			}
479			tracing.EndSpan(ctx, sc, err)
480		}()
481	}
482	if err := validation.Validate([]validation.Validation{
483		{TargetValue: client.SubscriptionID,
484			Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.Pattern, Rule: `^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$`, Chain: nil}}},
485		{TargetValue: resourceGroupName,
486			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
487				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
488				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
489		{TargetValue: workspaceName,
490			Constraints: []validation.Constraint{{Target: "workspaceName", Name: validation.MaxLength, Rule: 90, Chain: nil},
491				{Target: "workspaceName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
492		return result, validation.NewError("securityinsight.EntitiesClient", "Queries", err.Error())
493	}
494
495	req, err := client.QueriesPreparer(ctx, resourceGroupName, operationalInsightsResourceProvider, workspaceName, entityID)
496	if err != nil {
497		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Queries", nil, "Failure preparing request")
498		return
499	}
500
501	resp, err := client.QueriesSender(req)
502	if err != nil {
503		result.Response = autorest.Response{Response: resp}
504		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Queries", resp, "Failure sending request")
505		return
506	}
507
508	result, err = client.QueriesResponder(resp)
509	if err != nil {
510		err = autorest.NewErrorWithError(err, "securityinsight.EntitiesClient", "Queries", resp, "Failure responding to request")
511		return
512	}
513
514	return
515}
516
517// QueriesPreparer prepares the Queries request.
518func (client EntitiesClient) QueriesPreparer(ctx context.Context, resourceGroupName string, operationalInsightsResourceProvider string, workspaceName string, entityID string) (*http.Request, error) {
519	pathParameters := map[string]interface{}{
520		"entityId":                            autorest.Encode("path", entityID),
521		"operationalInsightsResourceProvider": autorest.Encode("path", operationalInsightsResourceProvider),
522		"resourceGroupName":                   autorest.Encode("path", resourceGroupName),
523		"subscriptionId":                      autorest.Encode("path", client.SubscriptionID),
524		"workspaceName":                       autorest.Encode("path", workspaceName),
525	}
526
527	const APIVersion = "2019-01-01-preview"
528	queryParameters := map[string]interface{}{
529		"api-version": APIVersion,
530		"kind":        autorest.Encode("query", "Insight"),
531	}
532
533	preparer := autorest.CreatePreparer(
534		autorest.AsGet(),
535		autorest.WithBaseURL(client.BaseURI),
536		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/entities/{entityId}/queries", pathParameters),
537		autorest.WithQueryParameters(queryParameters))
538	return preparer.Prepare((&http.Request{}).WithContext(ctx))
539}
540
541// QueriesSender sends the Queries request. The method will close the
542// http.Response Body if it receives an error.
543func (client EntitiesClient) QueriesSender(req *http.Request) (*http.Response, error) {
544	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
545}
546
547// QueriesResponder handles the response to the Queries request. The method always
548// closes the http.Response Body.
549func (client EntitiesClient) QueriesResponder(resp *http.Response) (result GetQueriesResponse, err error) {
550	err = autorest.Respond(
551		resp,
552		azure.WithErrorUnlessStatusCode(http.StatusOK),
553		autorest.ByUnmarshallingJSON(&result),
554		autorest.ByClosing())
555	result.Response = autorest.Response{Response: resp}
556	return
557}
558