From f347c7ce5dea45958ec9823df8f3460005e02397 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 14 Nov 2023 05:45:12 +0000 Subject: [PATCH] CodeGen from PR 3689 in openapi-env-test/azure-rest-api-specs Merge 60736f8697b8c792b57e05ee3b9329816e7d82cc into 41e238f9fd4ba837de65fca653a971f577529b12 --- .../resources/armlinks/CHANGELOG.md | 10 + .../resources/armlinks/autorest.md | 6 +- ...zz_generated_constants.go => constants.go} | 3 +- sdk/resourcemanager/resources/armlinks/go.mod | 2 +- .../{zz_generated_models.go => models.go} | 1 + .../resources/armlinks/models_serde.go | 270 ++++++++++++++++++ ...rations_client.go => operations_client.go} | 2 +- ...inks_client.go => resourcelinks_client.go} | 3 +- ...ed_response_types.go => response_types.go} | 1 + 9 files changed, 290 insertions(+), 8 deletions(-) rename sdk/resourcemanager/resources/armlinks/{zz_generated_constants.go => constants.go} (90%) rename sdk/resourcemanager/resources/armlinks/{zz_generated_models.go => models.go} (99%) create mode 100644 sdk/resourcemanager/resources/armlinks/models_serde.go rename sdk/resourcemanager/resources/armlinks/{zz_generated_operations_client.go => operations_client.go} (98%) rename sdk/resourcemanager/resources/armlinks/{zz_generated_resourcelinks_client.go => resourcelinks_client.go} (99%) rename sdk/resourcemanager/resources/armlinks/{zz_generated_response_types.go => response_types.go} (98%) diff --git a/sdk/resourcemanager/resources/armlinks/CHANGELOG.md b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md index 678e3a1a36b8..c99dbe86e4e6 100644 --- a/sdk/resourcemanager/resources/armlinks/CHANGELOG.md +++ b/sdk/resourcemanager/resources/armlinks/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 2.0.0 (2023-11-14) +### Breaking Changes + +- Type of `ResourceLink.Type` has been changed from `any` to `interface{}` +- Function `NewClientFactory` has been removed +- Function `*ClientFactory.NewOperationsClient` has been removed +- Function `*ClientFactory.NewResourceLinksClient` has been removed +- Struct `ClientFactory` has been removed + + ## 1.0.0 (2022-05-16) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlinks` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/resources/armlinks/autorest.md b/sdk/resourcemanager/resources/armlinks/autorest.md index 46cf034f953f..f3664b7c4f7b 100644 --- a/sdk/resourcemanager/resources/armlinks/autorest.md +++ b/sdk/resourcemanager/resources/armlinks/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0cc5e2efd6ffccf30e80d1e150b488dd87198b94/specification/resources/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 2.0.0 package-links: true ``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_constants.go b/sdk/resourcemanager/resources/armlinks/constants.go similarity index 90% rename from sdk/resourcemanager/resources/armlinks/zz_generated_constants.go rename to sdk/resourcemanager/resources/armlinks/constants.go index f67616136de4..e21d610809d1 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_constants.go +++ b/sdk/resourcemanager/resources/armlinks/constants.go @@ -5,10 +5,11 @@ // 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 armlinks const ( moduleName = "armlinks" - moduleVersion = "v1.0.0" + moduleVersion = "v2.0.0" ) diff --git a/sdk/resourcemanager/resources/armlinks/go.mod b/sdk/resourcemanager/resources/armlinks/go.mod index 3a720fa45ea0..87704e265541 100644 --- a/sdk/resourcemanager/resources/armlinks/go.mod +++ b/sdk/resourcemanager/resources/armlinks/go.mod @@ -1,4 +1,4 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlinks +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armlinks/v2 go 1.18 diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_models.go b/sdk/resourcemanager/resources/armlinks/models.go similarity index 99% rename from sdk/resourcemanager/resources/armlinks/zz_generated_models.go rename to sdk/resourcemanager/resources/armlinks/models.go index a8b72785668d..6aa4283bd8b3 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_models.go +++ b/sdk/resourcemanager/resources/armlinks/models.go @@ -5,6 +5,7 @@ // 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 armlinks diff --git a/sdk/resourcemanager/resources/armlinks/models_serde.go b/sdk/resourcemanager/resources/armlinks/models_serde.go new file mode 100644 index 000000000000..824c80936964 --- /dev/null +++ b/sdk/resourcemanager/resources/armlinks/models_serde.go @@ -0,0 +1,270 @@ +//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 armlinks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "display", o.Display) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) 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", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) 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", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) 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", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceLink. +func (r ResourceLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "type", &r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLink. +func (r *ResourceLink) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceLinkFilter. +func (r ResourceLinkFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "targetId", r.TargetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLinkFilter. +func (r *ResourceLinkFilter) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "targetId": + err = unpopulate(val, "TargetID", &r.TargetID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceLinkProperties. +func (r ResourceLinkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "notes", r.Notes) + populate(objectMap, "sourceId", r.SourceID) + populate(objectMap, "targetId", r.TargetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLinkProperties. +func (r *ResourceLinkProperties) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "notes": + err = unpopulate(val, "Notes", &r.Notes) + delete(rawMsg, key) + case "sourceId": + err = unpopulate(val, "SourceID", &r.SourceID) + delete(rawMsg, key) + case "targetId": + err = unpopulate(val, "TargetID", &r.TargetID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceLinkResult. +func (r ResourceLinkResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceLinkResult. +func (r *ResourceLinkResult) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_operations_client.go b/sdk/resourcemanager/resources/armlinks/operations_client.go similarity index 98% rename from sdk/resourcemanager/resources/armlinks/zz_generated_operations_client.go rename to sdk/resourcemanager/resources/armlinks/operations_client.go index 8de802d76232..3b9d96d28f5c 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_operations_client.go +++ b/sdk/resourcemanager/resources/armlinks/operations_client.go @@ -5,6 +5,7 @@ // 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 armlinks @@ -49,7 +50,6 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO } // NewListPager - Lists all of the available Microsoft.Resources REST API operations. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2016-09-01 // options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_resourcelinks_client.go b/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go similarity index 99% rename from sdk/resourcemanager/resources/armlinks/zz_generated_resourcelinks_client.go rename to sdk/resourcemanager/resources/armlinks/resourcelinks_client.go index 2f849054fc7e..7ccf60d6a95c 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_resourcelinks_client.go +++ b/sdk/resourcemanager/resources/armlinks/resourcelinks_client.go @@ -5,6 +5,7 @@ // 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 armlinks @@ -185,7 +186,6 @@ func (client *ResourceLinksClient) getHandleResponse(resp *http.Response) (Resou } // NewListAtSourceScopePager - Gets a list of resource links at and below the specified source scope. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2016-09-01 // scope - The fully qualified ID of the scope for getting the resource links. For example, to list resource links at and // under a resource group, set the scope to @@ -248,7 +248,6 @@ func (client *ResourceLinksClient) listAtSourceScopeHandleResponse(resp *http.Re } // NewListAtSubscriptionPager - Gets all the linked resources for the subscription. -// If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2016-09-01 // options - ResourceLinksClientListAtSubscriptionOptions contains the optional parameters for the ResourceLinksClient.ListAtSubscription // method. diff --git a/sdk/resourcemanager/resources/armlinks/zz_generated_response_types.go b/sdk/resourcemanager/resources/armlinks/response_types.go similarity index 98% rename from sdk/resourcemanager/resources/armlinks/zz_generated_response_types.go rename to sdk/resourcemanager/resources/armlinks/response_types.go index 8dd273290ed0..01b32b4d50e5 100644 --- a/sdk/resourcemanager/resources/armlinks/zz_generated_response_types.go +++ b/sdk/resourcemanager/resources/armlinks/response_types.go @@ -5,6 +5,7 @@ // 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 armlinks