From 8a0a1b2c4a239963a7d86f51bce39e75633c4d2c Mon Sep 17 00:00:00 2001 From: raychen Date: Mon, 29 Apr 2024 11:00:02 +0800 Subject: [PATCH 1/2] Change swagger to sdk config --- eng/swagger_to_sdk_config.json | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/eng/swagger_to_sdk_config.json b/eng/swagger_to_sdk_config.json index 3f394a4417af..68388fc8e894 100644 --- a/eng/swagger_to_sdk_config.json +++ b/eng/swagger_to_sdk_config.json @@ -4,9 +4,7 @@ "generateScript": { "path": "generator automation-v2", "stderr": { - "showInComment": "^\\[AUTOREST\\]", - "scriptError": "^\\[ERROR\\]", - "scriptWarning": "^\\[WARNING\\]" + "showInComment": "^[autorest]" } } }, @@ -16,10 +14,7 @@ }, "initOptions": { "initScript": { - "path": "sh ./eng/scripts/automation_init.sh", - "stderr": { - "scriptWarning": false - } + "path": "sh ./eng/scripts/automation_init.sh" } }, "packageOptions": { From d79c02844f7f9276ae0094e6b6cd13fda1009037 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 29 Apr 2024 22:52:27 +0000 Subject: [PATCH 2/2] CodeGen from PR 3329 in test-repo-billy/azure-rest-api-specs Merge 818e4345dffd53322d3b3590f234ee05fca38fbd into 81c88e4fbc4fde08d14f7f3825933706bd6205d6 --- .../agrifood/armagrifood/CHANGELOG.md | 109 ++ .../agrifood/armagrifood/README.md | 2 +- .../agrifood/armagrifood/autorest.md | 6 +- ...ent.go => checknameavailability_client.go} | 44 +- .../agrifood/armagrifood/client_factory.go | 98 +- .../agrifood/armagrifood/constants.go | 30 +- .../armagrifood/dataconnectors_client.go | 317 ++++ ...amanagerforagricultureextensions_client.go | 172 +++ ...tamanagerforagricultureresources_client.go | 442 ++++++ .../agrifood/armagrifood/extensions_client.go | 227 ++- .../extensions_client_example_test.go | 184 --- ...ver.go => checknameavailability_server.go} | 38 +- .../armagrifood/fake/dataconnectors_server.go | 274 ++++ ...managerforagricultureextensions_server.go} | 76 +- ...amanagerforagricultureresources_server.go} | 223 ++- .../armagrifood/fake/extensions_server.go | 140 +- .../fake/operationresults_server.go | 100 ++ .../fake/privateendpointconnections_server.go | 93 +- .../fake/privatelinkresources_server.go | 79 +- .../armagrifood/fake/server_factory.go | 84 +- .../armagrifood/fake/solutions_server.go | 368 +++++ .../fake/solutionsdiscoverability_server.go | 176 +++ .../agrifood/armagrifood/fake/time_rfc3339.go | 42 +- .../armagrifood/farmbeatsextensions_client.go | 171 --- ...farmbeatsextensions_client_example_test.go | 503 ------- .../armagrifood/farmbeatsmodels_client.go | 510 ------- .../farmbeatsmodels_client_example_test.go | 371 ----- .../agrifood/armagrifood/go.mod | 12 +- .../agrifood/armagrifood/go.sum | 19 - .../agrifood/armagrifood/interfaces.go | 18 + .../locations_client_example_test.go | 73 - .../agrifood/armagrifood/models.go | 560 +++++-- .../agrifood/armagrifood/models_serde.go | 1296 +++++++++++++---- .../armagrifood/operationresults_client.go | 108 ++ .../agrifood/armagrifood/operations_client.go | 4 +- .../operations_client_example_test.go | 126 -- .../agrifood/armagrifood/options.go | 191 ++- .../armagrifood/polymorphic_helpers.go | 34 + .../privateendpointconnections_client.go | 137 +- ...endpointconnections_client_example_test.go | 179 --- .../privatelinkresources_client.go | 85 +- ...rivatelinkresources_client_example_test.go | 90 -- .../agrifood/armagrifood/response_types.go | 139 -- .../agrifood/armagrifood/responses.go | 191 +++ .../agrifood/armagrifood/solutions_client.go | 357 +++++ .../solutionsdiscoverability_client.go | 162 +++ .../agrifood/armagrifood/time_rfc3339.go | 42 +- 47 files changed, 5101 insertions(+), 3601 deletions(-) rename sdk/resourcemanager/agrifood/armagrifood/{locations_client.go => checknameavailability_client.go} (54%) create mode 100644 sdk/resourcemanager/agrifood/armagrifood/dataconnectors_client.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureextensions_client.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureresources_client.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/extensions_client_example_test.go rename sdk/resourcemanager/agrifood/armagrifood/fake/{locations_server.go => checknameavailability_server.go} (55%) create mode 100644 sdk/resourcemanager/agrifood/armagrifood/fake/dataconnectors_server.go rename sdk/resourcemanager/agrifood/armagrifood/fake/{farmbeatsextensions_server.go => datamanagerforagricultureextensions_server.go} (58%) rename sdk/resourcemanager/agrifood/armagrifood/fake/{farmbeatsmodels_server.go => datamanagerforagricultureresources_server.go} (52%) create mode 100644 sdk/resourcemanager/agrifood/armagrifood/fake/operationresults_server.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/fake/solutions_server.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/fake/solutionsdiscoverability_server.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client_example_test.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client_example_test.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/interfaces.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/locations_client_example_test.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/operationresults_client.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/operations_client_example_test.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/polymorphic_helpers.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client_example_test.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client_example_test.go delete mode 100644 sdk/resourcemanager/agrifood/armagrifood/response_types.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/responses.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/solutions_client.go create mode 100644 sdk/resourcemanager/agrifood/armagrifood/solutionsdiscoverability_client.go diff --git a/sdk/resourcemanager/agrifood/armagrifood/CHANGELOG.md b/sdk/resourcemanager/agrifood/armagrifood/CHANGELOG.md index b8bc7bfa932b..436bfecf61f4 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/CHANGELOG.md +++ b/sdk/resourcemanager/agrifood/armagrifood/CHANGELOG.md @@ -1,5 +1,114 @@ # Release History +## 0.10.0 (2024-04-29) +### Breaking Changes + +- `PublicNetworkAccessHybrid` from enum `PublicNetworkAccess` has been removed +- Function `*ClientFactory.NewFarmBeatsExtensionsClient` has been removed +- Function `*ClientFactory.NewFarmBeatsModelsClient` has been removed +- Function `*ClientFactory.NewLocationsClient` has been removed +- Function `*ExtensionsClient.Create` has been removed +- Function `*ExtensionsClient.NewListByFarmBeatsPager` has been removed +- Function `*ExtensionsClient.Update` has been removed +- Function `NewFarmBeatsExtensionsClient` has been removed +- Function `*FarmBeatsExtensionsClient.Get` has been removed +- Function `*FarmBeatsExtensionsClient.NewListPager` has been removed +- Function `NewFarmBeatsModelsClient` has been removed +- Function `*FarmBeatsModelsClient.CreateOrUpdate` has been removed +- Function `*FarmBeatsModelsClient.Delete` has been removed +- Function `*FarmBeatsModelsClient.Get` has been removed +- Function `*FarmBeatsModelsClient.GetOperationResult` has been removed +- Function `*FarmBeatsModelsClient.NewListByResourceGroupPager` has been removed +- Function `*FarmBeatsModelsClient.NewListBySubscriptionPager` has been removed +- Function `*FarmBeatsModelsClient.BeginUpdate` has been removed +- Function `NewLocationsClient` has been removed +- Function `*LocationsClient.CheckNameAvailability` has been removed +- Operation `*PrivateEndpointConnectionsClient.NewListByResourcePager` does not support pagination anymore, use `*PrivateEndpointConnectionsClient.ListByResource` instead. +- Operation `*PrivateLinkResourcesClient.NewListByResourcePager` does not support pagination anymore, use `*PrivateLinkResourcesClient.ListByResource` instead. +- Struct `FarmBeats` has been removed +- Struct `FarmBeatsExtension` has been removed +- Struct `FarmBeatsExtensionListResponse` has been removed +- Struct `FarmBeatsExtensionProperties` has been removed +- Struct `FarmBeatsListResponse` has been removed +- Struct `FarmBeatsProperties` has been removed +- Struct `FarmBeatsUpdateProperties` has been removed +- Struct `FarmBeatsUpdateRequestModel` has been removed + +### Features Added + +- New value `ProvisioningStateRunning` added to enum type `ProvisioningState` +- New value `PublicNetworkAccessDisabled` added to enum type `PublicNetworkAccess` +- New enum type `AuthCredentialsKind` with values `AuthCredentialsKindAPIKeyAuthCredentials`, `AuthCredentialsKindOAuthClientCredentials` +- New function `*APIKeyAuthCredentials.GetAuthCredentials() *AuthCredentials` +- New function `*AuthCredentials.GetAuthCredentials() *AuthCredentials` +- New function `NewCheckNameAvailabilityClient(string, azcore.TokenCredential, *arm.ClientOptions) (*CheckNameAvailabilityClient, error)` +- New function `*CheckNameAvailabilityClient.CheckNameAvailability(context.Context, CheckNameAvailabilityRequest, *CheckNameAvailabilityClientCheckNameAvailabilityOptions) (CheckNameAvailabilityClientCheckNameAvailabilityResponse, error)` +- New function `*ClientFactory.NewCheckNameAvailabilityClient() *CheckNameAvailabilityClient` +- New function `*ClientFactory.NewDataConnectorsClient() *DataConnectorsClient` +- New function `*ClientFactory.NewDataManagerForAgricultureExtensionsClient() *DataManagerForAgricultureExtensionsClient` +- New function `*ClientFactory.NewDataManagerForAgricultureResourcesClient() *DataManagerForAgricultureResourcesClient` +- New function `*ClientFactory.NewOperationResultsClient() *OperationResultsClient` +- New function `*ClientFactory.NewSolutionsClient() *SolutionsClient` +- New function `*ClientFactory.NewSolutionsDiscoverabilityClient() *SolutionsDiscoverabilityClient` +- New function `NewDataConnectorsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DataConnectorsClient, error)` +- New function `*DataConnectorsClient.CreateOrUpdate(context.Context, string, string, string, DataConnector, *DataConnectorsClientCreateOrUpdateOptions) (DataConnectorsClientCreateOrUpdateResponse, error)` +- New function `*DataConnectorsClient.Delete(context.Context, string, string, string, *DataConnectorsClientDeleteOptions) (DataConnectorsClientDeleteResponse, error)` +- New function `*DataConnectorsClient.Get(context.Context, string, string, string, *DataConnectorsClientGetOptions) (DataConnectorsClientGetResponse, error)` +- New function `*DataConnectorsClient.NewListPager(string, string, *DataConnectorsClientListOptions) *runtime.Pager[DataConnectorsClientListResponse]` +- New function `NewDataManagerForAgricultureExtensionsClient(azcore.TokenCredential, *arm.ClientOptions) (*DataManagerForAgricultureExtensionsClient, error)` +- New function `*DataManagerForAgricultureExtensionsClient.Get(context.Context, string, *DataManagerForAgricultureExtensionsClientGetOptions) (DataManagerForAgricultureExtensionsClientGetResponse, error)` +- New function `*DataManagerForAgricultureExtensionsClient.NewListPager(*DataManagerForAgricultureExtensionsClientListOptions) *runtime.Pager[DataManagerForAgricultureExtensionsClientListResponse]` +- New function `NewDataManagerForAgricultureResourcesClient(string, azcore.TokenCredential, *arm.ClientOptions) (*DataManagerForAgricultureResourcesClient, error)` +- New function `*DataManagerForAgricultureResourcesClient.CreateOrUpdate(context.Context, string, string, DataManagerForAgriculture, *DataManagerForAgricultureResourcesClientCreateOrUpdateOptions) (DataManagerForAgricultureResourcesClientCreateOrUpdateResponse, error)` +- New function `*DataManagerForAgricultureResourcesClient.Delete(context.Context, string, string, *DataManagerForAgricultureResourcesClientDeleteOptions) (DataManagerForAgricultureResourcesClientDeleteResponse, error)` +- New function `*DataManagerForAgricultureResourcesClient.Get(context.Context, string, string, *DataManagerForAgricultureResourcesClientGetOptions) (DataManagerForAgricultureResourcesClientGetResponse, error)` +- New function `*DataManagerForAgricultureResourcesClient.NewListByResourceGroupPager(string, *DataManagerForAgricultureResourcesClientListByResourceGroupOptions) *runtime.Pager[DataManagerForAgricultureResourcesClientListByResourceGroupResponse]` +- New function `*DataManagerForAgricultureResourcesClient.NewListBySubscriptionPager(*DataManagerForAgricultureResourcesClientListBySubscriptionOptions) *runtime.Pager[DataManagerForAgricultureResourcesClientListBySubscriptionResponse]` +- New function `*DataManagerForAgricultureResourcesClient.BeginUpdate(context.Context, string, string, DataManagerForAgricultureUpdateRequestModel, *DataManagerForAgricultureResourcesClientBeginUpdateOptions) (*runtime.Poller[DataManagerForAgricultureResourcesClientUpdateResponse], error)` +- New function `*ExtensionsClient.CreateOrUpdate(context.Context, string, string, string, *ExtensionsClientCreateOrUpdateOptions) (ExtensionsClientCreateOrUpdateResponse, error)` +- New function `*ExtensionsClient.NewListByDataManagerForAgriculturePager(string, string, *ExtensionsClientListByDataManagerForAgricultureOptions) *runtime.Pager[ExtensionsClientListByDataManagerForAgricultureResponse]` +- New function `*OAuthClientCredentials.GetAuthCredentials() *AuthCredentials` +- New function `NewOperationResultsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*OperationResultsClient, error)` +- New function `*OperationResultsClient.Get(context.Context, string, string, *OperationResultsClientGetOptions) (OperationResultsClientGetResponse, error)` +- New function `NewSolutionsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*SolutionsClient, error)` +- New function `*SolutionsClient.CreateOrUpdate(context.Context, string, string, string, *SolutionsClientCreateOrUpdateOptions) (SolutionsClientCreateOrUpdateResponse, error)` +- New function `*SolutionsClient.Delete(context.Context, string, string, string, *SolutionsClientDeleteOptions) (SolutionsClientDeleteResponse, error)` +- New function `*SolutionsClient.Get(context.Context, string, string, string, *SolutionsClientGetOptions) (SolutionsClientGetResponse, error)` +- New function `*SolutionsClient.NewListPager(string, string, *SolutionsClientListOptions) *runtime.Pager[SolutionsClientListResponse]` +- New function `NewSolutionsDiscoverabilityClient(azcore.TokenCredential, *arm.ClientOptions) (*SolutionsDiscoverabilityClient, error)` +- New function `*SolutionsDiscoverabilityClient.Get(context.Context, string, *SolutionsDiscoverabilityClientGetOptions) (SolutionsDiscoverabilityClientGetResponse, error)` +- New function `*SolutionsDiscoverabilityClient.NewListPager(*SolutionsDiscoverabilityClientListOptions) *runtime.Pager[SolutionsDiscoverabilityClientListResponse]` +- New struct `APIKeyAuthCredentials` +- New struct `APIProperties` +- New struct `ArmAsyncOperationError` +- New struct `DataConnector` +- New struct `DataConnectorListResponse` +- New struct `DataConnectorProperties` +- New struct `DataManagerForAgriculture` +- New struct `DataManagerForAgricultureExtension` +- New struct `DataManagerForAgricultureExtensionListResponse` +- New struct `DataManagerForAgricultureExtensionProperties` +- New struct `DataManagerForAgricultureListResponse` +- New struct `DataManagerForAgricultureProperties` +- New struct `DataManagerForAgricultureSolution` +- New struct `DataManagerForAgricultureSolutionListResponse` +- New struct `DataManagerForAgricultureSolutionProperties` +- New struct `DataManagerForAgricultureUpdateProperties` +- New struct `DataManagerForAgricultureUpdateRequestModel` +- New struct `ExtensionInstallationRequest` +- New struct `KeyVaultProperties` +- New struct `MarketplaceOfferDetails` +- New struct `OAuthClientCredentials` +- New struct `Solution` +- New struct `SolutionListResponse` +- New struct `SolutionProperties` +- New field `Error` in struct `ArmAsyncOperation` +- New field `APIDefaultInputParameters`, `APIDocsLink`, `APIType` in struct `DetailedInformation` +- New field `SkipToken` in struct `ExtensionListResponse` +- New field `AdditionalAPIProperties` in struct `ExtensionProperties` +- New field `GroupIDs` in struct `PrivateEndpointConnectionProperties` + + ## 0.9.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/agrifood/armagrifood/README.md b/sdk/resourcemanager/agrifood/armagrifood/README.md index 704d32e461b2..622129b6e528 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/README.md +++ b/sdk/resourcemanager/agrifood/armagrifood/README.md @@ -57,7 +57,7 @@ clientFactory, err := armagrifood.NewClientFactory(, cred, &opt A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewExtensionsClient() +client := clientFactory.NewCheckNameAvailabilityClient() ``` ## Fakes diff --git a/sdk/resourcemanager/agrifood/armagrifood/autorest.md b/sdk/resourcemanager/agrifood/armagrifood/autorest.md index e3b6d344b55c..4f009714f94e 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/autorest.md +++ b/sdk/resourcemanager/agrifood/armagrifood/autorest.md @@ -5,8 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/agrifood/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/agrifood/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.9.0 +module-version: 0.10.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/agrifood/armagrifood/locations_client.go b/sdk/resourcemanager/agrifood/armagrifood/checknameavailability_client.go similarity index 54% rename from sdk/resourcemanager/agrifood/armagrifood/locations_client.go rename to sdk/resourcemanager/agrifood/armagrifood/checknameavailability_client.go index 004e24b4e0e2..b05dbecf960a 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/locations_client.go +++ b/sdk/resourcemanager/agrifood/armagrifood/checknameavailability_client.go @@ -20,23 +20,23 @@ import ( "strings" ) -// LocationsClient contains the methods for the Locations group. -// Don't use this type directly, use NewLocationsClient() instead. -type LocationsClient struct { +// CheckNameAvailabilityClient contains the methods for the CheckNameAvailability group. +// Don't use this type directly, use NewCheckNameAvailabilityClient() instead. +type CheckNameAvailabilityClient struct { internal *arm.Client subscriptionID string } -// NewLocationsClient creates a new instance of LocationsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// NewCheckNameAvailabilityClient creates a new instance of CheckNameAvailabilityClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. -func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationsClient, error) { +func NewCheckNameAvailabilityClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CheckNameAvailabilityClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } - client := &LocationsClient{ + client := &CheckNameAvailabilityClient{ subscriptionID: subscriptionID, internal: cl, } @@ -46,34 +46,34 @@ func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential // CheckNameAvailability - Checks the name availability of the resource with requested resource name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview -// - body - NameAvailabilityRequest object. -// - options - LocationsClientCheckNameAvailabilityOptions contains the optional parameters for the LocationsClient.CheckNameAvailability +// Generated from API version 2023-06-01-preview +// - nameAvailabilityRequest - NameAvailabilityRequest object. +// - options - CheckNameAvailabilityClientCheckNameAvailabilityOptions contains the optional parameters for the CheckNameAvailabilityClient.CheckNameAvailability // method. -func (client *LocationsClient) CheckNameAvailability(ctx context.Context, body CheckNameAvailabilityRequest, options *LocationsClientCheckNameAvailabilityOptions) (LocationsClientCheckNameAvailabilityResponse, error) { +func (client *CheckNameAvailabilityClient) CheckNameAvailability(ctx context.Context, nameAvailabilityRequest CheckNameAvailabilityRequest, options *CheckNameAvailabilityClientCheckNameAvailabilityOptions) (CheckNameAvailabilityClientCheckNameAvailabilityResponse, error) { var err error - const operationName = "LocationsClient.CheckNameAvailability" + const operationName = "CheckNameAvailabilityClient.CheckNameAvailability" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.checkNameAvailabilityCreateRequest(ctx, body, options) + req, err := client.checkNameAvailabilityCreateRequest(ctx, nameAvailabilityRequest, options) if err != nil { - return LocationsClientCheckNameAvailabilityResponse{}, err + return CheckNameAvailabilityClientCheckNameAvailabilityResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return LocationsClientCheckNameAvailabilityResponse{}, err + return CheckNameAvailabilityClientCheckNameAvailabilityResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusOK) { err = runtime.NewResponseError(httpResp) - return LocationsClientCheckNameAvailabilityResponse{}, err + return CheckNameAvailabilityClientCheckNameAvailabilityResponse{}, err } resp, err := client.checkNameAvailabilityHandleResponse(httpResp) return resp, err } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. -func (client *LocationsClient) checkNameAvailabilityCreateRequest(ctx context.Context, body CheckNameAvailabilityRequest, options *LocationsClientCheckNameAvailabilityOptions) (*policy.Request, error) { +func (client *CheckNameAvailabilityClient) checkNameAvailabilityCreateRequest(ctx context.Context, nameAvailabilityRequest CheckNameAvailabilityRequest, options *CheckNameAvailabilityClientCheckNameAvailabilityOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/checkNameAvailability" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -84,20 +84,20 @@ func (client *LocationsClient) checkNameAvailabilityCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, nameAvailabilityRequest); err != nil { return nil, err } return req, nil } // checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. -func (client *LocationsClient) checkNameAvailabilityHandleResponse(resp *http.Response) (LocationsClientCheckNameAvailabilityResponse, error) { - result := LocationsClientCheckNameAvailabilityResponse{} +func (client *CheckNameAvailabilityClient) checkNameAvailabilityHandleResponse(resp *http.Response) (CheckNameAvailabilityClientCheckNameAvailabilityResponse, error) { + result := CheckNameAvailabilityClientCheckNameAvailabilityResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { - return LocationsClientCheckNameAvailabilityResponse{}, err + return CheckNameAvailabilityClientCheckNameAvailabilityResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/agrifood/armagrifood/client_factory.go b/sdk/resourcemanager/agrifood/armagrifood/client_factory.go index 0500b2ead7d5..d9edda862441 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/client_factory.go +++ b/sdk/resourcemanager/agrifood/armagrifood/client_factory.go @@ -17,64 +17,106 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } -// NewExtensionsClient creates a new instance of ExtensionsClient. -func (c *ClientFactory) NewExtensionsClient() *ExtensionsClient { - subClient, _ := NewExtensionsClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewCheckNameAvailabilityClient creates a new instance of CheckNameAvailabilityClient. +func (c *ClientFactory) NewCheckNameAvailabilityClient() *CheckNameAvailabilityClient { + return &CheckNameAvailabilityClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewDataConnectorsClient creates a new instance of DataConnectorsClient. +func (c *ClientFactory) NewDataConnectorsClient() *DataConnectorsClient { + return &DataConnectorsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } -// NewFarmBeatsExtensionsClient creates a new instance of FarmBeatsExtensionsClient. -func (c *ClientFactory) NewFarmBeatsExtensionsClient() *FarmBeatsExtensionsClient { - subClient, _ := NewFarmBeatsExtensionsClient(c.credential, c.options) - return subClient +// NewDataManagerForAgricultureExtensionsClient creates a new instance of DataManagerForAgricultureExtensionsClient. +func (c *ClientFactory) NewDataManagerForAgricultureExtensionsClient() *DataManagerForAgricultureExtensionsClient { + return &DataManagerForAgricultureExtensionsClient{ + internal: c.internal, + } } -// NewFarmBeatsModelsClient creates a new instance of FarmBeatsModelsClient. -func (c *ClientFactory) NewFarmBeatsModelsClient() *FarmBeatsModelsClient { - subClient, _ := NewFarmBeatsModelsClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewDataManagerForAgricultureResourcesClient creates a new instance of DataManagerForAgricultureResourcesClient. +func (c *ClientFactory) NewDataManagerForAgricultureResourcesClient() *DataManagerForAgricultureResourcesClient { + return &DataManagerForAgricultureResourcesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } -// NewLocationsClient creates a new instance of LocationsClient. -func (c *ClientFactory) NewLocationsClient() *LocationsClient { - subClient, _ := NewLocationsClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewExtensionsClient creates a new instance of ExtensionsClient. +func (c *ClientFactory) NewExtensionsClient() *ExtensionsClient { + return &ExtensionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationResultsClient creates a new instance of OperationResultsClient. +func (c *ClientFactory) NewOperationResultsClient() *OperationResultsClient { + return &OperationResultsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { - subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateEndpointConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { - subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PrivateLinkResourcesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewSolutionsClient creates a new instance of SolutionsClient. +func (c *ClientFactory) NewSolutionsClient() *SolutionsClient { + return &SolutionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewSolutionsDiscoverabilityClient creates a new instance of SolutionsDiscoverabilityClient. +func (c *ClientFactory) NewSolutionsDiscoverabilityClient() *SolutionsDiscoverabilityClient { + return &SolutionsDiscoverabilityClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/agrifood/armagrifood/constants.go b/sdk/resourcemanager/agrifood/armagrifood/constants.go index 7a8e2d283c0a..f135a5f45bc4 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/constants.go +++ b/sdk/resourcemanager/agrifood/armagrifood/constants.go @@ -10,7 +10,7 @@ package armagrifood const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" - moduleVersion = "v0.9.0" + moduleVersion = "v0.10.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -27,6 +27,22 @@ func PossibleActionTypeValues() []ActionType { } } +// AuthCredentialsKind - Enum for different types of AuthCredentials supported. +type AuthCredentialsKind string + +const ( + AuthCredentialsKindAPIKeyAuthCredentials AuthCredentialsKind = "ApiKeyAuthCredentials" + AuthCredentialsKindOAuthClientCredentials AuthCredentialsKind = "OAuthClientCredentials" +) + +// PossibleAuthCredentialsKindValues returns the possible values for the AuthCredentialsKind const type. +func PossibleAuthCredentialsKindValues() []AuthCredentialsKind { + return []AuthCredentialsKind{ + AuthCredentialsKindAPIKeyAuthCredentials, + AuthCredentialsKindOAuthClientCredentials, + } +} + // CheckNameAvailabilityReason - The reason why the given name is not available. type CheckNameAvailabilityReason string @@ -120,13 +136,14 @@ func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointSer } } -// ProvisioningState - Sensor integration instance provisioning state. +// ProvisioningState - Data Manager For Agriculture instance provisioning state. type ProvisioningState string const ( ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateRunning ProvisioningState = "Running" ProvisioningStateSucceeded ProvisioningState = "Succeeded" ProvisioningStateUpdating ProvisioningState = "Updating" ) @@ -137,23 +154,24 @@ func PossibleProvisioningStateValues() []ProvisioningState { ProvisioningStateCreating, ProvisioningStateDeleting, ProvisioningStateFailed, + ProvisioningStateRunning, ProvisioningStateSucceeded, ProvisioningStateUpdating, } } -// PublicNetworkAccess - Property to allow or block public traffic for an Azure FarmBeats resource. +// PublicNetworkAccess - Property to allow or block public traffic for an Azure Data Manager For Agriculture resource. type PublicNetworkAccess string const ( - PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" - PublicNetworkAccessHybrid PublicNetworkAccess = "Hybrid" + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" ) // PossiblePublicNetworkAccessValues returns the possible values for the PublicNetworkAccess const type. func PossiblePublicNetworkAccessValues() []PublicNetworkAccess { return []PublicNetworkAccess{ + PublicNetworkAccessDisabled, PublicNetworkAccessEnabled, - PublicNetworkAccessHybrid, } } diff --git a/sdk/resourcemanager/agrifood/armagrifood/dataconnectors_client.go b/sdk/resourcemanager/agrifood/armagrifood/dataconnectors_client.go new file mode 100644 index 000000000000..501d612749c7 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/dataconnectors_client.go @@ -0,0 +1,317 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DataConnectorsClient contains the methods for the DataConnectors group. +// Don't use this type directly, use NewDataConnectorsClient() instead. +type DataConnectorsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDataConnectorsClient creates a new instance of DataConnectorsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDataConnectorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataConnectorsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DataConnectorsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create or update Data Connector For MADMA resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - dataConnectorName - Connector name. +// - body - Body must be valid DataConnector request. +// - options - DataConnectorsClientCreateOrUpdateOptions contains the optional parameters for the DataConnectorsClient.CreateOrUpdate +// method. +func (client *DataConnectorsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, body DataConnector, options *DataConnectorsClientCreateOrUpdateOptions) (DataConnectorsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "DataConnectorsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, dataConnectorName, body, options) + if err != nil { + return DataConnectorsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataConnectorsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DataConnectorsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DataConnectorsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, body DataConnector, options *DataConnectorsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/dataConnectors/{dataConnectorName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + if dataConnectorName == "" { + return nil, errors.New("parameter dataConnectorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataConnectorName}", url.PathEscape(dataConnectorName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DataConnectorsClient) createOrUpdateHandleResponse(resp *http.Response) (DataConnectorsClientCreateOrUpdateResponse, error) { + result := DataConnectorsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataConnector); err != nil { + return DataConnectorsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a Data Connectors with given dataConnector name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - dataConnectorName - Connector name. +// - options - DataConnectorsClientDeleteOptions contains the optional parameters for the DataConnectorsClient.Delete method. +func (client *DataConnectorsClient) Delete(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, options *DataConnectorsClientDeleteOptions) (DataConnectorsClientDeleteResponse, error) { + var err error + const operationName = "DataConnectorsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, dataConnectorName, options) + if err != nil { + return DataConnectorsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataConnectorsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DataConnectorsClientDeleteResponse{}, err + } + return DataConnectorsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataConnectorsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, options *DataConnectorsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/dataConnectors/{dataConnectorName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + if dataConnectorName == "" { + return nil, errors.New("parameter dataConnectorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataConnectorName}", url.PathEscape(dataConnectorName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get specific Data Connector resource by DataConnectorName. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - dataConnectorName - Connector name. +// - options - DataConnectorsClientGetOptions contains the optional parameters for the DataConnectorsClient.Get method. +func (client *DataConnectorsClient) Get(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, options *DataConnectorsClientGetOptions) (DataConnectorsClientGetResponse, error) { + var err error + const operationName = "DataConnectorsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, dataConnectorName, options) + if err != nil { + return DataConnectorsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataConnectorsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataConnectorsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DataConnectorsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, options *DataConnectorsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/dataConnectors/{dataConnectorName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + if dataConnectorName == "" { + return nil, errors.New("parameter dataConnectorName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataConnectorName}", url.PathEscape(dataConnectorName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataConnectorsClient) getHandleResponse(resp *http.Response) (DataConnectorsClientGetResponse, error) { + result := DataConnectorsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataConnector); err != nil { + return DataConnectorsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists the Data Connector Credentials for MADMA instance. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - options - DataConnectorsClientListOptions contains the optional parameters for the DataConnectorsClient.NewListPager method. +func (client *DataConnectorsClient) NewListPager(resourceGroupName string, dataManagerForAgricultureResourceName string, options *DataConnectorsClientListOptions) *runtime.Pager[DataConnectorsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DataConnectorsClientListResponse]{ + More: func(page DataConnectorsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataConnectorsClientListResponse) (DataConnectorsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataConnectorsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, options) + }, nil) + if err != nil { + return DataConnectorsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *DataConnectorsClient) listCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *DataConnectorsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/dataConnectors" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.MaxPageSize != nil { + reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DataConnectorsClient) listHandleResponse(resp *http.Response) (DataConnectorsClientListResponse, error) { + result := DataConnectorsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataConnectorListResponse); err != nil { + return DataConnectorsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureextensions_client.go b/sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureextensions_client.go new file mode 100644 index 000000000000..9acbc239ef29 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureextensions_client.go @@ -0,0 +1,172 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DataManagerForAgricultureExtensionsClient contains the methods for the DataManagerForAgricultureExtensions group. +// Don't use this type directly, use NewDataManagerForAgricultureExtensionsClient() instead. +type DataManagerForAgricultureExtensionsClient struct { + internal *arm.Client +} + +// NewDataManagerForAgricultureExtensionsClient creates a new instance of DataManagerForAgricultureExtensionsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDataManagerForAgricultureExtensionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DataManagerForAgricultureExtensionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DataManagerForAgricultureExtensionsClient{ + internal: cl, + } + return client, nil +} + +// Get - Get Data Manager For Agriculture extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - dataManagerForAgricultureExtensionID - dataManagerForAgricultureExtensionId to be queried. +// - options - DataManagerForAgricultureExtensionsClientGetOptions contains the optional parameters for the DataManagerForAgricultureExtensionsClient.Get +// method. +func (client *DataManagerForAgricultureExtensionsClient) Get(ctx context.Context, dataManagerForAgricultureExtensionID string, options *DataManagerForAgricultureExtensionsClientGetOptions) (DataManagerForAgricultureExtensionsClientGetResponse, error) { + var err error + const operationName = "DataManagerForAgricultureExtensionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, dataManagerForAgricultureExtensionID, options) + if err != nil { + return DataManagerForAgricultureExtensionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataManagerForAgricultureExtensionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataManagerForAgricultureExtensionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DataManagerForAgricultureExtensionsClient) getCreateRequest(ctx context.Context, dataManagerForAgricultureExtensionID string, options *DataManagerForAgricultureExtensionsClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions/{dataManagerForAgricultureExtensionId}" + if dataManagerForAgricultureExtensionID == "" { + return nil, errors.New("parameter dataManagerForAgricultureExtensionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureExtensionId}", url.PathEscape(dataManagerForAgricultureExtensionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataManagerForAgricultureExtensionsClient) getHandleResponse(resp *http.Response) (DataManagerForAgricultureExtensionsClientGetResponse, error) { + result := DataManagerForAgricultureExtensionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgricultureExtension); err != nil { + return DataManagerForAgricultureExtensionsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get list of Data Manager For Agriculture extension. +// +// Generated from API version 2023-06-01-preview +// - options - DataManagerForAgricultureExtensionsClientListOptions contains the optional parameters for the DataManagerForAgricultureExtensionsClient.NewListPager +// method. +func (client *DataManagerForAgricultureExtensionsClient) NewListPager(options *DataManagerForAgricultureExtensionsClientListOptions) *runtime.Pager[DataManagerForAgricultureExtensionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DataManagerForAgricultureExtensionsClientListResponse]{ + More: func(page DataManagerForAgricultureExtensionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataManagerForAgricultureExtensionsClientListResponse) (DataManagerForAgricultureExtensionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataManagerForAgricultureExtensionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return DataManagerForAgricultureExtensionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *DataManagerForAgricultureExtensionsClient) listCreateRequest(ctx context.Context, options *DataManagerForAgricultureExtensionsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.MaxPageSize != nil { + reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) + } + reqQP.Set("api-version", "2023-06-01-preview") + if options != nil && options.ExtensionCategories != nil { + for _, qv := range options.ExtensionCategories { + reqQP.Add("extensionCategories", qv) + } + } + if options != nil && options.FarmBeatsExtensionIDs != nil { + for _, qv := range options.FarmBeatsExtensionIDs { + reqQP.Add("farmBeatsExtensionIds", qv) + } + } + if options != nil && options.FarmBeatsExtensionNames != nil { + for _, qv := range options.FarmBeatsExtensionNames { + reqQP.Add("farmBeatsExtensionNames", qv) + } + } + if options != nil && options.PublisherIDs != nil { + for _, qv := range options.PublisherIDs { + reqQP.Add("publisherIds", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DataManagerForAgricultureExtensionsClient) listHandleResponse(resp *http.Response) (DataManagerForAgricultureExtensionsClientListResponse, error) { + result := DataManagerForAgricultureExtensionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgricultureExtensionListResponse); err != nil { + return DataManagerForAgricultureExtensionsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureresources_client.go b/sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureresources_client.go new file mode 100644 index 000000000000..8a62d41580e9 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/datamanagerforagricultureresources_client.go @@ -0,0 +1,442 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DataManagerForAgricultureResourcesClient contains the methods for the DataManagerForAgricultureResources group. +// Don't use this type directly, use NewDataManagerForAgricultureResourcesClient() instead. +type DataManagerForAgricultureResourcesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDataManagerForAgricultureResourcesClient creates a new instance of DataManagerForAgricultureResourcesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDataManagerForAgricultureResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataManagerForAgricultureResourcesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DataManagerForAgricultureResourcesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create or update Data Manager For Agriculture resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - request - Data Manager For Agriculture resource create or update request object. +// - options - DataManagerForAgricultureResourcesClientCreateOrUpdateOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.CreateOrUpdate +// method. +func (client *DataManagerForAgricultureResourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, request DataManagerForAgriculture, options *DataManagerForAgricultureResourcesClientCreateOrUpdateOptions) (DataManagerForAgricultureResourcesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "DataManagerForAgricultureResourcesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, request, options) + if err != nil { + return DataManagerForAgricultureResourcesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataManagerForAgricultureResourcesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DataManagerForAgricultureResourcesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DataManagerForAgricultureResourcesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, request DataManagerForAgriculture, options *DataManagerForAgricultureResourcesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, request); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DataManagerForAgricultureResourcesClient) createOrUpdateHandleResponse(resp *http.Response) (DataManagerForAgricultureResourcesClientCreateOrUpdateResponse, error) { + result := DataManagerForAgricultureResourcesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgriculture); err != nil { + return DataManagerForAgricultureResourcesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a Data Manager For Agriculture resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - options - DataManagerForAgricultureResourcesClientDeleteOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.Delete +// method. +func (client *DataManagerForAgricultureResourcesClient) Delete(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *DataManagerForAgricultureResourcesClientDeleteOptions) (DataManagerForAgricultureResourcesClientDeleteResponse, error) { + var err error + const operationName = "DataManagerForAgricultureResourcesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, options) + if err != nil { + return DataManagerForAgricultureResourcesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataManagerForAgricultureResourcesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DataManagerForAgricultureResourcesClientDeleteResponse{}, err + } + return DataManagerForAgricultureResourcesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataManagerForAgricultureResourcesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *DataManagerForAgricultureResourcesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get DataManagerForAgriculture resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - options - DataManagerForAgricultureResourcesClientGetOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.Get +// method. +func (client *DataManagerForAgricultureResourcesClient) Get(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *DataManagerForAgricultureResourcesClientGetOptions) (DataManagerForAgricultureResourcesClientGetResponse, error) { + var err error + const operationName = "DataManagerForAgricultureResourcesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, options) + if err != nil { + return DataManagerForAgricultureResourcesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataManagerForAgricultureResourcesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataManagerForAgricultureResourcesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DataManagerForAgricultureResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *DataManagerForAgricultureResourcesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataManagerForAgricultureResourcesClient) getHandleResponse(resp *http.Response) (DataManagerForAgricultureResourcesClientGetResponse, error) { + result := DataManagerForAgricultureResourcesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgriculture); err != nil { + return DataManagerForAgricultureResourcesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists the DataManagerForAgriculture instances for a resource group. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DataManagerForAgricultureResourcesClientListByResourceGroupOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.NewListByResourceGroupPager +// method. +func (client *DataManagerForAgricultureResourcesClient) NewListByResourceGroupPager(resourceGroupName string, options *DataManagerForAgricultureResourcesClientListByResourceGroupOptions) *runtime.Pager[DataManagerForAgricultureResourcesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DataManagerForAgricultureResourcesClientListByResourceGroupResponse]{ + More: func(page DataManagerForAgricultureResourcesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataManagerForAgricultureResourcesClientListByResourceGroupResponse) (DataManagerForAgricultureResourcesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataManagerForAgricultureResourcesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return DataManagerForAgricultureResourcesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DataManagerForAgricultureResourcesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DataManagerForAgricultureResourcesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.MaxPageSize != nil { + reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DataManagerForAgricultureResourcesClient) listByResourceGroupHandleResponse(resp *http.Response) (DataManagerForAgricultureResourcesClientListByResourceGroupResponse, error) { + result := DataManagerForAgricultureResourcesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgricultureListResponse); err != nil { + return DataManagerForAgricultureResourcesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists the DataManagerForAgriculture instances for a subscription. +// +// Generated from API version 2023-06-01-preview +// - options - DataManagerForAgricultureResourcesClientListBySubscriptionOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.NewListBySubscriptionPager +// method. +func (client *DataManagerForAgricultureResourcesClient) NewListBySubscriptionPager(options *DataManagerForAgricultureResourcesClientListBySubscriptionOptions) *runtime.Pager[DataManagerForAgricultureResourcesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[DataManagerForAgricultureResourcesClientListBySubscriptionResponse]{ + More: func(page DataManagerForAgricultureResourcesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataManagerForAgricultureResourcesClientListBySubscriptionResponse) (DataManagerForAgricultureResourcesClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataManagerForAgricultureResourcesClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return DataManagerForAgricultureResourcesClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DataManagerForAgricultureResourcesClient) listBySubscriptionCreateRequest(ctx context.Context, options *DataManagerForAgricultureResourcesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/farmBeats" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.MaxPageSize != nil { + reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DataManagerForAgricultureResourcesClient) listBySubscriptionHandleResponse(resp *http.Response) (DataManagerForAgricultureResourcesClientListBySubscriptionResponse, error) { + result := DataManagerForAgricultureResourcesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgricultureListResponse); err != nil { + return DataManagerForAgricultureResourcesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update a Data Manager For Agriculture resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - request - Request object. +// - options - DataManagerForAgricultureResourcesClientBeginUpdateOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.BeginUpdate +// method. +func (client *DataManagerForAgricultureResourcesClient) BeginUpdate(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, request DataManagerForAgricultureUpdateRequestModel, options *DataManagerForAgricultureResourcesClientBeginUpdateOptions) (*runtime.Poller[DataManagerForAgricultureResourcesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, dataManagerForAgricultureResourceName, request, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataManagerForAgricultureResourcesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataManagerForAgricultureResourcesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update a Data Manager For Agriculture resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +func (client *DataManagerForAgricultureResourcesClient) update(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, request DataManagerForAgricultureUpdateRequestModel, options *DataManagerForAgricultureResourcesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "DataManagerForAgricultureResourcesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, request, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DataManagerForAgricultureResourcesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, request DataManagerForAgricultureUpdateRequestModel, options *DataManagerForAgricultureResourcesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, request); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/extensions_client.go b/sdk/resourcemanager/agrifood/armagrifood/extensions_client.go index 81118456f76c..707f466ad78c 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/extensions_client.go +++ b/sdk/resourcemanager/agrifood/armagrifood/extensions_client.go @@ -29,7 +29,7 @@ type ExtensionsClient struct { } // NewExtensionsClient creates a new instance of ExtensionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExtensionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExtensionsClient, error) { @@ -44,39 +44,41 @@ func NewExtensionsClient(subscriptionID string, credential azcore.TokenCredentia return client, nil } -// Create - Install extension. +// CreateOrUpdate - Install or Update extension. Additional Api Properties are merged patch and if the extension is updated +// to a new version then the obsolete entries will be auto deleted from Additional Api Properties. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. // - extensionID - Id of extension resource. -// - options - ExtensionsClientCreateOptions contains the optional parameters for the ExtensionsClient.Create method. -func (client *ExtensionsClient) Create(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientCreateOptions) (ExtensionsClientCreateResponse, error) { +// - options - ExtensionsClientCreateOrUpdateOptions contains the optional parameters for the ExtensionsClient.CreateOrUpdate +// method. +func (client *ExtensionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *ExtensionsClientCreateOrUpdateOptions) (ExtensionsClientCreateOrUpdateResponse, error) { var err error - const operationName = "ExtensionsClient.Create" + const operationName = "ExtensionsClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, extensionID, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, extensionID, options) if err != nil { - return ExtensionsClientCreateResponse{}, err + return ExtensionsClientCreateOrUpdateResponse{}, err } httpResp, err := client.internal.Pipeline().Do(req) if err != nil { - return ExtensionsClientCreateResponse{}, err + return ExtensionsClientCreateOrUpdateResponse{}, err } if !runtime.HasStatusCode(httpResp, http.StatusCreated) { err = runtime.NewResponseError(httpResp) - return ExtensionsClientCreateResponse{}, err + return ExtensionsClientCreateOrUpdateResponse{}, err } - resp, err := client.createHandleResponse(httpResp) + resp, err := client.createOrUpdateHandleResponse(httpResp) return resp, err } -// createCreateRequest creates the Create request. -func (client *ExtensionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientCreateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}" +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ExtensionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *ExtensionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/extensions/{extensionId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -85,10 +87,10 @@ func (client *ExtensionsClient) createCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) if extensionID == "" { return nil, errors.New("parameter extensionID cannot be empty") } @@ -98,17 +100,23 @@ func (client *ExtensionsClient) createCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.RequestBody != nil { + if err := runtime.MarshalAsJSON(req, *options.RequestBody); err != nil { + return nil, err + } + return req, nil + } return req, nil } -// createHandleResponse handles the Create response. -func (client *ExtensionsClient) createHandleResponse(resp *http.Response) (ExtensionsClientCreateResponse, error) { - result := ExtensionsClientCreateResponse{} +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ExtensionsClient) createOrUpdateHandleResponse(resp *http.Response) (ExtensionsClientCreateOrUpdateResponse, error) { + result := ExtensionsClientCreateOrUpdateResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.Extension); err != nil { - return ExtensionsClientCreateResponse{}, err + return ExtensionsClientCreateOrUpdateResponse{}, err } return result, nil } @@ -116,18 +124,18 @@ func (client *ExtensionsClient) createHandleResponse(resp *http.Response) (Exten // Delete - Uninstall extension. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. // - extensionID - Id of extension resource. // - options - ExtensionsClientDeleteOptions contains the optional parameters for the ExtensionsClient.Delete method. -func (client *ExtensionsClient) Delete(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientDeleteOptions) (ExtensionsClientDeleteResponse, error) { +func (client *ExtensionsClient) Delete(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *ExtensionsClientDeleteOptions) (ExtensionsClientDeleteResponse, error) { var err error const operationName = "ExtensionsClient.Delete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, extensionID, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, extensionID, options) if err != nil { return ExtensionsClientDeleteResponse{}, err } @@ -143,8 +151,8 @@ func (client *ExtensionsClient) Delete(ctx context.Context, resourceGroupName st } // deleteCreateRequest creates the Delete request. -func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}" +func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *ExtensionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/extensions/{extensionId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -153,10 +161,10 @@ func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourc return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) if extensionID == "" { return nil, errors.New("parameter extensionID cannot be empty") } @@ -166,7 +174,7 @@ func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -175,18 +183,18 @@ func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourc // Get - Get installed extension details by extension id. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. // - extensionID - Id of extension resource. // - options - ExtensionsClientGetOptions contains the optional parameters for the ExtensionsClient.Get method. -func (client *ExtensionsClient) Get(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientGetOptions) (ExtensionsClientGetResponse, error) { +func (client *ExtensionsClient) Get(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *ExtensionsClientGetOptions) (ExtensionsClientGetResponse, error) { var err error const operationName = "ExtensionsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, extensionID, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, extensionID, options) if err != nil { return ExtensionsClientGetResponse{}, err } @@ -203,8 +211,8 @@ func (client *ExtensionsClient) Get(ctx context.Context, resourceGroupName strin } // getCreateRequest creates the Get request. -func (client *ExtensionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}" +func (client *ExtensionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *ExtensionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/extensions/{extensionId}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -213,10 +221,10 @@ func (client *ExtensionsClient) getCreateRequest(ctx context.Context, resourceGr return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) if extensionID == "" { return nil, errors.New("parameter extensionID cannot be empty") } @@ -226,7 +234,7 @@ func (client *ExtensionsClient) getCreateRequest(ctx context.Context, resourceGr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -241,39 +249,39 @@ func (client *ExtensionsClient) getHandleResponse(resp *http.Response) (Extensio return result, nil } -// NewListByFarmBeatsPager - Get installed extensions details. +// NewListByDataManagerForAgriculturePager - Get installed extensions details. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - options - ExtensionsClientListByFarmBeatsOptions contains the optional parameters for the ExtensionsClient.NewListByFarmBeatsPager +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - options - ExtensionsClientListByDataManagerForAgricultureOptions contains the optional parameters for the ExtensionsClient.NewListByDataManagerForAgriculturePager // method. -func (client *ExtensionsClient) NewListByFarmBeatsPager(resourceGroupName string, farmBeatsResourceName string, options *ExtensionsClientListByFarmBeatsOptions) *runtime.Pager[ExtensionsClientListByFarmBeatsResponse] { - return runtime.NewPager(runtime.PagingHandler[ExtensionsClientListByFarmBeatsResponse]{ - More: func(page ExtensionsClientListByFarmBeatsResponse) bool { +func (client *ExtensionsClient) NewListByDataManagerForAgriculturePager(resourceGroupName string, dataManagerForAgricultureResourceName string, options *ExtensionsClientListByDataManagerForAgricultureOptions) *runtime.Pager[ExtensionsClientListByDataManagerForAgricultureResponse] { + return runtime.NewPager(runtime.PagingHandler[ExtensionsClientListByDataManagerForAgricultureResponse]{ + More: func(page ExtensionsClientListByDataManagerForAgricultureResponse) bool { return page.NextLink != nil && len(*page.NextLink) > 0 }, - Fetcher: func(ctx context.Context, page *ExtensionsClientListByFarmBeatsResponse) (ExtensionsClientListByFarmBeatsResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExtensionsClient.NewListByFarmBeatsPager") + Fetcher: func(ctx context.Context, page *ExtensionsClientListByDataManagerForAgricultureResponse) (ExtensionsClientListByDataManagerForAgricultureResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExtensionsClient.NewListByDataManagerForAgriculturePager") nextLink := "" if page != nil { nextLink = *page.NextLink } resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByFarmBeatsCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, options) + return client.listByDataManagerForAgricultureCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, options) }, nil) if err != nil { - return ExtensionsClientListByFarmBeatsResponse{}, err + return ExtensionsClientListByDataManagerForAgricultureResponse{}, err } - return client.listByFarmBeatsHandleResponse(resp) + return client.listByDataManagerForAgricultureHandleResponse(resp) }, Tracer: client.internal.Tracer(), }) } -// listByFarmBeatsCreateRequest creates the ListByFarmBeats request. -func (client *ExtensionsClient) listByFarmBeatsCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *ExtensionsClientListByFarmBeatsOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions" +// listByDataManagerForAgricultureCreateRequest creates the ListByDataManagerForAgriculture request. +func (client *ExtensionsClient) listByDataManagerForAgricultureCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *ExtensionsClientListByDataManagerForAgricultureOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/extensions" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -282,111 +290,42 @@ func (client *ExtensionsClient) listByFarmBeatsCreateRequest(ctx context.Context return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") - if options != nil && options.ExtensionIDs != nil { - for _, qv := range options.ExtensionIDs { - reqQP.Add("extensionIds", qv) - } - } - if options != nil && options.ExtensionCategories != nil { - for _, qv := range options.ExtensionCategories { - reqQP.Add("extensionCategories", qv) - } - } if options != nil && options.MaxPageSize != nil { reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) } if options != nil && options.SkipToken != nil { reqQP.Set("$skipToken", *options.SkipToken) } - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByFarmBeatsHandleResponse handles the ListByFarmBeats response. -func (client *ExtensionsClient) listByFarmBeatsHandleResponse(resp *http.Response) (ExtensionsClientListByFarmBeatsResponse, error) { - result := ExtensionsClientListByFarmBeatsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionListResponse); err != nil { - return ExtensionsClientListByFarmBeatsResponse{}, err - } - return result, nil -} - -// Update - Upgrade to latest extension. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - extensionID - Id of extension resource. -// - options - ExtensionsClientUpdateOptions contains the optional parameters for the ExtensionsClient.Update method. -func (client *ExtensionsClient) Update(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientUpdateOptions) (ExtensionsClientUpdateResponse, error) { - var err error - const operationName = "ExtensionsClient.Update" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, extensionID, options) - if err != nil { - return ExtensionsClientUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExtensionsClientUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExtensionsClientUpdateResponse{}, err - } - resp, err := client.updateHandleResponse(httpResp) - return resp, err -} - -// updateCreateRequest creates the Update request. -func (client *ExtensionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *ExtensionsClientUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) - if extensionID == "" { - return nil, errors.New("parameter extensionID cannot be empty") + reqQP.Set("api-version", "2023-06-01-preview") + if options != nil && options.ExtensionCategories != nil { + for _, qv := range options.ExtensionCategories { + reqQP.Add("extensionCategories", qv) + } } - urlPath = strings.ReplaceAll(urlPath, "{extensionId}", url.PathEscape(extensionID)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err + if options != nil && options.ExtensionIDs != nil { + for _, qv := range options.ExtensionIDs { + reqQP.Add("extensionIds", qv) + } } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } -// updateHandleResponse handles the Update response. -func (client *ExtensionsClient) updateHandleResponse(resp *http.Response) (ExtensionsClientUpdateResponse, error) { - result := ExtensionsClientUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.Extension); err != nil { - return ExtensionsClientUpdateResponse{}, err +// listByDataManagerForAgricultureHandleResponse handles the ListByDataManagerForAgriculture response. +func (client *ExtensionsClient) listByDataManagerForAgricultureHandleResponse(resp *http.Response) (ExtensionsClientListByDataManagerForAgricultureResponse, error) { + result := ExtensionsClientListByDataManagerForAgricultureResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionListResponse); err != nil { + return ExtensionsClientListByDataManagerForAgricultureResponse{}, err } return result, nil } diff --git a/sdk/resourcemanager/agrifood/armagrifood/extensions_client_example_test.go b/sdk/resourcemanager/agrifood/armagrifood/extensions_client_example_test.go deleted file mode 100644 index d5fba6c07b3d..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/extensions_client_example_test.go +++ /dev/null @@ -1,184 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armagrifood_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Create.json -func ExampleExtensionsClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExtensionsClient().Create(ctx, "examples-rg", "examples-farmbeatsResourceName", "provider.extension", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Get.json -func ExampleExtensionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExtensionsClient().Get(ctx, "examples-rg", "examples-farmbeatsResourceName", "provider.extension", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Extension = armagrifood.Extension{ - // Name: to.Ptr("provider.extension"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/extensions"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/extensions/provider.extension"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // ETag: to.Ptr("7200b954-0000-0700-0000-603cbbc40000"), - // Properties: &armagrifood.ExtensionProperties{ - // ExtensionAPIDocsLink: to.Ptr("https://docs.provider.com/documentation/extension"), - // ExtensionAuthLink: to.Ptr("https://www.provider.com/extension/"), - // ExtensionCategory: to.Ptr("Weather"), - // InstalledExtensionVersion: to.Ptr("1.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Update.json -func ExampleExtensionsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExtensionsClient().Update(ctx, "examples-rg", "examples-farmbeatsResourceName", "provider.extension", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Extension = armagrifood.Extension{ - // Name: to.Ptr("provider.extension"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/extensions"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/extensions/provider.extension"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // ETag: to.Ptr("7200b954-0000-0700-0000-603cbbc40000"), - // Properties: &armagrifood.ExtensionProperties{ - // ExtensionAPIDocsLink: to.Ptr("https://docs.provider.com/documentation/extension"), - // ExtensionAuthLink: to.Ptr("https://www.provider.com/extension/"), - // ExtensionCategory: to.Ptr("Weather"), - // InstalledExtensionVersion: to.Ptr("2.0"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Delete.json -func ExampleExtensionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExtensionsClient().Delete(ctx, "examples-rg", "examples-farmbeatsResourceName", "provider.extension", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_ListByFarmBeats.json -func ExampleExtensionsClient_NewListByFarmBeatsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewExtensionsClient().NewListByFarmBeatsPager("examples-rg", "examples-farmbeatsResourceName", &armagrifood.ExtensionsClientListByFarmBeatsOptions{ExtensionIDs: []string{}, - ExtensionCategories: []string{}, - MaxPageSize: nil, - SkipToken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ExtensionListResponse = armagrifood.ExtensionListResponse{ - // Value: []*armagrifood.Extension{ - // { - // Name: to.Ptr("provider.extension"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/extensions"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/extensions/provider.extension"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // ETag: to.Ptr("7200b954-0000-0700-0000-603cbbc40000"), - // Properties: &armagrifood.ExtensionProperties{ - // ExtensionAPIDocsLink: to.Ptr("https://docs.provider.com/documentation/extension"), - // ExtensionAuthLink: to.Ptr("https://www.provider.com/extension/"), - // ExtensionCategory: to.Ptr("Weather"), - // InstalledExtensionVersion: to.Ptr("1.0"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/locations_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/checknameavailability_server.go similarity index 55% rename from sdk/resourcemanager/agrifood/armagrifood/fake/locations_server.go rename to sdk/resourcemanager/agrifood/armagrifood/fake/checknameavailability_server.go index a80bd736e0bb..f8a6c1c87cd4 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/locations_server.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/checknameavailability_server.go @@ -20,28 +20,28 @@ import ( "regexp" ) -// LocationsServer is a fake server for instances of the armagrifood.LocationsClient type. -type LocationsServer struct { - // CheckNameAvailability is the fake for method LocationsClient.CheckNameAvailability +// CheckNameAvailabilityServer is a fake server for instances of the armagrifood.CheckNameAvailabilityClient type. +type CheckNameAvailabilityServer struct { + // CheckNameAvailability is the fake for method CheckNameAvailabilityClient.CheckNameAvailability // HTTP status codes to indicate success: http.StatusOK - CheckNameAvailability func(ctx context.Context, body armagrifood.CheckNameAvailabilityRequest, options *armagrifood.LocationsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armagrifood.LocationsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + CheckNameAvailability func(ctx context.Context, nameAvailabilityRequest armagrifood.CheckNameAvailabilityRequest, options *armagrifood.CheckNameAvailabilityClientCheckNameAvailabilityOptions) (resp azfake.Responder[armagrifood.CheckNameAvailabilityClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) } -// NewLocationsServerTransport creates a new instance of LocationsServerTransport with the provided implementation. -// The returned LocationsServerTransport instance is connected to an instance of armagrifood.LocationsClient via the +// NewCheckNameAvailabilityServerTransport creates a new instance of CheckNameAvailabilityServerTransport with the provided implementation. +// The returned CheckNameAvailabilityServerTransport instance is connected to an instance of armagrifood.CheckNameAvailabilityClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewLocationsServerTransport(srv *LocationsServer) *LocationsServerTransport { - return &LocationsServerTransport{srv: srv} +func NewCheckNameAvailabilityServerTransport(srv *CheckNameAvailabilityServer) *CheckNameAvailabilityServerTransport { + return &CheckNameAvailabilityServerTransport{srv: srv} } -// LocationsServerTransport connects instances of armagrifood.LocationsClient to instances of LocationsServer. -// Don't use this type directly, use NewLocationsServerTransport instead. -type LocationsServerTransport struct { - srv *LocationsServer +// CheckNameAvailabilityServerTransport connects instances of armagrifood.CheckNameAvailabilityClient to instances of CheckNameAvailabilityServer. +// Don't use this type directly, use NewCheckNameAvailabilityServerTransport instead. +type CheckNameAvailabilityServerTransport struct { + srv *CheckNameAvailabilityServer } -// Do implements the policy.Transporter interface for LocationsServerTransport. -func (l *LocationsServerTransport) Do(req *http.Request) (*http.Response, error) { +// Do implements the policy.Transporter interface for CheckNameAvailabilityServerTransport. +func (c *CheckNameAvailabilityServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { @@ -52,8 +52,8 @@ func (l *LocationsServerTransport) Do(req *http.Request) (*http.Response, error) var err error switch method { - case "LocationsClient.CheckNameAvailability": - resp, err = l.dispatchCheckNameAvailability(req) + case "CheckNameAvailabilityClient.CheckNameAvailability": + resp, err = c.dispatchCheckNameAvailability(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -65,8 +65,8 @@ func (l *LocationsServerTransport) Do(req *http.Request) (*http.Response, error) return resp, nil } -func (l *LocationsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { - if l.srv.CheckNameAvailability == nil { +func (c *CheckNameAvailabilityServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if c.srv.CheckNameAvailability == nil { return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} } const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/checkNameAvailability` @@ -79,7 +79,7 @@ func (l *LocationsServerTransport) dispatchCheckNameAvailability(req *http.Reque if err != nil { return nil, err } - respr, errRespr := l.srv.CheckNameAvailability(req.Context(), body, nil) + respr, errRespr := c.srv.CheckNameAvailability(req.Context(), body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/dataconnectors_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/dataconnectors_server.go new file mode 100644 index 000000000000..985d20fcf33b --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/dataconnectors_server.go @@ -0,0 +1,274 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// DataConnectorsServer is a fake server for instances of the armagrifood.DataConnectorsClient type. +type DataConnectorsServer struct { + // CreateOrUpdate is the fake for method DataConnectorsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, body armagrifood.DataConnector, options *armagrifood.DataConnectorsClientCreateOrUpdateOptions) (resp azfake.Responder[armagrifood.DataConnectorsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method DataConnectorsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, options *armagrifood.DataConnectorsClientDeleteOptions) (resp azfake.Responder[armagrifood.DataConnectorsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DataConnectorsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, dataConnectorName string, options *armagrifood.DataConnectorsClientGetOptions) (resp azfake.Responder[armagrifood.DataConnectorsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DataConnectorsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, dataManagerForAgricultureResourceName string, options *armagrifood.DataConnectorsClientListOptions) (resp azfake.PagerResponder[armagrifood.DataConnectorsClientListResponse]) +} + +// NewDataConnectorsServerTransport creates a new instance of DataConnectorsServerTransport with the provided implementation. +// The returned DataConnectorsServerTransport instance is connected to an instance of armagrifood.DataConnectorsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDataConnectorsServerTransport(srv *DataConnectorsServer) *DataConnectorsServerTransport { + return &DataConnectorsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armagrifood.DataConnectorsClientListResponse]](), + } +} + +// DataConnectorsServerTransport connects instances of armagrifood.DataConnectorsClient to instances of DataConnectorsServer. +// Don't use this type directly, use NewDataConnectorsServerTransport instead. +type DataConnectorsServerTransport struct { + srv *DataConnectorsServer + newListPager *tracker[azfake.PagerResponder[armagrifood.DataConnectorsClientListResponse]] +} + +// Do implements the policy.Transporter interface for DataConnectorsServerTransport. +func (d *DataConnectorsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DataConnectorsClient.CreateOrUpdate": + resp, err = d.dispatchCreateOrUpdate(req) + case "DataConnectorsClient.Delete": + resp, err = d.dispatchDelete(req) + case "DataConnectorsClient.Get": + resp, err = d.dispatchGet(req) + case "DataConnectorsClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DataConnectorsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnectors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armagrifood.DataConnector](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + dataConnectorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataConnectorName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, dataConnectorNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataConnector, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataConnectorsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if d.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnectors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + dataConnectorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataConnectorName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Delete(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, dataConnectorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataConnectorsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnectors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + dataConnectorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataConnectorName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, dataConnectorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataConnector, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataConnectorsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnectors` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + maxPageSizeUnescaped, err := url.QueryUnescape(qp.Get("$maxPageSize")) + if err != nil { + return nil, err + } + maxPageSizeParam, err := parseOptional(maxPageSizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + var options *armagrifood.DataConnectorsClientListOptions + if maxPageSizeParam != nil || skipTokenParam != nil { + options = &armagrifood.DataConnectorsClientListOptions{ + MaxPageSize: maxPageSizeParam, + SkipToken: skipTokenParam, + } + } + resp := d.srv.NewListPager(resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, options) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armagrifood.DataConnectorsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/farmbeatsextensions_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/datamanagerforagricultureextensions_server.go similarity index 58% rename from sdk/resourcemanager/agrifood/armagrifood/fake/farmbeatsextensions_server.go rename to sdk/resourcemanager/agrifood/armagrifood/fake/datamanagerforagricultureextensions_server.go index 2522ca1b9565..1a3277cc3219 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/farmbeatsextensions_server.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/datamanagerforagricultureextensions_server.go @@ -23,36 +23,36 @@ import ( "strconv" ) -// FarmBeatsExtensionsServer is a fake server for instances of the armagrifood.FarmBeatsExtensionsClient type. -type FarmBeatsExtensionsServer struct { - // Get is the fake for method FarmBeatsExtensionsClient.Get +// DataManagerForAgricultureExtensionsServer is a fake server for instances of the armagrifood.DataManagerForAgricultureExtensionsClient type. +type DataManagerForAgricultureExtensionsServer struct { + // Get is the fake for method DataManagerForAgricultureExtensionsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, farmBeatsExtensionID string, options *armagrifood.FarmBeatsExtensionsClientGetOptions) (resp azfake.Responder[armagrifood.FarmBeatsExtensionsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, dataManagerForAgricultureExtensionID string, options *armagrifood.DataManagerForAgricultureExtensionsClientGetOptions) (resp azfake.Responder[armagrifood.DataManagerForAgricultureExtensionsClientGetResponse], errResp azfake.ErrorResponder) - // NewListPager is the fake for method FarmBeatsExtensionsClient.NewListPager + // NewListPager is the fake for method DataManagerForAgricultureExtensionsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armagrifood.FarmBeatsExtensionsClientListOptions) (resp azfake.PagerResponder[armagrifood.FarmBeatsExtensionsClientListResponse]) + NewListPager func(options *armagrifood.DataManagerForAgricultureExtensionsClientListOptions) (resp azfake.PagerResponder[armagrifood.DataManagerForAgricultureExtensionsClientListResponse]) } -// NewFarmBeatsExtensionsServerTransport creates a new instance of FarmBeatsExtensionsServerTransport with the provided implementation. -// The returned FarmBeatsExtensionsServerTransport instance is connected to an instance of armagrifood.FarmBeatsExtensionsClient via the +// NewDataManagerForAgricultureExtensionsServerTransport creates a new instance of DataManagerForAgricultureExtensionsServerTransport with the provided implementation. +// The returned DataManagerForAgricultureExtensionsServerTransport instance is connected to an instance of armagrifood.DataManagerForAgricultureExtensionsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewFarmBeatsExtensionsServerTransport(srv *FarmBeatsExtensionsServer) *FarmBeatsExtensionsServerTransport { - return &FarmBeatsExtensionsServerTransport{ +func NewDataManagerForAgricultureExtensionsServerTransport(srv *DataManagerForAgricultureExtensionsServer) *DataManagerForAgricultureExtensionsServerTransport { + return &DataManagerForAgricultureExtensionsServerTransport{ srv: srv, - newListPager: newTracker[azfake.PagerResponder[armagrifood.FarmBeatsExtensionsClientListResponse]](), + newListPager: newTracker[azfake.PagerResponder[armagrifood.DataManagerForAgricultureExtensionsClientListResponse]](), } } -// FarmBeatsExtensionsServerTransport connects instances of armagrifood.FarmBeatsExtensionsClient to instances of FarmBeatsExtensionsServer. -// Don't use this type directly, use NewFarmBeatsExtensionsServerTransport instead. -type FarmBeatsExtensionsServerTransport struct { - srv *FarmBeatsExtensionsServer - newListPager *tracker[azfake.PagerResponder[armagrifood.FarmBeatsExtensionsClientListResponse]] +// DataManagerForAgricultureExtensionsServerTransport connects instances of armagrifood.DataManagerForAgricultureExtensionsClient to instances of DataManagerForAgricultureExtensionsServer. +// Don't use this type directly, use NewDataManagerForAgricultureExtensionsServerTransport instead. +type DataManagerForAgricultureExtensionsServerTransport struct { + srv *DataManagerForAgricultureExtensionsServer + newListPager *tracker[azfake.PagerResponder[armagrifood.DataManagerForAgricultureExtensionsClientListResponse]] } -// Do implements the policy.Transporter interface for FarmBeatsExtensionsServerTransport. -func (f *FarmBeatsExtensionsServerTransport) Do(req *http.Request) (*http.Response, error) { +// Do implements the policy.Transporter interface for DataManagerForAgricultureExtensionsServerTransport. +func (d *DataManagerForAgricultureExtensionsServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { @@ -63,10 +63,10 @@ func (f *FarmBeatsExtensionsServerTransport) Do(req *http.Request) (*http.Respon var err error switch method { - case "FarmBeatsExtensionsClient.Get": - resp, err = f.dispatchGet(req) - case "FarmBeatsExtensionsClient.NewListPager": - resp, err = f.dispatchNewListPager(req) + case "DataManagerForAgricultureExtensionsClient.Get": + resp, err = d.dispatchGet(req) + case "DataManagerForAgricultureExtensionsClient.NewListPager": + resp, err = d.dispatchNewListPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -78,21 +78,21 @@ func (f *FarmBeatsExtensionsServerTransport) Do(req *http.Request) (*http.Respon return resp, nil } -func (f *FarmBeatsExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if f.srv.Get == nil { +func (d *DataManagerForAgricultureExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/providers/Microsoft\.AgFoodPlatform/farmBeatsExtensionDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/providers/Microsoft\.AgFoodPlatform/farmBeatsExtensionDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - farmBeatsExtensionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsExtensionId")]) + dataManagerForAgricultureExtensionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureExtensionId")]) if err != nil { return nil, err } - respr, errRespr := f.srv.Get(req.Context(), farmBeatsExtensionIDParam, nil) + respr, errRespr := d.srv.Get(req.Context(), dataManagerForAgricultureExtensionIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -100,18 +100,18 @@ func (f *FarmBeatsExtensionsServerTransport) dispatchGet(req *http.Request) (*ht if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).FarmBeatsExtension, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataManagerForAgricultureExtension, req) if err != nil { return nil, err } return resp, nil } -func (f *FarmBeatsExtensionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if f.srv.NewListPager == nil { +func (d *DataManagerForAgricultureExtensionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } - newListPager := f.newListPager.get(req) + newListPager := d.newListPager.get(req) if newListPager == nil { qp := req.URL.Query() farmBeatsExtensionIDsEscaped := qp["farmBeatsExtensionIds"] @@ -164,9 +164,9 @@ func (f *FarmBeatsExtensionsServerTransport) dispatchNewListPager(req *http.Requ if err != nil { return nil, err } - var options *armagrifood.FarmBeatsExtensionsClientListOptions + var options *armagrifood.DataManagerForAgricultureExtensionsClientListOptions if len(farmBeatsExtensionIDsParam) > 0 || len(farmBeatsExtensionNamesParam) > 0 || len(extensionCategoriesParam) > 0 || len(publisherIDsParam) > 0 || maxPageSizeParam != nil { - options = &armagrifood.FarmBeatsExtensionsClientListOptions{ + options = &armagrifood.DataManagerForAgricultureExtensionsClientListOptions{ FarmBeatsExtensionIDs: farmBeatsExtensionIDsParam, FarmBeatsExtensionNames: farmBeatsExtensionNamesParam, ExtensionCategories: extensionCategoriesParam, @@ -174,10 +174,10 @@ func (f *FarmBeatsExtensionsServerTransport) dispatchNewListPager(req *http.Requ MaxPageSize: maxPageSizeParam, } } - resp := f.srv.NewListPager(options) + resp := d.srv.NewListPager(options) newListPager = &resp - f.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armagrifood.FarmBeatsExtensionsClientListResponse, createLink func() string) { + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armagrifood.DataManagerForAgricultureExtensionsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -186,11 +186,11 @@ func (f *FarmBeatsExtensionsServerTransport) dispatchNewListPager(req *http.Requ return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - f.newListPager.remove(req) + d.newListPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListPager) { - f.newListPager.remove(req) + d.newListPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/farmbeatsmodels_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/datamanagerforagricultureresources_server.go similarity index 52% rename from sdk/resourcemanager/agrifood/armagrifood/fake/farmbeatsmodels_server.go rename to sdk/resourcemanager/agrifood/armagrifood/fake/datamanagerforagricultureresources_server.go index 9818811f36bd..2030956c2814 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/farmbeatsmodels_server.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/datamanagerforagricultureresources_server.go @@ -23,60 +23,56 @@ import ( "strconv" ) -// FarmBeatsModelsServer is a fake server for instances of the armagrifood.FarmBeatsModelsClient type. -type FarmBeatsModelsServer struct { - // CreateOrUpdate is the fake for method FarmBeatsModelsClient.CreateOrUpdate +// DataManagerForAgricultureResourcesServer is a fake server for instances of the armagrifood.DataManagerForAgricultureResourcesClient type. +type DataManagerForAgricultureResourcesServer struct { + // CreateOrUpdate is the fake for method DataManagerForAgricultureResourcesClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, body armagrifood.FarmBeats, options *armagrifood.FarmBeatsModelsClientCreateOrUpdateOptions) (resp azfake.Responder[armagrifood.FarmBeatsModelsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, request armagrifood.DataManagerForAgriculture, options *armagrifood.DataManagerForAgricultureResourcesClientCreateOrUpdateOptions) (resp azfake.Responder[armagrifood.DataManagerForAgricultureResourcesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - // Delete is the fake for method FarmBeatsModelsClient.Delete + // Delete is the fake for method DataManagerForAgricultureResourcesClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *armagrifood.FarmBeatsModelsClientDeleteOptions) (resp azfake.Responder[armagrifood.FarmBeatsModelsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *armagrifood.DataManagerForAgricultureResourcesClientDeleteOptions) (resp azfake.Responder[armagrifood.DataManagerForAgricultureResourcesClientDeleteResponse], errResp azfake.ErrorResponder) - // Get is the fake for method FarmBeatsModelsClient.Get + // Get is the fake for method DataManagerForAgricultureResourcesClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *armagrifood.FarmBeatsModelsClientGetOptions) (resp azfake.Responder[armagrifood.FarmBeatsModelsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *armagrifood.DataManagerForAgricultureResourcesClientGetOptions) (resp azfake.Responder[armagrifood.DataManagerForAgricultureResourcesClientGetResponse], errResp azfake.ErrorResponder) - // GetOperationResult is the fake for method FarmBeatsModelsClient.GetOperationResult + // NewListByResourceGroupPager is the fake for method DataManagerForAgricultureResourcesClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK - GetOperationResult func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, operationResultsID string, options *armagrifood.FarmBeatsModelsClientGetOperationResultOptions) (resp azfake.Responder[armagrifood.FarmBeatsModelsClientGetOperationResultResponse], errResp azfake.ErrorResponder) + NewListByResourceGroupPager func(resourceGroupName string, options *armagrifood.DataManagerForAgricultureResourcesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armagrifood.DataManagerForAgricultureResourcesClientListByResourceGroupResponse]) - // NewListByResourceGroupPager is the fake for method FarmBeatsModelsClient.NewListByResourceGroupPager + // NewListBySubscriptionPager is the fake for method DataManagerForAgricultureResourcesClient.NewListBySubscriptionPager // HTTP status codes to indicate success: http.StatusOK - NewListByResourceGroupPager func(resourceGroupName string, options *armagrifood.FarmBeatsModelsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armagrifood.FarmBeatsModelsClientListByResourceGroupResponse]) + NewListBySubscriptionPager func(options *armagrifood.DataManagerForAgricultureResourcesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armagrifood.DataManagerForAgricultureResourcesClientListBySubscriptionResponse]) - // NewListBySubscriptionPager is the fake for method FarmBeatsModelsClient.NewListBySubscriptionPager - // HTTP status codes to indicate success: http.StatusOK - NewListBySubscriptionPager func(options *armagrifood.FarmBeatsModelsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armagrifood.FarmBeatsModelsClientListBySubscriptionResponse]) - - // BeginUpdate is the fake for method FarmBeatsModelsClient.BeginUpdate + // BeginUpdate is the fake for method DataManagerForAgricultureResourcesClient.BeginUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, body armagrifood.FarmBeatsUpdateRequestModel, options *armagrifood.FarmBeatsModelsClientBeginUpdateOptions) (resp azfake.PollerResponder[armagrifood.FarmBeatsModelsClientUpdateResponse], errResp azfake.ErrorResponder) + BeginUpdate func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, request armagrifood.DataManagerForAgricultureUpdateRequestModel, options *armagrifood.DataManagerForAgricultureResourcesClientBeginUpdateOptions) (resp azfake.PollerResponder[armagrifood.DataManagerForAgricultureResourcesClientUpdateResponse], errResp azfake.ErrorResponder) } -// NewFarmBeatsModelsServerTransport creates a new instance of FarmBeatsModelsServerTransport with the provided implementation. -// The returned FarmBeatsModelsServerTransport instance is connected to an instance of armagrifood.FarmBeatsModelsClient via the +// NewDataManagerForAgricultureResourcesServerTransport creates a new instance of DataManagerForAgricultureResourcesServerTransport with the provided implementation. +// The returned DataManagerForAgricultureResourcesServerTransport instance is connected to an instance of armagrifood.DataManagerForAgricultureResourcesClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewFarmBeatsModelsServerTransport(srv *FarmBeatsModelsServer) *FarmBeatsModelsServerTransport { - return &FarmBeatsModelsServerTransport{ +func NewDataManagerForAgricultureResourcesServerTransport(srv *DataManagerForAgricultureResourcesServer) *DataManagerForAgricultureResourcesServerTransport { + return &DataManagerForAgricultureResourcesServerTransport{ srv: srv, - newListByResourceGroupPager: newTracker[azfake.PagerResponder[armagrifood.FarmBeatsModelsClientListByResourceGroupResponse]](), - newListBySubscriptionPager: newTracker[azfake.PagerResponder[armagrifood.FarmBeatsModelsClientListBySubscriptionResponse]](), - beginUpdate: newTracker[azfake.PollerResponder[armagrifood.FarmBeatsModelsClientUpdateResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armagrifood.DataManagerForAgricultureResourcesClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armagrifood.DataManagerForAgricultureResourcesClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armagrifood.DataManagerForAgricultureResourcesClientUpdateResponse]](), } } -// FarmBeatsModelsServerTransport connects instances of armagrifood.FarmBeatsModelsClient to instances of FarmBeatsModelsServer. -// Don't use this type directly, use NewFarmBeatsModelsServerTransport instead. -type FarmBeatsModelsServerTransport struct { - srv *FarmBeatsModelsServer - newListByResourceGroupPager *tracker[azfake.PagerResponder[armagrifood.FarmBeatsModelsClientListByResourceGroupResponse]] - newListBySubscriptionPager *tracker[azfake.PagerResponder[armagrifood.FarmBeatsModelsClientListBySubscriptionResponse]] - beginUpdate *tracker[azfake.PollerResponder[armagrifood.FarmBeatsModelsClientUpdateResponse]] +// DataManagerForAgricultureResourcesServerTransport connects instances of armagrifood.DataManagerForAgricultureResourcesClient to instances of DataManagerForAgricultureResourcesServer. +// Don't use this type directly, use NewDataManagerForAgricultureResourcesServerTransport instead. +type DataManagerForAgricultureResourcesServerTransport struct { + srv *DataManagerForAgricultureResourcesServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armagrifood.DataManagerForAgricultureResourcesClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armagrifood.DataManagerForAgricultureResourcesClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armagrifood.DataManagerForAgricultureResourcesClientUpdateResponse]] } -// Do implements the policy.Transporter interface for FarmBeatsModelsServerTransport. -func (f *FarmBeatsModelsServerTransport) Do(req *http.Request) (*http.Response, error) { +// Do implements the policy.Transporter interface for DataManagerForAgricultureResourcesServerTransport. +func (d *DataManagerForAgricultureResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) method, ok := rawMethod.(string) if !ok { @@ -87,20 +83,18 @@ func (f *FarmBeatsModelsServerTransport) Do(req *http.Request) (*http.Response, var err error switch method { - case "FarmBeatsModelsClient.CreateOrUpdate": - resp, err = f.dispatchCreateOrUpdate(req) - case "FarmBeatsModelsClient.Delete": - resp, err = f.dispatchDelete(req) - case "FarmBeatsModelsClient.Get": - resp, err = f.dispatchGet(req) - case "FarmBeatsModelsClient.GetOperationResult": - resp, err = f.dispatchGetOperationResult(req) - case "FarmBeatsModelsClient.NewListByResourceGroupPager": - resp, err = f.dispatchNewListByResourceGroupPager(req) - case "FarmBeatsModelsClient.NewListBySubscriptionPager": - resp, err = f.dispatchNewListBySubscriptionPager(req) - case "FarmBeatsModelsClient.BeginUpdate": - resp, err = f.dispatchBeginUpdate(req) + case "DataManagerForAgricultureResourcesClient.CreateOrUpdate": + resp, err = d.dispatchCreateOrUpdate(req) + case "DataManagerForAgricultureResourcesClient.Delete": + resp, err = d.dispatchDelete(req) + case "DataManagerForAgricultureResourcesClient.Get": + resp, err = d.dispatchGet(req) + case "DataManagerForAgricultureResourcesClient.NewListByResourceGroupPager": + resp, err = d.dispatchNewListByResourceGroupPager(req) + case "DataManagerForAgricultureResourcesClient.NewListBySubscriptionPager": + resp, err = d.dispatchNewListBySubscriptionPager(req) + case "DataManagerForAgricultureResourcesClient.BeginUpdate": + resp, err = d.dispatchBeginUpdate(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -112,17 +106,17 @@ func (f *FarmBeatsModelsServerTransport) Do(req *http.Request) (*http.Response, return resp, nil } -func (f *FarmBeatsModelsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { - if f.srv.CreateOrUpdate == nil { +func (d *DataManagerForAgricultureResourcesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armagrifood.FarmBeats](req) + body, err := server.UnmarshalRequestAsJSON[armagrifood.DataManagerForAgriculture](req) if err != nil { return nil, err } @@ -130,11 +124,11 @@ func (f *FarmBeatsModelsServerTransport) dispatchCreateOrUpdate(req *http.Reques if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } - respr, errRespr := f.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, body, nil) + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -142,18 +136,18 @@ func (f *FarmBeatsModelsServerTransport) dispatchCreateOrUpdate(req *http.Reques if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).FarmBeats, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataManagerForAgriculture, req) if err != nil { return nil, err } return resp, nil } -func (f *FarmBeatsModelsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { - if f.srv.Delete == nil { +func (d *DataManagerForAgricultureResourcesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if d.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -163,11 +157,11 @@ func (f *FarmBeatsModelsServerTransport) dispatchDelete(req *http.Request) (*htt if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } - respr, errRespr := f.srv.Delete(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, nil) + respr, errRespr := d.srv.Delete(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -182,11 +176,11 @@ func (f *FarmBeatsModelsServerTransport) dispatchDelete(req *http.Request) (*htt return resp, nil } -func (f *FarmBeatsModelsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if f.srv.Get == nil { +func (d *DataManagerForAgricultureResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -196,48 +190,11 @@ func (f *FarmBeatsModelsServerTransport) dispatchGet(req *http.Request) (*http.R if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) - if err != nil { - return nil, err - } - respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).FarmBeats, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (f *FarmBeatsModelsServerTransport) dispatchGetOperationResult(req *http.Request) (*http.Response, error) { - if f.srv.GetOperationResult == nil { - return nil, &nonRetriableError{errors.New("fake for method GetOperationResult not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) - if err != nil { - return nil, err - } - operationResultsIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationResultsId")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } - respr, errRespr := f.srv.GetOperationResult(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, operationResultsIDParam, nil) + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -245,18 +202,18 @@ func (f *FarmBeatsModelsServerTransport) dispatchGetOperationResult(req *http.Re if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ArmAsyncOperation, req) + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataManagerForAgriculture, req) if err != nil { return nil, err } return resp, nil } -func (f *FarmBeatsModelsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { - if f.srv.NewListByResourceGroupPager == nil { +func (d *DataManagerForAgricultureResourcesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByResourceGroupPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} } - newListByResourceGroupPager := f.newListByResourceGroupPager.get(req) + newListByResourceGroupPager := d.newListByResourceGroupPager.get(req) if newListByResourceGroupPager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats` regex := regexp.MustCompile(regexStr) @@ -288,17 +245,17 @@ func (f *FarmBeatsModelsServerTransport) dispatchNewListByResourceGroupPager(req if err != nil { return nil, err } - var options *armagrifood.FarmBeatsModelsClientListByResourceGroupOptions + var options *armagrifood.DataManagerForAgricultureResourcesClientListByResourceGroupOptions if maxPageSizeParam != nil || skipTokenParam != nil { - options = &armagrifood.FarmBeatsModelsClientListByResourceGroupOptions{ + options = &armagrifood.DataManagerForAgricultureResourcesClientListByResourceGroupOptions{ MaxPageSize: maxPageSizeParam, SkipToken: skipTokenParam, } } - resp := f.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + resp := d.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) newListByResourceGroupPager = &resp - f.newListByResourceGroupPager.add(req, newListByResourceGroupPager) - server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armagrifood.FarmBeatsModelsClientListByResourceGroupResponse, createLink func() string) { + d.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armagrifood.DataManagerForAgricultureResourcesClientListByResourceGroupResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -307,20 +264,20 @@ func (f *FarmBeatsModelsServerTransport) dispatchNewListByResourceGroupPager(req return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - f.newListByResourceGroupPager.remove(req) + d.newListByResourceGroupPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListByResourceGroupPager) { - f.newListByResourceGroupPager.remove(req) + d.newListByResourceGroupPager.remove(req) } return resp, nil } -func (f *FarmBeatsModelsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { - if f.srv.NewListBySubscriptionPager == nil { +func (d *DataManagerForAgricultureResourcesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListBySubscriptionPager == nil { return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} } - newListBySubscriptionPager := f.newListBySubscriptionPager.get(req) + newListBySubscriptionPager := d.newListBySubscriptionPager.get(req) if newListBySubscriptionPager == nil { const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats` regex := regexp.MustCompile(regexStr) @@ -348,17 +305,17 @@ func (f *FarmBeatsModelsServerTransport) dispatchNewListBySubscriptionPager(req return nil, err } skipTokenParam := getOptional(skipTokenUnescaped) - var options *armagrifood.FarmBeatsModelsClientListBySubscriptionOptions + var options *armagrifood.DataManagerForAgricultureResourcesClientListBySubscriptionOptions if maxPageSizeParam != nil || skipTokenParam != nil { - options = &armagrifood.FarmBeatsModelsClientListBySubscriptionOptions{ + options = &armagrifood.DataManagerForAgricultureResourcesClientListBySubscriptionOptions{ MaxPageSize: maxPageSizeParam, SkipToken: skipTokenParam, } } - resp := f.srv.NewListBySubscriptionPager(options) + resp := d.srv.NewListBySubscriptionPager(options) newListBySubscriptionPager = &resp - f.newListBySubscriptionPager.add(req, newListBySubscriptionPager) - server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armagrifood.FarmBeatsModelsClientListBySubscriptionResponse, createLink func() string) { + d.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armagrifood.DataManagerForAgricultureResourcesClientListBySubscriptionResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -367,28 +324,28 @@ func (f *FarmBeatsModelsServerTransport) dispatchNewListBySubscriptionPager(req return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - f.newListBySubscriptionPager.remove(req) + d.newListBySubscriptionPager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } if !server.PagerResponderMore(newListBySubscriptionPager) { - f.newListBySubscriptionPager.remove(req) + d.newListBySubscriptionPager.remove(req) } return resp, nil } -func (f *FarmBeatsModelsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { - if f.srv.BeginUpdate == nil { +func (d *DataManagerForAgricultureResourcesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} } - beginUpdate := f.beginUpdate.get(req) + beginUpdate := d.beginUpdate.get(req) if beginUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - body, err := server.UnmarshalRequestAsJSON[armagrifood.FarmBeatsUpdateRequestModel](req) + body, err := server.UnmarshalRequestAsJSON[armagrifood.DataManagerForAgricultureUpdateRequestModel](req) if err != nil { return nil, err } @@ -396,16 +353,16 @@ func (f *FarmBeatsModelsServerTransport) dispatchBeginUpdate(req *http.Request) if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } - respr, errRespr := f.srv.BeginUpdate(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, body, nil) + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } beginUpdate = &respr - f.beginUpdate.add(req, beginUpdate) + d.beginUpdate.add(req, beginUpdate) } resp, err := server.PollerResponderNext(beginUpdate, req) @@ -414,11 +371,11 @@ func (f *FarmBeatsModelsServerTransport) dispatchBeginUpdate(req *http.Request) } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - f.beginUpdate.remove(req) + d.beginUpdate.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } if !server.PollerResponderMore(beginUpdate) { - f.beginUpdate.remove(req) + d.beginUpdate.remove(req) } return resp, nil diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/extensions_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/extensions_server.go index b26178a7c886..a583dd0ce5ec 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/extensions_server.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/extensions_server.go @@ -19,31 +19,28 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" "net/http" "net/url" + "reflect" "regexp" "strconv" ) // ExtensionsServer is a fake server for instances of the armagrifood.ExtensionsClient type. type ExtensionsServer struct { - // Create is the fake for method ExtensionsClient.Create + // CreateOrUpdate is the fake for method ExtensionsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusCreated - Create func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *armagrifood.ExtensionsClientCreateOptions) (resp azfake.Responder[armagrifood.ExtensionsClientCreateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *armagrifood.ExtensionsClientCreateOrUpdateOptions) (resp azfake.Responder[armagrifood.ExtensionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ExtensionsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *armagrifood.ExtensionsClientDeleteOptions) (resp azfake.Responder[armagrifood.ExtensionsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *armagrifood.ExtensionsClientDeleteOptions) (resp azfake.Responder[armagrifood.ExtensionsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method ExtensionsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *armagrifood.ExtensionsClientGetOptions) (resp azfake.Responder[armagrifood.ExtensionsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, extensionID string, options *armagrifood.ExtensionsClientGetOptions) (resp azfake.Responder[armagrifood.ExtensionsClientGetResponse], errResp azfake.ErrorResponder) - // NewListByFarmBeatsPager is the fake for method ExtensionsClient.NewListByFarmBeatsPager + // NewListByDataManagerForAgriculturePager is the fake for method ExtensionsClient.NewListByDataManagerForAgriculturePager // HTTP status codes to indicate success: http.StatusOK - NewListByFarmBeatsPager func(resourceGroupName string, farmBeatsResourceName string, options *armagrifood.ExtensionsClientListByFarmBeatsOptions) (resp azfake.PagerResponder[armagrifood.ExtensionsClientListByFarmBeatsResponse]) - - // Update is the fake for method ExtensionsClient.Update - // HTTP status codes to indicate success: http.StatusOK - Update func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, extensionID string, options *armagrifood.ExtensionsClientUpdateOptions) (resp azfake.Responder[armagrifood.ExtensionsClientUpdateResponse], errResp azfake.ErrorResponder) + NewListByDataManagerForAgriculturePager func(resourceGroupName string, dataManagerForAgricultureResourceName string, options *armagrifood.ExtensionsClientListByDataManagerForAgricultureOptions) (resp azfake.PagerResponder[armagrifood.ExtensionsClientListByDataManagerForAgricultureResponse]) } // NewExtensionsServerTransport creates a new instance of ExtensionsServerTransport with the provided implementation. @@ -51,16 +48,16 @@ type ExtensionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewExtensionsServerTransport(srv *ExtensionsServer) *ExtensionsServerTransport { return &ExtensionsServerTransport{ - srv: srv, - newListByFarmBeatsPager: newTracker[azfake.PagerResponder[armagrifood.ExtensionsClientListByFarmBeatsResponse]](), + srv: srv, + newListByDataManagerForAgriculturePager: newTracker[azfake.PagerResponder[armagrifood.ExtensionsClientListByDataManagerForAgricultureResponse]](), } } // ExtensionsServerTransport connects instances of armagrifood.ExtensionsClient to instances of ExtensionsServer. // Don't use this type directly, use NewExtensionsServerTransport instead. type ExtensionsServerTransport struct { - srv *ExtensionsServer - newListByFarmBeatsPager *tracker[azfake.PagerResponder[armagrifood.ExtensionsClientListByFarmBeatsResponse]] + srv *ExtensionsServer + newListByDataManagerForAgriculturePager *tracker[azfake.PagerResponder[armagrifood.ExtensionsClientListByDataManagerForAgricultureResponse]] } // Do implements the policy.Transporter interface for ExtensionsServerTransport. @@ -75,16 +72,14 @@ func (e *ExtensionsServerTransport) Do(req *http.Request) (*http.Response, error var err error switch method { - case "ExtensionsClient.Create": - resp, err = e.dispatchCreate(req) + case "ExtensionsClient.CreateOrUpdate": + resp, err = e.dispatchCreateOrUpdate(req) case "ExtensionsClient.Delete": resp, err = e.dispatchDelete(req) case "ExtensionsClient.Get": resp, err = e.dispatchGet(req) - case "ExtensionsClient.NewListByFarmBeatsPager": - resp, err = e.dispatchNewListByFarmBeatsPager(req) - case "ExtensionsClient.Update": - resp, err = e.dispatchUpdate(req) + case "ExtensionsClient.NewListByDataManagerForAgriculturePager": + resp, err = e.dispatchNewListByDataManagerForAgriculturePager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -96,21 +91,25 @@ func (e *ExtensionsServerTransport) Do(req *http.Request) (*http.Response, error return resp, nil } -func (e *ExtensionsServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { - if e.srv.Create == nil { - return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} +func (e *ExtensionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if e.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + body, err := server.UnmarshalRequestAsJSON[armagrifood.ExtensionInstallationRequest](req) + if err != nil { + return nil, err + } resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -118,7 +117,13 @@ func (e *ExtensionsServerTransport) dispatchCreate(req *http.Request) (*http.Res if err != nil { return nil, err } - respr, errRespr := e.srv.Create(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, extensionIDParam, nil) + var options *armagrifood.ExtensionsClientCreateOrUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armagrifood.ExtensionsClientCreateOrUpdateOptions{ + RequestBody: &body, + } + } + respr, errRespr := e.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, extensionIDParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -137,7 +142,7 @@ func (e *ExtensionsServerTransport) dispatchDelete(req *http.Request) (*http.Res if e.srv.Delete == nil { return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -147,7 +152,7 @@ func (e *ExtensionsServerTransport) dispatchDelete(req *http.Request) (*http.Res if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -155,7 +160,7 @@ func (e *ExtensionsServerTransport) dispatchDelete(req *http.Request) (*http.Res if err != nil { return nil, err } - respr, errRespr := e.srv.Delete(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, extensionIDParam, nil) + respr, errRespr := e.srv.Delete(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, extensionIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -174,7 +179,7 @@ func (e *ExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Respon if e.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -184,7 +189,7 @@ func (e *ExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Respon if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -192,7 +197,7 @@ func (e *ExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Respon if err != nil { return nil, err } - respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, extensionIDParam, nil) + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, extensionIDParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -207,13 +212,13 @@ func (e *ExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Respon return resp, nil } -func (e *ExtensionsServerTransport) dispatchNewListByFarmBeatsPager(req *http.Request) (*http.Response, error) { - if e.srv.NewListByFarmBeatsPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByFarmBeatsPager not implemented")} +func (e *ExtensionsServerTransport) dispatchNewListByDataManagerForAgriculturePager(req *http.Request) (*http.Response, error) { + if e.srv.NewListByDataManagerForAgriculturePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDataManagerForAgriculturePager not implemented")} } - newListByFarmBeatsPager := e.newListByFarmBeatsPager.get(req) - if newListByFarmBeatsPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions` + newListByDataManagerForAgriculturePager := e.newListByDataManagerForAgriculturePager.get(req) + if newListByDataManagerForAgriculturePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { @@ -224,7 +229,7 @@ func (e *ExtensionsServerTransport) dispatchNewListByFarmBeatsPager(req *http.Re if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -265,69 +270,32 @@ func (e *ExtensionsServerTransport) dispatchNewListByFarmBeatsPager(req *http.Re return nil, err } skipTokenParam := getOptional(skipTokenUnescaped) - var options *armagrifood.ExtensionsClientListByFarmBeatsOptions + var options *armagrifood.ExtensionsClientListByDataManagerForAgricultureOptions if len(extensionIDsParam) > 0 || len(extensionCategoriesParam) > 0 || maxPageSizeParam != nil || skipTokenParam != nil { - options = &armagrifood.ExtensionsClientListByFarmBeatsOptions{ + options = &armagrifood.ExtensionsClientListByDataManagerForAgricultureOptions{ ExtensionIDs: extensionIDsParam, ExtensionCategories: extensionCategoriesParam, MaxPageSize: maxPageSizeParam, SkipToken: skipTokenParam, } } - resp := e.srv.NewListByFarmBeatsPager(resourceGroupNameParam, farmBeatsResourceNameParam, options) - newListByFarmBeatsPager = &resp - e.newListByFarmBeatsPager.add(req, newListByFarmBeatsPager) - server.PagerResponderInjectNextLinks(newListByFarmBeatsPager, req, func(page *armagrifood.ExtensionsClientListByFarmBeatsResponse, createLink func() string) { + resp := e.srv.NewListByDataManagerForAgriculturePager(resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, options) + newListByDataManagerForAgriculturePager = &resp + e.newListByDataManagerForAgriculturePager.add(req, newListByDataManagerForAgriculturePager) + server.PagerResponderInjectNextLinks(newListByDataManagerForAgriculturePager, req, func(page *armagrifood.ExtensionsClientListByDataManagerForAgricultureResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } - resp, err := server.PagerResponderNext(newListByFarmBeatsPager, req) + resp, err := server.PagerResponderNext(newListByDataManagerForAgriculturePager, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK}, resp.StatusCode) { - e.newListByFarmBeatsPager.remove(req) + e.newListByDataManagerForAgriculturePager.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - if !server.PagerResponderMore(newListByFarmBeatsPager) { - e.newListByFarmBeatsPager.remove(req) - } - return resp, nil -} - -func (e *ExtensionsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { - if e.srv.Update == nil { - return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) - if err != nil { - return nil, err - } - extensionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionId")]) - if err != nil { - return nil, err - } - respr, errRespr := e.srv.Update(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, extensionIDParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Extension, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListByDataManagerForAgriculturePager) { + e.newListByDataManagerForAgriculturePager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/operationresults_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/operationresults_server.go new file mode 100644 index 000000000000..e22f0d383f10 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/operationresults_server.go @@ -0,0 +1,100 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" + "net/http" + "net/url" + "regexp" +) + +// OperationResultsServer is a fake server for instances of the armagrifood.OperationResultsClient type. +type OperationResultsServer struct { + // Get is the fake for method OperationResultsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, locations string, operationResultsID string, options *armagrifood.OperationResultsClientGetOptions) (resp azfake.Responder[armagrifood.OperationResultsClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationResultsServerTransport creates a new instance of OperationResultsServerTransport with the provided implementation. +// The returned OperationResultsServerTransport instance is connected to an instance of armagrifood.OperationResultsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationResultsServerTransport(srv *OperationResultsServer) *OperationResultsServerTransport { + return &OperationResultsServerTransport{srv: srv} +} + +// OperationResultsServerTransport connects instances of armagrifood.OperationResultsClient to instances of OperationResultsServer. +// Don't use this type directly, use NewOperationResultsServerTransport instead. +type OperationResultsServerTransport struct { + srv *OperationResultsServer +} + +// Do implements the policy.Transporter interface for OperationResultsServerTransport. +func (o *OperationResultsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationResultsClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationResultsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationsParam, err := url.PathUnescape(matches[regex.SubexpIndex("locations")]) + if err != nil { + return nil, err + } + operationResultsIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationResultsId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), locationsParam, operationResultsIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ArmAsyncOperation, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/privateendpointconnections_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/privateendpointconnections_server.go index 0b78ad9620cf..1c5ca7125d3e 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/privateendpointconnections_server.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/privateendpointconnections_server.go @@ -25,19 +25,19 @@ import ( type PrivateEndpointConnectionsServer struct { // CreateOrUpdate is the fake for method PrivateEndpointConnectionsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK - CreateOrUpdate func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, body armagrifood.PrivateEndpointConnection, options *armagrifood.PrivateEndpointConnectionsClientCreateOrUpdateOptions) (resp azfake.Responder[armagrifood.PrivateEndpointConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, request armagrifood.PrivateEndpointConnection, options *armagrifood.PrivateEndpointConnectionsClientCreateOrUpdateOptions) (resp azfake.Responder[armagrifood.PrivateEndpointConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // BeginDelete is the fake for method PrivateEndpointConnectionsClient.BeginDelete // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, options *armagrifood.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armagrifood.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + BeginDelete func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, options *armagrifood.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armagrifood.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) // Get is the fake for method PrivateEndpointConnectionsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, options *armagrifood.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armagrifood.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, options *armagrifood.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armagrifood.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) - // NewListByResourcePager is the fake for method PrivateEndpointConnectionsClient.NewListByResourcePager + // ListByResource is the fake for method PrivateEndpointConnectionsClient.ListByResource // HTTP status codes to indicate success: http.StatusOK - NewListByResourcePager func(resourceGroupName string, farmBeatsResourceName string, options *armagrifood.PrivateEndpointConnectionsClientListByResourceOptions) (resp azfake.PagerResponder[armagrifood.PrivateEndpointConnectionsClientListByResourceResponse]) + ListByResource func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *armagrifood.PrivateEndpointConnectionsClientListByResourceOptions) (resp azfake.Responder[armagrifood.PrivateEndpointConnectionsClientListByResourceResponse], errResp azfake.ErrorResponder) } // NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. @@ -45,18 +45,16 @@ type PrivateEndpointConnectionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { return &PrivateEndpointConnectionsServerTransport{ - srv: srv, - beginDelete: newTracker[azfake.PollerResponder[armagrifood.PrivateEndpointConnectionsClientDeleteResponse]](), - newListByResourcePager: newTracker[azfake.PagerResponder[armagrifood.PrivateEndpointConnectionsClientListByResourceResponse]](), + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armagrifood.PrivateEndpointConnectionsClientDeleteResponse]](), } } // PrivateEndpointConnectionsServerTransport connects instances of armagrifood.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. // Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. type PrivateEndpointConnectionsServerTransport struct { - srv *PrivateEndpointConnectionsServer - beginDelete *tracker[azfake.PollerResponder[armagrifood.PrivateEndpointConnectionsClientDeleteResponse]] - newListByResourcePager *tracker[azfake.PagerResponder[armagrifood.PrivateEndpointConnectionsClientListByResourceResponse]] + srv *PrivateEndpointConnectionsServer + beginDelete *tracker[azfake.PollerResponder[armagrifood.PrivateEndpointConnectionsClientDeleteResponse]] } // Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. @@ -77,8 +75,8 @@ func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http resp, err = p.dispatchBeginDelete(req) case "PrivateEndpointConnectionsClient.Get": resp, err = p.dispatchGet(req) - case "PrivateEndpointConnectionsClient.NewListByResourcePager": - resp, err = p.dispatchNewListByResourcePager(req) + case "PrivateEndpointConnectionsClient.ListByResource": + resp, err = p.dispatchListByResource(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -94,7 +92,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchCreateOrUpdate(req * if p.srv.CreateOrUpdate == nil { return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -108,7 +106,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchCreateOrUpdate(req * if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -116,7 +114,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchCreateOrUpdate(req * if err != nil { return nil, err } - respr, errRespr := p.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, privateEndpointConnectionNameParam, body, nil) + respr, errRespr := p.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, privateEndpointConnectionNameParam, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -137,7 +135,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *htt } beginDelete := p.beginDelete.get(req) if beginDelete == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -147,7 +145,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *htt if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -155,7 +153,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *htt if err != nil { return nil, err } - respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, privateEndpointConnectionNameParam, nil) + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, privateEndpointConnectionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -183,7 +181,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques if p.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -193,7 +191,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -201,7 +199,7 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques if err != nil { return nil, err } - respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, privateEndpointConnectionNameParam, nil) + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, privateEndpointConnectionNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -216,40 +214,35 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques return resp, nil } -func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListByResourcePager(req *http.Request) (*http.Response, error) { - if p.srv.NewListByResourcePager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByResourcePager not implemented")} +func (p *PrivateEndpointConnectionsServerTransport) dispatchListByResource(req *http.Request) (*http.Response, error) { + if p.srv.ListByResource == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByResource not implemented")} } - newListByResourcePager := p.newListByResourcePager.get(req) - if newListByResourcePager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) - if err != nil { - return nil, err - } - resp := p.srv.NewListByResourcePager(resourceGroupNameParam, farmBeatsResourceNameParam, nil) - newListByResourcePager = &resp - p.newListByResourcePager.add(req, newListByResourcePager) + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp, err := server.PagerResponderNext(newListByResourcePager, req) + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - p.newListByResourcePager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ListByResource(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr } - if !server.PagerResponderMore(newListByResourcePager) { - p.newListByResourcePager.remove(req) + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrivateEndpointConnectionListResult, req) + if err != nil { + return nil, err } return resp, nil } diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/privatelinkresources_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/privatelinkresources_server.go index ef3ddc205b9a..eb85802f626d 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/privatelinkresources_server.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/privatelinkresources_server.go @@ -25,28 +25,24 @@ import ( type PrivateLinkResourcesServer struct { // Get is the fake for method PrivateLinkResourcesClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, subResourceName string, options *armagrifood.PrivateLinkResourcesClientGetOptions) (resp azfake.Responder[armagrifood.PrivateLinkResourcesClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, subResourceName string, options *armagrifood.PrivateLinkResourcesClientGetOptions) (resp azfake.Responder[armagrifood.PrivateLinkResourcesClientGetResponse], errResp azfake.ErrorResponder) - // NewListByResourcePager is the fake for method PrivateLinkResourcesClient.NewListByResourcePager + // ListByResource is the fake for method PrivateLinkResourcesClient.ListByResource // HTTP status codes to indicate success: http.StatusOK - NewListByResourcePager func(resourceGroupName string, farmBeatsResourceName string, options *armagrifood.PrivateLinkResourcesClientListByResourceOptions) (resp azfake.PagerResponder[armagrifood.PrivateLinkResourcesClientListByResourceResponse]) + ListByResource func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *armagrifood.PrivateLinkResourcesClientListByResourceOptions) (resp azfake.Responder[armagrifood.PrivateLinkResourcesClientListByResourceResponse], errResp azfake.ErrorResponder) } // NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. // The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armagrifood.PrivateLinkResourcesClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { - return &PrivateLinkResourcesServerTransport{ - srv: srv, - newListByResourcePager: newTracker[azfake.PagerResponder[armagrifood.PrivateLinkResourcesClientListByResourceResponse]](), - } + return &PrivateLinkResourcesServerTransport{srv: srv} } // PrivateLinkResourcesServerTransport connects instances of armagrifood.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. // Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. type PrivateLinkResourcesServerTransport struct { - srv *PrivateLinkResourcesServer - newListByResourcePager *tracker[azfake.PagerResponder[armagrifood.PrivateLinkResourcesClientListByResourceResponse]] + srv *PrivateLinkResourcesServer } // Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. @@ -63,8 +59,8 @@ func (p *PrivateLinkResourcesServerTransport) Do(req *http.Request) (*http.Respo switch method { case "PrivateLinkResourcesClient.Get": resp, err = p.dispatchGet(req) - case "PrivateLinkResourcesClient.NewListByResourcePager": - resp, err = p.dispatchNewListByResourcePager(req) + case "PrivateLinkResourcesClient.ListByResource": + resp, err = p.dispatchListByResource(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -80,7 +76,7 @@ func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*h if p.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { @@ -90,7 +86,7 @@ func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*h if err != nil { return nil, err } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } @@ -98,7 +94,7 @@ func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*h if err != nil { return nil, err } - respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, farmBeatsResourceNameParam, subResourceNameParam, nil) + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, subResourceNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -113,40 +109,35 @@ func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*h return resp, nil } -func (p *PrivateLinkResourcesServerTransport) dispatchNewListByResourcePager(req *http.Request) (*http.Response, error) { - if p.srv.NewListByResourcePager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByResourcePager not implemented")} - } - newListByResourcePager := p.newListByResourcePager.get(req) - if newListByResourcePager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - farmBeatsResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("farmBeatsResourceName")]) - if err != nil { - return nil, err - } - resp := p.srv.NewListByResourcePager(resourceGroupNameParam, farmBeatsResourceNameParam, nil) - newListByResourcePager = &resp - p.newListByResourcePager.add(req, newListByResourcePager) - } - resp, err := server.PagerResponderNext(newListByResourcePager, req) +func (p *PrivateLinkResourcesServerTransport) dispatchListByResource(req *http.Request) (*http.Response, error) { + if p.srv.ListByResource == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByResource not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - p.newListByResourcePager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + respr, errRespr := p.srv.ListByResource(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr } - if !server.PagerResponderMore(newListByResourcePager) { - p.newListByResourcePager.remove(req) + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrivateLinkResourceListResult, req) + if err != nil { + return nil, err } return resp, nil } diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/server_factory.go b/sdk/resourcemanager/agrifood/armagrifood/fake/server_factory.go index 980a84cdd5ab..dcd873414c71 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/server_factory.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/server_factory.go @@ -19,13 +19,17 @@ import ( // ServerFactory is a fake server for instances of the armagrifood.ClientFactory type. type ServerFactory struct { - ExtensionsServer ExtensionsServer - FarmBeatsExtensionsServer FarmBeatsExtensionsServer - FarmBeatsModelsServer FarmBeatsModelsServer - LocationsServer LocationsServer - OperationsServer OperationsServer - PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer - PrivateLinkResourcesServer PrivateLinkResourcesServer + CheckNameAvailabilityServer CheckNameAvailabilityServer + DataConnectorsServer DataConnectorsServer + DataManagerForAgricultureExtensionsServer DataManagerForAgricultureExtensionsServer + DataManagerForAgricultureResourcesServer DataManagerForAgricultureResourcesServer + ExtensionsServer ExtensionsServer + OperationResultsServer OperationResultsServer + OperationsServer OperationsServer + PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer + PrivateLinkResourcesServer PrivateLinkResourcesServer + SolutionsServer SolutionsServer + SolutionsDiscoverabilityServer SolutionsDiscoverabilityServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -40,15 +44,19 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armagrifood.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trExtensionsServer *ExtensionsServerTransport - trFarmBeatsExtensionsServer *FarmBeatsExtensionsServerTransport - trFarmBeatsModelsServer *FarmBeatsModelsServerTransport - trLocationsServer *LocationsServerTransport - trOperationsServer *OperationsServerTransport - trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport - trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport + srv *ServerFactory + trMu sync.Mutex + trCheckNameAvailabilityServer *CheckNameAvailabilityServerTransport + trDataConnectorsServer *DataConnectorsServerTransport + trDataManagerForAgricultureExtensionsServer *DataManagerForAgricultureExtensionsServerTransport + trDataManagerForAgricultureResourcesServer *DataManagerForAgricultureResourcesServerTransport + trExtensionsServer *ExtensionsServerTransport + trOperationResultsServer *OperationResultsServerTransport + trOperationsServer *OperationsServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport + trSolutionsServer *SolutionsServerTransport + trSolutionsDiscoverabilityServer *SolutionsDiscoverabilityServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -64,22 +72,34 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { + case "CheckNameAvailabilityClient": + initServer(s, &s.trCheckNameAvailabilityServer, func() *CheckNameAvailabilityServerTransport { + return NewCheckNameAvailabilityServerTransport(&s.srv.CheckNameAvailabilityServer) + }) + resp, err = s.trCheckNameAvailabilityServer.Do(req) + case "DataConnectorsClient": + initServer(s, &s.trDataConnectorsServer, func() *DataConnectorsServerTransport { + return NewDataConnectorsServerTransport(&s.srv.DataConnectorsServer) + }) + resp, err = s.trDataConnectorsServer.Do(req) + case "DataManagerForAgricultureExtensionsClient": + initServer(s, &s.trDataManagerForAgricultureExtensionsServer, func() *DataManagerForAgricultureExtensionsServerTransport { + return NewDataManagerForAgricultureExtensionsServerTransport(&s.srv.DataManagerForAgricultureExtensionsServer) + }) + resp, err = s.trDataManagerForAgricultureExtensionsServer.Do(req) + case "DataManagerForAgricultureResourcesClient": + initServer(s, &s.trDataManagerForAgricultureResourcesServer, func() *DataManagerForAgricultureResourcesServerTransport { + return NewDataManagerForAgricultureResourcesServerTransport(&s.srv.DataManagerForAgricultureResourcesServer) + }) + resp, err = s.trDataManagerForAgricultureResourcesServer.Do(req) case "ExtensionsClient": initServer(s, &s.trExtensionsServer, func() *ExtensionsServerTransport { return NewExtensionsServerTransport(&s.srv.ExtensionsServer) }) resp, err = s.trExtensionsServer.Do(req) - case "FarmBeatsExtensionsClient": - initServer(s, &s.trFarmBeatsExtensionsServer, func() *FarmBeatsExtensionsServerTransport { - return NewFarmBeatsExtensionsServerTransport(&s.srv.FarmBeatsExtensionsServer) - }) - resp, err = s.trFarmBeatsExtensionsServer.Do(req) - case "FarmBeatsModelsClient": - initServer(s, &s.trFarmBeatsModelsServer, func() *FarmBeatsModelsServerTransport { - return NewFarmBeatsModelsServerTransport(&s.srv.FarmBeatsModelsServer) + case "OperationResultsClient": + initServer(s, &s.trOperationResultsServer, func() *OperationResultsServerTransport { + return NewOperationResultsServerTransport(&s.srv.OperationResultsServer) }) - resp, err = s.trFarmBeatsModelsServer.Do(req) - case "LocationsClient": - initServer(s, &s.trLocationsServer, func() *LocationsServerTransport { return NewLocationsServerTransport(&s.srv.LocationsServer) }) - resp, err = s.trLocationsServer.Do(req) + resp, err = s.trOperationResultsServer.Do(req) case "OperationsClient": initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) resp, err = s.trOperationsServer.Do(req) @@ -93,6 +113,14 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) }) resp, err = s.trPrivateLinkResourcesServer.Do(req) + case "SolutionsClient": + initServer(s, &s.trSolutionsServer, func() *SolutionsServerTransport { return NewSolutionsServerTransport(&s.srv.SolutionsServer) }) + resp, err = s.trSolutionsServer.Do(req) + case "SolutionsDiscoverabilityClient": + initServer(s, &s.trSolutionsDiscoverabilityServer, func() *SolutionsDiscoverabilityServerTransport { + return NewSolutionsDiscoverabilityServerTransport(&s.srv.SolutionsDiscoverabilityServer) + }) + resp, err = s.trSolutionsDiscoverabilityServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/solutions_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/solutions_server.go new file mode 100644 index 000000000000..e946ac07a6b0 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/solutions_server.go @@ -0,0 +1,368 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" + "net/http" + "net/url" + "reflect" + "regexp" + "strconv" + "time" +) + +// SolutionsServer is a fake server for instances of the armagrifood.SolutionsClient type. +type SolutionsServer struct { + // CreateOrUpdate is the fake for method SolutionsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *armagrifood.SolutionsClientCreateOrUpdateOptions) (resp azfake.Responder[armagrifood.SolutionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method SolutionsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *armagrifood.SolutionsClientDeleteOptions) (resp azfake.Responder[armagrifood.SolutionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SolutionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *armagrifood.SolutionsClientGetOptions) (resp azfake.Responder[armagrifood.SolutionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SolutionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, dataManagerForAgricultureResourceName string, options *armagrifood.SolutionsClientListOptions) (resp azfake.PagerResponder[armagrifood.SolutionsClientListResponse]) +} + +// NewSolutionsServerTransport creates a new instance of SolutionsServerTransport with the provided implementation. +// The returned SolutionsServerTransport instance is connected to an instance of armagrifood.SolutionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSolutionsServerTransport(srv *SolutionsServer) *SolutionsServerTransport { + return &SolutionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armagrifood.SolutionsClientListResponse]](), + } +} + +// SolutionsServerTransport connects instances of armagrifood.SolutionsClient to instances of SolutionsServer. +// Don't use this type directly, use NewSolutionsServerTransport instead. +type SolutionsServerTransport struct { + srv *SolutionsServer + newListPager *tracker[azfake.PagerResponder[armagrifood.SolutionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for SolutionsServerTransport. +func (s *SolutionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SolutionsClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SolutionsClient.Delete": + resp, err = s.dispatchDelete(req) + case "SolutionsClient.Get": + resp, err = s.dispatchGet(req) + case "SolutionsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SolutionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/solutions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armagrifood.Solution](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + solutionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("solutionId")]) + if err != nil { + return nil, err + } + var options *armagrifood.SolutionsClientCreateOrUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armagrifood.SolutionsClientCreateOrUpdateOptions{ + RequestBody: &body, + } + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, solutionIDParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Solution, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SolutionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/solutions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + solutionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("solutionId")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, solutionIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SolutionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/solutions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + solutionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("solutionId")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, solutionIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Solution, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SolutionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AgFoodPlatform/farmBeats/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/solutions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataManagerForAgricultureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureResourceName")]) + if err != nil { + return nil, err + } + solutionIDsEscaped := qp["solutionIds"] + solutionIDsParam := make([]string, len(solutionIDsEscaped)) + for i, v := range solutionIDsEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + solutionIDsParam[i] = u + } + iDsEscaped := qp["ids"] + iDsParam := make([]string, len(iDsEscaped)) + for i, v := range iDsEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + iDsParam[i] = u + } + namesEscaped := qp["names"] + namesParam := make([]string, len(namesEscaped)) + for i, v := range namesEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + namesParam[i] = u + } + propertyFiltersEscaped := qp["propertyFilters"] + propertyFiltersParam := make([]string, len(propertyFiltersEscaped)) + for i, v := range propertyFiltersEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + propertyFiltersParam[i] = u + } + statusesEscaped := qp["statuses"] + statusesParam := make([]string, len(statusesEscaped)) + for i, v := range statusesEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + statusesParam[i] = u + } + minCreatedDateTimeUnescaped, err := url.QueryUnescape(qp.Get("minCreatedDateTime")) + if err != nil { + return nil, err + } + minCreatedDateTimeParam, err := parseOptional(minCreatedDateTimeUnescaped, func(v string) (time.Time, error) { return time.Parse(time.RFC3339Nano, v) }) + if err != nil { + return nil, err + } + maxCreatedDateTimeUnescaped, err := url.QueryUnescape(qp.Get("maxCreatedDateTime")) + if err != nil { + return nil, err + } + maxCreatedDateTimeParam, err := parseOptional(maxCreatedDateTimeUnescaped, func(v string) (time.Time, error) { return time.Parse(time.RFC3339Nano, v) }) + if err != nil { + return nil, err + } + minLastModifiedDateTimeUnescaped, err := url.QueryUnescape(qp.Get("minLastModifiedDateTime")) + if err != nil { + return nil, err + } + minLastModifiedDateTimeParam, err := parseOptional(minLastModifiedDateTimeUnescaped, func(v string) (time.Time, error) { return time.Parse(time.RFC3339Nano, v) }) + if err != nil { + return nil, err + } + maxLastModifiedDateTimeUnescaped, err := url.QueryUnescape(qp.Get("maxLastModifiedDateTime")) + if err != nil { + return nil, err + } + maxLastModifiedDateTimeParam, err := parseOptional(maxLastModifiedDateTimeUnescaped, func(v string) (time.Time, error) { return time.Parse(time.RFC3339Nano, v) }) + if err != nil { + return nil, err + } + maxPageSizeUnescaped, err := url.QueryUnescape(qp.Get("$maxPageSize")) + if err != nil { + return nil, err + } + maxPageSizeParam, err := parseOptional(maxPageSizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + var options *armagrifood.SolutionsClientListOptions + if len(solutionIDsParam) > 0 || len(iDsParam) > 0 || len(namesParam) > 0 || len(propertyFiltersParam) > 0 || len(statusesParam) > 0 || minCreatedDateTimeParam != nil || maxCreatedDateTimeParam != nil || minLastModifiedDateTimeParam != nil || maxLastModifiedDateTimeParam != nil || maxPageSizeParam != nil || skipTokenParam != nil { + options = &armagrifood.SolutionsClientListOptions{ + SolutionIDs: solutionIDsParam, + IDs: iDsParam, + Names: namesParam, + PropertyFilters: propertyFiltersParam, + Statuses: statusesParam, + MinCreatedDateTime: minCreatedDateTimeParam, + MaxCreatedDateTime: maxCreatedDateTimeParam, + MinLastModifiedDateTime: minLastModifiedDateTimeParam, + MaxLastModifiedDateTime: maxLastModifiedDateTimeParam, + MaxPageSize: maxPageSizeParam, + SkipToken: skipTokenParam, + } + } + resp := s.srv.NewListPager(resourceGroupNameParam, dataManagerForAgricultureResourceNameParam, options) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armagrifood.SolutionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/solutionsdiscoverability_server.go b/sdk/resourcemanager/agrifood/armagrifood/fake/solutionsdiscoverability_server.go new file mode 100644 index 000000000000..1e55ff32520f --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/solutionsdiscoverability_server.go @@ -0,0 +1,176 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// SolutionsDiscoverabilityServer is a fake server for instances of the armagrifood.SolutionsDiscoverabilityClient type. +type SolutionsDiscoverabilityServer struct { + // Get is the fake for method SolutionsDiscoverabilityClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, dataManagerForAgricultureSolutionID string, options *armagrifood.SolutionsDiscoverabilityClientGetOptions) (resp azfake.Responder[armagrifood.SolutionsDiscoverabilityClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SolutionsDiscoverabilityClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armagrifood.SolutionsDiscoverabilityClientListOptions) (resp azfake.PagerResponder[armagrifood.SolutionsDiscoverabilityClientListResponse]) +} + +// NewSolutionsDiscoverabilityServerTransport creates a new instance of SolutionsDiscoverabilityServerTransport with the provided implementation. +// The returned SolutionsDiscoverabilityServerTransport instance is connected to an instance of armagrifood.SolutionsDiscoverabilityClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSolutionsDiscoverabilityServerTransport(srv *SolutionsDiscoverabilityServer) *SolutionsDiscoverabilityServerTransport { + return &SolutionsDiscoverabilityServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armagrifood.SolutionsDiscoverabilityClientListResponse]](), + } +} + +// SolutionsDiscoverabilityServerTransport connects instances of armagrifood.SolutionsDiscoverabilityClient to instances of SolutionsDiscoverabilityServer. +// Don't use this type directly, use NewSolutionsDiscoverabilityServerTransport instead. +type SolutionsDiscoverabilityServerTransport struct { + srv *SolutionsDiscoverabilityServer + newListPager *tracker[azfake.PagerResponder[armagrifood.SolutionsDiscoverabilityClientListResponse]] +} + +// Do implements the policy.Transporter interface for SolutionsDiscoverabilityServerTransport. +func (s *SolutionsDiscoverabilityServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SolutionsDiscoverabilityClient.Get": + resp, err = s.dispatchGet(req) + case "SolutionsDiscoverabilityClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SolutionsDiscoverabilityServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.AgFoodPlatform/farmBeatsSolutionDefinitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + dataManagerForAgricultureSolutionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataManagerForAgricultureSolutionId")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), dataManagerForAgricultureSolutionIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataManagerForAgricultureSolution, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SolutionsDiscoverabilityServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + qp := req.URL.Query() + farmBeatsSolutionIDsEscaped := qp["farmBeatsSolutionIds"] + farmBeatsSolutionIDsParam := make([]string, len(farmBeatsSolutionIDsEscaped)) + for i, v := range farmBeatsSolutionIDsEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + farmBeatsSolutionIDsParam[i] = u + } + farmBeatsSolutionNamesEscaped := qp["farmBeatsSolutionNames"] + farmBeatsSolutionNamesParam := make([]string, len(farmBeatsSolutionNamesEscaped)) + for i, v := range farmBeatsSolutionNamesEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + farmBeatsSolutionNamesParam[i] = u + } + maxPageSizeUnescaped, err := url.QueryUnescape(qp.Get("$maxPageSize")) + if err != nil { + return nil, err + } + maxPageSizeParam, err := parseOptional(maxPageSizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armagrifood.SolutionsDiscoverabilityClientListOptions + if len(farmBeatsSolutionIDsParam) > 0 || len(farmBeatsSolutionNamesParam) > 0 || maxPageSizeParam != nil { + options = &armagrifood.SolutionsDiscoverabilityClientListOptions{ + FarmBeatsSolutionIDs: farmBeatsSolutionIDsParam, + FarmBeatsSolutionNames: farmBeatsSolutionNamesParam, + MaxPageSize: maxPageSizeParam, + } + } + resp := s.srv.NewListPager(options) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armagrifood.SolutionsDiscoverabilityClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/fake/time_rfc3339.go b/sdk/resourcemanager/agrifood/armagrifood/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/fake/time_rfc3339.go +++ b/sdk/resourcemanager/agrifood/armagrifood/fake/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client.go b/sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client.go deleted file mode 100644 index 8f7925ba083f..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client.go +++ /dev/null @@ -1,171 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armagrifood - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// FarmBeatsExtensionsClient contains the methods for the FarmBeatsExtensions group. -// Don't use this type directly, use NewFarmBeatsExtensionsClient() instead. -type FarmBeatsExtensionsClient struct { - internal *arm.Client -} - -// NewFarmBeatsExtensionsClient creates a new instance of FarmBeatsExtensionsClient with the specified values. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewFarmBeatsExtensionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*FarmBeatsExtensionsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &FarmBeatsExtensionsClient{ - internal: cl, - } - return client, nil -} - -// Get - Get farmBeats extension. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -// - farmBeatsExtensionID - farmBeatsExtensionId to be queried. -// - options - FarmBeatsExtensionsClientGetOptions contains the optional parameters for the FarmBeatsExtensionsClient.Get method. -func (client *FarmBeatsExtensionsClient) Get(ctx context.Context, farmBeatsExtensionID string, options *FarmBeatsExtensionsClientGetOptions) (FarmBeatsExtensionsClientGetResponse, error) { - var err error - const operationName = "FarmBeatsExtensionsClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, farmBeatsExtensionID, options) - if err != nil { - return FarmBeatsExtensionsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return FarmBeatsExtensionsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return FarmBeatsExtensionsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *FarmBeatsExtensionsClient) getCreateRequest(ctx context.Context, farmBeatsExtensionID string, options *FarmBeatsExtensionsClientGetOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions/{farmBeatsExtensionId}" - if farmBeatsExtensionID == "" { - return nil, errors.New("parameter farmBeatsExtensionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsExtensionId}", url.PathEscape(farmBeatsExtensionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *FarmBeatsExtensionsClient) getHandleResponse(resp *http.Response) (FarmBeatsExtensionsClientGetResponse, error) { - result := FarmBeatsExtensionsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.FarmBeatsExtension); err != nil { - return FarmBeatsExtensionsClientGetResponse{}, err - } - return result, nil -} - -// NewListPager - Get list of farmBeats extension. -// -// Generated from API version 2021-09-01-preview -// - options - FarmBeatsExtensionsClientListOptions contains the optional parameters for the FarmBeatsExtensionsClient.NewListPager -// method. -func (client *FarmBeatsExtensionsClient) NewListPager(options *FarmBeatsExtensionsClientListOptions) *runtime.Pager[FarmBeatsExtensionsClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[FarmBeatsExtensionsClientListResponse]{ - More: func(page FarmBeatsExtensionsClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *FarmBeatsExtensionsClientListResponse) (FarmBeatsExtensionsClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FarmBeatsExtensionsClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) - }, nil) - if err != nil { - return FarmBeatsExtensionsClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *FarmBeatsExtensionsClient) listCreateRequest(ctx context.Context, options *FarmBeatsExtensionsClientListOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions" - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - if options != nil && options.FarmBeatsExtensionIDs != nil { - for _, qv := range options.FarmBeatsExtensionIDs { - reqQP.Add("farmBeatsExtensionIds", qv) - } - } - if options != nil && options.FarmBeatsExtensionNames != nil { - for _, qv := range options.FarmBeatsExtensionNames { - reqQP.Add("farmBeatsExtensionNames", qv) - } - } - if options != nil && options.ExtensionCategories != nil { - for _, qv := range options.ExtensionCategories { - reqQP.Add("extensionCategories", qv) - } - } - if options != nil && options.PublisherIDs != nil { - for _, qv := range options.PublisherIDs { - reqQP.Add("publisherIds", qv) - } - } - if options != nil && options.MaxPageSize != nil { - reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) - } - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *FarmBeatsExtensionsClient) listHandleResponse(resp *http.Response) (FarmBeatsExtensionsClientListResponse, error) { - result := FarmBeatsExtensionsClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.FarmBeatsExtensionListResponse); err != nil { - return FarmBeatsExtensionsClientListResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client_example_test.go b/sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client_example_test.go deleted file mode 100644 index 525be58124c7..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsextensions_client_example_test.go +++ /dev/null @@ -1,503 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armagrifood_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsExtensions_List.json -func ExampleFarmBeatsExtensionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFarmBeatsExtensionsClient().NewListPager(&armagrifood.FarmBeatsExtensionsClientListOptions{FarmBeatsExtensionIDs: []string{}, - FarmBeatsExtensionNames: []string{}, - ExtensionCategories: []string{}, - PublisherIDs: []string{}, - MaxPageSize: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.FarmBeatsExtensionListResponse = armagrifood.FarmBeatsExtensionListResponse{ - // Value: []*armagrifood.FarmBeatsExtension{ - // { - // Name: to.Ptr("DTN.ContentServices"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions"), - // ID: to.Ptr("Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions/DTN.ContentServices"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-12T15:28:06.000Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-12T15:30:01.000Z"); return t}()), - // }, - // Properties: &armagrifood.FarmBeatsExtensionProperties{ - // DetailedInformation: []*armagrifood.DetailedInformation{ - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("days"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetDailyObservations"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("sunrise"), - // to.Ptr("sunset"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("maxTemperature"), - // to.Ptr("minTemperature"), - // to.Ptr("avgHeatIndex"), - // to.Ptr("maxHeatIndex"), - // to.Ptr("minHeatIndex"), - // to.Ptr("maxWindChill"), - // to.Ptr("minWindChill"), - // to.Ptr("maxFeelsLike"), - // to.Ptr("minFeelsLike"), - // to.Ptr("avgFeelsLike"), - // to.Ptr("maxWindSpeed"), - // to.Ptr("avgWetBulbGlobeTemp"), - // to.Ptr("maxWetBulbGlobeTemp"), - // to.Ptr("minWetBulbGlobeTemp"), - // to.Ptr("minutesOfSunshine"), - // to.Ptr("cornHeatUnit"), - // to.Ptr("evapotranspiration")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("growingDegreeDay"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }, - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("hours"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetHourlyObservations"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("feelsLike"), - // to.Ptr("visibilityWeatherCode"), - // to.Ptr("visibilityWeatherDescription"), - // to.Ptr("minutesOfSunshine")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("visibility"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection"), - // to.Ptr("windGust")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }, - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("days"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetHourlyForecasts"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("feelsLike"), - // to.Ptr("visibilityWeatherCode"), - // to.Ptr("visibilityWeatherDescription"), - // to.Ptr("minutesOfSunshine")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("visibility"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection"), - // to.Ptr("windGust")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }, - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("days"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetDailyForecasts"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("sunrise"), - // to.Ptr("sunset"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("maxTemperature"), - // to.Ptr("minTemperature"), - // to.Ptr("avgHeatIndex"), - // to.Ptr("maxHeatIndex"), - // to.Ptr("minHeatIndex"), - // to.Ptr("maxWindChill"), - // to.Ptr("minWindChill"), - // to.Ptr("maxFeelsLike"), - // to.Ptr("minFeelsLike"), - // to.Ptr("avgFeelsLike"), - // to.Ptr("maxWindSpeed"), - // to.Ptr("avgWetBulbGlobeTemp"), - // to.Ptr("maxWetBulbGlobeTemp"), - // to.Ptr("minWetBulbGlobeTemp"), - // to.Ptr("minutesOfSunshine"), - // to.Ptr("cornHeatUnit"), - // to.Ptr("evapotranspiration")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("growingDegreeDay"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }}, - // ExtensionAPIDocsLink: to.Ptr("https://cs-docs.dtn.com/api/weather-observations-and-forecasts-rest-api/"), - // ExtensionAuthLink: to.Ptr("https://www.dtn.com/dtn-content-integration/"), - // ExtensionCategory: to.Ptr("Weather"), - // FarmBeatsExtensionID: to.Ptr("DTN.ContentServices"), - // FarmBeatsExtensionName: to.Ptr("DTN"), - // FarmBeatsExtensionVersion: to.Ptr("1.0"), - // PublisherID: to.Ptr("dtn"), - // TargetResourceType: to.Ptr("FarmBeats"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsExtensions_Get.json -func ExampleFarmBeatsExtensionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFarmBeatsExtensionsClient().Get(ctx, "DTN.ContentServices", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FarmBeatsExtension = armagrifood.FarmBeatsExtension{ - // Name: to.Ptr("DTN.ContentServices"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions"), - // ID: to.Ptr("Microsoft.AgFoodPlatform/farmBeatsExtensionDefinitions/DTN.ContentServices"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-12T15:28:06.000Z"); return t}()), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-12T15:30:01.000Z"); return t}()), - // }, - // Properties: &armagrifood.FarmBeatsExtensionProperties{ - // DetailedInformation: []*armagrifood.DetailedInformation{ - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("days"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetDailyObservations"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("sunrise"), - // to.Ptr("sunset"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("maxTemperature"), - // to.Ptr("minTemperature"), - // to.Ptr("avgHeatIndex"), - // to.Ptr("maxHeatIndex"), - // to.Ptr("minHeatIndex"), - // to.Ptr("maxWindChill"), - // to.Ptr("minWindChill"), - // to.Ptr("maxFeelsLike"), - // to.Ptr("minFeelsLike"), - // to.Ptr("avgFeelsLike"), - // to.Ptr("maxWindSpeed"), - // to.Ptr("avgWetBulbGlobeTemp"), - // to.Ptr("maxWetBulbGlobeTemp"), - // to.Ptr("minWetBulbGlobeTemp"), - // to.Ptr("minutesOfSunshine"), - // to.Ptr("cornHeatUnit"), - // to.Ptr("evapotranspiration")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("growingDegreeDay"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }, - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("hours"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetHourlyObservations"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("feelsLike"), - // to.Ptr("visibilityWeatherCode"), - // to.Ptr("visibilityWeatherDescription"), - // to.Ptr("minutesOfSunshine")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("visibility"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection"), - // to.Ptr("windGust")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }, - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("days"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetHourlyForecasts"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("feelsLike"), - // to.Ptr("visibilityWeatherCode"), - // to.Ptr("visibilityWeatherDescription"), - // to.Ptr("minutesOfSunshine")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("visibility"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection"), - // to.Ptr("windGust")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }, - // { - // APIInputParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("lat"), - // to.Ptr("lon"), - // to.Ptr("days"), - // to.Ptr("units"), - // to.Ptr("precision"), - // to.Ptr("sector")}, - // APIName: to.Ptr("GetDailyForecasts"), - // CustomParameters: []*string{ - // to.Ptr("stationId"), - // to.Ptr("stationLatitude"), - // to.Ptr("stationLongitude"), - // to.Ptr("timeZone"), - // to.Ptr("sunrise"), - // to.Ptr("sunset"), - // to.Ptr("weatherCode"), - // to.Ptr("weatherDescription"), - // to.Ptr("maxTemperature"), - // to.Ptr("minTemperature"), - // to.Ptr("avgHeatIndex"), - // to.Ptr("maxHeatIndex"), - // to.Ptr("minHeatIndex"), - // to.Ptr("maxWindChill"), - // to.Ptr("minWindChill"), - // to.Ptr("maxFeelsLike"), - // to.Ptr("minFeelsLike"), - // to.Ptr("avgFeelsLike"), - // to.Ptr("maxWindSpeed"), - // to.Ptr("avgWetBulbGlobeTemp"), - // to.Ptr("maxWetBulbGlobeTemp"), - // to.Ptr("minWetBulbGlobeTemp"), - // to.Ptr("minutesOfSunshine"), - // to.Ptr("cornHeatUnit"), - // to.Ptr("evapotranspiration")}, - // PlatformParameters: []*string{ - // to.Ptr("cloudCover"), - // to.Ptr("dewPoint"), - // to.Ptr("growingDegreeDay"), - // to.Ptr("precipitation"), - // to.Ptr("pressure"), - // to.Ptr("relativeHumidity"), - // to.Ptr("temperature"), - // to.Ptr("wetBulbTemperature"), - // to.Ptr("dateTime"), - // to.Ptr("windChill"), - // to.Ptr("windSpeed"), - // to.Ptr("windDirection")}, - // UnitsSupported: &armagrifood.UnitSystemsInfo{ - // Key: to.Ptr("units"), - // Values: []*string{ - // to.Ptr("us"), - // to.Ptr("si")}, - // }, - // }}, - // ExtensionAPIDocsLink: to.Ptr("https://cs-docs.dtn.com/api/weather-observations-and-forecasts-rest-api/"), - // ExtensionAuthLink: to.Ptr("https://www.dtn.com/dtn-content-integration/"), - // ExtensionCategory: to.Ptr("Weather"), - // FarmBeatsExtensionID: to.Ptr("DTN.ContentServices"), - // FarmBeatsExtensionName: to.Ptr("DTN"), - // FarmBeatsExtensionVersion: to.Ptr("1.0"), - // PublisherID: to.Ptr("dtn"), - // TargetResourceType: to.Ptr("FarmBeats"), - // }, - // } -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client.go b/sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client.go deleted file mode 100644 index 79213418a4be..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client.go +++ /dev/null @@ -1,510 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armagrifood - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strconv" - "strings" -) - -// FarmBeatsModelsClient contains the methods for the FarmBeatsModels group. -// Don't use this type directly, use NewFarmBeatsModelsClient() instead. -type FarmBeatsModelsClient struct { - internal *arm.Client - subscriptionID string -} - -// NewFarmBeatsModelsClient creates a new instance of FarmBeatsModelsClient with the specified values. -// - subscriptionID - The ID of the target subscription. -// - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. -func NewFarmBeatsModelsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FarmBeatsModelsClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &FarmBeatsModelsClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CreateOrUpdate - Create or update FarmBeats resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - body - FarmBeats resource create or update request object. -// - options - FarmBeatsModelsClientCreateOrUpdateOptions contains the optional parameters for the FarmBeatsModelsClient.CreateOrUpdate -// method. -func (client *FarmBeatsModelsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, body FarmBeats, options *FarmBeatsModelsClientCreateOrUpdateOptions) (FarmBeatsModelsClientCreateOrUpdateResponse, error) { - var err error - const operationName = "FarmBeatsModelsClient.CreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, body, options) - if err != nil { - return FarmBeatsModelsClientCreateOrUpdateResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return FarmBeatsModelsClientCreateOrUpdateResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return FarmBeatsModelsClientCreateOrUpdateResponse{}, err - } - resp, err := client.createOrUpdateHandleResponse(httpResp) - return resp, err -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *FarmBeatsModelsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, body FarmBeats, options *FarmBeatsModelsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { - return nil, err - } - return req, nil -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *FarmBeatsModelsClient) createOrUpdateHandleResponse(resp *http.Response) (FarmBeatsModelsClientCreateOrUpdateResponse, error) { - result := FarmBeatsModelsClientCreateOrUpdateResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.FarmBeats); err != nil { - return FarmBeatsModelsClientCreateOrUpdateResponse{}, err - } - return result, nil -} - -// Delete - Delete a FarmBeats resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - options - FarmBeatsModelsClientDeleteOptions contains the optional parameters for the FarmBeatsModelsClient.Delete method. -func (client *FarmBeatsModelsClient) Delete(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *FarmBeatsModelsClientDeleteOptions) (FarmBeatsModelsClientDeleteResponse, error) { - var err error - const operationName = "FarmBeatsModelsClient.Delete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, options) - if err != nil { - return FarmBeatsModelsClientDeleteResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return FarmBeatsModelsClientDeleteResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return FarmBeatsModelsClientDeleteResponse{}, err - } - return FarmBeatsModelsClientDeleteResponse{}, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *FarmBeatsModelsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *FarmBeatsModelsClientDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Get FarmBeats resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - options - FarmBeatsModelsClientGetOptions contains the optional parameters for the FarmBeatsModelsClient.Get method. -func (client *FarmBeatsModelsClient) Get(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *FarmBeatsModelsClientGetOptions) (FarmBeatsModelsClientGetResponse, error) { - var err error - const operationName = "FarmBeatsModelsClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, options) - if err != nil { - return FarmBeatsModelsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return FarmBeatsModelsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return FarmBeatsModelsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *FarmBeatsModelsClient) getCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *FarmBeatsModelsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *FarmBeatsModelsClient) getHandleResponse(resp *http.Response) (FarmBeatsModelsClientGetResponse, error) { - result := FarmBeatsModelsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.FarmBeats); err != nil { - return FarmBeatsModelsClientGetResponse{}, err - } - return result, nil -} - -// GetOperationResult - Get operationResults for a FarmBeats resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - operationResultsID - The operation results id. -// - options - FarmBeatsModelsClientGetOperationResultOptions contains the optional parameters for the FarmBeatsModelsClient.GetOperationResult -// method. -func (client *FarmBeatsModelsClient) GetOperationResult(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, operationResultsID string, options *FarmBeatsModelsClientGetOperationResultOptions) (FarmBeatsModelsClientGetOperationResultResponse, error) { - var err error - const operationName = "FarmBeatsModelsClient.GetOperationResult" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getOperationResultCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, operationResultsID, options) - if err != nil { - return FarmBeatsModelsClientGetOperationResultResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return FarmBeatsModelsClientGetOperationResultResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return FarmBeatsModelsClientGetOperationResultResponse{}, err - } - resp, err := client.getOperationResultHandleResponse(httpResp) - return resp, err -} - -// getOperationResultCreateRequest creates the GetOperationResult request. -func (client *FarmBeatsModelsClient) getOperationResultCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, operationResultsID string, options *FarmBeatsModelsClientGetOperationResultOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/operationResults/{operationResultsId}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) - if operationResultsID == "" { - return nil, errors.New("parameter operationResultsID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{operationResultsId}", url.PathEscape(operationResultsID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getOperationResultHandleResponse handles the GetOperationResult response. -func (client *FarmBeatsModelsClient) getOperationResultHandleResponse(resp *http.Response) (FarmBeatsModelsClientGetOperationResultResponse, error) { - result := FarmBeatsModelsClientGetOperationResultResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.ArmAsyncOperation); err != nil { - return FarmBeatsModelsClientGetOperationResultResponse{}, err - } - return result, nil -} - -// NewListByResourceGroupPager - Lists the FarmBeats instances for a resource group. -// -// Generated from API version 2021-09-01-preview -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - options - FarmBeatsModelsClientListByResourceGroupOptions contains the optional parameters for the FarmBeatsModelsClient.NewListByResourceGroupPager -// method. -func (client *FarmBeatsModelsClient) NewListByResourceGroupPager(resourceGroupName string, options *FarmBeatsModelsClientListByResourceGroupOptions) *runtime.Pager[FarmBeatsModelsClientListByResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[FarmBeatsModelsClientListByResourceGroupResponse]{ - More: func(page FarmBeatsModelsClientListByResourceGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *FarmBeatsModelsClientListByResourceGroupResponse) (FarmBeatsModelsClientListByResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FarmBeatsModelsClient.NewListByResourceGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - }, nil) - if err != nil { - return FarmBeatsModelsClientListByResourceGroupResponse{}, err - } - return client.listByResourceGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *FarmBeatsModelsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *FarmBeatsModelsClientListByResourceGroupOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - if options != nil && options.MaxPageSize != nil { - reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) - } - if options != nil && options.SkipToken != nil { - reqQP.Set("$skipToken", *options.SkipToken) - } - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByResourceGroupHandleResponse handles the ListByResourceGroup response. -func (client *FarmBeatsModelsClient) listByResourceGroupHandleResponse(resp *http.Response) (FarmBeatsModelsClientListByResourceGroupResponse, error) { - result := FarmBeatsModelsClientListByResourceGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.FarmBeatsListResponse); err != nil { - return FarmBeatsModelsClientListByResourceGroupResponse{}, err - } - return result, nil -} - -// NewListBySubscriptionPager - Lists the FarmBeats instances for a subscription. -// -// Generated from API version 2021-09-01-preview -// - options - FarmBeatsModelsClientListBySubscriptionOptions contains the optional parameters for the FarmBeatsModelsClient.NewListBySubscriptionPager -// method. -func (client *FarmBeatsModelsClient) NewListBySubscriptionPager(options *FarmBeatsModelsClientListBySubscriptionOptions) *runtime.Pager[FarmBeatsModelsClientListBySubscriptionResponse] { - return runtime.NewPager(runtime.PagingHandler[FarmBeatsModelsClientListBySubscriptionResponse]{ - More: func(page FarmBeatsModelsClientListBySubscriptionResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *FarmBeatsModelsClientListBySubscriptionResponse) (FarmBeatsModelsClientListBySubscriptionResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FarmBeatsModelsClient.NewListBySubscriptionPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listBySubscriptionCreateRequest(ctx, options) - }, nil) - if err != nil { - return FarmBeatsModelsClientListBySubscriptionResponse{}, err - } - return client.listBySubscriptionHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *FarmBeatsModelsClient) listBySubscriptionCreateRequest(ctx context.Context, options *FarmBeatsModelsClientListBySubscriptionOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/farmBeats" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - if options != nil && options.MaxPageSize != nil { - reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) - } - if options != nil && options.SkipToken != nil { - reqQP.Set("$skipToken", *options.SkipToken) - } - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listBySubscriptionHandleResponse handles the ListBySubscription response. -func (client *FarmBeatsModelsClient) listBySubscriptionHandleResponse(resp *http.Response) (FarmBeatsModelsClientListBySubscriptionResponse, error) { - result := FarmBeatsModelsClientListBySubscriptionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.FarmBeatsListResponse); err != nil { - return FarmBeatsModelsClientListBySubscriptionResponse{}, err - } - return result, nil -} - -// BeginUpdate - Update a FarmBeats resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - body - Request object. -// - options - FarmBeatsModelsClientBeginUpdateOptions contains the optional parameters for the FarmBeatsModelsClient.BeginUpdate -// method. -func (client *FarmBeatsModelsClient) BeginUpdate(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, body FarmBeatsUpdateRequestModel, options *FarmBeatsModelsClientBeginUpdateOptions) (*runtime.Poller[FarmBeatsModelsClientUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, farmBeatsResourceName, body, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FarmBeatsModelsClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FarmBeatsModelsClientUpdateResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Update - Update a FarmBeats resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2021-09-01-preview -func (client *FarmBeatsModelsClient) update(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, body FarmBeatsUpdateRequestModel, options *FarmBeatsModelsClientBeginUpdateOptions) (*http.Response, error) { - var err error - const operationName = "FarmBeatsModelsClient.BeginUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, body, options) - if err != nil { - return nil, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// updateCreateRequest creates the Update request. -func (client *FarmBeatsModelsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, body FarmBeatsUpdateRequestModel, options *FarmBeatsModelsClientBeginUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { - return nil, err - } - return req, nil -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client_example_test.go b/sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client_example_test.go deleted file mode 100644 index 8940f0f2b3de..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/farmbeatsmodels_client_example_test.go +++ /dev/null @@ -1,371 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armagrifood_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Get.json -func ExampleFarmBeatsModelsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFarmBeatsModelsClient().Get(ctx, "examples-rg", "examples-farmBeatsResourceName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FarmBeats = armagrifood.FarmBeats{ - // Name: to.Ptr("examples-farmBeatsResourceName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // Location: to.Ptr("eastus2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Properties: &armagrifood.FarmBeatsProperties{ - // InstanceURI: to.Ptr("https://examples-farmbeatsResourceName.eastus2.farmbeats.azure.net"), - // ProvisioningState: to.Ptr(armagrifood.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_CreateOrUpdate.json -func ExampleFarmBeatsModelsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFarmBeatsModelsClient().CreateOrUpdate(ctx, "examples-rg", "examples-farmbeatsResourceName", armagrifood.FarmBeats{ - Location: to.Ptr("eastus2"), - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FarmBeats = armagrifood.FarmBeats{ - // Name: to.Ptr("examples-farmbeatsResourceName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // Location: to.Ptr("eastus2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Properties: &armagrifood.FarmBeatsProperties{ - // InstanceURI: to.Ptr("https://examples-farmbeatsResourceName.eastus2.farmbeats.azure.net"), - // ProvisioningState: to.Ptr(armagrifood.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Update.json -func ExampleFarmBeatsModelsClient_BeginUpdate_farmBeatsModelsUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFarmBeatsModelsClient().BeginUpdate(ctx, "examples-rg", "examples-farmBeatsResourceName", armagrifood.FarmBeatsUpdateRequestModel{ - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FarmBeats = armagrifood.FarmBeats{ - // Name: to.Ptr("examples-farmBeatsResourceName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // Location: to.Ptr("eastus2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Properties: &armagrifood.FarmBeatsProperties{ - // InstanceURI: to.Ptr("https://examples-farmbeatsResourceName.eastus2.farmbeats.azure.net"), - // ProvisioningState: to.Ptr(armagrifood.ProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_UpdateWithSensor.json -func ExampleFarmBeatsModelsClient_BeginUpdate_farmBeatsModelsUpdateWithSensor() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewFarmBeatsModelsClient().BeginUpdate(ctx, "examples-rg", "examples-farmBeatsResourceName", armagrifood.FarmBeatsUpdateRequestModel{ - Identity: &armagrifood.Identity{ - Type: to.Ptr("SystemAssigned"), - }, - Properties: &armagrifood.FarmBeatsUpdateProperties{ - SensorIntegration: &armagrifood.SensorIntegration{ - Enabled: to.Ptr("True"), - }, - }, - Tags: map[string]*string{ - "key1": to.Ptr("value1"), - "key2": to.Ptr("value2"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.FarmBeats = armagrifood.FarmBeats{ - // Name: to.Ptr("examples-farmBeatsResourceName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // Location: to.Ptr("eastus2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Identity: &armagrifood.Identity{ - // Type: to.Ptr("SystemAssigned"), - // TenantID: to.Ptr("abcdefgh-86f1-41af-91ab-2d7cd011db47"), - // }, - // Properties: &armagrifood.FarmBeatsProperties{ - // InstanceURI: to.Ptr("https://examples-farmbeatsResourceName.eastus2.farmbeats.azure.net"), - // ProvisioningState: to.Ptr(armagrifood.ProvisioningStateSucceeded), - // SensorIntegration: &armagrifood.SensorIntegration{ - // Enabled: to.Ptr("True"), - // ProvisioningState: to.Ptr(armagrifood.ProvisioningStateSucceeded), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Delete.json -func ExampleFarmBeatsModelsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewFarmBeatsModelsClient().Delete(ctx, "examples-rg", "examples-farmBeatsResourceName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_ListBySubscription.json -func ExampleFarmBeatsModelsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFarmBeatsModelsClient().NewListBySubscriptionPager(&armagrifood.FarmBeatsModelsClientListBySubscriptionOptions{MaxPageSize: nil, - SkipToken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.FarmBeatsListResponse = armagrifood.FarmBeatsListResponse{ - // Value: []*armagrifood.FarmBeats{ - // { - // Name: to.Ptr("examples-farmBeatsResourceName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // Location: to.Ptr("eastus2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Properties: &armagrifood.FarmBeatsProperties{ - // InstanceURI: to.Ptr("https://examples-farmbeatsResourceName.eastus2.farmbeats.azure.net"), - // ProvisioningState: to.Ptr(armagrifood.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_ListByResourceGroup.json -func ExampleFarmBeatsModelsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewFarmBeatsModelsClient().NewListByResourceGroupPager("examples-rg", &armagrifood.FarmBeatsModelsClientListByResourceGroupOptions{MaxPageSize: nil, - SkipToken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.FarmBeatsListResponse = armagrifood.FarmBeatsListResponse{ - // Value: []*armagrifood.FarmBeats{ - // { - // Name: to.Ptr("examples-farmBeatsResourceName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName"), - // SystemData: &armagrifood.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // CreatedBy: to.Ptr("string"), - // CreatedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-01T01:01:01.107Z"); return t}()), - // LastModifiedBy: to.Ptr("string"), - // LastModifiedByType: to.Ptr(armagrifood.CreatedByTypeUser), - // }, - // Location: to.Ptr("eastus2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("value1"), - // "key2": to.Ptr("value2"), - // }, - // Properties: &armagrifood.FarmBeatsProperties{ - // InstanceURI: to.Ptr("https://examples-farmbeatsResourceName.eastus2.farmbeats.azure.net"), - // ProvisioningState: to.Ptr(armagrifood.ProvisioningStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_GetOperationResult.json -func ExampleFarmBeatsModelsClient_GetOperationResult() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewFarmBeatsModelsClient().GetOperationResult(ctx, "examples-rg", "examples-farmBeatsResourceName", "resource-provisioning-id-farmBeatsResourceName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ArmAsyncOperation = armagrifood.ArmAsyncOperation{ - // Status: to.Ptr("Succeeded"), - // } -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/go.mod b/sdk/resourcemanager/agrifood/armagrifood/go.mod index bdc90e441e1d..ff1bfc7c64f8 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/go.mod +++ b/sdk/resourcemanager/agrifood/armagrifood/go.mod @@ -2,20 +2,10 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifoo go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect - github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/google/uuid v1.3.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.21.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/agrifood/armagrifood/go.sum b/sdk/resourcemanager/agrifood/armagrifood/go.sum index 5228c81c4b02..520f1a7d9768 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/go.sum +++ b/sdk/resourcemanager/agrifood/armagrifood/go.sum @@ -1,31 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0 h1:sUFnFjzDUie80h24I7mrKtwCKgLY9L8h5Tp2x9+TWqk= github.com/Azure/azure-sdk-for-go/sdk/internal v1.6.0/go.mod h1:52JbnQTp15qg5mRkMBHwp0j0ZFwHJ42Sx3zVV5RE9p0= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= -github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/agrifood/armagrifood/interfaces.go b/sdk/resourcemanager/agrifood/armagrifood/interfaces.go new file mode 100644 index 000000000000..3e43c7a10071 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/interfaces.go @@ -0,0 +1,18 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +// AuthCredentialsClassification provides polymorphic access to related types. +// Call the interface's GetAuthCredentials() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *APIKeyAuthCredentials, *AuthCredentials, *OAuthClientCredentials +type AuthCredentialsClassification interface { + // GetAuthCredentials returns the AuthCredentials content of the underlying type. + GetAuthCredentials() *AuthCredentials +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/locations_client_example_test.go b/sdk/resourcemanager/agrifood/armagrifood/locations_client_example_test.go deleted file mode 100644 index ea41a6e7615f..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/locations_client_example_test.go +++ /dev/null @@ -1,73 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armagrifood_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Locations_CheckNameAvailability_AlreadyExists.json -func ExampleLocationsClient_CheckNameAvailability_locationsCheckNameAvailabilityAlreadyExists() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewLocationsClient().CheckNameAvailability(ctx, armagrifood.CheckNameAvailabilityRequest{ - Name: to.Ptr("existingaccountname"), - Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckNameAvailabilityResponse = armagrifood.CheckNameAvailabilityResponse{ - // Message: to.Ptr("An account named 'existingaccountname' is already in use."), - // NameAvailable: to.Ptr(false), - // Reason: to.Ptr(armagrifood.CheckNameAvailabilityReasonAlreadyExists), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Locations_CheckNameAvailability_Available.json -func ExampleLocationsClient_CheckNameAvailability_locationsCheckNameAvailabilityAvailable() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewLocationsClient().CheckNameAvailability(ctx, armagrifood.CheckNameAvailabilityRequest{ - Name: to.Ptr("newaccountname"), - Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckNameAvailabilityResponse = armagrifood.CheckNameAvailabilityResponse{ - // NameAvailable: to.Ptr(true), - // } -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/models.go b/sdk/resourcemanager/agrifood/armagrifood/models.go index 34f793632f39..a8dc0320ffa6 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/models.go +++ b/sdk/resourcemanager/agrifood/armagrifood/models.go @@ -10,12 +10,55 @@ package armagrifood import "time" +// APIKeyAuthCredentials - ApiKeyAuthCredentials class for ApiKey based Auth. +type APIKeyAuthCredentials struct { + // REQUIRED; Properties of the key vault. + APIKey *KeyVaultProperties + + // REQUIRED; Enum for different types of AuthCredentials supported. + Kind *AuthCredentialsKind +} + +// GetAuthCredentials implements the AuthCredentialsClassification interface for type APIKeyAuthCredentials. +func (a *APIKeyAuthCredentials) GetAuthCredentials() *AuthCredentials { + return &AuthCredentials{ + Kind: a.Kind, + } +} + +// APIProperties - Api properties. +type APIProperties struct { + // Interval in minutes for which the weather data for the api needs to be refreshed. + APIFreshnessTimeInMinutes *int32 +} + // ArmAsyncOperation - Arm async operation class. Ref: https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/async-operations. type ArmAsyncOperation struct { + // Arm async operation error class. Ref: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#azure-asyncoperation-resource-format. + Error *ArmAsyncOperationError + // Status of the async operation. Status *string } +// ArmAsyncOperationError - Arm async operation error class. Ref: https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/async-api-reference.md#azure-asyncoperation-resource-format. +type ArmAsyncOperationError struct { + // Status of the async operation. + Code *string + + // Status of the async operation. + Message *string +} + +// AuthCredentials abstract base class for Auth Purpose. +type AuthCredentials struct { + // REQUIRED; Enum for different types of AuthCredentials supported. + Kind *AuthCredentialsKind +} + +// GetAuthCredentials implements the AuthCredentialsClassification interface for type AuthCredentials. +func (a *AuthCredentials) GetAuthCredentials() *AuthCredentials { return a } + // CheckNameAvailabilityRequest - The check availability request body. type CheckNameAvailabilityRequest struct { // The name of the resource for which availability needs to be checked. @@ -37,67 +80,15 @@ type CheckNameAvailabilityResponse struct { Reason *CheckNameAvailabilityReason } -// DetailedInformation - Model to capture detailed information for farmBeatsExtensions. -type DetailedInformation struct { - // List of apiInputParameters. - APIInputParameters []*string - - // ApiName available for the farmBeatsExtension. - APIName *string - - // List of customParameters. - CustomParameters []*string - - // List of platformParameters. - PlatformParameters []*string - - // Unit systems info for the data provider. - UnitsSupported *UnitSystemsInfo -} - -// ErrorAdditionalInfo - The resource management error additional info. -type ErrorAdditionalInfo struct { - // READ-ONLY; The additional info. - Info any - - // READ-ONLY; The additional info type. - Type *string -} - -// ErrorDetail - The error detail. -type ErrorDetail struct { - // READ-ONLY; The error additional info. - AdditionalInfo []*ErrorAdditionalInfo - - // READ-ONLY; The error code. - Code *string - - // READ-ONLY; The error details. - Details []*ErrorDetail - - // READ-ONLY; The error message. - Message *string - - // READ-ONLY; The error target. - Target *string -} - -// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. -// (This also follows the OData error response format.). -type ErrorResponse struct { - // The error object. - Error *ErrorDetail -} - -// Extension resource. -type Extension struct { - // Extension resource properties. - Properties *ExtensionProperties +// DataConnector Model. +type DataConnector struct { + // REQUIRED; DataConnector Properties. + Properties *DataConnectorProperties // READ-ONLY; The ETag value to implement optimistic concurrency. ETag *string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -110,48 +101,36 @@ type Extension struct { Type *string } -// ExtensionListResponse - Paged response contains list of requested objects and a URL link to get the next set of results. -type ExtensionListResponse struct { - // List of requested objects. - Value []*Extension +// DataConnectorListResponse - Paged response contains list of requested objects and a URL link to get the next set of results. +type DataConnectorListResponse struct { + // REQUIRED; List of requested objects. + Value []*DataConnector - // READ-ONLY; Continuation link (absolute URI) to the next page of results in the list. + // Continuation link (absolute URI) to the next page of results in the list. NextLink *string } -// ExtensionProperties - Extension resource properties. -type ExtensionProperties struct { - // READ-ONLY; Extension api docs link. - ExtensionAPIDocsLink *string - - // READ-ONLY; Extension auth link. - ExtensionAuthLink *string - - // READ-ONLY; Extension category. e.g. weather/sensor/satellite. - ExtensionCategory *string - - // READ-ONLY; Extension Id. - ExtensionID *string - - // READ-ONLY; Installed extension version. - InstalledExtensionVersion *string +// DataConnectorProperties - DataConnector Properties. +type DataConnectorProperties struct { + // REQUIRED; AuthCredentials abstract base class for Auth Purpose. + Credentials AuthCredentialsClassification } -// FarmBeats ARM Resource. -type FarmBeats struct { +// DataManagerForAgriculture - Data Manager For Agriculture ARM Resource. +type DataManagerForAgriculture struct { // REQUIRED; The geo-location where the resource lives Location *string // Identity for the resource. Identity *Identity - // FarmBeats ARM Resource properties. - Properties *FarmBeatsProperties + // Data Manager For Agriculture ARM Resource properties. + Properties *DataManagerForAgricultureProperties // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -164,12 +143,12 @@ type FarmBeats struct { Type *string } -// FarmBeatsExtension - FarmBeats extension resource. -type FarmBeatsExtension struct { - // FarmBeatsExtension properties. - Properties *FarmBeatsExtensionProperties +// DataManagerForAgricultureExtension - DataManagerForAgriculture extension resource. +type DataManagerForAgricultureExtension struct { + // DataManagerForAgricultureExtension properties. + Properties *DataManagerForAgricultureExtensionProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -182,18 +161,21 @@ type FarmBeatsExtension struct { Type *string } -// FarmBeatsExtensionListResponse - Paged response contains list of requested objects and a URL link to get the next set of -// results. -type FarmBeatsExtensionListResponse struct { - // List of requested objects. - Value []*FarmBeatsExtension +// DataManagerForAgricultureExtensionListResponse - Paged response contains list of requested objects and a URL link to get +// the next set of results. +type DataManagerForAgricultureExtensionListResponse struct { + // REQUIRED; List of requested objects. + Value []*DataManagerForAgricultureExtension - // READ-ONLY; Continuation link (absolute URI) to the next page of results in the list. + // Continuation link (absolute URI) to the next page of results in the list. NextLink *string + + // Token used in retrieving the next page. If null, there are no additional pages. + SkipToken *string } -// FarmBeatsExtensionProperties - FarmBeatsExtension properties. -type FarmBeatsExtensionProperties struct { +// DataManagerForAgricultureExtensionProperties - DataManagerForAgricultureExtension properties. +type DataManagerForAgricultureExtensionProperties struct { // READ-ONLY; Textual description. Description *string @@ -202,94 +184,328 @@ type FarmBeatsExtensionProperties struct { // PlatformParameters and Units supported. DetailedInformation []*DetailedInformation - // READ-ONLY; FarmBeatsExtension api docs link. + // READ-ONLY; Data Manager For Agriculture Extension api docs link. ExtensionAPIDocsLink *string - // READ-ONLY; FarmBeatsExtension auth link. + // READ-ONLY; Data Manager For Agriculture Extension auth link. ExtensionAuthLink *string // READ-ONLY; Category of the extension. e.g. weather/sensor/satellite. ExtensionCategory *string - // READ-ONLY; FarmBeatsExtension ID. + // READ-ONLY; Data Manager For Agriculture Extension ID. FarmBeatsExtensionID *string - // READ-ONLY; FarmBeatsExtension name. + // READ-ONLY; Data Manager For Agriculture Extension name. FarmBeatsExtensionName *string - // READ-ONLY; FarmBeatsExtension version. + // READ-ONLY; Data Manager For Agriculture Extension version. FarmBeatsExtensionVersion *string // READ-ONLY; Publisher ID. PublisherID *string - // READ-ONLY; Target ResourceType of the farmBeatsExtension. + // READ-ONLY; Target ResourceType of the Data Manager For Agriculture Extension. TargetResourceType *string } -// FarmBeatsListResponse - Paged response contains list of requested objects and a URL link to get the next set of results. -type FarmBeatsListResponse struct { - // List of requested objects. - Value []*FarmBeats +// DataManagerForAgricultureListResponse - Paged response contains list of requested objects and a URL link to get the next +// set of results. +type DataManagerForAgricultureListResponse struct { + // REQUIRED; List of requested objects. + Value []*DataManagerForAgriculture - // READ-ONLY; Continuation link (absolute URI) to the next page of results in the list. + // Continuation link (absolute URI) to the next page of results in the list. NextLink *string + + // Token used in retrieving the next page. If null, there are no additional pages. + SkipToken *string } -// FarmBeatsProperties - FarmBeats ARM Resource properties. -type FarmBeatsProperties struct { - // Property to allow or block public traffic for an Azure FarmBeats resource. +// DataManagerForAgricultureProperties - Data Manager For Agriculture ARM Resource properties. +type DataManagerForAgricultureProperties struct { + // Property to allow or block public traffic for an Azure Data Manager For Agriculture resource. PublicNetworkAccess *PublicNetworkAccess // Sensor integration request model. SensorIntegration *SensorIntegration - // READ-ONLY; Uri of the FarmBeats instance. + // READ-ONLY; Uri of the Data Manager For Agriculture instance. InstanceURI *string - // READ-ONLY; The Private Endpoint Connection resource. - PrivateEndpointConnections *PrivateEndpointConnection + // READ-ONLY; Private endpoints. + PrivateEndpointConnections []*PrivateEndpointConnection - // READ-ONLY; FarmBeats instance provisioning state. + // READ-ONLY; Data Manager For Agriculture instance provisioning state. ProvisioningState *ProvisioningState } -// FarmBeatsUpdateProperties - FarmBeats ARM Resource properties. -type FarmBeatsUpdateProperties struct { - // Property to allow or block public traffic for an Azure FarmBeats resource. +// DataManagerForAgricultureSolution - DataManagerForAgriculture solution resource. +type DataManagerForAgricultureSolution struct { + // DataManagerForAgricultureSolution properties. + Properties *DataManagerForAgricultureSolutionProperties + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// DataManagerForAgricultureSolutionListResponse - Paged response contains list of requested objects and a URL link to get +// the next set of results. +type DataManagerForAgricultureSolutionListResponse struct { + // REQUIRED; List of requested objects. + Value []*DataManagerForAgricultureSolution + + // Continuation link (absolute URI) to the next page of results in the list. + NextLink *string + + // Token used in retrieving the next page. If null, there are no additional pages. + SkipToken *string +} + +// DataManagerForAgricultureSolutionProperties - DataManagerForAgricultureSolution properties. +type DataManagerForAgricultureSolutionProperties struct { + MarketplaceOfferDetails *MarketplaceOfferDetails + + // READ-ONLY; Application id of the multi tenant application to be used by partner to access Data Manager For Agriculture + // data. + AccessFBApplicationID *string + + // READ-ONLY; Application name of the multi tenant application to be used by partner to access Data Manager For Agriculture + // Data. + AccessFBApplicationName *string + + // READ-ONLY; List of ActionIds needed to make the SaaS multi tenant application access relevant fb data. + ActionIDs []*string + + // READ-ONLY; Gets scope of the Data manager For Agriculture data access that's required for processing solution request to + // partner. Example: For gdd they might need weatherScope and satelliteScope. + DataAccessScopes []*string + + // READ-ONLY; Gets api-version Swagger Document Dictionary to capture all api-versions of swagger exposed by partner to Data + // Manager For Agriculture. + OpenAPISpecsDictionary map[string]any + + // READ-ONLY; Solution Partner Id. + PartnerID *string + + // READ-ONLY; Solution Partner Tenant Id. + PartnerTenantID *string + + // READ-ONLY; Role Id of the SaaS multi tenant application to access relevant fb data. + RoleID *string + + // READ-ONLY; Role Name of the SaaS multi tenant application to access relevant fb data. + RoleName *string + + // READ-ONLY; Application id of the SaaS multi tenant application. + SaaSApplicationID *string +} + +// DataManagerForAgricultureUpdateProperties - Data Manager For Agriculture ARM Resource properties. +type DataManagerForAgricultureUpdateProperties struct { + // Property to allow or block public traffic for an Azure Data Manager For Agriculture resource. PublicNetworkAccess *PublicNetworkAccess // Sensor integration request model. SensorIntegration *SensorIntegration } -// FarmBeatsUpdateRequestModel - FarmBeats update request. -type FarmBeatsUpdateRequestModel struct { +// DataManagerForAgricultureUpdateRequestModel - DataManagerForAgriculture update request. +type DataManagerForAgricultureUpdateRequestModel struct { // Identity for the resource. Identity *Identity // Geo-location where the resource lives. Location *string - // FarmBeats ARM Resource properties. - Properties *FarmBeatsUpdateProperties + // Data Manager For Agriculture ARM Resource properties. + Properties *DataManagerForAgricultureUpdateProperties // Resource tags. Tags map[string]*string } +// DetailedInformation - Model to capture detailed information for Data Manager For AgricultureExtensions. +type DetailedInformation struct { + // List of defaultParameters. + APIDefaultInputParameters []*string + + // Extension provider's API documentation link. + APIDocsLink *string + + // List of apiInputParameters. + APIInputParameters []*string + + // ApiName available for the Data Manager For Agriculture Extension. + APIName *string + + // Type of Api in Extension. + APIType *string + + // List of customParameters. + CustomParameters []*string + + // List of platformParameters. + PlatformParameters []*string + + // Unit systems info for the data provider. + UnitsSupported *UnitSystemsInfo +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail +} + +// Extension resource. +type Extension struct { + // Extension resource properties. + Properties *ExtensionProperties + + // READ-ONLY; The ETag value to implement optimistic concurrency. + ETag *string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// ExtensionInstallationRequest - Extension Installation Request Body. +type ExtensionInstallationRequest struct { + // Additional Api Properties. + AdditionalAPIProperties map[string]*APIProperties + + // Extension Version. + ExtensionVersion *string +} + +// ExtensionListResponse - Paged response contains list of requested objects and a URL link to get the next set of results. +type ExtensionListResponse struct { + // REQUIRED; List of requested objects. + Value []*Extension + + // Token used in retrieving the next page. If null, there are no additional pages. + SkipToken *string + + // READ-ONLY; Continuation link (absolute URI) to the next page of results in the list. + NextLink *string +} + +// ExtensionProperties - Extension resource properties. +type ExtensionProperties struct { + // READ-ONLY; Additional Api Properties. + AdditionalAPIProperties map[string]*APIProperties + + // READ-ONLY; Extension api docs link. + ExtensionAPIDocsLink *string + + // READ-ONLY; Extension auth link. + ExtensionAuthLink *string + + // READ-ONLY; Extension category. e.g. weather/sensor/satellite. + ExtensionCategory *string + + // READ-ONLY; Extension Id. + ExtensionID *string + + // READ-ONLY; Installed extension version. + InstalledExtensionVersion *string +} + // Identity for the resource. type Identity struct { // The identity type. Type *string - // READ-ONLY; The principal ID of resource identity. + // READ-ONLY; The principal ID of resource identity. The value must be an UUID. PrincipalID *string - // READ-ONLY; The tenant ID of resource. + // READ-ONLY; The tenant ID of resource. The value must be an UUID. TenantID *string } +// KeyVaultProperties - Properties of the key vault. +type KeyVaultProperties struct { + // REQUIRED; Name of Key Vault key. + KeyName *string + + // REQUIRED; Uri of the key vault. + KeyVaultURI *string + + // REQUIRED; Version of Key Vault key. + KeyVersion *string +} + +type MarketplaceOfferDetails struct { + PublisherID *string + SaasOfferID *string +} + +// OAuthClientCredentials for clientId clientSecret auth. +type OAuthClientCredentials struct { + // REQUIRED; ClientId associated with the provider. + ClientID *string + + // REQUIRED; Properties of the key vault. + ClientSecret *KeyVaultProperties + + // REQUIRED; Enum for different types of AuthCredentials supported. + Kind *AuthCredentialsKind +} + +// GetAuthCredentials implements the AuthCredentialsClassification interface for type OAuthClientCredentials. +func (o *OAuthClientCredentials) GetAuthCredentials() *AuthCredentials { + return &AuthCredentials{ + Kind: o.Kind, + } +} + // Operation - Details of a REST API operation, returned from the Resource Provider Operations API type Operation struct { // Localized display information for this particular operation. @@ -339,18 +555,18 @@ type OperationListResult struct { Value []*Operation } -// PrivateEndpoint - The Private Endpoint resource. +// PrivateEndpoint - The private endpoint resource. type PrivateEndpoint struct { - // READ-ONLY; The ARM identifier for Private Endpoint + // READ-ONLY; The ARM identifier for private endpoint. ID *string } -// PrivateEndpointConnection - The Private Endpoint Connection resource. +// PrivateEndpointConnection - The private endpoint connection resource. type PrivateEndpointConnection struct { // Resource properties. Properties *PrivateEndpointConnectionProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -363,30 +579,33 @@ type PrivateEndpointConnection struct { Type *string } -// PrivateEndpointConnectionListResult - List of private endpoint connection associated with the specified storage account +// PrivateEndpointConnectionListResult - List of private endpoint connections associated with the specified resource. type PrivateEndpointConnectionListResult struct { - // Array of private endpoint connections + // Array of private endpoint connections. Value []*PrivateEndpointConnection } -// PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnectProperties. +// PrivateEndpointConnectionProperties - Properties of the private endpoint connection. type PrivateEndpointConnectionProperties struct { // REQUIRED; A collection of information about the state of the connection between service consumer and provider. PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState - // The resource of private end point. + // The private endpoint resource. PrivateEndpoint *PrivateEndpoint + // READ-ONLY; The group ids for the private endpoint resource. + GroupIDs []*string + // READ-ONLY; The provisioning state of the private endpoint connection resource. ProvisioningState *PrivateEndpointConnectionProvisioningState } -// PrivateLinkResource - A private link resource +// PrivateLinkResource - A private link resource. type PrivateLinkResource struct { // Resource properties. Properties *PrivateLinkResourceProperties - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -399,7 +618,7 @@ type PrivateLinkResource struct { Type *string } -// PrivateLinkResourceListResult - A list of private link resources +// PrivateLinkResourceListResult - A list of private link resources. type PrivateLinkResourceListResult struct { // Array of private link resources Value []*PrivateLinkResource @@ -407,7 +626,7 @@ type PrivateLinkResourceListResult struct { // PrivateLinkResourceProperties - Properties of a private link resource. type PrivateLinkResourceProperties struct { - // The private link resource Private link DNS zone name. + // The private link resource private link DNS zone name. RequiredZoneNames []*string // READ-ONLY; The private link resource group id. @@ -433,7 +652,7 @@ type PrivateLinkServiceConnectionState struct { // ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a // location type ProxyResource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -448,7 +667,7 @@ type ProxyResource struct { // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource @@ -463,7 +682,7 @@ type Resource struct { // SensorIntegration - Sensor integration request model. type SensorIntegration struct { - // Sensor integration enable state. Allowed values are True, None + // Sensor integration enable state. Enabled *string // Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows @@ -474,6 +693,69 @@ type SensorIntegration struct { ProvisioningState *ProvisioningState } +// Solution resource. +type Solution struct { + // Solution resource properties. + Properties *SolutionProperties + + // READ-ONLY; The ETag value to implement optimistic concurrency. + ETag *string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// SolutionListResponse - Paged response contains list of requested objects and a URL link to get the next set of results. +type SolutionListResponse struct { + // REQUIRED; List of requested objects. + Value []*Solution + + // Continuation link (absolute URI) to the next page of results in the list. + NextLink *string + + // Token used in retrieving the next page. If null, there are no additional pages. + SkipToken *string +} + +// SolutionProperties - Solution resource properties. +type SolutionProperties struct { + // REQUIRED; SaaS application Marketplace Publisher Id. + MarketplacePublisherID *string + + // REQUIRED; SaaS application Offer Id. + OfferID *string + + // REQUIRED; SaaS application Plan Id. + PlanID *string + + // REQUIRED; SaaS subscriptionId of the installed SaaS application. + SaasSubscriptionID *string + + // REQUIRED; SaaS subscription name of the installed SaaS application. + SaasSubscriptionName *string + + // REQUIRED; SaaS application Term Id. + TermID *string + + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]any + + // Role Assignment Id. + RoleAssignmentID *string + + // READ-ONLY; Partner Id of the Solution. + PartnerID *string +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -504,7 +786,7 @@ type TrackedResource struct { // Resource tags. Tags map[string]*string - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" ID *string // READ-ONLY; The name of the resource diff --git a/sdk/resourcemanager/agrifood/armagrifood/models_serde.go b/sdk/resourcemanager/agrifood/armagrifood/models_serde.go index 84f0304967e1..083e48f2377a 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/models_serde.go +++ b/sdk/resourcemanager/agrifood/armagrifood/models_serde.go @@ -15,9 +15,68 @@ import ( "reflect" ) +// MarshalJSON implements the json.Marshaller interface for type APIKeyAuthCredentials. +func (a APIKeyAuthCredentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiKey", a.APIKey) + objectMap["kind"] = AuthCredentialsKindAPIKeyAuthCredentials + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIKeyAuthCredentials. +func (a *APIKeyAuthCredentials) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiKey": + err = unpopulate(val, "APIKey", &a.APIKey) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type APIProperties. +func (a APIProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiFreshnessTimeInMinutes", a.APIFreshnessTimeInMinutes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIProperties. +func (a *APIProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiFreshnessTimeInMinutes": + err = unpopulate(val, "APIFreshnessTimeInMinutes", &a.APIFreshnessTimeInMinutes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ArmAsyncOperation. func (a ArmAsyncOperation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "error", a.Error) populate(objectMap, "status", a.Status) return json.Marshal(objectMap) } @@ -31,6 +90,9 @@ func (a *ArmAsyncOperation) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "error": + err = unpopulate(val, "Error", &a.Error) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &a.Status) delete(rawMsg, key) @@ -42,6 +104,64 @@ func (a *ArmAsyncOperation) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ArmAsyncOperationError. +func (a ArmAsyncOperationError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "code", a.Code) + populate(objectMap, "message", a.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArmAsyncOperationError. +func (a *ArmAsyncOperationError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &a.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &a.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AuthCredentials. +func (a AuthCredentials) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["kind"] = a.Kind + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AuthCredentials. +func (a *AuthCredentials) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "kind": + err = unpopulate(val, "Kind", &a.Kind) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -108,19 +228,20 @@ func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type DetailedInformation. -func (d DetailedInformation) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DataConnector. +func (d DataConnector) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "apiInputParameters", d.APIInputParameters) - populate(objectMap, "apiName", d.APIName) - populate(objectMap, "customParameters", d.CustomParameters) - populate(objectMap, "platformParameters", d.PlatformParameters) - populate(objectMap, "unitsSupported", d.UnitsSupported) + populate(objectMap, "eTag", d.ETag) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type DetailedInformation. -func (d *DetailedInformation) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnector. +func (d *DataConnector) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", d, err) @@ -128,20 +249,23 @@ func (d *DetailedInformation) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "apiInputParameters": - err = unpopulate(val, "APIInputParameters", &d.APIInputParameters) + case "eTag": + err = unpopulate(val, "ETag", &d.ETag) delete(rawMsg, key) - case "apiName": - err = unpopulate(val, "APIName", &d.APIName) + case "id": + err = unpopulate(val, "ID", &d.ID) delete(rawMsg, key) - case "customParameters": - err = unpopulate(val, "CustomParameters", &d.CustomParameters) + case "name": + err = unpopulate(val, "Name", &d.Name) delete(rawMsg, key) - case "platformParameters": - err = unpopulate(val, "PlatformParameters", &d.PlatformParameters) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) delete(rawMsg, key) - case "unitsSupported": - err = unpopulate(val, "UnitsSupported", &d.UnitsSupported) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) } if err != nil { @@ -151,219 +275,673 @@ func (d *DetailedInformation) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. -func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DataConnectorListResponse. +func (d DataConnectorListResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateAny(objectMap, "info", e.Info) - populate(objectMap, "type", e.Type) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. -func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectorListResponse. +func (d *DataConnectorListResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "info": - err = unpopulate(val, "Info", &e.Info) + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &e.Type) + case "value": + err = unpopulate(val, "Value", &d.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. -func (e ErrorDetail) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DataConnectorProperties. +func (d DataConnectorProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "additionalInfo", e.AdditionalInfo) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) - populate(objectMap, "target", e.Target) + populate(objectMap, "credentials", d.Credentials) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. -func (e *ErrorDetail) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectorProperties. +func (d *DataConnectorProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "additionalInfo": - err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) - delete(rawMsg, key) - case "code": - err = unpopulate(val, "Code", &e.Code) - delete(rawMsg, key) - case "details": - err = unpopulate(val, "Details", &e.Details) - delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &e.Message) - delete(rawMsg, key) - case "target": - err = unpopulate(val, "Target", &e.Target) + case "credentials": + d.Credentials, err = unmarshalAuthCredentialsClassification(val) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. -func (e ErrorResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgriculture. +func (d DataManagerForAgriculture) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "error", e.Error) + populate(objectMap, "id", d.ID) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. -func (e *ErrorResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgriculture. +func (d *DataManagerForAgriculture) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &d.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Extension. -func (e Extension) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureExtension. +func (d DataManagerForAgricultureExtension) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "eTag", e.ETag) - populate(objectMap, "id", e.ID) - populate(objectMap, "name", e.Name) - populate(objectMap, "properties", e.Properties) - populate(objectMap, "systemData", e.SystemData) - populate(objectMap, "type", e.Type) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Extension. -func (e *Extension) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureExtension. +func (d *DataManagerForAgricultureExtension) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { - case "eTag": - err = unpopulate(val, "ETag", &e.ETag) - delete(rawMsg, key) case "id": - err = unpopulate(val, "ID", &e.ID) + err = unpopulate(val, "ID", &d.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &e.Name) + err = unpopulate(val, "Name", &d.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &e.Properties) + err = unpopulate(val, "Properties", &d.Properties) delete(rawMsg, key) case "systemData": - err = unpopulate(val, "SystemData", &e.SystemData) + err = unpopulate(val, "SystemData", &d.SystemData) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &e.Type) + err = unpopulate(val, "Type", &d.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ExtensionListResponse. -func (e ExtensionListResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureExtensionListResponse. +func (d DataManagerForAgricultureExtensionListResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", e.NextLink) - populate(objectMap, "value", e.Value) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "$skipToken", d.SkipToken) + populate(objectMap, "value", d.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionListResponse. -func (e *ExtensionListResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureExtensionListResponse. +func (d *DataManagerForAgricultureExtensionListResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": - err = unpopulate(val, "NextLink", &e.NextLink) + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "$skipToken": + err = unpopulate(val, "SkipToken", &d.SkipToken) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &e.Value) + err = unpopulate(val, "Value", &d.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type ExtensionProperties. -func (e ExtensionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureExtensionProperties. +func (d DataManagerForAgricultureExtensionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "extensionApiDocsLink", e.ExtensionAPIDocsLink) - populate(objectMap, "extensionAuthLink", e.ExtensionAuthLink) - populate(objectMap, "extensionCategory", e.ExtensionCategory) - populate(objectMap, "extensionId", e.ExtensionID) - populate(objectMap, "installedExtensionVersion", e.InstalledExtensionVersion) + populate(objectMap, "description", d.Description) + populate(objectMap, "detailedInformation", d.DetailedInformation) + populate(objectMap, "extensionApiDocsLink", d.ExtensionAPIDocsLink) + populate(objectMap, "extensionAuthLink", d.ExtensionAuthLink) + populate(objectMap, "extensionCategory", d.ExtensionCategory) + populate(objectMap, "farmBeatsExtensionId", d.FarmBeatsExtensionID) + populate(objectMap, "farmBeatsExtensionName", d.FarmBeatsExtensionName) + populate(objectMap, "farmBeatsExtensionVersion", d.FarmBeatsExtensionVersion) + populate(objectMap, "publisherId", d.PublisherID) + populate(objectMap, "targetResourceType", d.TargetResourceType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionProperties. -func (e *ExtensionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureExtensionProperties. +func (d *DataManagerForAgricultureExtensionProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) + return fmt.Errorf("unmarshalling type %T: %v", d, err) } for key, val := range rawMsg { var err error switch key { + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "detailedInformation": + err = unpopulate(val, "DetailedInformation", &d.DetailedInformation) + delete(rawMsg, key) case "extensionApiDocsLink": - err = unpopulate(val, "ExtensionAPIDocsLink", &e.ExtensionAPIDocsLink) + err = unpopulate(val, "ExtensionAPIDocsLink", &d.ExtensionAPIDocsLink) + delete(rawMsg, key) + case "extensionAuthLink": + err = unpopulate(val, "ExtensionAuthLink", &d.ExtensionAuthLink) + delete(rawMsg, key) + case "extensionCategory": + err = unpopulate(val, "ExtensionCategory", &d.ExtensionCategory) + delete(rawMsg, key) + case "farmBeatsExtensionId": + err = unpopulate(val, "FarmBeatsExtensionID", &d.FarmBeatsExtensionID) + delete(rawMsg, key) + case "farmBeatsExtensionName": + err = unpopulate(val, "FarmBeatsExtensionName", &d.FarmBeatsExtensionName) + delete(rawMsg, key) + case "farmBeatsExtensionVersion": + err = unpopulate(val, "FarmBeatsExtensionVersion", &d.FarmBeatsExtensionVersion) + delete(rawMsg, key) + case "publisherId": + err = unpopulate(val, "PublisherID", &d.PublisherID) + delete(rawMsg, key) + case "targetResourceType": + err = unpopulate(val, "TargetResourceType", &d.TargetResourceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureListResponse. +func (d DataManagerForAgricultureListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "$skipToken", d.SkipToken) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureListResponse. +func (d *DataManagerForAgricultureListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "$skipToken": + err = unpopulate(val, "SkipToken", &d.SkipToken) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureProperties. +func (d DataManagerForAgricultureProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "instanceUri", d.InstanceURI) + populate(objectMap, "privateEndpointConnections", d.PrivateEndpointConnections) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "publicNetworkAccess", d.PublicNetworkAccess) + populate(objectMap, "sensorIntegration", d.SensorIntegration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureProperties. +func (d *DataManagerForAgricultureProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceUri": + err = unpopulate(val, "InstanceURI", &d.InstanceURI) + delete(rawMsg, key) + case "privateEndpointConnections": + err = unpopulate(val, "PrivateEndpointConnections", &d.PrivateEndpointConnections) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &d.PublicNetworkAccess) + delete(rawMsg, key) + case "sensorIntegration": + err = unpopulate(val, "SensorIntegration", &d.SensorIntegration) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureSolution. +func (d DataManagerForAgricultureSolution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureSolution. +func (d *DataManagerForAgricultureSolution) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureSolutionListResponse. +func (d DataManagerForAgricultureSolutionListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "$skipToken", d.SkipToken) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureSolutionListResponse. +func (d *DataManagerForAgricultureSolutionListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "$skipToken": + err = unpopulate(val, "SkipToken", &d.SkipToken) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureSolutionProperties. +func (d DataManagerForAgricultureSolutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "accessFBApplicationId", d.AccessFBApplicationID) + populate(objectMap, "accessFBApplicationName", d.AccessFBApplicationName) + populate(objectMap, "actionIds", d.ActionIDs) + populate(objectMap, "dataAccessScopes", d.DataAccessScopes) + populate(objectMap, "marketplaceOfferDetails", d.MarketplaceOfferDetails) + populate(objectMap, "openApiSpecsDictionary", d.OpenAPISpecsDictionary) + populate(objectMap, "partnerId", d.PartnerID) + populate(objectMap, "partnerTenantId", d.PartnerTenantID) + populate(objectMap, "roleId", d.RoleID) + populate(objectMap, "roleName", d.RoleName) + populate(objectMap, "saaSApplicationId", d.SaaSApplicationID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureSolutionProperties. +func (d *DataManagerForAgricultureSolutionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accessFBApplicationId": + err = unpopulate(val, "AccessFBApplicationID", &d.AccessFBApplicationID) + delete(rawMsg, key) + case "accessFBApplicationName": + err = unpopulate(val, "AccessFBApplicationName", &d.AccessFBApplicationName) + delete(rawMsg, key) + case "actionIds": + err = unpopulate(val, "ActionIDs", &d.ActionIDs) + delete(rawMsg, key) + case "dataAccessScopes": + err = unpopulate(val, "DataAccessScopes", &d.DataAccessScopes) + delete(rawMsg, key) + case "marketplaceOfferDetails": + err = unpopulate(val, "MarketplaceOfferDetails", &d.MarketplaceOfferDetails) + delete(rawMsg, key) + case "openApiSpecsDictionary": + err = unpopulate(val, "OpenAPISpecsDictionary", &d.OpenAPISpecsDictionary) + delete(rawMsg, key) + case "partnerId": + err = unpopulate(val, "PartnerID", &d.PartnerID) + delete(rawMsg, key) + case "partnerTenantId": + err = unpopulate(val, "PartnerTenantID", &d.PartnerTenantID) + delete(rawMsg, key) + case "roleId": + err = unpopulate(val, "RoleID", &d.RoleID) + delete(rawMsg, key) + case "roleName": + err = unpopulate(val, "RoleName", &d.RoleName) + delete(rawMsg, key) + case "saaSApplicationId": + err = unpopulate(val, "SaaSApplicationID", &d.SaaSApplicationID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureUpdateProperties. +func (d DataManagerForAgricultureUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "publicNetworkAccess", d.PublicNetworkAccess) + populate(objectMap, "sensorIntegration", d.SensorIntegration) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureUpdateProperties. +func (d *DataManagerForAgricultureUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &d.PublicNetworkAccess) + delete(rawMsg, key) + case "sensorIntegration": + err = unpopulate(val, "SensorIntegration", &d.SensorIntegration) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataManagerForAgricultureUpdateRequestModel. +func (d DataManagerForAgricultureUpdateRequestModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "location", d.Location) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataManagerForAgricultureUpdateRequestModel. +func (d *DataManagerForAgricultureUpdateRequestModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &d.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DetailedInformation. +func (d DetailedInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiDefaultInputParameters", d.APIDefaultInputParameters) + populate(objectMap, "apiDocsLink", d.APIDocsLink) + populate(objectMap, "apiInputParameters", d.APIInputParameters) + populate(objectMap, "apiName", d.APIName) + populate(objectMap, "apiType", d.APIType) + populate(objectMap, "customParameters", d.CustomParameters) + populate(objectMap, "platformParameters", d.PlatformParameters) + populate(objectMap, "unitsSupported", d.UnitsSupported) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DetailedInformation. +func (d *DetailedInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiDefaultInputParameters": + err = unpopulate(val, "APIDefaultInputParameters", &d.APIDefaultInputParameters) + delete(rawMsg, key) + case "apiDocsLink": + err = unpopulate(val, "APIDocsLink", &d.APIDocsLink) + delete(rawMsg, key) + case "apiInputParameters": + err = unpopulate(val, "APIInputParameters", &d.APIInputParameters) + delete(rawMsg, key) + case "apiName": + err = unpopulate(val, "APIName", &d.APIName) + delete(rawMsg, key) + case "apiType": + err = unpopulate(val, "APIType", &d.APIType) + delete(rawMsg, key) + case "customParameters": + err = unpopulate(val, "CustomParameters", &d.CustomParameters) + delete(rawMsg, key) + case "platformParameters": + err = unpopulate(val, "PlatformParameters", &d.PlatformParameters) + delete(rawMsg, key) + case "unitsSupported": + err = unpopulate(val, "UnitsSupported", &d.UnitsSupported) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) delete(rawMsg, key) - case "extensionAuthLink": - err = unpopulate(val, "ExtensionAuthLink", &e.ExtensionAuthLink) + case "code": + err = unpopulate(val, "Code", &e.Code) delete(rawMsg, key) - case "extensionCategory": - err = unpopulate(val, "ExtensionCategory", &e.ExtensionCategory) + case "details": + err = unpopulate(val, "Details", &e.Details) delete(rawMsg, key) - case "extensionId": - err = unpopulate(val, "ExtensionID", &e.ExtensionID) + case "message": + err = unpopulate(val, "Message", &e.Message) delete(rawMsg, key) - case "installedExtensionVersion": - err = unpopulate(val, "InstalledExtensionVersion", &e.InstalledExtensionVersion) + case "target": + err = unpopulate(val, "Target", &e.Target) delete(rawMsg, key) } if err != nil { @@ -373,372 +951,324 @@ func (e *ExtensionProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeats. -func (f FarmBeats) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", f.ID) - populate(objectMap, "identity", f.Identity) - populate(objectMap, "location", f.Location) - populate(objectMap, "name", f.Name) - populate(objectMap, "properties", f.Properties) - populate(objectMap, "systemData", f.SystemData) - populate(objectMap, "tags", f.Tags) - populate(objectMap, "type", f.Type) + populate(objectMap, "error", e.Error) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeats. -func (f *FarmBeats) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &f.ID) - delete(rawMsg, key) - case "identity": - err = unpopulate(val, "Identity", &f.Identity) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &f.Location) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &f.Name) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &f.Properties) - delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &f.SystemData) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &f.Tags) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &f.Type) + case "error": + err = unpopulate(val, "Error", &e.Error) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeatsExtension. -func (f FarmBeatsExtension) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Extension. +func (e Extension) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", f.ID) - populate(objectMap, "name", f.Name) - populate(objectMap, "properties", f.Properties) - populate(objectMap, "systemData", f.SystemData) - populate(objectMap, "type", f.Type) + populate(objectMap, "eTag", e.ETag) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeatsExtension. -func (f *FarmBeatsExtension) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Extension. +func (e *Extension) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { + case "eTag": + err = unpopulate(val, "ETag", &e.ETag) + delete(rawMsg, key) case "id": - err = unpopulate(val, "ID", &f.ID) + err = unpopulate(val, "ID", &e.ID) delete(rawMsg, key) case "name": - err = unpopulate(val, "Name", &f.Name) + err = unpopulate(val, "Name", &e.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &f.Properties) + err = unpopulate(val, "Properties", &e.Properties) delete(rawMsg, key) case "systemData": - err = unpopulate(val, "SystemData", &f.SystemData) + err = unpopulate(val, "SystemData", &e.SystemData) delete(rawMsg, key) case "type": - err = unpopulate(val, "Type", &f.Type) + err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeatsExtensionListResponse. -func (f FarmBeatsExtensionListResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtensionInstallationRequest. +func (e ExtensionInstallationRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", f.NextLink) - populate(objectMap, "value", f.Value) + populate(objectMap, "additionalApiProperties", e.AdditionalAPIProperties) + populate(objectMap, "extensionVersion", e.ExtensionVersion) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeatsExtensionListResponse. -func (f *FarmBeatsExtensionListResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionInstallationRequest. +func (e *ExtensionInstallationRequest) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &f.NextLink) + case "additionalApiProperties": + err = unpopulate(val, "AdditionalAPIProperties", &e.AdditionalAPIProperties) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &f.Value) + case "extensionVersion": + err = unpopulate(val, "ExtensionVersion", &e.ExtensionVersion) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeatsExtensionProperties. -func (f FarmBeatsExtensionProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtensionListResponse. +func (e ExtensionListResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", f.Description) - populate(objectMap, "detailedInformation", f.DetailedInformation) - populate(objectMap, "extensionApiDocsLink", f.ExtensionAPIDocsLink) - populate(objectMap, "extensionAuthLink", f.ExtensionAuthLink) - populate(objectMap, "extensionCategory", f.ExtensionCategory) - populate(objectMap, "farmBeatsExtensionId", f.FarmBeatsExtensionID) - populate(objectMap, "farmBeatsExtensionName", f.FarmBeatsExtensionName) - populate(objectMap, "farmBeatsExtensionVersion", f.FarmBeatsExtensionVersion) - populate(objectMap, "publisherId", f.PublisherID) - populate(objectMap, "targetResourceType", f.TargetResourceType) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "$skipToken", e.SkipToken) + populate(objectMap, "value", e.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeatsExtensionProperties. -func (f *FarmBeatsExtensionProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionListResponse. +func (e *ExtensionListResponse) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &f.Description) - delete(rawMsg, key) - case "detailedInformation": - err = unpopulate(val, "DetailedInformation", &f.DetailedInformation) - delete(rawMsg, key) - case "extensionApiDocsLink": - err = unpopulate(val, "ExtensionAPIDocsLink", &f.ExtensionAPIDocsLink) - delete(rawMsg, key) - case "extensionAuthLink": - err = unpopulate(val, "ExtensionAuthLink", &f.ExtensionAuthLink) - delete(rawMsg, key) - case "extensionCategory": - err = unpopulate(val, "ExtensionCategory", &f.ExtensionCategory) - delete(rawMsg, key) - case "farmBeatsExtensionId": - err = unpopulate(val, "FarmBeatsExtensionID", &f.FarmBeatsExtensionID) - delete(rawMsg, key) - case "farmBeatsExtensionName": - err = unpopulate(val, "FarmBeatsExtensionName", &f.FarmBeatsExtensionName) - delete(rawMsg, key) - case "farmBeatsExtensionVersion": - err = unpopulate(val, "FarmBeatsExtensionVersion", &f.FarmBeatsExtensionVersion) + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) delete(rawMsg, key) - case "publisherId": - err = unpopulate(val, "PublisherID", &f.PublisherID) + case "$skipToken": + err = unpopulate(val, "SkipToken", &e.SkipToken) delete(rawMsg, key) - case "targetResourceType": - err = unpopulate(val, "TargetResourceType", &f.TargetResourceType) + case "value": + err = unpopulate(val, "Value", &e.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeatsListResponse. -func (f FarmBeatsListResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type ExtensionProperties. +func (e ExtensionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", f.NextLink) - populate(objectMap, "value", f.Value) + populate(objectMap, "additionalApiProperties", e.AdditionalAPIProperties) + populate(objectMap, "extensionApiDocsLink", e.ExtensionAPIDocsLink) + populate(objectMap, "extensionAuthLink", e.ExtensionAuthLink) + populate(objectMap, "extensionCategory", e.ExtensionCategory) + populate(objectMap, "extensionId", e.ExtensionID) + populate(objectMap, "installedExtensionVersion", e.InstalledExtensionVersion) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeatsListResponse. -func (f *FarmBeatsListResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtensionProperties. +func (e *ExtensionProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } for key, val := range rawMsg { var err error switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &f.NextLink) + case "additionalApiProperties": + err = unpopulate(val, "AdditionalAPIProperties", &e.AdditionalAPIProperties) delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &f.Value) + case "extensionApiDocsLink": + err = unpopulate(val, "ExtensionAPIDocsLink", &e.ExtensionAPIDocsLink) + delete(rawMsg, key) + case "extensionAuthLink": + err = unpopulate(val, "ExtensionAuthLink", &e.ExtensionAuthLink) + delete(rawMsg, key) + case "extensionCategory": + err = unpopulate(val, "ExtensionCategory", &e.ExtensionCategory) + delete(rawMsg, key) + case "extensionId": + err = unpopulate(val, "ExtensionID", &e.ExtensionID) + delete(rawMsg, key) + case "installedExtensionVersion": + err = unpopulate(val, "InstalledExtensionVersion", &e.InstalledExtensionVersion) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", e, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeatsProperties. -func (f FarmBeatsProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "instanceUri", f.InstanceURI) - populate(objectMap, "privateEndpointConnections", f.PrivateEndpointConnections) - populate(objectMap, "provisioningState", f.ProvisioningState) - populate(objectMap, "publicNetworkAccess", f.PublicNetworkAccess) - populate(objectMap, "sensorIntegration", f.SensorIntegration) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + objectMap["type"] = "SystemAssigned" return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeatsProperties. -func (f *FarmBeatsProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. +func (i *Identity) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } for key, val := range rawMsg { var err error switch key { - case "instanceUri": - err = unpopulate(val, "InstanceURI", &f.InstanceURI) - delete(rawMsg, key) - case "privateEndpointConnections": - err = unpopulate(val, "PrivateEndpointConnections", &f.PrivateEndpointConnections) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + case "principalId": + err = unpopulate(val, "PrincipalID", &i.PrincipalID) delete(rawMsg, key) - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &f.PublicNetworkAccess) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) delete(rawMsg, key) - case "sensorIntegration": - err = unpopulate(val, "SensorIntegration", &f.SensorIntegration) + case "type": + err = unpopulate(val, "Type", &i.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeatsUpdateProperties. -func (f FarmBeatsUpdateProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type KeyVaultProperties. +func (k KeyVaultProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "publicNetworkAccess", f.PublicNetworkAccess) - populate(objectMap, "sensorIntegration", f.SensorIntegration) + populate(objectMap, "keyName", k.KeyName) + populate(objectMap, "keyVaultUri", k.KeyVaultURI) + populate(objectMap, "keyVersion", k.KeyVersion) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeatsUpdateProperties. -func (f *FarmBeatsUpdateProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultProperties. +func (k *KeyVaultProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", k, err) } for key, val := range rawMsg { var err error switch key { - case "publicNetworkAccess": - err = unpopulate(val, "PublicNetworkAccess", &f.PublicNetworkAccess) + case "keyName": + err = unpopulate(val, "KeyName", &k.KeyName) delete(rawMsg, key) - case "sensorIntegration": - err = unpopulate(val, "SensorIntegration", &f.SensorIntegration) + case "keyVaultUri": + err = unpopulate(val, "KeyVaultURI", &k.KeyVaultURI) + delete(rawMsg, key) + case "keyVersion": + err = unpopulate(val, "KeyVersion", &k.KeyVersion) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", k, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type FarmBeatsUpdateRequestModel. -func (f FarmBeatsUpdateRequestModel) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MarketplaceOfferDetails. +func (m MarketplaceOfferDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "identity", f.Identity) - populate(objectMap, "location", f.Location) - populate(objectMap, "properties", f.Properties) - populate(objectMap, "tags", f.Tags) + populate(objectMap, "publisherId", m.PublisherID) + populate(objectMap, "saasOfferId", m.SaasOfferID) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type FarmBeatsUpdateRequestModel. -func (f *FarmBeatsUpdateRequestModel) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type MarketplaceOfferDetails. +func (m *MarketplaceOfferDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } for key, val := range rawMsg { var err error switch key { - case "identity": - err = unpopulate(val, "Identity", &f.Identity) - delete(rawMsg, key) - case "location": - err = unpopulate(val, "Location", &f.Location) - delete(rawMsg, key) - case "properties": - err = unpopulate(val, "Properties", &f.Properties) + case "publisherId": + err = unpopulate(val, "PublisherID", &m.PublisherID) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &f.Tags) + case "saasOfferId": + err = unpopulate(val, "SaasOfferID", &m.SaasOfferID) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", f, err) + return fmt.Errorf("unmarshalling type %T: %v", m, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type Identity. -func (i Identity) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type OAuthClientCredentials. +func (o OAuthClientCredentials) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "principalId", i.PrincipalID) - populate(objectMap, "tenantId", i.TenantID) - objectMap["type"] = "SystemAssigned" + populate(objectMap, "clientId", o.ClientID) + populate(objectMap, "clientSecret", o.ClientSecret) + objectMap["kind"] = AuthCredentialsKindOAuthClientCredentials return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type Identity. -func (i *Identity) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type OAuthClientCredentials. +func (o *OAuthClientCredentials) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } for key, val := range rawMsg { var err error switch key { - case "principalId": - err = unpopulate(val, "PrincipalID", &i.PrincipalID) + case "clientId": + err = unpopulate(val, "ClientID", &o.ClientID) delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, "TenantID", &i.TenantID) + case "clientSecret": + err = unpopulate(val, "ClientSecret", &o.ClientSecret) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &i.Type) + case "kind": + err = unpopulate(val, "Kind", &o.Kind) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", o, err) } } return nil @@ -957,6 +1487,7 @@ func (p *PrivateEndpointConnectionListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionProperties. func (p PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "groupIds", p.GroupIDs) populate(objectMap, "privateEndpoint", p.PrivateEndpoint) populate(objectMap, "privateLinkServiceConnectionState", p.PrivateLinkServiceConnectionState) populate(objectMap, "provisioningState", p.ProvisioningState) @@ -972,6 +1503,9 @@ func (p *PrivateEndpointConnectionProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "groupIds": + err = unpopulate(val, "GroupIDs", &p.GroupIDs) + delete(rawMsg, key) case "privateEndpoint": err = unpopulate(val, "PrivateEndpoint", &p.PrivateEndpoint) delete(rawMsg, key) @@ -1242,6 +1776,158 @@ func (s *SensorIntegration) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Solution. +func (s Solution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", s.ETag) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Solution. +func (s *Solution) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &s.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SolutionListResponse. +func (s SolutionListResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "$skipToken", s.SkipToken) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SolutionListResponse. +func (s *SolutionListResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "$skipToken": + err = unpopulate(val, "SkipToken", &s.SkipToken) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SolutionProperties. +func (s SolutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "marketplacePublisherId", s.MarketplacePublisherID) + populate(objectMap, "offerId", s.OfferID) + populate(objectMap, "partnerId", s.PartnerID) + populate(objectMap, "planId", s.PlanID) + populate(objectMap, "roleAssignmentId", s.RoleAssignmentID) + populate(objectMap, "saasSubscriptionId", s.SaasSubscriptionID) + populate(objectMap, "saasSubscriptionName", s.SaasSubscriptionName) + populate(objectMap, "termId", s.TermID) + if s.AdditionalProperties != nil { + for key, val := range s.AdditionalProperties { + objectMap[key] = val + } + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SolutionProperties. +func (s *SolutionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "marketplacePublisherId": + err = unpopulate(val, "MarketplacePublisherID", &s.MarketplacePublisherID) + delete(rawMsg, key) + case "offerId": + err = unpopulate(val, "OfferID", &s.OfferID) + delete(rawMsg, key) + case "partnerId": + err = unpopulate(val, "PartnerID", &s.PartnerID) + delete(rawMsg, key) + case "planId": + err = unpopulate(val, "PlanID", &s.PlanID) + delete(rawMsg, key) + case "roleAssignmentId": + err = unpopulate(val, "RoleAssignmentID", &s.RoleAssignmentID) + delete(rawMsg, key) + case "saasSubscriptionId": + err = unpopulate(val, "SaasSubscriptionID", &s.SaasSubscriptionID) + delete(rawMsg, key) + case "saasSubscriptionName": + err = unpopulate(val, "SaasSubscriptionName", &s.SaasSubscriptionName) + delete(rawMsg, key) + case "termId": + err = unpopulate(val, "TermID", &s.TermID) + delete(rawMsg, key) + default: + if s.AdditionalProperties == nil { + s.AdditionalProperties = map[string]any{} + } + if val != nil { + var aux any + err = json.Unmarshal(val, &aux) + s.AdditionalProperties[key] = aux + } + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1388,7 +2074,7 @@ func populateAny(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/agrifood/armagrifood/operationresults_client.go b/sdk/resourcemanager/agrifood/armagrifood/operationresults_client.go new file mode 100644 index 000000000000..8838378feaab --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/operationresults_client.go @@ -0,0 +1,108 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// OperationResultsClient contains the methods for the OperationResults group. +// Don't use this type directly, use NewOperationResultsClient() instead. +type OperationResultsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewOperationResultsClient creates a new instance of OperationResultsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationResultsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationResultsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get operationResults for a Data Manager For Agriculture resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - locations - Location. +// - operationResultsID - operationResultsId for a specific location. +// - options - OperationResultsClientGetOptions contains the optional parameters for the OperationResultsClient.Get method. +func (client *OperationResultsClient) Get(ctx context.Context, locations string, operationResultsID string, options *OperationResultsClientGetOptions) (OperationResultsClientGetResponse, error) { + var err error + const operationName = "OperationResultsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, locations, operationResultsID, options) + if err != nil { + return OperationResultsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationResultsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OperationResultsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *OperationResultsClient) getCreateRequest(ctx context.Context, locations string, operationResultsID string, options *OperationResultsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/locations/{locations}/operationResults/{operationResultsId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if locations == "" { + return nil, errors.New("parameter locations cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locations}", url.PathEscape(locations)) + if operationResultsID == "" { + return nil, errors.New("parameter operationResultsID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationResultsId}", url.PathEscape(operationResultsID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationResultsClient) getHandleResponse(resp *http.Response) (OperationResultsClientGetResponse, error) { + result := OperationResultsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ArmAsyncOperation); err != nil { + return OperationResultsClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/operations_client.go b/sdk/resourcemanager/agrifood/armagrifood/operations_client.go index 20e321737c75..288bac255c23 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/operations_client.go +++ b/sdk/resourcemanager/agrifood/armagrifood/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists the available operations of Microsoft.AgFoodPlatform resource provider. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/agrifood/armagrifood/operations_client_example_test.go b/sdk/resourcemanager/agrifood/armagrifood/operations_client_example_test.go deleted file mode 100644 index df3e40d6b19c..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/operations_client_example_test.go +++ /dev/null @@ -1,126 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armagrifood_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armagrifood.OperationListResult{ - // Value: []*armagrifood.Operation{ - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/read"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("Gets or Lists existing AgFoodPlatform FarmBeats resource(s)."), - // Operation: to.Ptr("Get or List AgFoodPlatform FarmBeats resource(s)."), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("AgFoodPlatform FarmBeats"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/write"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("Creates or Updates AgFoodPlatform FarmBeats."), - // Operation: to.Ptr("Create or Update AgFoodPlatform FarmBeats."), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("AgFoodPlatform FarmBeats"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/delete"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("Deletes an existing AgFoodPlatform FarmBeats resource."), - // Operation: to.Ptr("Delete AgFoodPlatform FarmBeats resource."), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("AgFoodPlatform FarmBeats"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/locations/checkNameAvailability/action"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("Checks that resource name is valid and is not in use."), - // Operation: to.Ptr("Check Name Availability"), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("Locations"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/operations/read"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("List all operations in Microsoft AgFoodPlatform resource provider."), - // Operation: to.Ptr("List all operations."), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("List all operations in Microsoft AgFoodPlatform resource provider."), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/extensions/read"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("Gets or Lists existing AgFoodPlatform Extensions resource(s)."), - // Operation: to.Ptr("Get or List AgFoodPlatform Extensions resource(s)."), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("AgFoodPlatform Extensions"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/extensions/write"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("Creates or Updates AgFoodPlatform Extensions."), - // Operation: to.Ptr("Create or Update AgFoodPlatform Extensions."), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("AgFoodPlatform Extensions"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/extensions/delete"), - // Display: &armagrifood.OperationDisplay{ - // Description: to.Ptr("Deletes an existing AgFoodPlatform Extensions resource."), - // Operation: to.Ptr("Delete AgFoodPlatform Extensions resource."), - // Provider: to.Ptr("Microsoft AgFoodPlatform"), - // Resource: to.Ptr("AgFoodPlatform Extensions"), - // }, - // IsDataAction: to.Ptr(false), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/options.go b/sdk/resourcemanager/agrifood/armagrifood/options.go index 6bfe1363c3b6..bac3e959b657 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/options.go +++ b/sdk/resourcemanager/agrifood/armagrifood/options.go @@ -8,56 +8,55 @@ package armagrifood -// ExtensionsClientCreateOptions contains the optional parameters for the ExtensionsClient.Create method. -type ExtensionsClientCreateOptions struct { +import "time" + +// CheckNameAvailabilityClientCheckNameAvailabilityOptions contains the optional parameters for the CheckNameAvailabilityClient.CheckNameAvailability +// method. +type CheckNameAvailabilityClientCheckNameAvailabilityOptions struct { // placeholder for future optional parameters } -// ExtensionsClientDeleteOptions contains the optional parameters for the ExtensionsClient.Delete method. -type ExtensionsClientDeleteOptions struct { +// DataConnectorsClientCreateOrUpdateOptions contains the optional parameters for the DataConnectorsClient.CreateOrUpdate +// method. +type DataConnectorsClientCreateOrUpdateOptions struct { // placeholder for future optional parameters } -// ExtensionsClientGetOptions contains the optional parameters for the ExtensionsClient.Get method. -type ExtensionsClientGetOptions struct { +// DataConnectorsClientDeleteOptions contains the optional parameters for the DataConnectorsClient.Delete method. +type DataConnectorsClientDeleteOptions struct { // placeholder for future optional parameters } -// ExtensionsClientListByFarmBeatsOptions contains the optional parameters for the ExtensionsClient.NewListByFarmBeatsPager -// method. -type ExtensionsClientListByFarmBeatsOptions struct { - // Installed extension categories. - ExtensionCategories []string - - // Installed extension ids. - ExtensionIDs []string +// DataConnectorsClientGetOptions contains the optional parameters for the DataConnectorsClient.Get method. +type DataConnectorsClientGetOptions struct { + // placeholder for future optional parameters +} +// DataConnectorsClientListOptions contains the optional parameters for the DataConnectorsClient.NewListPager method. +type DataConnectorsClientListOptions struct { // Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. MaxPageSize *int32 - // Skip token for getting next set of results. + // Continuation token for getting next set of results. SkipToken *string } -// ExtensionsClientUpdateOptions contains the optional parameters for the ExtensionsClient.Update method. -type ExtensionsClientUpdateOptions struct { - // placeholder for future optional parameters -} - -// FarmBeatsExtensionsClientGetOptions contains the optional parameters for the FarmBeatsExtensionsClient.Get method. -type FarmBeatsExtensionsClientGetOptions struct { +// DataManagerForAgricultureExtensionsClientGetOptions contains the optional parameters for the DataManagerForAgricultureExtensionsClient.Get +// method. +type DataManagerForAgricultureExtensionsClientGetOptions struct { // placeholder for future optional parameters } -// FarmBeatsExtensionsClientListOptions contains the optional parameters for the FarmBeatsExtensionsClient.NewListPager method. -type FarmBeatsExtensionsClientListOptions struct { +// DataManagerForAgricultureExtensionsClientListOptions contains the optional parameters for the DataManagerForAgricultureExtensionsClient.NewListPager +// method. +type DataManagerForAgricultureExtensionsClientListOptions struct { // Extension categories. ExtensionCategories []string - // FarmBeatsExtension ids. + // DataManagerForAgricultureExtension ids. FarmBeatsExtensionIDs []string - // FarmBeats extension names. + // DataManagerForAgriculture extension names. FarmBeatsExtensionNames []string // Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. @@ -67,37 +66,34 @@ type FarmBeatsExtensionsClientListOptions struct { PublisherIDs []string } -// FarmBeatsModelsClientBeginUpdateOptions contains the optional parameters for the FarmBeatsModelsClient.BeginUpdate method. -type FarmBeatsModelsClientBeginUpdateOptions struct { +// DataManagerForAgricultureResourcesClientBeginUpdateOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.BeginUpdate +// method. +type DataManagerForAgricultureResourcesClientBeginUpdateOptions struct { // Resumes the LRO from the provided token. ResumeToken string } -// FarmBeatsModelsClientCreateOrUpdateOptions contains the optional parameters for the FarmBeatsModelsClient.CreateOrUpdate +// DataManagerForAgricultureResourcesClientCreateOrUpdateOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.CreateOrUpdate // method. -type FarmBeatsModelsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// FarmBeatsModelsClientDeleteOptions contains the optional parameters for the FarmBeatsModelsClient.Delete method. -type FarmBeatsModelsClientDeleteOptions struct { +type DataManagerForAgricultureResourcesClientCreateOrUpdateOptions struct { // placeholder for future optional parameters } -// FarmBeatsModelsClientGetOperationResultOptions contains the optional parameters for the FarmBeatsModelsClient.GetOperationResult +// DataManagerForAgricultureResourcesClientDeleteOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.Delete // method. -type FarmBeatsModelsClientGetOperationResultOptions struct { +type DataManagerForAgricultureResourcesClientDeleteOptions struct { // placeholder for future optional parameters } -// FarmBeatsModelsClientGetOptions contains the optional parameters for the FarmBeatsModelsClient.Get method. -type FarmBeatsModelsClientGetOptions struct { +// DataManagerForAgricultureResourcesClientGetOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.Get +// method. +type DataManagerForAgricultureResourcesClientGetOptions struct { // placeholder for future optional parameters } -// FarmBeatsModelsClientListByResourceGroupOptions contains the optional parameters for the FarmBeatsModelsClient.NewListByResourceGroupPager +// DataManagerForAgricultureResourcesClientListByResourceGroupOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.NewListByResourceGroupPager // method. -type FarmBeatsModelsClientListByResourceGroupOptions struct { +type DataManagerForAgricultureResourcesClientListByResourceGroupOptions struct { // Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. MaxPageSize *int32 @@ -105,9 +101,9 @@ type FarmBeatsModelsClientListByResourceGroupOptions struct { SkipToken *string } -// FarmBeatsModelsClientListBySubscriptionOptions contains the optional parameters for the FarmBeatsModelsClient.NewListBySubscriptionPager +// DataManagerForAgricultureResourcesClientListBySubscriptionOptions contains the optional parameters for the DataManagerForAgricultureResourcesClient.NewListBySubscriptionPager // method. -type FarmBeatsModelsClientListBySubscriptionOptions struct { +type DataManagerForAgricultureResourcesClientListBySubscriptionOptions struct { // Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. MaxPageSize *int32 @@ -115,9 +111,40 @@ type FarmBeatsModelsClientListBySubscriptionOptions struct { SkipToken *string } -// LocationsClientCheckNameAvailabilityOptions contains the optional parameters for the LocationsClient.CheckNameAvailability +// ExtensionsClientCreateOrUpdateOptions contains the optional parameters for the ExtensionsClient.CreateOrUpdate method. +type ExtensionsClientCreateOrUpdateOptions struct { + // Extension resource request body. + RequestBody *ExtensionInstallationRequest +} + +// ExtensionsClientDeleteOptions contains the optional parameters for the ExtensionsClient.Delete method. +type ExtensionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ExtensionsClientGetOptions contains the optional parameters for the ExtensionsClient.Get method. +type ExtensionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ExtensionsClientListByDataManagerForAgricultureOptions contains the optional parameters for the ExtensionsClient.NewListByDataManagerForAgriculturePager // method. -type LocationsClientCheckNameAvailabilityOptions struct { +type ExtensionsClientListByDataManagerForAgricultureOptions struct { + // Installed extension categories. + ExtensionCategories []string + + // Installed extension ids. + ExtensionIDs []string + + // Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + MaxPageSize *int32 + + // Skip token for getting next set of results. + SkipToken *string +} + +// OperationResultsClientGetOptions contains the optional parameters for the OperationResultsClient.Get method. +type OperationResultsClientGetOptions struct { // placeholder for future optional parameters } @@ -145,7 +172,7 @@ type PrivateEndpointConnectionsClientGetOptions struct { // placeholder for future optional parameters } -// PrivateEndpointConnectionsClientListByResourceOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByResourcePager +// PrivateEndpointConnectionsClientListByResourceOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByResource // method. type PrivateEndpointConnectionsClientListByResourceOptions struct { // placeholder for future optional parameters @@ -156,8 +183,78 @@ type PrivateLinkResourcesClientGetOptions struct { // placeholder for future optional parameters } -// PrivateLinkResourcesClientListByResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByResourcePager +// PrivateLinkResourcesClientListByResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByResource // method. type PrivateLinkResourcesClientListByResourceOptions struct { // placeholder for future optional parameters } + +// SolutionsClientCreateOrUpdateOptions contains the optional parameters for the SolutionsClient.CreateOrUpdate method. +type SolutionsClientCreateOrUpdateOptions struct { + // Solution resource request body. + RequestBody *Solution +} + +// SolutionsClientDeleteOptions contains the optional parameters for the SolutionsClient.Delete method. +type SolutionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SolutionsClientGetOptions contains the optional parameters for the SolutionsClient.Get method. +type SolutionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// SolutionsClientListOptions contains the optional parameters for the SolutionsClient.NewListPager method. +type SolutionsClientListOptions struct { + // Ids of the resource. + IDs []string + + // Maximum creation date of resource (inclusive). + MaxCreatedDateTime *time.Time + + // Maximum last modified date of resource (inclusive). + MaxLastModifiedDateTime *time.Time + + // Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + MaxPageSize *int32 + + // Minimum creation date of resource (inclusive). + MinCreatedDateTime *time.Time + + // Minimum last modified date of resource (inclusive). + MinLastModifiedDateTime *time.Time + + // Names of the resource. + Names []string + + // Filters on key-value pairs within the Properties object. eg. "{testKey} eq {testValue}". + PropertyFilters []string + + // Skip token for getting next set of results. + SkipToken *string + + // Installed Solution ids. + SolutionIDs []string + + // Statuses of the resource. + Statuses []string +} + +// SolutionsDiscoverabilityClientGetOptions contains the optional parameters for the SolutionsDiscoverabilityClient.Get method. +type SolutionsDiscoverabilityClientGetOptions struct { + // placeholder for future optional parameters +} + +// SolutionsDiscoverabilityClientListOptions contains the optional parameters for the SolutionsDiscoverabilityClient.NewListPager +// method. +type SolutionsDiscoverabilityClientListOptions struct { + // Ids of Data Manager For Agriculture Solutions which the customer requests to fetch. + FarmBeatsSolutionIDs []string + + // Names of Data Manager For Agriculture Solutions which the customer requests to fetch. + FarmBeatsSolutionNames []string + + // Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + MaxPageSize *int32 +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/polymorphic_helpers.go b/sdk/resourcemanager/agrifood/armagrifood/polymorphic_helpers.go new file mode 100644 index 000000000000..5c1882141049 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/polymorphic_helpers.go @@ -0,0 +1,34 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +import "encoding/json" + +func unmarshalAuthCredentialsClassification(rawMsg json.RawMessage) (AuthCredentialsClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b AuthCredentialsClassification + switch m["kind"] { + case string(AuthCredentialsKindAPIKeyAuthCredentials): + b = &APIKeyAuthCredentials{} + case string(AuthCredentialsKindOAuthClientCredentials): + b = &OAuthClientCredentials{} + default: + b = &AuthCredentials{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client.go b/sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client.go index 8835436f61e8..22a6f6ac3154 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client.go +++ b/sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client.go @@ -28,7 +28,7 @@ type PrivateEndpointConnectionsClient struct { } // NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { @@ -46,20 +46,20 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // CreateOrUpdate - Approves or Rejects a Private endpoint connection request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. // - privateEndpointConnectionName - Private endpoint connection name. -// - body - Request object. +// - request - Request object. // - options - PrivateEndpointConnectionsClientCreateOrUpdateOptions contains the optional parameters for the PrivateEndpointConnectionsClient.CreateOrUpdate // method. -func (client *PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, body PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOrUpdateOptions) (PrivateEndpointConnectionsClientCreateOrUpdateResponse, error) { +func (client *PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, request PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOrUpdateOptions) (PrivateEndpointConnectionsClientCreateOrUpdateResponse, error) { var err error const operationName = "PrivateEndpointConnectionsClient.CreateOrUpdate" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, privateEndpointConnectionName, body, options) + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, privateEndpointConnectionName, request, options) if err != nil { return PrivateEndpointConnectionsClientCreateOrUpdateResponse{}, err } @@ -76,8 +76,8 @@ func (client *PrivateEndpointConnectionsClient) CreateOrUpdate(ctx context.Conte } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, body PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOrUpdateOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/privateEndpointConnections/{privateEndpointConnectionName}" +func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, request PrivateEndpointConnection, options *PrivateEndpointConnectionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/privateEndpointConnections/{privateEndpointConnectionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -86,10 +86,10 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -99,10 +99,10 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, body); err != nil { + if err := runtime.MarshalAsJSON(req, request); err != nil { return nil, err } return req, nil @@ -120,20 +120,20 @@ func (client *PrivateEndpointConnectionsClient) createOrUpdateHandleResponse(res // BeginDelete - Delete Private endpoint connection request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. // - privateEndpointConnectionName - Private endpoint connection name. // - options - PrivateEndpointConnectionsClientBeginDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.BeginDelete // method. -func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*runtime.Poller[PrivateEndpointConnectionsClientDeleteResponse], error) { +func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*runtime.Poller[PrivateEndpointConnectionsClientDeleteResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceGroupName, farmBeatsResourceName, privateEndpointConnectionName, options) + resp, err := client.deleteOperation(ctx, resourceGroupName, dataManagerForAgricultureResourceName, privateEndpointConnectionName, options) if err != nil { return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, Tracer: client.internal.Tracer(), }) return poller, err @@ -147,14 +147,14 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Delete - Delete Private endpoint connection request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview -func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { +// Generated from API version 2023-06-01-preview +func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error const operationName = "PrivateEndpointConnectionsClient.BeginDelete" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, privateEndpointConnectionName, options) + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, privateEndpointConnectionName, options) if err != nil { return nil, err } @@ -170,8 +170,8 @@ func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Cont } // deleteCreateRequest creates the Delete request. -func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/privateEndpointConnections/{privateEndpointConnectionName}" +func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/privateEndpointConnections/{privateEndpointConnectionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -180,10 +180,10 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -193,7 +193,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -202,19 +202,19 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // Get - Get Private endpoint connection object. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. // - privateEndpointConnectionName - Private endpoint connection name. // - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get // method. -func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { +func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { var err error const operationName = "PrivateEndpointConnectionsClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, privateEndpointConnectionName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } @@ -231,8 +231,8 @@ func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourc } // getCreateRequest creates the Get request. -func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/privateEndpointConnections/{privateEndpointConnectionName}" +func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/privateEndpointConnections/{privateEndpointConnectionName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -241,10 +241,10 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) if privateEndpointConnectionName == "" { return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") } @@ -254,7 +254,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -269,40 +269,39 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res return result, nil } -// NewListByResourcePager - Get list of Private endpoint connections. +// ListByResource - Get list of Private endpoint connections. +// If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - options - PrivateEndpointConnectionsClientListByResourceOptions contains the optional parameters for the PrivateEndpointConnectionsClient.NewListByResourcePager +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - options - PrivateEndpointConnectionsClientListByResourceOptions contains the optional parameters for the PrivateEndpointConnectionsClient.ListByResource // method. -func (client *PrivateEndpointConnectionsClient) NewListByResourcePager(resourceGroupName string, farmBeatsResourceName string, options *PrivateEndpointConnectionsClientListByResourceOptions) *runtime.Pager[PrivateEndpointConnectionsClientListByResourceResponse] { - return runtime.NewPager(runtime.PagingHandler[PrivateEndpointConnectionsClientListByResourceResponse]{ - More: func(page PrivateEndpointConnectionsClientListByResourceResponse) bool { - return false - }, - Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListByResourceResponse) (PrivateEndpointConnectionsClientListByResourceResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListByResourcePager") - req, err := client.listByResourceCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, options) - if err != nil { - return PrivateEndpointConnectionsClientListByResourceResponse{}, err - } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PrivateEndpointConnectionsClientListByResourceResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientListByResourceResponse{}, runtime.NewResponseError(resp) - } - return client.listByResourceHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) +func (client *PrivateEndpointConnectionsClient) ListByResource(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *PrivateEndpointConnectionsClientListByResourceOptions) (PrivateEndpointConnectionsClientListByResourceResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.ListByResource" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByResourceCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, options) + if err != nil { + return PrivateEndpointConnectionsClientListByResourceResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionsClientListByResourceResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientListByResourceResponse{}, err + } + resp, err := client.listByResourceHandleResponse(httpResp) + return resp, err } // listByResourceCreateRequest creates the ListByResource request. -func (client *PrivateEndpointConnectionsClient) listByResourceCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *PrivateEndpointConnectionsClientListByResourceOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/privateEndpointConnections" +func (client *PrivateEndpointConnectionsClient) listByResourceCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *PrivateEndpointConnectionsClientListByResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/privateEndpointConnections" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -311,16 +310,16 @@ func (client *PrivateEndpointConnectionsClient) listByResourceCreateRequest(ctx return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client_example_test.go b/sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client_example_test.go deleted file mode 100644 index 55932f5965c8..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/privateendpointconnections_client_example_test.go +++ /dev/null @@ -1,179 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armagrifood_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json -func ExamplePrivateEndpointConnectionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateEndpointConnectionsClient().CreateOrUpdate(ctx, "examples-rg", "examples-farmbeatsResourceName", "privateEndpointConnectionName", armagrifood.PrivateEndpointConnection{ - Properties: &armagrifood.PrivateEndpointConnectionProperties{ - PrivateLinkServiceConnectionState: &armagrifood.PrivateLinkServiceConnectionState{ - Description: to.Ptr("Approved by johndoe@contoso.com"), - Status: to.Ptr(armagrifood.PrivateEndpointServiceConnectionStatusApproved), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PrivateEndpointConnection = armagrifood.PrivateEndpointConnection{ - // Name: to.Ptr("privateEndpointConnectionName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/privateEndpointConnections/privateEndpointConnectionName"), - // Properties: &armagrifood.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armagrifood.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), - // }, - // PrivateLinkServiceConnectionState: &armagrifood.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Approved by johndoe@contoso.com"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armagrifood.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armagrifood.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Get.json -func ExamplePrivateEndpointConnectionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateEndpointConnectionsClient().Get(ctx, "examples-rg", "examples-farmbeatsResourceName", "privateEndpointConnectionName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PrivateEndpointConnection = armagrifood.PrivateEndpointConnection{ - // Name: to.Ptr("privateEndpointConnectionName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/privateEndpointConnections/privateEndpointConnectionName"), - // Properties: &armagrifood.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armagrifood.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), - // }, - // PrivateLinkServiceConnectionState: &armagrifood.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Approved by johndoe@contoso.com"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armagrifood.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armagrifood.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Delete.json -func ExamplePrivateEndpointConnectionsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPrivateEndpointConnectionsClient().BeginDelete(ctx, "examples-rg", "examples-farmbeatsResourceName", "privateEndpointConnectionName", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_ListByResource.json -func ExamplePrivateEndpointConnectionsClient_NewListByResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPrivateEndpointConnectionsClient().NewListByResourcePager("examples-rg", "examples-farmbeatsResourceName", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PrivateEndpointConnectionListResult = armagrifood.PrivateEndpointConnectionListResult{ - // Value: []*armagrifood.PrivateEndpointConnection{ - // { - // Name: to.Ptr("privateEndpointConnectionName"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/privateEndpointConnections/privateEndpointConnectionName"), - // Properties: &armagrifood.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armagrifood.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName"), - // }, - // PrivateLinkServiceConnectionState: &armagrifood.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Approved by johndoe@contoso.com"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armagrifood.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armagrifood.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }, - // { - // Name: to.Ptr("privateEndpointConnectionName2"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/privateEndpointConnections"), - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/privateEndpointConnections/privateEndpointConnectionName2"), - // Properties: &armagrifood.PrivateEndpointConnectionProperties{ - // PrivateEndpoint: &armagrifood.PrivateEndpoint{ - // ID: to.Ptr("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/rg1Network/providers/Microsoft.Network/privateEndpoints/privateEndpointName2"), - // }, - // PrivateLinkServiceConnectionState: &armagrifood.PrivateLinkServiceConnectionState{ - // Description: to.Ptr("Approved by johndoe@contoso.com"), - // ActionsRequired: to.Ptr("None"), - // Status: to.Ptr(armagrifood.PrivateEndpointServiceConnectionStatusApproved), - // }, - // ProvisioningState: to.Ptr(armagrifood.PrivateEndpointConnectionProvisioningStateSucceeded), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client.go b/sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client.go index 6319ca827cfe..d1c19aeb4510 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client.go +++ b/sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client.go @@ -28,7 +28,7 @@ type PrivateLinkResourcesClient struct { } // NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { @@ -46,19 +46,19 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // Get - Get Private link resource object. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. // - subResourceName - Sub resource name. // - options - PrivateLinkResourcesClientGetOptions contains the optional parameters for the PrivateLinkResourcesClient.Get // method. -func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, subResourceName string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { +func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, subResourceName string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { var err error const operationName = "PrivateLinkResourcesClient.Get" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, subResourceName, options) + req, err := client.getCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, subResourceName, options) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err } @@ -75,8 +75,8 @@ func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroup } // getCreateRequest creates the Get request. -func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, subResourceName string, options *PrivateLinkResourcesClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/privateLinkResources/{subResourceName}" +func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, subResourceName string, options *PrivateLinkResourcesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/privateLinkResources/{subResourceName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -85,10 +85,10 @@ func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) if subResourceName == "" { return nil, errors.New("parameter subResourceName cannot be empty") } @@ -98,7 +98,7 @@ func (client *PrivateLinkResourcesClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -113,40 +113,39 @@ func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) return result, nil } -// NewListByResourcePager - Get list of Private link resources. +// ListByResource - Get list of Private link resources. +// If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-09-01-preview +// Generated from API version 2023-06-01-preview // - resourceGroupName - The name of the resource group. The name is case insensitive. -// - farmBeatsResourceName - FarmBeats resource name. -// - options - PrivateLinkResourcesClientListByResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.NewListByResourcePager +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - options - PrivateLinkResourcesClientListByResourceOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByResource // method. -func (client *PrivateLinkResourcesClient) NewListByResourcePager(resourceGroupName string, farmBeatsResourceName string, options *PrivateLinkResourcesClientListByResourceOptions) *runtime.Pager[PrivateLinkResourcesClientListByResourceResponse] { - return runtime.NewPager(runtime.PagingHandler[PrivateLinkResourcesClientListByResourceResponse]{ - More: func(page PrivateLinkResourcesClientListByResourceResponse) bool { - return false - }, - Fetcher: func(ctx context.Context, page *PrivateLinkResourcesClientListByResourceResponse) (PrivateLinkResourcesClientListByResourceResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkResourcesClient.NewListByResourcePager") - req, err := client.listByResourceCreateRequest(ctx, resourceGroupName, farmBeatsResourceName, options) - if err != nil { - return PrivateLinkResourcesClientListByResourceResponse{}, err - } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PrivateLinkResourcesClientListByResourceResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkResourcesClientListByResourceResponse{}, runtime.NewResponseError(resp) - } - return client.listByResourceHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) +func (client *PrivateLinkResourcesClient) ListByResource(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *PrivateLinkResourcesClientListByResourceOptions) (PrivateLinkResourcesClientListByResourceResponse, error) { + var err error + const operationName = "PrivateLinkResourcesClient.ListByResource" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listByResourceCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, options) + if err != nil { + return PrivateLinkResourcesClientListByResourceResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PrivateLinkResourcesClientListByResourceResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkResourcesClientListByResourceResponse{}, err + } + resp, err := client.listByResourceHandleResponse(httpResp) + return resp, err } // listByResourceCreateRequest creates the ListByResource request. -func (client *PrivateLinkResourcesClient) listByResourceCreateRequest(ctx context.Context, resourceGroupName string, farmBeatsResourceName string, options *PrivateLinkResourcesClientListByResourceOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{farmBeatsResourceName}/privateLinkResources" +func (client *PrivateLinkResourcesClient) listByResourceCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *PrivateLinkResourcesClientListByResourceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/privateLinkResources" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") } @@ -155,16 +154,16 @@ func (client *PrivateLinkResourcesClient) listByResourceCreateRequest(ctx contex return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if farmBeatsResourceName == "" { - return nil, errors.New("parameter farmBeatsResourceName cannot be empty") + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{farmBeatsResourceName}", url.PathEscape(farmBeatsResourceName)) + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-09-01-preview") + reqQP.Set("api-version", "2023-06-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client_example_test.go b/sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client_example_test.go deleted file mode 100644 index 3dbe6f58ed39..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/privatelinkresources_client_example_test.go +++ /dev/null @@ -1,90 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armagrifood_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/agrifood/armagrifood" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateLinkResources_ListByResource.json -func ExamplePrivateLinkResourcesClient_NewListByResourcePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewPrivateLinkResourcesClient().NewListByResourcePager("examples-rg", "examples-farmbeatsResourceName", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.PrivateLinkResourceListResult = armagrifood.PrivateLinkResourceListResult{ - // Value: []*armagrifood.PrivateLinkResource{ - // { - // Name: to.Ptr("farmbeats"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/privateLinkResources"), - // ID: to.Ptr("subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/privateLinkResources/farmbeats"), - // Properties: &armagrifood.PrivateLinkResourceProperties{ - // GroupID: to.Ptr("farmbeats"), - // RequiredMembers: []*string{ - // to.Ptr("farmbeats")}, - // RequiredZoneNames: []*string{ - // to.Ptr("privatelink.farmbeats.azure.net")}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/a7af6049f4b4743ef3b649f3852bcc7bd9a43ee0/specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateLinkResources_Get.json -func ExamplePrivateLinkResourcesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armagrifood.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPrivateLinkResourcesClient().Get(ctx, "examples-rg", "examples-farmbeatsResourceName", "farmbeats", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PrivateLinkResource = armagrifood.PrivateLinkResource{ - // Name: to.Ptr("farmbeats"), - // Type: to.Ptr("Microsoft.AgFoodPlatform/farmBeats/privateLinkResources"), - // ID: to.Ptr("subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/examples-rg/providers/Microsoft.AgFoodPlatform/farmBeats/examples-farmbeatsResourceName/privateLinkResources/farmbeats"), - // Properties: &armagrifood.PrivateLinkResourceProperties{ - // GroupID: to.Ptr("farmbeats"), - // RequiredMembers: []*string{ - // to.Ptr("farmbeats")}, - // RequiredZoneNames: []*string{ - // to.Ptr("privatelink.farmbeats.azure.net")}, - // }, - // } -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/response_types.go b/sdk/resourcemanager/agrifood/armagrifood/response_types.go deleted file mode 100644 index acc62b4339f9..000000000000 --- a/sdk/resourcemanager/agrifood/armagrifood/response_types.go +++ /dev/null @@ -1,139 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armagrifood - -// ExtensionsClientCreateResponse contains the response from method ExtensionsClient.Create. -type ExtensionsClientCreateResponse struct { - // Extension resource. - Extension -} - -// ExtensionsClientDeleteResponse contains the response from method ExtensionsClient.Delete. -type ExtensionsClientDeleteResponse struct { - // placeholder for future response values -} - -// ExtensionsClientGetResponse contains the response from method ExtensionsClient.Get. -type ExtensionsClientGetResponse struct { - // Extension resource. - Extension -} - -// ExtensionsClientListByFarmBeatsResponse contains the response from method ExtensionsClient.NewListByFarmBeatsPager. -type ExtensionsClientListByFarmBeatsResponse struct { - // Paged response contains list of requested objects and a URL link to get the next set of results. - ExtensionListResponse -} - -// ExtensionsClientUpdateResponse contains the response from method ExtensionsClient.Update. -type ExtensionsClientUpdateResponse struct { - // Extension resource. - Extension -} - -// FarmBeatsExtensionsClientGetResponse contains the response from method FarmBeatsExtensionsClient.Get. -type FarmBeatsExtensionsClientGetResponse struct { - // FarmBeats extension resource. - FarmBeatsExtension -} - -// FarmBeatsExtensionsClientListResponse contains the response from method FarmBeatsExtensionsClient.NewListPager. -type FarmBeatsExtensionsClientListResponse struct { - // Paged response contains list of requested objects and a URL link to get the next set of results. - FarmBeatsExtensionListResponse -} - -// FarmBeatsModelsClientCreateOrUpdateResponse contains the response from method FarmBeatsModelsClient.CreateOrUpdate. -type FarmBeatsModelsClientCreateOrUpdateResponse struct { - // FarmBeats ARM Resource. - FarmBeats -} - -// FarmBeatsModelsClientDeleteResponse contains the response from method FarmBeatsModelsClient.Delete. -type FarmBeatsModelsClientDeleteResponse struct { - // placeholder for future response values -} - -// FarmBeatsModelsClientGetOperationResultResponse contains the response from method FarmBeatsModelsClient.GetOperationResult. -type FarmBeatsModelsClientGetOperationResultResponse struct { - // Arm async operation class. - // Ref: https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/async-operations. - ArmAsyncOperation -} - -// FarmBeatsModelsClientGetResponse contains the response from method FarmBeatsModelsClient.Get. -type FarmBeatsModelsClientGetResponse struct { - // FarmBeats ARM Resource. - FarmBeats -} - -// FarmBeatsModelsClientListByResourceGroupResponse contains the response from method FarmBeatsModelsClient.NewListByResourceGroupPager. -type FarmBeatsModelsClientListByResourceGroupResponse struct { - // Paged response contains list of requested objects and a URL link to get the next set of results. - FarmBeatsListResponse -} - -// FarmBeatsModelsClientListBySubscriptionResponse contains the response from method FarmBeatsModelsClient.NewListBySubscriptionPager. -type FarmBeatsModelsClientListBySubscriptionResponse struct { - // Paged response contains list of requested objects and a URL link to get the next set of results. - FarmBeatsListResponse -} - -// FarmBeatsModelsClientUpdateResponse contains the response from method FarmBeatsModelsClient.BeginUpdate. -type FarmBeatsModelsClientUpdateResponse struct { - // FarmBeats ARM Resource. - FarmBeats -} - -// LocationsClientCheckNameAvailabilityResponse contains the response from method LocationsClient.CheckNameAvailability. -type LocationsClientCheckNameAvailabilityResponse struct { - // The check availability result. - CheckNameAvailabilityResponse -} - -// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. -type OperationsClientListResponse struct { - // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. - OperationListResult -} - -// PrivateEndpointConnectionsClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionsClient.CreateOrUpdate. -type PrivateEndpointConnectionsClientCreateOrUpdateResponse struct { - // The Private Endpoint Connection resource. - PrivateEndpointConnection -} - -// PrivateEndpointConnectionsClientDeleteResponse contains the response from method PrivateEndpointConnectionsClient.BeginDelete. -type PrivateEndpointConnectionsClientDeleteResponse struct { - // placeholder for future response values -} - -// PrivateEndpointConnectionsClientGetResponse contains the response from method PrivateEndpointConnectionsClient.Get. -type PrivateEndpointConnectionsClientGetResponse struct { - // The Private Endpoint Connection resource. - PrivateEndpointConnection -} - -// PrivateEndpointConnectionsClientListByResourceResponse contains the response from method PrivateEndpointConnectionsClient.NewListByResourcePager. -type PrivateEndpointConnectionsClientListByResourceResponse struct { - // List of private endpoint connection associated with the specified storage account - PrivateEndpointConnectionListResult -} - -// PrivateLinkResourcesClientGetResponse contains the response from method PrivateLinkResourcesClient.Get. -type PrivateLinkResourcesClientGetResponse struct { - // A private link resource - PrivateLinkResource -} - -// PrivateLinkResourcesClientListByResourceResponse contains the response from method PrivateLinkResourcesClient.NewListByResourcePager. -type PrivateLinkResourcesClientListByResourceResponse struct { - // A list of private link resources - PrivateLinkResourceListResult -} diff --git a/sdk/resourcemanager/agrifood/armagrifood/responses.go b/sdk/resourcemanager/agrifood/armagrifood/responses.go new file mode 100644 index 000000000000..11ff995b6f12 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/responses.go @@ -0,0 +1,191 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +// CheckNameAvailabilityClientCheckNameAvailabilityResponse contains the response from method CheckNameAvailabilityClient.CheckNameAvailability. +type CheckNameAvailabilityClientCheckNameAvailabilityResponse struct { + // The check availability result. + CheckNameAvailabilityResponse +} + +// DataConnectorsClientCreateOrUpdateResponse contains the response from method DataConnectorsClient.CreateOrUpdate. +type DataConnectorsClientCreateOrUpdateResponse struct { + // DataConnector Model. + DataConnector +} + +// DataConnectorsClientDeleteResponse contains the response from method DataConnectorsClient.Delete. +type DataConnectorsClientDeleteResponse struct { + // placeholder for future response values +} + +// DataConnectorsClientGetResponse contains the response from method DataConnectorsClient.Get. +type DataConnectorsClientGetResponse struct { + // DataConnector Model. + DataConnector +} + +// DataConnectorsClientListResponse contains the response from method DataConnectorsClient.NewListPager. +type DataConnectorsClientListResponse struct { + // Paged response contains list of requested objects and a URL link to get the next set of results. + DataConnectorListResponse +} + +// DataManagerForAgricultureExtensionsClientGetResponse contains the response from method DataManagerForAgricultureExtensionsClient.Get. +type DataManagerForAgricultureExtensionsClientGetResponse struct { + // DataManagerForAgriculture extension resource. + DataManagerForAgricultureExtension +} + +// DataManagerForAgricultureExtensionsClientListResponse contains the response from method DataManagerForAgricultureExtensionsClient.NewListPager. +type DataManagerForAgricultureExtensionsClientListResponse struct { + // Paged response contains list of requested objects and a URL link to get the next set of results. + DataManagerForAgricultureExtensionListResponse +} + +// DataManagerForAgricultureResourcesClientCreateOrUpdateResponse contains the response from method DataManagerForAgricultureResourcesClient.CreateOrUpdate. +type DataManagerForAgricultureResourcesClientCreateOrUpdateResponse struct { + // Data Manager For Agriculture ARM Resource. + DataManagerForAgriculture +} + +// DataManagerForAgricultureResourcesClientDeleteResponse contains the response from method DataManagerForAgricultureResourcesClient.Delete. +type DataManagerForAgricultureResourcesClientDeleteResponse struct { + // placeholder for future response values +} + +// DataManagerForAgricultureResourcesClientGetResponse contains the response from method DataManagerForAgricultureResourcesClient.Get. +type DataManagerForAgricultureResourcesClientGetResponse struct { + // Data Manager For Agriculture ARM Resource. + DataManagerForAgriculture +} + +// DataManagerForAgricultureResourcesClientListByResourceGroupResponse contains the response from method DataManagerForAgricultureResourcesClient.NewListByResourceGroupPager. +type DataManagerForAgricultureResourcesClientListByResourceGroupResponse struct { + // Paged response contains list of requested objects and a URL link to get the next set of results. + DataManagerForAgricultureListResponse +} + +// DataManagerForAgricultureResourcesClientListBySubscriptionResponse contains the response from method DataManagerForAgricultureResourcesClient.NewListBySubscriptionPager. +type DataManagerForAgricultureResourcesClientListBySubscriptionResponse struct { + // Paged response contains list of requested objects and a URL link to get the next set of results. + DataManagerForAgricultureListResponse +} + +// DataManagerForAgricultureResourcesClientUpdateResponse contains the response from method DataManagerForAgricultureResourcesClient.BeginUpdate. +type DataManagerForAgricultureResourcesClientUpdateResponse struct { + // Data Manager For Agriculture ARM Resource. + DataManagerForAgriculture +} + +// ExtensionsClientCreateOrUpdateResponse contains the response from method ExtensionsClient.CreateOrUpdate. +type ExtensionsClientCreateOrUpdateResponse struct { + // Extension resource. + Extension +} + +// ExtensionsClientDeleteResponse contains the response from method ExtensionsClient.Delete. +type ExtensionsClientDeleteResponse struct { + // placeholder for future response values +} + +// ExtensionsClientGetResponse contains the response from method ExtensionsClient.Get. +type ExtensionsClientGetResponse struct { + // Extension resource. + Extension +} + +// ExtensionsClientListByDataManagerForAgricultureResponse contains the response from method ExtensionsClient.NewListByDataManagerForAgriculturePager. +type ExtensionsClientListByDataManagerForAgricultureResponse struct { + // Paged response contains list of requested objects and a URL link to get the next set of results. + ExtensionListResponse +} + +// OperationResultsClientGetResponse contains the response from method OperationResultsClient.Get. +type OperationResultsClientGetResponse struct { + // Arm async operation class. + // Ref: https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/async-operations. + ArmAsyncOperation +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// PrivateEndpointConnectionsClientCreateOrUpdateResponse contains the response from method PrivateEndpointConnectionsClient.CreateOrUpdate. +type PrivateEndpointConnectionsClientCreateOrUpdateResponse struct { + // The private endpoint connection resource. + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsClientDeleteResponse contains the response from method PrivateEndpointConnectionsClient.BeginDelete. +type PrivateEndpointConnectionsClientDeleteResponse struct { + // placeholder for future response values +} + +// PrivateEndpointConnectionsClientGetResponse contains the response from method PrivateEndpointConnectionsClient.Get. +type PrivateEndpointConnectionsClientGetResponse struct { + // The private endpoint connection resource. + PrivateEndpointConnection +} + +// PrivateEndpointConnectionsClientListByResourceResponse contains the response from method PrivateEndpointConnectionsClient.ListByResource. +type PrivateEndpointConnectionsClientListByResourceResponse struct { + // List of private endpoint connections associated with the specified resource. + PrivateEndpointConnectionListResult +} + +// PrivateLinkResourcesClientGetResponse contains the response from method PrivateLinkResourcesClient.Get. +type PrivateLinkResourcesClientGetResponse struct { + // A private link resource. + PrivateLinkResource +} + +// PrivateLinkResourcesClientListByResourceResponse contains the response from method PrivateLinkResourcesClient.ListByResource. +type PrivateLinkResourcesClientListByResourceResponse struct { + // A list of private link resources. + PrivateLinkResourceListResult +} + +// SolutionsClientCreateOrUpdateResponse contains the response from method SolutionsClient.CreateOrUpdate. +type SolutionsClientCreateOrUpdateResponse struct { + // Solution resource. + Solution +} + +// SolutionsClientDeleteResponse contains the response from method SolutionsClient.Delete. +type SolutionsClientDeleteResponse struct { + // placeholder for future response values +} + +// SolutionsClientGetResponse contains the response from method SolutionsClient.Get. +type SolutionsClientGetResponse struct { + // Solution resource. + Solution +} + +// SolutionsClientListResponse contains the response from method SolutionsClient.NewListPager. +type SolutionsClientListResponse struct { + // Paged response contains list of requested objects and a URL link to get the next set of results. + SolutionListResponse +} + +// SolutionsDiscoverabilityClientGetResponse contains the response from method SolutionsDiscoverabilityClient.Get. +type SolutionsDiscoverabilityClientGetResponse struct { + // DataManagerForAgriculture solution resource. + DataManagerForAgricultureSolution +} + +// SolutionsDiscoverabilityClientListResponse contains the response from method SolutionsDiscoverabilityClient.NewListPager. +type SolutionsDiscoverabilityClientListResponse struct { + // Paged response contains list of requested objects and a URL link to get the next set of results. + DataManagerForAgricultureSolutionListResponse +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/solutions_client.go b/sdk/resourcemanager/agrifood/armagrifood/solutions_client.go new file mode 100644 index 000000000000..28b971fe8e51 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/solutions_client.go @@ -0,0 +1,357 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// SolutionsClient contains the methods for the Solutions group. +// Don't use this type directly, use NewSolutionsClient() instead. +type SolutionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewSolutionsClient creates a new instance of SolutionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSolutionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SolutionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SolutionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Install Or Update Solution. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - solutionID - SolutionId for Data Manager For Agriculture Resource. +// - options - SolutionsClientCreateOrUpdateOptions contains the optional parameters for the SolutionsClient.CreateOrUpdate +// method. +func (client *SolutionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *SolutionsClientCreateOrUpdateOptions) (SolutionsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "SolutionsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, solutionID, options) + if err != nil { + return SolutionsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SolutionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SolutionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SolutionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *SolutionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/solutions/{solutionId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + if solutionID == "" { + return nil, errors.New("parameter solutionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{solutionId}", url.PathEscape(solutionID)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.RequestBody != nil { + if err := runtime.MarshalAsJSON(req, *options.RequestBody); err != nil { + return nil, err + } + return req, nil + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SolutionsClient) createOrUpdateHandleResponse(resp *http.Response) (SolutionsClientCreateOrUpdateResponse, error) { + result := SolutionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Solution); err != nil { + return SolutionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Uninstall Solution. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - solutionID - SolutionId for Data Manager For Agriculture Resource. +// - options - SolutionsClientDeleteOptions contains the optional parameters for the SolutionsClient.Delete method. +func (client *SolutionsClient) Delete(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *SolutionsClientDeleteOptions) (SolutionsClientDeleteResponse, error) { + var err error + const operationName = "SolutionsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, solutionID, options) + if err != nil { + return SolutionsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SolutionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SolutionsClientDeleteResponse{}, err + } + return SolutionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SolutionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *SolutionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/solutions/{solutionId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + if solutionID == "" { + return nil, errors.New("parameter solutionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{solutionId}", url.PathEscape(solutionID)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get installed Solution details by Solution id. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - solutionID - SolutionId for Data Manager For Agriculture Resource. +// - options - SolutionsClientGetOptions contains the optional parameters for the SolutionsClient.Get method. +func (client *SolutionsClient) Get(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *SolutionsClientGetOptions) (SolutionsClientGetResponse, error) { + var err error + const operationName = "SolutionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, solutionID, options) + if err != nil { + return SolutionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SolutionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SolutionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SolutionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, solutionID string, options *SolutionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/solutions/{solutionId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + if solutionID == "" { + return nil, errors.New("parameter solutionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{solutionId}", url.PathEscape(solutionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SolutionsClient) getHandleResponse(resp *http.Response) (SolutionsClientGetResponse, error) { + result := SolutionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Solution); err != nil { + return SolutionsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get installed Solutions details. +// +// Generated from API version 2023-06-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataManagerForAgricultureResourceName - DataManagerForAgriculture resource name. +// - options - SolutionsClientListOptions contains the optional parameters for the SolutionsClient.NewListPager method. +func (client *SolutionsClient) NewListPager(resourceGroupName string, dataManagerForAgricultureResourceName string, options *SolutionsClientListOptions) *runtime.Pager[SolutionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SolutionsClientListResponse]{ + More: func(page SolutionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SolutionsClientListResponse) (SolutionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SolutionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, dataManagerForAgricultureResourceName, options) + }, nil) + if err != nil { + return SolutionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *SolutionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, dataManagerForAgricultureResourceName string, options *SolutionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform/farmBeats/{dataManagerForAgricultureResourceName}/solutions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataManagerForAgricultureResourceName == "" { + return nil, errors.New("parameter dataManagerForAgricultureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureResourceName}", url.PathEscape(dataManagerForAgricultureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.MaxPageSize != nil { + reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + reqQP.Set("api-version", "2023-06-01-preview") + if options != nil && options.IDs != nil { + for _, qv := range options.IDs { + reqQP.Add("ids", qv) + } + } + if options != nil && options.MaxCreatedDateTime != nil { + reqQP.Set("maxCreatedDateTime", options.MaxCreatedDateTime.Format(time.RFC3339Nano)) + } + if options != nil && options.MaxLastModifiedDateTime != nil { + reqQP.Set("maxLastModifiedDateTime", options.MaxLastModifiedDateTime.Format(time.RFC3339Nano)) + } + if options != nil && options.MinCreatedDateTime != nil { + reqQP.Set("minCreatedDateTime", options.MinCreatedDateTime.Format(time.RFC3339Nano)) + } + if options != nil && options.MinLastModifiedDateTime != nil { + reqQP.Set("minLastModifiedDateTime", options.MinLastModifiedDateTime.Format(time.RFC3339Nano)) + } + if options != nil && options.Names != nil { + for _, qv := range options.Names { + reqQP.Add("names", qv) + } + } + if options != nil && options.PropertyFilters != nil { + for _, qv := range options.PropertyFilters { + reqQP.Add("propertyFilters", qv) + } + } + if options != nil && options.SolutionIDs != nil { + for _, qv := range options.SolutionIDs { + reqQP.Add("solutionIds", qv) + } + } + if options != nil && options.Statuses != nil { + for _, qv := range options.Statuses { + reqQP.Add("statuses", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SolutionsClient) listHandleResponse(resp *http.Response) (SolutionsClientListResponse, error) { + result := SolutionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SolutionListResponse); err != nil { + return SolutionsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/solutionsdiscoverability_client.go b/sdk/resourcemanager/agrifood/armagrifood/solutionsdiscoverability_client.go new file mode 100644 index 000000000000..7e3b38f7c024 --- /dev/null +++ b/sdk/resourcemanager/agrifood/armagrifood/solutionsdiscoverability_client.go @@ -0,0 +1,162 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armagrifood + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// SolutionsDiscoverabilityClient contains the methods for the SolutionsDiscoverability group. +// Don't use this type directly, use NewSolutionsDiscoverabilityClient() instead. +type SolutionsDiscoverabilityClient struct { + internal *arm.Client +} + +// NewSolutionsDiscoverabilityClient creates a new instance of SolutionsDiscoverabilityClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSolutionsDiscoverabilityClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SolutionsDiscoverabilityClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SolutionsDiscoverabilityClient{ + internal: cl, + } + return client, nil +} + +// Get - Get Data Manager For Agriculture solution by id. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-06-01-preview +// - dataManagerForAgricultureSolutionID - dataManagerForAgricultureSolutionId to be queried. +// - options - SolutionsDiscoverabilityClientGetOptions contains the optional parameters for the SolutionsDiscoverabilityClient.Get +// method. +func (client *SolutionsDiscoverabilityClient) Get(ctx context.Context, dataManagerForAgricultureSolutionID string, options *SolutionsDiscoverabilityClientGetOptions) (SolutionsDiscoverabilityClientGetResponse, error) { + var err error + const operationName = "SolutionsDiscoverabilityClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, dataManagerForAgricultureSolutionID, options) + if err != nil { + return SolutionsDiscoverabilityClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SolutionsDiscoverabilityClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SolutionsDiscoverabilityClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SolutionsDiscoverabilityClient) getCreateRequest(ctx context.Context, dataManagerForAgricultureSolutionID string, options *SolutionsDiscoverabilityClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AgFoodPlatform/farmBeatsSolutionDefinitions/{dataManagerForAgricultureSolutionId}" + if dataManagerForAgricultureSolutionID == "" { + return nil, errors.New("parameter dataManagerForAgricultureSolutionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataManagerForAgricultureSolutionId}", url.PathEscape(dataManagerForAgricultureSolutionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-06-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SolutionsDiscoverabilityClient) getHandleResponse(resp *http.Response) (SolutionsDiscoverabilityClientGetResponse, error) { + result := SolutionsDiscoverabilityClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgricultureSolution); err != nil { + return SolutionsDiscoverabilityClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get list of Data Manager For Agriculture solutions. +// +// Generated from API version 2023-06-01-preview +// - options - SolutionsDiscoverabilityClientListOptions contains the optional parameters for the SolutionsDiscoverabilityClient.NewListPager +// method. +func (client *SolutionsDiscoverabilityClient) NewListPager(options *SolutionsDiscoverabilityClientListOptions) *runtime.Pager[SolutionsDiscoverabilityClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SolutionsDiscoverabilityClientListResponse]{ + More: func(page SolutionsDiscoverabilityClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SolutionsDiscoverabilityClientListResponse) (SolutionsDiscoverabilityClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SolutionsDiscoverabilityClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return SolutionsDiscoverabilityClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *SolutionsDiscoverabilityClient) listCreateRequest(ctx context.Context, options *SolutionsDiscoverabilityClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AgFoodPlatform/farmBeatsSolutionDefinitions" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.MaxPageSize != nil { + reqQP.Set("$maxPageSize", strconv.FormatInt(int64(*options.MaxPageSize), 10)) + } + reqQP.Set("api-version", "2023-06-01-preview") + if options != nil && options.FarmBeatsSolutionIDs != nil { + for _, qv := range options.FarmBeatsSolutionIDs { + reqQP.Add("farmBeatsSolutionIds", qv) + } + } + if options != nil && options.FarmBeatsSolutionNames != nil { + for _, qv := range options.FarmBeatsSolutionNames { + reqQP.Add("farmBeatsSolutionNames", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SolutionsDiscoverabilityClient) listHandleResponse(resp *http.Response) (SolutionsDiscoverabilityClientListResponse, error) { + result := SolutionsDiscoverabilityClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataManagerForAgricultureSolutionListResponse); err != nil { + return SolutionsDiscoverabilityClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/agrifood/armagrifood/time_rfc3339.go b/sdk/resourcemanager/agrifood/armagrifood/time_rfc3339.go index 2ee0f37095a3..e178fb14d254 100644 --- a/sdk/resourcemanager/agrifood/armagrifood/time_rfc3339.go +++ b/sdk/resourcemanager/agrifood/armagrifood/time_rfc3339.go @@ -19,12 +19,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +44,33 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339