diff --git a/profiles/preview/preview/enterpriseknowledgegraphservice/enterpriseknowledgegraphservice/enterpriseknowledgegraphserviceapi/models.go b/profiles/preview/preview/enterpriseknowledgegraphservice/enterpriseknowledgegraphservice/enterpriseknowledgegraphserviceapi/models.go new file mode 100644 index 000000000000..d460633cd87b --- /dev/null +++ b/profiles/preview/preview/enterpriseknowledgegraphservice/enterpriseknowledgegraphservice/enterpriseknowledgegraphserviceapi/models.go @@ -0,0 +1,25 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package enterpriseknowledgegraphserviceapi + +import original "github.com/Azure/azure-sdk-for-go/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/enterpriseknowledgegraphserviceapi" + +type EnterpriseKnowledgeGraphClientAPI = original.EnterpriseKnowledgeGraphClientAPI +type OperationsClientAPI = original.OperationsClientAPI diff --git a/profiles/preview/preview/enterpriseknowledgegraphservice/enterpriseknowledgegraphservice/models.go b/profiles/preview/preview/enterpriseknowledgegraphservice/enterpriseknowledgegraphservice/models.go new file mode 100644 index 000000000000..11bebf1ab1e0 --- /dev/null +++ b/profiles/preview/preview/enterpriseknowledgegraphservice/enterpriseknowledgegraphservice/models.go @@ -0,0 +1,107 @@ +// +build go1.9 + +// Copyright 2019 Microsoft Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package enterpriseknowledgegraphservice + +import ( + "context" + + original "github.com/Azure/azure-sdk-for-go/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice" +) + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type ProvisioningState = original.ProvisioningState + +const ( + Creating ProvisioningState = original.Creating + Deleting ProvisioningState = original.Deleting + Failed ProvisioningState = original.Failed + Succeeded ProvisioningState = original.Succeeded +) + +type SkuName = original.SkuName + +const ( + F0 SkuName = original.F0 + S1 SkuName = original.S1 +) + +type BaseClient = original.BaseClient +type EnterpriseKnowledgeGraph = original.EnterpriseKnowledgeGraph +type EnterpriseKnowledgeGraphClient = original.EnterpriseKnowledgeGraphClient +type EnterpriseKnowledgeGraphProperties = original.EnterpriseKnowledgeGraphProperties +type EnterpriseKnowledgeGraphResponseList = original.EnterpriseKnowledgeGraphResponseList +type EnterpriseKnowledgeGraphResponseListIterator = original.EnterpriseKnowledgeGraphResponseListIterator +type EnterpriseKnowledgeGraphResponseListPage = original.EnterpriseKnowledgeGraphResponseListPage +type Error = original.Error +type ErrorBody = original.ErrorBody +type OperationDisplayInfo = original.OperationDisplayInfo +type OperationEntity = original.OperationEntity +type OperationEntityListResult = original.OperationEntityListResult +type OperationEntityListResultIterator = original.OperationEntityListResultIterator +type OperationEntityListResultPage = original.OperationEntityListResultPage +type OperationsClient = original.OperationsClient +type Resource = original.Resource +type Sku = original.Sku + +func New(subscriptionID string) BaseClient { + return original.New(subscriptionID) +} +func NewEnterpriseKnowledgeGraphClient(subscriptionID string) EnterpriseKnowledgeGraphClient { + return original.NewEnterpriseKnowledgeGraphClient(subscriptionID) +} +func NewEnterpriseKnowledgeGraphClientWithBaseURI(baseURI string, subscriptionID string) EnterpriseKnowledgeGraphClient { + return original.NewEnterpriseKnowledgeGraphClientWithBaseURI(baseURI, subscriptionID) +} +func NewEnterpriseKnowledgeGraphResponseListIterator(page EnterpriseKnowledgeGraphResponseListPage) EnterpriseKnowledgeGraphResponseListIterator { + return original.NewEnterpriseKnowledgeGraphResponseListIterator(page) +} +func NewEnterpriseKnowledgeGraphResponseListPage(getNextPage func(context.Context, EnterpriseKnowledgeGraphResponseList) (EnterpriseKnowledgeGraphResponseList, error)) EnterpriseKnowledgeGraphResponseListPage { + return original.NewEnterpriseKnowledgeGraphResponseListPage(getNextPage) +} +func NewOperationEntityListResultIterator(page OperationEntityListResultPage) OperationEntityListResultIterator { + return original.NewOperationEntityListResultIterator(page) +} +func NewOperationEntityListResultPage(getNextPage func(context.Context, OperationEntityListResult) (OperationEntityListResult, error)) OperationEntityListResultPage { + return original.NewOperationEntityListResultPage(getNextPage) +} +func NewOperationsClient(subscriptionID string) OperationsClient { + return original.NewOperationsClient(subscriptionID) +} +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleProvisioningStateValues() []ProvisioningState { + return original.PossibleProvisioningStateValues() +} +func PossibleSkuNameValues() []SkuName { + return original.PossibleSkuNameValues() +} +func UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/client.go b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/client.go new file mode 100644 index 000000000000..8f62ccff413c --- /dev/null +++ b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/client.go @@ -0,0 +1,52 @@ +// Package enterpriseknowledgegraphservice implements the Azure ARM Enterpriseknowledgegraphservice service API version +// 2018-12-03. +// +// Azure Enterprise Knowledge Graph Service is a platform for creating knowledge graphs at scale. +package enterpriseknowledgegraphservice + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Enterpriseknowledgegraphservice + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Enterpriseknowledgegraphservice. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/enterpriseknowledgegraph.go b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/enterpriseknowledgegraph.go new file mode 100644 index 000000000000..4837286b5dd1 --- /dev/null +++ b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/enterpriseknowledgegraph.go @@ -0,0 +1,636 @@ +package enterpriseknowledgegraphservice + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// EnterpriseKnowledgeGraphClient is the azure Enterprise Knowledge Graph Service is a platform for creating knowledge +// graphs at scale. +type EnterpriseKnowledgeGraphClient struct { + BaseClient +} + +// NewEnterpriseKnowledgeGraphClient creates an instance of the EnterpriseKnowledgeGraphClient client. +func NewEnterpriseKnowledgeGraphClient(subscriptionID string) EnterpriseKnowledgeGraphClient { + return NewEnterpriseKnowledgeGraphClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewEnterpriseKnowledgeGraphClientWithBaseURI creates an instance of the EnterpriseKnowledgeGraphClient client. +func NewEnterpriseKnowledgeGraphClientWithBaseURI(baseURI string, subscriptionID string) EnterpriseKnowledgeGraphClient { + return EnterpriseKnowledgeGraphClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a EnterpriseKnowledgeGraph Service. EnterpriseKnowledgeGraph Service is a resource group wide +// resource type. +// Parameters: +// resourceGroupName - the name of the EnterpriseKnowledgeGraph resource group in the user subscription. +// resourceName - the name of the EnterpriseKnowledgeGraph resource. +// parameters - the parameters to provide for the created EnterpriseKnowledgeGraph. +func (client EnterpriseKnowledgeGraphClient) Create(ctx context.Context, resourceGroupName string, resourceName string, parameters EnterpriseKnowledgeGraph) (result EnterpriseKnowledgeGraph, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.Create") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Create", nil, "Failure preparing request") + return + } + + resp, err := client.CreateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Create", resp, "Failure sending request") + return + } + + result, err = client.CreateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Create", resp, "Failure responding to request") + } + + return +} + +// CreatePreparer prepares the Create request. +func (client EnterpriseKnowledgeGraphClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters EnterpriseKnowledgeGraph) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-12-03" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EnterpriseKnowledgeGraph/services/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client EnterpriseKnowledgeGraphClient) CreateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client EnterpriseKnowledgeGraphClient) CreateResponder(resp *http.Response) (result EnterpriseKnowledgeGraph, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a EnterpriseKnowledgeGraph Service from the resource group. +// Parameters: +// resourceGroupName - the name of the EnterpriseKnowledgeGraph resource group in the user subscription. +// resourceName - the name of the EnterpriseKnowledgeGraph resource. +func (client EnterpriseKnowledgeGraphClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client EnterpriseKnowledgeGraphClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-12-03" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EnterpriseKnowledgeGraph/services/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client EnterpriseKnowledgeGraphClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client EnterpriseKnowledgeGraphClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get returns a EnterpriseKnowledgeGraph service specified by the parameters. +// Parameters: +// resourceGroupName - the name of the EnterpriseKnowledgeGraph resource group in the user subscription. +// resourceName - the name of the EnterpriseKnowledgeGraph resource. +func (client EnterpriseKnowledgeGraphClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result EnterpriseKnowledgeGraph, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client EnterpriseKnowledgeGraphClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-12-03" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EnterpriseKnowledgeGraph/services/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client EnterpriseKnowledgeGraphClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client EnterpriseKnowledgeGraphClient) GetResponder(resp *http.Response) (result EnterpriseKnowledgeGraph, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List returns all the resources of a particular type belonging to a subscription. +func (client EnterpriseKnowledgeGraphClient) List(ctx context.Context) (result EnterpriseKnowledgeGraphResponseListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.List") + defer func() { + sc := -1 + if result.ekgrl.Response.Response != nil { + sc = result.ekgrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ekgrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "List", resp, "Failure sending request") + return + } + + result.ekgrl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client EnterpriseKnowledgeGraphClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-12-03" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.EnterpriseKnowledgeGraph/services", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client EnterpriseKnowledgeGraphClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client EnterpriseKnowledgeGraphClient) ListResponder(resp *http.Response) (result EnterpriseKnowledgeGraphResponseList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client EnterpriseKnowledgeGraphClient) listNextResults(ctx context.Context, lastResults EnterpriseKnowledgeGraphResponseList) (result EnterpriseKnowledgeGraphResponseList, err error) { + req, err := lastResults.enterpriseKnowledgeGraphResponseListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client EnterpriseKnowledgeGraphClient) ListComplete(ctx context.Context) (result EnterpriseKnowledgeGraphResponseListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByResourceGroup returns all the resources of a particular type belonging to a resource group +// Parameters: +// resourceGroupName - the name of the EnterpriseKnowledgeGraph resource group in the user subscription. +func (client EnterpriseKnowledgeGraphClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result EnterpriseKnowledgeGraphResponseListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.ekgrl.Response.Response != nil { + sc = result.ekgrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "ListByResourceGroup", err.Error()) + } + + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.ekgrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.ekgrl, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client EnterpriseKnowledgeGraphClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-12-03" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EnterpriseKnowledgeGraph/services", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client EnterpriseKnowledgeGraphClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client EnterpriseKnowledgeGraphClient) ListByResourceGroupResponder(resp *http.Response) (result EnterpriseKnowledgeGraphResponseList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client EnterpriseKnowledgeGraphClient) listByResourceGroupNextResults(ctx context.Context, lastResults EnterpriseKnowledgeGraphResponseList) (result EnterpriseKnowledgeGraphResponseList, err error) { + req, err := lastResults.enterpriseKnowledgeGraphResponseListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client EnterpriseKnowledgeGraphClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result EnterpriseKnowledgeGraphResponseListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update updates a EnterpriseKnowledgeGraph Service +// Parameters: +// resourceGroupName - the name of the EnterpriseKnowledgeGraph resource group in the user subscription. +// resourceName - the name of the EnterpriseKnowledgeGraph resource. +// parameters - the parameters to provide for the created EnterpriseKnowledgeGraph. +func (client EnterpriseKnowledgeGraphClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters EnterpriseKnowledgeGraph) (result EnterpriseKnowledgeGraph, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}, + {TargetValue: resourceName, + Constraints: []validation.Constraint{{Target: "resourceName", Name: validation.MaxLength, Rule: 64, Chain: nil}, + {Target: "resourceName", Name: validation.MinLength, Rule: 2, Chain: nil}, + {Target: "resourceName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9][a-zA-Z0-9_.-]*$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client EnterpriseKnowledgeGraphClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters EnterpriseKnowledgeGraph) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-12-03" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EnterpriseKnowledgeGraph/services/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client EnterpriseKnowledgeGraphClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client EnterpriseKnowledgeGraphClient) UpdateResponder(resp *http.Response) (result EnterpriseKnowledgeGraph, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/enterpriseknowledgegraphserviceapi/interfaces.go b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/enterpriseknowledgegraphserviceapi/interfaces.go new file mode 100644 index 000000000000..a2a4337360c6 --- /dev/null +++ b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/enterpriseknowledgegraphserviceapi/interfaces.go @@ -0,0 +1,43 @@ +package enterpriseknowledgegraphserviceapi + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice" + "github.com/Azure/go-autorest/autorest" +) + +// EnterpriseKnowledgeGraphClientAPI contains the set of methods on the EnterpriseKnowledgeGraphClient type. +type EnterpriseKnowledgeGraphClientAPI interface { + Create(ctx context.Context, resourceGroupName string, resourceName string, parameters enterpriseknowledgegraphservice.EnterpriseKnowledgeGraph) (result enterpriseknowledgegraphservice.EnterpriseKnowledgeGraph, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result autorest.Response, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result enterpriseknowledgegraphservice.EnterpriseKnowledgeGraph, err error) + List(ctx context.Context) (result enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphResponseListPage, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphResponseListPage, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, parameters enterpriseknowledgegraphservice.EnterpriseKnowledgeGraph) (result enterpriseknowledgegraphservice.EnterpriseKnowledgeGraph, err error) +} + +var _ EnterpriseKnowledgeGraphClientAPI = (*enterpriseknowledgegraphservice.EnterpriseKnowledgeGraphClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result enterpriseknowledgegraphservice.OperationEntityListResultPage, err error) +} + +var _ OperationsClientAPI = (*enterpriseknowledgegraphservice.OperationsClient)(nil) diff --git a/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/models.go b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/models.go new file mode 100644 index 000000000000..5256337efd35 --- /dev/null +++ b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/models.go @@ -0,0 +1,479 @@ +package enterpriseknowledgegraphservice + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice" + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Creating, Deleting, Failed, Succeeded} +} + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // F0 ... + F0 SkuName = "F0" + // S1 ... + S1 SkuName = "S1" +) + +// PossibleSkuNameValues returns an array of possible values for the SkuName const type. +func PossibleSkuNameValues() []SkuName { + return []SkuName{F0, S1} +} + +// EnterpriseKnowledgeGraph enterpriseKnowledgeGraph resource definition +type EnterpriseKnowledgeGraph struct { + autorest.Response `json:"-"` + // Properties - The set of properties specific to EnterpriseKnowledgeGraph resource + Properties *EnterpriseKnowledgeGraphProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Specifies the resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Specifies the name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Specifies the type of the resource. + Type *string `json:"type,omitempty"` + // Location - Specifies the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Contains resource tags defined as key/value pairs. + Tags map[string]*string `json:"tags"` + // Sku - Gets or sets the SKU of the resource. + Sku *Sku `json:"sku,omitempty"` +} + +// MarshalJSON is the custom marshaler for EnterpriseKnowledgeGraph. +func (ekg EnterpriseKnowledgeGraph) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ekg.Properties != nil { + objectMap["properties"] = ekg.Properties + } + if ekg.Location != nil { + objectMap["location"] = ekg.Location + } + if ekg.Tags != nil { + objectMap["tags"] = ekg.Tags + } + if ekg.Sku != nil { + objectMap["sku"] = ekg.Sku + } + return json.Marshal(objectMap) +} + +// EnterpriseKnowledgeGraphProperties the parameters to provide for the EnterpriseKnowledgeGraph. +type EnterpriseKnowledgeGraphProperties struct { + // Description - The description of the EnterpriseKnowledgeGraph + Description *string `json:"description,omitempty"` + // Metadata - Specifies the metadata of the resource. + Metadata interface{} `json:"metadata,omitempty"` + // ProvisioningState - The state of EnterpriseKnowledgeGraph provisioning. Possible values include: 'Creating', 'Deleting', 'Failed', 'Succeeded' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` +} + +// EnterpriseKnowledgeGraphResponseList the list of EnterpriseKnowledgeGraph service operation response. +type EnterpriseKnowledgeGraphResponseList struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of EnterpriseKnowledgeGraph service resources. + NextLink *string `json:"nextLink,omitempty"` + // Value - READ-ONLY; Gets the list of EnterpriseKnowledgeGraph service results and their properties. + Value *[]EnterpriseKnowledgeGraph `json:"value,omitempty"` +} + +// EnterpriseKnowledgeGraphResponseListIterator provides access to a complete listing of +// EnterpriseKnowledgeGraph values. +type EnterpriseKnowledgeGraphResponseListIterator struct { + i int + page EnterpriseKnowledgeGraphResponseListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *EnterpriseKnowledgeGraphResponseListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphResponseListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *EnterpriseKnowledgeGraphResponseListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EnterpriseKnowledgeGraphResponseListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter EnterpriseKnowledgeGraphResponseListIterator) Response() EnterpriseKnowledgeGraphResponseList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter EnterpriseKnowledgeGraphResponseListIterator) Value() EnterpriseKnowledgeGraph { + if !iter.page.NotDone() { + return EnterpriseKnowledgeGraph{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EnterpriseKnowledgeGraphResponseListIterator type. +func NewEnterpriseKnowledgeGraphResponseListIterator(page EnterpriseKnowledgeGraphResponseListPage) EnterpriseKnowledgeGraphResponseListIterator { + return EnterpriseKnowledgeGraphResponseListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ekgrl EnterpriseKnowledgeGraphResponseList) IsEmpty() bool { + return ekgrl.Value == nil || len(*ekgrl.Value) == 0 +} + +// enterpriseKnowledgeGraphResponseListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ekgrl EnterpriseKnowledgeGraphResponseList) enterpriseKnowledgeGraphResponseListPreparer(ctx context.Context) (*http.Request, error) { + if ekgrl.NextLink == nil || len(to.String(ekgrl.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ekgrl.NextLink))) +} + +// EnterpriseKnowledgeGraphResponseListPage contains a page of EnterpriseKnowledgeGraph values. +type EnterpriseKnowledgeGraphResponseListPage struct { + fn func(context.Context, EnterpriseKnowledgeGraphResponseList) (EnterpriseKnowledgeGraphResponseList, error) + ekgrl EnterpriseKnowledgeGraphResponseList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *EnterpriseKnowledgeGraphResponseListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnterpriseKnowledgeGraphResponseListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ekgrl) + if err != nil { + return err + } + page.ekgrl = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *EnterpriseKnowledgeGraphResponseListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EnterpriseKnowledgeGraphResponseListPage) NotDone() bool { + return !page.ekgrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EnterpriseKnowledgeGraphResponseListPage) Response() EnterpriseKnowledgeGraphResponseList { + return page.ekgrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EnterpriseKnowledgeGraphResponseListPage) Values() []EnterpriseKnowledgeGraph { + if page.ekgrl.IsEmpty() { + return nil + } + return *page.ekgrl.Value +} + +// Creates a new instance of the EnterpriseKnowledgeGraphResponseListPage type. +func NewEnterpriseKnowledgeGraphResponseListPage(getNextPage func(context.Context, EnterpriseKnowledgeGraphResponseList) (EnterpriseKnowledgeGraphResponseList, error)) EnterpriseKnowledgeGraphResponseListPage { + return EnterpriseKnowledgeGraphResponseListPage{fn: getNextPage} +} + +// Error enterpriseKnowledgeGraph Service error object. +type Error struct { + // Error - The error body. + Error *ErrorBody `json:"error,omitempty"` +} + +// ErrorBody enterpriseKnowledgeGraph Service error body. +type ErrorBody struct { + // Code - error code + Code *string `json:"code,omitempty"` + // Message - error message + Message *string `json:"message,omitempty"` +} + +// OperationDisplayInfo the operation supported by EnterpriseKnowledgeGraph Service Management. +type OperationDisplayInfo struct { + // Description - The description of the operation. + Description *string `json:"description,omitempty"` + // Operation - The action that users can perform, based on their permission level. + Operation *string `json:"operation,omitempty"` + // Provider - Service provider: Microsoft EnterpriseKnowledgeGraph Service. + Provider *string `json:"provider,omitempty"` + // Resource - Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationEntity the operations supported by EnterpriseKnowledgeGraph Service Management. +type OperationEntity struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The operation supported by EnterpriseKnowledgeGraph Service Management. + Display *OperationDisplayInfo `json:"display,omitempty"` + // Origin - The origin of the operation. + Origin *string `json:"origin,omitempty"` + // Properties - Additional properties. + Properties interface{} `json:"properties,omitempty"` +} + +// OperationEntityListResult the list of EnterpriseKnowledgeGraph service operation response. +type OperationEntityListResult struct { + autorest.Response `json:"-"` + // NextLink - The link used to get the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + // Value - The list of operations. + Value *[]OperationEntity `json:"value,omitempty"` +} + +// OperationEntityListResultIterator provides access to a complete listing of OperationEntity values. +type OperationEntityListResultIterator struct { + i int + page OperationEntityListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationEntityListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationEntityListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationEntityListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationEntityListResultIterator) Response() OperationEntityListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationEntityListResultIterator) Value() OperationEntity { + if !iter.page.NotDone() { + return OperationEntity{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationEntityListResultIterator type. +func NewOperationEntityListResultIterator(page OperationEntityListResultPage) OperationEntityListResultIterator { + return OperationEntityListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (oelr OperationEntityListResult) IsEmpty() bool { + return oelr.Value == nil || len(*oelr.Value) == 0 +} + +// operationEntityListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (oelr OperationEntityListResult) operationEntityListResultPreparer(ctx context.Context) (*http.Request, error) { + if oelr.NextLink == nil || len(to.String(oelr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(oelr.NextLink))) +} + +// OperationEntityListResultPage contains a page of OperationEntity values. +type OperationEntityListResultPage struct { + fn func(context.Context, OperationEntityListResult) (OperationEntityListResult, error) + oelr OperationEntityListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationEntityListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationEntityListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.oelr) + if err != nil { + return err + } + page.oelr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationEntityListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationEntityListResultPage) NotDone() bool { + return !page.oelr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationEntityListResultPage) Response() OperationEntityListResult { + return page.oelr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationEntityListResultPage) Values() []OperationEntity { + if page.oelr.IsEmpty() { + return nil + } + return *page.oelr.Value +} + +// Creates a new instance of the OperationEntityListResultPage type. +func NewOperationEntityListResultPage(getNextPage func(context.Context, OperationEntityListResult) (OperationEntityListResult, error)) OperationEntityListResultPage { + return OperationEntityListResultPage{fn: getNextPage} +} + +// Resource azure resource +type Resource struct { + // ID - READ-ONLY; Specifies the resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Specifies the name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Specifies the type of the resource. + Type *string `json:"type,omitempty"` + // Location - Specifies the location of the resource. + Location *string `json:"location,omitempty"` + // Tags - Contains resource tags defined as key/value pairs. + Tags map[string]*string `json:"tags"` + // Sku - Gets or sets the SKU of the resource. + Sku *Sku `json:"sku,omitempty"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.Location != nil { + objectMap["location"] = r.Location + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + if r.Sku != nil { + objectMap["sku"] = r.Sku + } + return json.Marshal(objectMap) +} + +// Sku the SKU of the EnterpriseKnowledgeGraph service account. +type Sku struct { + // Name - The sku name. Possible values include: 'F0', 'S1' + Name SkuName `json:"name,omitempty"` +} diff --git a/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/operations.go b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/operations.go new file mode 100644 index 000000000000..210d66376466 --- /dev/null +++ b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/operations.go @@ -0,0 +1,148 @@ +package enterpriseknowledgegraphservice + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the azure Enterprise Knowledge Graph Service is a platform for creating knowledge graphs at +// scale. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all the available EnterpriseKnowledgeGraph services operations. +func (client OperationsClient) List(ctx context.Context) (result OperationEntityListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.oelr.Response.Response != nil { + sc = result.oelr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.oelr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.oelr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-12-03" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.EnterpriseKnowledgeGraph/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationEntityListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationEntityListResult) (result OperationEntityListResult, err error) { + req, err := lastResults.operationEntityListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "enterpriseknowledgegraphservice.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationEntityListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/version.go b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/version.go new file mode 100644 index 000000000000..dc3c0d68ed17 --- /dev/null +++ b/services/preview/enterpriseknowledgegraphservice/2018-12-03/enterpriseknowledgegraphservice/version.go @@ -0,0 +1,30 @@ +package enterpriseknowledgegraphservice + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " enterpriseknowledgegraphservice/2018-12-03" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}