diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 55566bedc8e9f..238af1b2f3b7f 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -463,6 +463,7 @@ com.azure.resourcemanager:azure-resourcemanager-devopsinfrastructure;1.0.0-beta. com.azure.resourcemanager:azure-resourcemanager-oracledatabase;1.0.0;1.1.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-informaticadatamanagement;1.0.0;1.1.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-mongocluster;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-computefleet;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0;1.1.0-beta.1 io.clientcore:clientcore-parent;1.0.0-beta.1;1.0.0-beta.1 diff --git a/pom.xml b/pom.xml index 5090732934e20..ead99cd9b85cf 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ sdk/cognitiveservices sdk/commerce sdk/communication + sdk/computefleet sdk/confidentialledger sdk/confluent sdk/connectedvmware diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/CHANGELOG.md b/sdk/computefleet/azure-resourcemanager-computefleet/CHANGELOG.md new file mode 100644 index 0000000000000..d15cfdf5b8143 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/CHANGELOG.md @@ -0,0 +1,9 @@ +# Release History + +## 1.0.0-beta.1 (2024-07-16) + +- Azure Resource Manager Compute Fleet client library for Java. This package contains Microsoft Azure SDK for Compute Fleet Management SDK. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +### Features Added + +- Initial release for the azure-resourcemanager-computefleet Java SDK. diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/README.md b/sdk/computefleet/azure-resourcemanager-computefleet/README.md new file mode 100644 index 0000000000000..f38fcd20fa007 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/README.md @@ -0,0 +1,104 @@ +# Azure Resource Manager Compute Fleet client library for Java + +Azure Resource Manager Compute Fleet client library for Java. + +This package contains Microsoft Azure SDK for Compute Fleet Management SDK. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-computefleet;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-computefleet + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +ComputeFleetManager manager = ComputeFleetManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/computefleet/azure-resourcemanager-computefleet/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fcomputefleet%2Fazure-resourcemanager-computefleet%2FREADME.png) diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/SAMPLE.md b/sdk/computefleet/azure-resourcemanager-computefleet/SAMPLE.md new file mode 100644 index 0000000000000..4a2a825adbd26 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/SAMPLE.md @@ -0,0 +1,311 @@ +# Code snippets and samples + + +## Fleets + +- [CreateOrUpdate](#fleets_createorupdate) +- [Delete](#fleets_delete) +- [GetByResourceGroup](#fleets_getbyresourcegroup) +- [List](#fleets_list) +- [ListByResourceGroup](#fleets_listbyresourcegroup) +- [ListVirtualMachineScaleSets](#fleets_listvirtualmachinescalesets) +- [Update](#fleets_update) + +## Operations + +- [List](#operations_list) +### Fleets_CreateOrUpdate + +```java +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.computefleet.models.ComputeProfile; +import com.azure.resourcemanager.computefleet.models.EvictionPolicy; +import com.azure.resourcemanager.computefleet.models.FleetProperties; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentity; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.computefleet.models.RegularPriorityAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.RegularPriorityProfile; +import com.azure.resourcemanager.computefleet.models.SpotAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.SpotPriorityProfile; +import com.azure.resourcemanager.computefleet.models.UserAssignedIdentity; +import com.azure.resourcemanager.computefleet.models.VmSizeProfile; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Fleets CreateOrUpdate. + */ +public final class FleetsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_CreateOrUpdate.json + */ + /** + * Sample code: Fleets_CreateOrUpdate. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsCreateOrUpdate(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) + throws IOException { + manager.fleets() + .define("testFleet") + .withRegion("westus") + .withExistingResourceGroup("rgazurefleet") + .withTags(mapOf("key3518", "fakeTokenPlaceholder")) + .withProperties(new FleetProperties() + .withSpotPriorityProfile(new SpotPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withMaxPricePerVM(0.00865D) + .withEvictionPolicy(EvictionPolicy.DELETE) + .withAllocationStrategy(SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED) + .withMaintain(true)) + .withRegularPriorityProfile(new RegularPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withAllocationStrategy(RegularPriorityAllocationStrategy.LOWEST_PRICE)) + .withVmSizesProfile(Arrays.asList(new VmSizeProfile().withName("Standard_d1_v2").withRank(19225))) + .withComputeProfile(new ComputeProfile().withBaseVirtualMachineProfile(SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize( + "{\"osProfile\":{\"computerNamePrefix\":\"o\",\"adminUsername\":\"nrgzqciiaaxjrqldbmjbqkyhntp\",\"adminPassword\":\"adfbrdxpv\",\"customData\":\"xjjib\",\"windowsConfiguration\":{\"provisionVMAgent\":true,\"enableAutomaticUpdates\":true,\"timeZone\":\"hlyjiqcfksgrpjrct\",\"additionalUnattendContent\":[{\"passName\":\"OobeSystem\",\"componentName\":\"Microsoft-Windows-Shell-Setup\",\"settingName\":\"AutoLogon\",\"content\":\"bubmqbxjkj\"}],\"patchSettings\":{\"patchMode\":\"Manual\",\"enableHotpatching\":true,\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"winRM\":{\"listeners\":[{\"protocol\":\"Http\",\"certificateUrl\":\"phwesineizrl\"}]},\"enableVMAgentPlatformUpdates\":true},\"linuxConfiguration\":{\"disablePasswordAuthentication\":true,\"ssh\":{\"publicKeys\":[{\"path\":\"kmqz\",\"keyData\":\"kivgsubusvpprwqaqpjcmhsv\"}]},\"provisionVMAgent\":true,\"patchSettings\":{\"patchMode\":\"ImageDefault\",\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"enableVMAgentPlatformUpdates\":true},\"secrets\":[{\"sourceVault\":{\"id\":\"groxwd\"},\"vaultCertificates\":[{\"certificateUrl\":\"tyldwkzafmnkvpo\",\"certificateStore\":\"nlxrwavpzhueffxsshlun\"}]}],\"allowExtensionOperations\":true,\"requireGuestProvisionSignal\":true},\"storageProfile\":{\"imageReference\":{\"publisher\":\"mqxgwbiyjzmxavhbkd\",\"offer\":\"isxgumkarlkomp\",\"sku\":\"eojmppqcrnpmxirtp\",\"version\":\"wvpcqefgtmqdgltiuz\",\"sharedGalleryImageId\":\"kmkgihoxwlawuuhcinfirktdwkmx\",\"communityGalleryImageId\":\"vlqe\",\"id\":\"aiunknwgksu\"},\"osDisk\":{\"name\":\"wfttw\",\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diffDiskSettings\":{\"option\":\"Local\",\"placement\":\"CacheDisk\"},\"diskSizeGB\":14,\"osType\":\"Windows\",\"image\":{\"uri\":\"thqceubivdrjs\"},\"vhdContainers\":[\"tkzcwddtinkfpnfklatw\"],\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"deleteOption\":\"Delete\"},\"dataDisks\":[{\"name\":\"eogiykmdmeikswxmigjws\",\"lun\":14,\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diskSizeGB\":6,\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"diskIOPSReadWrite\":27,\"diskMBpsReadWrite\":2,\"deleteOption\":\"Delete\"}],\"diskControllerType\":\"uzb\"},\"networkProfile\":{\"healthProbe\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"networkInterfaceConfigurations\":[{\"name\":\"i\",\"properties\":{\"primary\":true,\"enableAcceleratedNetworking\":true,\"disableTcpStateTracking\":true,\"enableFpga\":true,\"networkSecurityGroup\":{\"id\":\"groxwd\"},\"dnsSettings\":{\"dnsServers\":[\"nxmmfolhclsesu\"]},\"ipConfigurations\":[{\"name\":\"oezqhkidfhyywlfzwuotilrpbqnjg\",\"properties\":{\"subnet\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"primary\":true,\"publicIPAddressConfiguration\":{\"name\":\"fvpqf\",\"properties\":{\"idleTimeoutInMinutes\":9,\"dnsSettings\":{\"domainNameLabel\":\"ukrddzvmorpmfsczjwtbvp\",\"domainNameLabelScope\":\"TenantReuse\"},\"ipTags\":[{\"ipTagType\":\"sddgsoemnzgqizale\",\"tag\":\"wufmhrjsakbiaetyara\"}],\"publicIPPrefix\":{\"id\":\"groxwd\"},\"publicIPAddressVersion\":\"IPv4\",\"deleteOption\":\"Delete\"},\"sku\":{\"name\":\"Basic\",\"tier\":\"Regional\"}},\"privateIPAddressVersion\":\"IPv4\",\"applicationGatewayBackendAddressPools\":[{\"id\":\"groxwd\"}],\"applicationSecurityGroups\":[{\"id\":\"groxwd\"}],\"loadBalancerBackendAddressPools\":[{\"id\":\"groxwd\"}],\"loadBalancerInboundNatPools\":[{\"id\":\"groxwd\"}]}}],\"enableIPForwarding\":true,\"deleteOption\":\"Delete\",\"auxiliaryMode\":\"None\",\"auxiliarySku\":\"None\"}}],\"networkApiVersion\":\"2020-11-01\"},\"securityProfile\":{\"uefiSettings\":{\"secureBootEnabled\":true,\"vTpmEnabled\":true},\"encryptionAtHost\":true,\"securityType\":\"TrustedLaunch\",\"encryptionIdentity\":{\"userAssignedIdentityResourceId\":\"qoersmt\"},\"proxyAgentSettings\":{\"enabled\":true,\"mode\":\"Audit\",\"keyIncarnationId\":20}},\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":true,\"storageUri\":\"rzamfwghybpx\"}},\"extensionProfile\":{\"extensions\":[{\"name\":\"bndxuxx\",\"properties\":{\"forceUpdateTag\":\"yhgxw\",\"publisher\":\"kpxtirxjfprhs\",\"type\":\"pgjilctjjwaa\",\"typeHandlerVersion\":\"zevivcoilxmbwlrihhhibq\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"provisionAfterExtensions\":[\"nftzosroolbcwmpupujzqwqe\"],\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}}}}],\"extensionsTimeBudget\":\"mbhjahtdygwgyszdwjtvlvtgchdwil\"},\"licenseType\":\"v\",\"scheduledEventsProfile\":{\"terminateNotificationProfile\":{\"notBeforeTimeout\":\"iljppmmw\",\"enable\":true},\"osImageNotificationProfile\":{\"notBeforeTimeout\":\"olbpadmevekyczfokodtfprxti\",\"enable\":true}},\"userData\":\"s\",\"capacityReservation\":{\"capacityReservationGroup\":{\"id\":\"groxwd\"}},\"applicationProfile\":{\"galleryApplications\":[{\"tags\":\"eyrqjbib\",\"order\":5,\"packageReferenceId\":\"lfxqiadouhmbovcd\",\"configurationReference\":\"ulztmiavpojpbpbddgnuuiimxcpau\",\"treatFailureAsDeploymentFailure\":true,\"enableAutomaticUpgrade\":true}]},\"hardwareProfile\":{\"vmSizeProperties\":{\"vCPUsAvailable\":16,\"vCPUsPerCore\":23}},\"serviceArtifactReference\":{\"id\":\"qlkeeyskyr\"},\"securityPostureReference\":{\"id\":\"mubredelfbshboaxrsxiajihahaa\",\"excludeExtensions\":[{\"properties\":{\"forceUpdateTag\":\"oriasdwawveilgusfrn\",\"publisher\":\"rxoajzb\",\"type\":\"vhrtgbaqdkbrrqxsdiiaqxksmqukl\",\"typeHandlerVersion\":\"bvzbiibps\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"instanceView\":{\"name\":\"ip\",\"type\":\"woadxvobquacooaujyg\",\"typeHandlerVersion\":\"ftkkqxdqiofgsusvxekdcpua\",\"substatuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}],\"statuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}]},\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}},\"provisionAfterExtensions\":[\"lwsfavklrgzuwmyxscskt\"]},\"location\":\"wrqxhbqaebwkzmcdmngyqmhogc\",\"tags\":{\"key7356\":\"apuftleiygpnemfzryiop\"}}]}}", + Object.class, SerializerEncoding.JSON)) + .withComputeApiVersion("2023-07-01") + .withPlatformFaultDomainCount(1))) + .withZones(Arrays.asList("zone1", "zone2")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf("key9851", new UserAssignedIdentity()))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Fleets_Delete + +```java +/** + * Samples for Fleets Delete. + */ +public final class FleetsDeleteSamples { + /* + * x-ms-original-file: specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_Delete.json + */ + /** + * Sample code: Fleets_Delete. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsDelete(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().delete("rgazurefleet", "testFleet", com.azure.core.util.Context.NONE); + } +} +``` + +### Fleets_GetByResourceGroup + +```java +/** + * Samples for Fleets GetByResourceGroup. + */ +public final class FleetsGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_Get.json + */ + /** + * Sample code: Fleets_Get. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsGet(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().getByResourceGroupWithResponse("rgazurefleet", "testFleet", com.azure.core.util.Context.NONE); + } +} +``` + +### Fleets_List + +```java +/** + * Samples for Fleets List. + */ +public final class FleetsListSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_ListBySubscription.json + */ + /** + * Sample code: Fleets_ListBySubscription. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsListBySubscription(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Fleets_ListByResourceGroup + +```java +/** + * Samples for Fleets ListByResourceGroup. + */ +public final class FleetsListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_ListByResourceGroup.json + */ + /** + * Sample code: Fleets_ListByResourceGroup. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsListByResourceGroup(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().listByResourceGroup("rgazurefleet", com.azure.core.util.Context.NONE); + } +} +``` + +### Fleets_ListVirtualMachineScaleSets + +```java +/** + * Samples for Fleets ListVirtualMachineScaleSets. + */ +public final class FleetsListVirtualMachineScaleSetsSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_ListVirtualMachineScaleSets. + * json + */ + /** + * Sample code: Fleets_ListVirtualMachineScaleSets. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void + fleetsListVirtualMachineScaleSets(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets() + .listVirtualMachineScaleSetsWithResponse("rgazurefleet", "myFleet", com.azure.core.util.Context.NONE); + } +} +``` + +### Fleets_Update + +```java +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.computefleet.models.ComputeProfile; +import com.azure.resourcemanager.computefleet.models.EvictionPolicy; +import com.azure.resourcemanager.computefleet.models.Fleet; +import com.azure.resourcemanager.computefleet.models.FleetProperties; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityUpdate; +import com.azure.resourcemanager.computefleet.models.RegularPriorityAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.RegularPriorityProfile; +import com.azure.resourcemanager.computefleet.models.ResourcePlanUpdate; +import com.azure.resourcemanager.computefleet.models.SpotAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.SpotPriorityProfile; +import com.azure.resourcemanager.computefleet.models.VmSizeProfile; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Fleets Update. + */ +public final class FleetsUpdateSamples { + /* + * x-ms-original-file: specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_Update.json + */ + /** + * Sample code: Fleets_Update. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsUpdate(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) + throws IOException { + Fleet resource = manager.fleets() + .getByResourceGroupWithResponse("rgazurefleet", "testFleet", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentityUpdate().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf())) + .withPlan(new ResourcePlanUpdate().withName("jwgrcrnrtfoxn") + .withPublisher("iozjbiqqckqm") + .withProduct("cgopbyvdyqikahwyxfpzwaqk") + .withPromotionCode("fakeTokenPlaceholder") + .withVersion("wa")) + .withProperties(new FleetProperties() + .withSpotPriorityProfile(new SpotPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withMaxPricePerVM(0.00865D) + .withEvictionPolicy(EvictionPolicy.DELETE) + .withAllocationStrategy(SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED) + .withMaintain(true)) + .withRegularPriorityProfile(new RegularPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withAllocationStrategy(RegularPriorityAllocationStrategy.LOWEST_PRICE)) + .withVmSizesProfile(Arrays.asList(new VmSizeProfile().withName("Standard_d1_v2").withRank(19225))) + .withComputeProfile(new ComputeProfile().withBaseVirtualMachineProfile(SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize( + "{\"osProfile\":{\"computerNamePrefix\":\"o\",\"adminUsername\":\"nrgzqciiaaxjrqldbmjbqkyhntp\",\"adminPassword\":\"adfbrdxpv\",\"customData\":\"xjjib\",\"windowsConfiguration\":{\"provisionVMAgent\":true,\"enableAutomaticUpdates\":true,\"timeZone\":\"hlyjiqcfksgrpjrct\",\"additionalUnattendContent\":[{\"passName\":\"OobeSystem\",\"componentName\":\"Microsoft-Windows-Shell-Setup\",\"settingName\":\"AutoLogon\",\"content\":\"bubmqbxjkj\"}],\"patchSettings\":{\"patchMode\":\"Manual\",\"enableHotpatching\":true,\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"winRM\":{\"listeners\":[{\"protocol\":\"Http\",\"certificateUrl\":\"phwesineizrl\"}]},\"enableVMAgentPlatformUpdates\":true},\"linuxConfiguration\":{\"disablePasswordAuthentication\":true,\"ssh\":{\"publicKeys\":[{\"path\":\"kmqz\",\"keyData\":\"kivgsubusvpprwqaqpjcmhsv\"}]},\"provisionVMAgent\":true,\"patchSettings\":{\"patchMode\":\"ImageDefault\",\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"enableVMAgentPlatformUpdates\":true},\"secrets\":[{\"sourceVault\":{\"id\":\"groxwd\"},\"vaultCertificates\":[{\"certificateUrl\":\"tyldwkzafmnkvpo\",\"certificateStore\":\"nlxrwavpzhueffxsshlun\"}]}],\"allowExtensionOperations\":true,\"requireGuestProvisionSignal\":true},\"storageProfile\":{\"imageReference\":{\"publisher\":\"mqxgwbiyjzmxavhbkd\",\"offer\":\"isxgumkarlkomp\",\"sku\":\"eojmppqcrnpmxirtp\",\"version\":\"wvpcqefgtmqdgltiuz\",\"sharedGalleryImageId\":\"kmkgihoxwlawuuhcinfirktdwkmx\",\"communityGalleryImageId\":\"vlqe\",\"id\":\"aiunknwgksu\"},\"osDisk\":{\"name\":\"wfttw\",\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diffDiskSettings\":{\"option\":\"Local\",\"placement\":\"CacheDisk\"},\"diskSizeGB\":14,\"osType\":\"Windows\",\"image\":{\"uri\":\"thqceubivdrjs\"},\"vhdContainers\":[\"tkzcwddtinkfpnfklatw\"],\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"deleteOption\":\"Delete\"},\"dataDisks\":[{\"name\":\"eogiykmdmeikswxmigjws\",\"lun\":14,\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diskSizeGB\":6,\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"diskIOPSReadWrite\":27,\"diskMBpsReadWrite\":2,\"deleteOption\":\"Delete\"}],\"diskControllerType\":\"uzb\"},\"networkProfile\":{\"healthProbe\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"networkInterfaceConfigurations\":[{\"name\":\"i\",\"properties\":{\"primary\":true,\"enableAcceleratedNetworking\":true,\"disableTcpStateTracking\":true,\"enableFpga\":true,\"networkSecurityGroup\":{\"id\":\"groxwd\"},\"dnsSettings\":{\"dnsServers\":[\"nxmmfolhclsesu\"]},\"ipConfigurations\":[{\"name\":\"oezqhkidfhyywlfzwuotilrpbqnjg\",\"properties\":{\"subnet\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"primary\":true,\"publicIPAddressConfiguration\":{\"name\":\"fvpqf\",\"properties\":{\"idleTimeoutInMinutes\":9,\"dnsSettings\":{\"domainNameLabel\":\"ukrddzvmorpmfsczjwtbvp\",\"domainNameLabelScope\":\"TenantReuse\"},\"ipTags\":[{\"ipTagType\":\"sddgsoemnzgqizale\",\"tag\":\"wufmhrjsakbiaetyara\"}],\"publicIPPrefix\":{\"id\":\"groxwd\"},\"publicIPAddressVersion\":\"IPv4\",\"deleteOption\":\"Delete\"},\"sku\":{\"name\":\"Basic\",\"tier\":\"Regional\"}},\"privateIPAddressVersion\":\"IPv4\",\"applicationGatewayBackendAddressPools\":[{\"id\":\"groxwd\"}],\"applicationSecurityGroups\":[{\"id\":\"groxwd\"}],\"loadBalancerBackendAddressPools\":[{\"id\":\"groxwd\"}],\"loadBalancerInboundNatPools\":[{\"id\":\"groxwd\"}]}}],\"enableIPForwarding\":true,\"deleteOption\":\"Delete\",\"auxiliaryMode\":\"None\",\"auxiliarySku\":\"None\"}}],\"networkApiVersion\":\"2020-11-01\"},\"securityProfile\":{\"uefiSettings\":{\"secureBootEnabled\":true,\"vTpmEnabled\":true},\"encryptionAtHost\":true,\"securityType\":\"TrustedLaunch\",\"encryptionIdentity\":{\"userAssignedIdentityResourceId\":\"qoersmt\"},\"proxyAgentSettings\":{\"enabled\":true,\"mode\":\"Audit\",\"keyIncarnationId\":20}},\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":true,\"storageUri\":\"rzamfwghybpx\"}},\"extensionProfile\":{\"extensions\":[{\"name\":\"bndxuxx\",\"properties\":{\"forceUpdateTag\":\"yhgxw\",\"publisher\":\"kpxtirxjfprhs\",\"type\":\"pgjilctjjwaa\",\"typeHandlerVersion\":\"zevivcoilxmbwlrihhhibq\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"provisionAfterExtensions\":[\"nftzosroolbcwmpupujzqwqe\"],\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}}}}],\"extensionsTimeBudget\":\"mbhjahtdygwgyszdwjtvlvtgchdwil\"},\"licenseType\":\"v\",\"scheduledEventsProfile\":{\"terminateNotificationProfile\":{\"notBeforeTimeout\":\"iljppmmw\",\"enable\":true},\"osImageNotificationProfile\":{\"notBeforeTimeout\":\"olbpadmevekyczfokodtfprxti\",\"enable\":true}},\"userData\":\"s\",\"capacityReservation\":{\"capacityReservationGroup\":{\"id\":\"groxwd\"}},\"applicationProfile\":{\"galleryApplications\":[{\"tags\":\"eyrqjbib\",\"order\":5,\"packageReferenceId\":\"lfxqiadouhmbovcd\",\"configurationReference\":\"ulztmiavpojpbpbddgnuuiimxcpau\",\"treatFailureAsDeploymentFailure\":true,\"enableAutomaticUpgrade\":true}]},\"hardwareProfile\":{\"vmSizeProperties\":{\"vCPUsAvailable\":16,\"vCPUsPerCore\":23}},\"serviceArtifactReference\":{\"id\":\"qlkeeyskyr\"},\"securityPostureReference\":{\"id\":\"mubredelfbshboaxrsxiajihahaa\",\"excludeExtensions\":[{\"properties\":{\"forceUpdateTag\":\"oriasdwawveilgusfrn\",\"publisher\":\"rxoajzb\",\"type\":\"vhrtgbaqdkbrrqxsdiiaqxksmqukl\",\"typeHandlerVersion\":\"bvzbiibps\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"instanceView\":{\"name\":\"ip\",\"type\":\"woadxvobquacooaujyg\",\"typeHandlerVersion\":\"ftkkqxdqiofgsusvxekdcpua\",\"substatuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}],\"statuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}]},\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}},\"provisionAfterExtensions\":[\"lwsfavklrgzuwmyxscskt\"]},\"location\":\"wrqxhbqaebwkzmcdmngyqmhogc\",\"tags\":{}}]}}", + Object.class, SerializerEncoding.JSON)) + .withComputeApiVersion("2023-07-01") + .withPlatformFaultDomainCount(1))) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Operations_List + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void operationsList(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/pom.xml b/sdk/computefleet/azure-resourcemanager-computefleet/pom.xml new file mode 100644 index 0000000000000..9fbd6d36e152e --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-computefleet + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Compute Fleet Management + This package contains Microsoft Azure SDK for Compute Fleet Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + true + + + + com.azure + azure-json + 1.1.0 + + + com.azure + azure-core + 1.50.0 + + + com.azure + azure-core-management + 1.15.1 + + + com.azure + azure-core-test + 1.26.1 + test + + + com.azure + azure-identity + 1.13.0 + test + + + org.junit.jupiter + junit-jupiter-api + 5.9.3 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.9.3 + test + + + org.slf4j + slf4j-simple + 1.7.36 + test + + + diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/ComputeFleetManager.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/ComputeFleetManager.java new file mode 100644 index 0000000000000..255411eb972d5 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/ComputeFleetManager.java @@ -0,0 +1,290 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.computefleet.fluent.AzureFleetClient; +import com.azure.resourcemanager.computefleet.implementation.AzureFleetClientBuilder; +import com.azure.resourcemanager.computefleet.implementation.FleetsImpl; +import com.azure.resourcemanager.computefleet.implementation.OperationsImpl; +import com.azure.resourcemanager.computefleet.models.Fleets; +import com.azure.resourcemanager.computefleet.models.Operations; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to ComputeFleetManager. + */ +public final class ComputeFleetManager { + private Operations operations; + + private Fleets fleets; + + private final AzureFleetClient clientObject; + + private ComputeFleetManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new AzureFleetClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Compute Fleet service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Compute Fleet service API instance. + */ + public static ComputeFleetManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Compute Fleet service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Compute Fleet service API instance. + */ + public static ComputeFleetManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ComputeFleetManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ComputeFleetManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ComputeFleetManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Compute Fleet service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Compute Fleet service API instance. + */ + public ComputeFleetManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.computefleet") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new ComputeFleetManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets the resource collection API of Fleets. It manages Fleet. + * + * @return Resource collection API of Fleets. + */ + public Fleets fleets() { + if (this.fleets == null) { + this.fleets = new FleetsImpl(clientObject.getFleets(), this); + } + return fleets; + } + + /** + * Gets wrapped service client AzureFleetClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client AzureFleetClient. + */ + public AzureFleetClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/AzureFleetClient.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/AzureFleetClient.java new file mode 100644 index 0000000000000..fe07fb794c180 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/AzureFleetClient.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for AzureFleetClient class. + */ +public interface AzureFleetClient { + /** + * Gets Server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the FleetsClient object to access its operations. + * + * @return the FleetsClient object. + */ + FleetsClient getFleets(); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/FleetsClient.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/FleetsClient.java new file mode 100644 index 0000000000000..004a6f254d1e1 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/FleetsClient.java @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.computefleet.fluent.models.FleetInner; +import com.azure.resourcemanager.computefleet.fluent.models.VirtualMachineScaleSetListResultInner; +import com.azure.resourcemanager.computefleet.models.FleetUpdate; + +/** + * An instance of this class provides access to all the operations defined in FleetsClient. + */ +public interface FleetsClient { + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, String fleetName, Context context); + + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FleetInner getByResourceGroup(String resourceGroupName, String fleetName); + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, FleetInner> beginCreateOrUpdate(String resourceGroupName, String fleetName, + FleetInner resource); + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, FleetInner> beginCreateOrUpdate(String resourceGroupName, String fleetName, + FleetInner resource, Context context); + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FleetInner createOrUpdate(String resourceGroupName, String fleetName, FleetInner resource); + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FleetInner createOrUpdate(String resourceGroupName, String fleetName, FleetInner resource, Context context); + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, FleetInner> beginUpdate(String resourceGroupName, String fleetName, + FleetUpdate properties); + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, FleetInner> beginUpdate(String resourceGroupName, String fleetName, + FleetUpdate properties, Context context); + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FleetInner update(String resourceGroupName, String fleetName, FleetUpdate properties); + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FleetInner update(String resourceGroupName, String fleetName, FleetUpdate properties, Context context); + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String fleetName); + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String fleetName, Context context); + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String fleetName); + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String fleetName, Context context); + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List Fleet resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List Fleet resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response listVirtualMachineScaleSetsWithResponse(String resourceGroupName, + String name, Context context); + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + VirtualMachineScaleSetListResultInner listVirtualMachineScaleSets(String resourceGroupName, String name); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/OperationsClient.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/OperationsClient.java new file mode 100644 index 0000000000000..d246da6970e51 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.computefleet.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/FleetInner.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/FleetInner.java new file mode 100644 index 0000000000000..708158787a157 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/FleetInner.java @@ -0,0 +1,286 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.computefleet.models.FleetProperties; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentity; +import com.azure.resourcemanager.computefleet.models.Plan; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * An Compute Fleet resource. + */ +@Fluent +public final class FleetInner extends Resource { + /* + * The resource-specific properties for this resource. + */ + private FleetProperties properties; + + /* + * Zones in which the Compute Fleet is available + */ + private List zones; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Details of the resource plan. + */ + private Plan plan; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /* + * The name of the resource. + */ + private String name; + + /* + * The type of the resource. + */ + private String type; + + /** + * Creates an instance of FleetInner class. + */ + public FleetInner() { + } + + /** + * Get the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + public FleetProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The resource-specific properties for this resource. + * + * @param properties the properties value to set. + * @return the FleetInner object itself. + */ + public FleetInner withProperties(FleetProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the zones property: Zones in which the Compute Fleet is available. + * + * @return the zones value. + */ + public List zones() { + return this.zones; + } + + /** + * Set the zones property: Zones in which the Compute Fleet is available. + * + * @param zones the zones value to set. + * @return the FleetInner object itself. + */ + public FleetInner withZones(List zones) { + this.zones = zones; + return this; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the FleetInner object itself. + */ + public FleetInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the plan property: Details of the resource plan. + * + * @return the plan value. + */ + public Plan plan() { + return this.plan; + } + + /** + * Set the plan property: Details of the resource plan. + * + * @param plan the plan value to set. + * @return the FleetInner object itself. + */ + public FleetInner withPlan(Plan plan) { + this.plan = plan; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * {@inheritDoc} + */ + @Override + public FleetInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public FleetInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + if (identity() != null) { + identity().validate(); + } + if (plan() != null) { + plan().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + jsonWriter.writeArrayField("zones", this.zones, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeJsonField("plan", this.plan); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FleetInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FleetInner if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FleetInner. + */ + public static FleetInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FleetInner deserializedFleetInner = new FleetInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedFleetInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedFleetInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedFleetInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedFleetInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedFleetInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedFleetInner.properties = FleetProperties.fromJson(reader); + } else if ("zones".equals(fieldName)) { + List zones = reader.readArray(reader1 -> reader1.getString()); + deserializedFleetInner.zones = zones; + } else if ("identity".equals(fieldName)) { + deserializedFleetInner.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("plan".equals(fieldName)) { + deserializedFleetInner.plan = Plan.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedFleetInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedFleetInner; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/OperationInner.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/OperationInner.java new file mode 100644 index 0000000000000..708872b353238 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/OperationInner.java @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.computefleet.models.ActionType; +import com.azure.resourcemanager.computefleet.models.OperationDisplay; +import com.azure.resourcemanager.computefleet.models.Origin; +import java.io.IOException; + +/** + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Immutable +public final class OperationInner implements JsonSerializable { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + * Resource Manager/control-plane operations. + */ + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + private Origin origin; + + /* + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + private OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("display", this.display); + jsonWriter.writeStringField("actionType", this.actionType == null ? null : this.actionType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationInner. + */ + public static OperationInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationInner deserializedOperationInner = new OperationInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationInner.name = reader.getString(); + } else if ("isDataAction".equals(fieldName)) { + deserializedOperationInner.isDataAction = reader.getNullable(JsonReader::getBoolean); + } else if ("display".equals(fieldName)) { + deserializedOperationInner.display = OperationDisplay.fromJson(reader); + } else if ("origin".equals(fieldName)) { + deserializedOperationInner.origin = Origin.fromString(reader.getString()); + } else if ("actionType".equals(fieldName)) { + deserializedOperationInner.actionType = ActionType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationInner; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/VirtualMachineScaleSetListResultInner.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/VirtualMachineScaleSetListResultInner.java new file mode 100644 index 0000000000000..926fd9f06ef24 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/VirtualMachineScaleSetListResultInner.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.computefleet.models.VirtualMachineScaleSet; +import java.io.IOException; +import java.util.List; + +/** + * The response of a VirtualMachineScaleSet list operation. + */ +@Immutable +public final class VirtualMachineScaleSetListResultInner + implements JsonSerializable { + /* + * The VirtualMachineScaleSet items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of VirtualMachineScaleSetListResultInner class. + */ + private VirtualMachineScaleSetListResultInner() { + } + + /** + * Get the value property: The VirtualMachineScaleSet items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property value in model VirtualMachineScaleSetListResultInner")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(VirtualMachineScaleSetListResultInner.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VirtualMachineScaleSetListResultInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VirtualMachineScaleSetListResultInner if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VirtualMachineScaleSetListResultInner. + */ + public static VirtualMachineScaleSetListResultInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VirtualMachineScaleSetListResultInner deserializedVirtualMachineScaleSetListResultInner + = new VirtualMachineScaleSetListResultInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> VirtualMachineScaleSet.fromJson(reader1)); + deserializedVirtualMachineScaleSetListResultInner.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedVirtualMachineScaleSetListResultInner.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedVirtualMachineScaleSetListResultInner; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/package-info.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/package-info.java new file mode 100644 index 0000000000000..3964e665c73a9 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for ComputeFleet. + */ +package com.azure.resourcemanager.computefleet.fluent.models; diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/package-info.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/package-info.java new file mode 100644 index 0000000000000..05f4ab839fd83 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/fluent/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for ComputeFleet. + */ +package com.azure.resourcemanager.computefleet.fluent; diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/AzureFleetClientBuilder.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/AzureFleetClientBuilder.java new file mode 100644 index 0000000000000..533a8e59a3c82 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/AzureFleetClientBuilder.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the AzureFleetClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { AzureFleetClientImpl.class }) +public final class AzureFleetClientBuilder { + /* + * Server parameter + */ + private String endpoint; + + /** + * Sets Server parameter. + * + * @param endpoint the endpoint value. + * @return the AzureFleetClientBuilder. + */ + public AzureFleetClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the AzureFleetClientBuilder. + */ + public AzureFleetClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the AzureFleetClientBuilder. + */ + public AzureFleetClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AzureFleetClientBuilder. + */ + public AzureFleetClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the AzureFleetClientBuilder. + */ + public AzureFleetClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the AzureFleetClientBuilder. + */ + public AzureFleetClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of AzureFleetClientImpl with the provided parameters. + * + * @return an instance of AzureFleetClientImpl. + */ + public AzureFleetClientImpl buildClient() { + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + AzureFleetClientImpl client = new AzureFleetClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, this.endpoint, this.subscriptionId); + return client; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/AzureFleetClientImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/AzureFleetClientImpl.java new file mode 100644 index 0000000000000..1c6069e318974 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/AzureFleetClientImpl.java @@ -0,0 +1,304 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.computefleet.fluent.AzureFleetClient; +import com.azure.resourcemanager.computefleet.fluent.FleetsClient; +import com.azure.resourcemanager.computefleet.fluent.OperationsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the AzureFleetClientImpl type. + */ +@ServiceClient(builder = AzureFleetClientBuilder.class) +public final class AzureFleetClientImpl implements AzureFleetClient { + /** + * Server parameter. + */ + private final String endpoint; + + /** + * Gets Server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The OperationsClient object to access its operations. + */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * The FleetsClient object to access its operations. + */ + private final FleetsClient fleets; + + /** + * Gets the FleetsClient object to access its operations. + * + * @return the FleetsClient object. + */ + public FleetsClient getFleets() { + return this.fleets; + } + + /** + * Initializes an instance of AzureFleetClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Server parameter. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + AzureFleetClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, Duration defaultPollInterval, + AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2024-05-01-preview"; + this.operations = new OperationsClientImpl(this); + this.fleets = new FleetsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AzureFleetClientImpl.class); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetImpl.java new file mode 100644 index 0000000000000..e0904e6d0ff96 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetImpl.java @@ -0,0 +1,228 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.computefleet.fluent.models.FleetInner; +import com.azure.resourcemanager.computefleet.models.Fleet; +import com.azure.resourcemanager.computefleet.models.FleetProperties; +import com.azure.resourcemanager.computefleet.models.FleetUpdate; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentity; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityUpdate; +import com.azure.resourcemanager.computefleet.models.Plan; +import com.azure.resourcemanager.computefleet.models.ResourcePlanUpdate; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public final class FleetImpl implements Fleet, Fleet.Definition, Fleet.Update { + private FleetInner innerObject; + + private final com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public FleetProperties properties() { + return this.innerModel().properties(); + } + + public List zones() { + List inner = this.innerModel().zones(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public Plan plan() { + return this.innerModel().plan(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public FleetInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.computefleet.ComputeFleetManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String fleetName; + + private FleetUpdate updateProperties; + + public FleetImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public Fleet create() { + this.innerObject = serviceManager.serviceClient() + .getFleets() + .createOrUpdate(resourceGroupName, fleetName, this.innerModel(), Context.NONE); + return this; + } + + public Fleet create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getFleets() + .createOrUpdate(resourceGroupName, fleetName, this.innerModel(), context); + return this; + } + + FleetImpl(String name, com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager) { + this.innerObject = new FleetInner(); + this.serviceManager = serviceManager; + this.fleetName = name; + } + + public FleetImpl update() { + this.updateProperties = new FleetUpdate(); + return this; + } + + public Fleet apply() { + this.innerObject = serviceManager.serviceClient() + .getFleets() + .update(resourceGroupName, fleetName, updateProperties, Context.NONE); + return this; + } + + public Fleet apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getFleets() + .update(resourceGroupName, fleetName, updateProperties, context); + return this; + } + + FleetImpl(FleetInner innerObject, com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.fleetName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "fleets"); + } + + public Fleet refresh() { + this.innerObject = serviceManager.serviceClient() + .getFleets() + .getByResourceGroupWithResponse(resourceGroupName, fleetName, Context.NONE) + .getValue(); + return this; + } + + public Fleet refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getFleets() + .getByResourceGroupWithResponse(resourceGroupName, fleetName, context) + .getValue(); + return this; + } + + public FleetImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public FleetImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public FleetImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateProperties.withTags(tags); + return this; + } + } + + public FleetImpl withProperties(FleetProperties properties) { + if (isInCreateMode()) { + this.innerModel().withProperties(properties); + return this; + } else { + this.updateProperties.withProperties(properties); + return this; + } + } + + public FleetImpl withZones(List zones) { + this.innerModel().withZones(zones); + return this; + } + + public FleetImpl withIdentity(ManagedServiceIdentity identity) { + this.innerModel().withIdentity(identity); + return this; + } + + public FleetImpl withPlan(Plan plan) { + this.innerModel().withPlan(plan); + return this; + } + + public FleetImpl withIdentity(ManagedServiceIdentityUpdate identity) { + this.updateProperties.withIdentity(identity); + return this; + } + + public FleetImpl withPlan(ResourcePlanUpdate plan) { + this.updateProperties.withPlan(plan); + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetsClientImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetsClientImpl.java new file mode 100644 index 0000000000000..86f6606cca790 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetsClientImpl.java @@ -0,0 +1,1393 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.computefleet.fluent.FleetsClient; +import com.azure.resourcemanager.computefleet.fluent.models.FleetInner; +import com.azure.resourcemanager.computefleet.fluent.models.VirtualMachineScaleSetListResultInner; +import com.azure.resourcemanager.computefleet.implementation.models.FleetListResult; +import com.azure.resourcemanager.computefleet.models.FleetUpdate; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in FleetsClient. + */ +public final class FleetsClientImpl implements FleetsClient { + /** + * The proxy service used to perform REST calls. + */ + private final FleetsService service; + + /** + * The service client containing this operation class. + */ + private final AzureFleetClientImpl client; + + /** + * Initializes an instance of FleetsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FleetsClientImpl(AzureFleetClientImpl client) { + this.service = RestProxy.create(FleetsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureFleetClientFleets to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AzureFleetClientFlee") + public interface FleetsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("fleetName") String fleetName, + @HeaderParam("accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("fleetName") String fleetName, + @HeaderParam("accept") String accept, @BodyParam("application/json") FleetInner resource, Context context); + + @Headers({ "Content-Type: application/json" }) + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("fleetName") String fleetName, + @HeaderParam("accept") String accept, @BodyParam("application/json") FleetUpdate properties, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName}") + @ExpectedResponses({ 202, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("fleetName") String fleetName, + @HeaderParam("accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.AzureFleet/fleets") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{name}/virtualMachineScaleSets") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listVirtualMachineScaleSets( + @HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("name") String name, + @HeaderParam("accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, Context context); + } + + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String fleetName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, fleetName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync(String resourceGroupName, String fleetName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, fleetName, accept, context); + } + + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String fleetName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, fleetName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, String fleetName, + Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, fleetName, context).block(); + } + + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FleetInner getByResourceGroup(String resourceGroupName, String fleetName) { + return getByResourceGroupWithResponse(resourceGroupName, fleetName, Context.NONE).getValue(); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String fleetName, + FleetInner resource) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, fleetName, accept, resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync(String resourceGroupName, String fleetName, + FleetInner resource, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + if (resource == null) { + return Mono.error(new IllegalArgumentException("Parameter resource is required and cannot be null.")); + } else { + resource.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, fleetName, accept, resource, context); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, FleetInner> beginCreateOrUpdateAsync(String resourceGroupName, + String fleetName, FleetInner resource) { + Mono>> mono = createOrUpdateWithResponseAsync(resourceGroupName, fleetName, resource); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), FleetInner.class, + FleetInner.class, this.client.getContext()); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, FleetInner> beginCreateOrUpdateAsync(String resourceGroupName, + String fleetName, FleetInner resource, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createOrUpdateWithResponseAsync(resourceGroupName, fleetName, resource, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), FleetInner.class, + FleetInner.class, context); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, FleetInner> beginCreateOrUpdate(String resourceGroupName, + String fleetName, FleetInner resource) { + return this.beginCreateOrUpdateAsync(resourceGroupName, fleetName, resource).getSyncPoller(); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, FleetInner> beginCreateOrUpdate(String resourceGroupName, + String fleetName, FleetInner resource, Context context) { + return this.beginCreateOrUpdateAsync(resourceGroupName, fleetName, resource, context).getSyncPoller(); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String fleetName, FleetInner resource) { + return beginCreateOrUpdateAsync(resourceGroupName, fleetName, resource).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, String fleetName, FleetInner resource, + Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, fleetName, resource, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FleetInner createOrUpdate(String resourceGroupName, String fleetName, FleetInner resource) { + return createOrUpdateAsync(resourceGroupName, fleetName, resource).block(); + } + + /** + * Create a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param resource Resource create parameters. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FleetInner createOrUpdate(String resourceGroupName, String fleetName, FleetInner resource, Context context) { + return createOrUpdateAsync(resourceGroupName, fleetName, resource, context).block(); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String fleetName, + FleetUpdate properties) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, fleetName, accept, properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync(String resourceGroupName, String fleetName, + FleetUpdate properties, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + if (properties == null) { + return Mono.error(new IllegalArgumentException("Parameter properties is required and cannot be null.")); + } else { + properties.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.update(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, fleetName, accept, properties, context); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, FleetInner> beginUpdateAsync(String resourceGroupName, String fleetName, + FleetUpdate properties) { + Mono>> mono = updateWithResponseAsync(resourceGroupName, fleetName, properties); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), FleetInner.class, + FleetInner.class, this.client.getContext()); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, FleetInner> beginUpdateAsync(String resourceGroupName, String fleetName, + FleetUpdate properties, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = updateWithResponseAsync(resourceGroupName, fleetName, properties, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), FleetInner.class, + FleetInner.class, context); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, FleetInner> beginUpdate(String resourceGroupName, String fleetName, + FleetUpdate properties) { + return this.beginUpdateAsync(resourceGroupName, fleetName, properties).getSyncPoller(); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, FleetInner> beginUpdate(String resourceGroupName, String fleetName, + FleetUpdate properties, Context context) { + return this.beginUpdateAsync(resourceGroupName, fleetName, properties, context).getSyncPoller(); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String fleetName, FleetUpdate properties) { + return beginUpdateAsync(resourceGroupName, fleetName, properties).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String fleetName, FleetUpdate properties, + Context context) { + return beginUpdateAsync(resourceGroupName, fleetName, properties, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FleetInner update(String resourceGroupName, String fleetName, FleetUpdate properties) { + return updateAsync(resourceGroupName, fleetName, properties).block(); + } + + /** + * Update a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param properties The resource properties to be updated. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an Compute Fleet resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FleetInner update(String resourceGroupName, String fleetName, FleetUpdate properties, Context context) { + return updateAsync(resourceGroupName, fleetName, properties, context).block(); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String fleetName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, fleetName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String fleetName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (fleetName == null) { + return Mono.error(new IllegalArgumentException("Parameter fleetName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.delete(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, fleetName, accept, context); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String fleetName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, fleetName); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + this.client.getContext()); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String fleetName, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = deleteWithResponseAsync(resourceGroupName, fleetName, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, + context); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String fleetName) { + return this.beginDeleteAsync(resourceGroupName, fleetName).getSyncPoller(); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String fleetName, Context context) { + return this.beginDeleteAsync(resourceGroupName, fleetName, context).getSyncPoller(); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String fleetName) { + return beginDeleteAsync(resourceGroupName, fleetName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String fleetName, Context context) { + return beginDeleteAsync(resourceGroupName, fleetName, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String fleetName) { + deleteAsync(resourceGroupName, fleetName).block(); + } + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String fleetName, Context context) { + deleteAsync(resourceGroupName, fleetName, context).block(); + } + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * List Fleet resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List Fleet resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), accept, + context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List Fleet resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * List Fleet resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * List Fleet resources by subscription ID. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List Fleet resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listVirtualMachineScaleSetsWithResponseAsync(String resourceGroupName, String name) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listVirtualMachineScaleSets(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, name, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation along with {@link Response} on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listVirtualMachineScaleSetsWithResponseAsync(String resourceGroupName, String name, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (name == null) { + return Mono.error(new IllegalArgumentException("Parameter name is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listVirtualMachineScaleSets(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, name, accept, context); + } + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono listVirtualMachineScaleSetsAsync(String resourceGroupName, + String name) { + return listVirtualMachineScaleSetsWithResponseAsync(resourceGroupName, name) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response + listVirtualMachineScaleSetsWithResponse(String resourceGroupName, String name, Context context) { + return listVirtualMachineScaleSetsWithResponseAsync(resourceGroupName, name, context).block(); + } + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public VirtualMachineScaleSetListResultInner listVirtualMachineScaleSets(String resourceGroupName, String name) { + return listVirtualMachineScaleSetsWithResponse(resourceGroupName, name, Context.NONE).getValue(); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetsImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetsImpl.java new file mode 100644 index 0000000000000..6e6beb9a79dd1 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/FleetsImpl.java @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.computefleet.fluent.FleetsClient; +import com.azure.resourcemanager.computefleet.fluent.models.FleetInner; +import com.azure.resourcemanager.computefleet.fluent.models.VirtualMachineScaleSetListResultInner; +import com.azure.resourcemanager.computefleet.models.Fleet; +import com.azure.resourcemanager.computefleet.models.Fleets; +import com.azure.resourcemanager.computefleet.models.VirtualMachineScaleSetListResult; + +public final class FleetsImpl implements Fleets { + private static final ClientLogger LOGGER = new ClientLogger(FleetsImpl.class); + + private final FleetsClient innerClient; + + private final com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager; + + public FleetsImpl(FleetsClient innerClient, + com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, String fleetName, Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, fleetName, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new FleetImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Fleet getByResourceGroup(String resourceGroupName, String fleetName) { + FleetInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, fleetName); + if (inner != null) { + return new FleetImpl(inner, this.manager()); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String fleetName) { + this.serviceClient().delete(resourceGroupName, fleetName); + } + + public void delete(String resourceGroupName, String fleetName, Context context) { + this.serviceClient().delete(resourceGroupName, fleetName, context); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, inner1 -> new FleetImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new FleetImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new FleetImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new FleetImpl(inner1, this.manager())); + } + + public Response listVirtualMachineScaleSetsWithResponse(String resourceGroupName, + String name, Context context) { + Response inner + = this.serviceClient().listVirtualMachineScaleSetsWithResponse(resourceGroupName, name, context); + if (inner != null) { + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new VirtualMachineScaleSetListResultImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public VirtualMachineScaleSetListResult listVirtualMachineScaleSets(String resourceGroupName, String name) { + VirtualMachineScaleSetListResultInner inner + = this.serviceClient().listVirtualMachineScaleSets(resourceGroupName, name); + if (inner != null) { + return new VirtualMachineScaleSetListResultImpl(inner, this.manager()); + } else { + return null; + } + } + + public Fleet getById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String fleetName = ResourceManagerUtils.getValueFromIdByName(id, "fleets"); + if (fleetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'fleets'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, fleetName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String fleetName = ResourceManagerUtils.getValueFromIdByName(id, "fleets"); + if (fleetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'fleets'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, fleetName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String fleetName = ResourceManagerUtils.getValueFromIdByName(id, "fleets"); + if (fleetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'fleets'.", id))); + } + this.delete(resourceGroupName, fleetName, Context.NONE); + } + + public void deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String fleetName = ResourceManagerUtils.getValueFromIdByName(id, "fleets"); + if (fleetName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'fleets'.", id))); + } + this.delete(resourceGroupName, fleetName, context); + } + + private FleetsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.computefleet.ComputeFleetManager manager() { + return this.serviceManager; + } + + public FleetImpl define(String name) { + return new FleetImpl(name, this.manager()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationImpl.java new file mode 100644 index 0000000000000..32190c6d2aec3 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationImpl.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.resourcemanager.computefleet.fluent.models.OperationInner; +import com.azure.resourcemanager.computefleet.models.ActionType; +import com.azure.resourcemanager.computefleet.models.Operation; +import com.azure.resourcemanager.computefleet.models.OperationDisplay; +import com.azure.resourcemanager.computefleet.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager; + + OperationImpl(OperationInner innerObject, + com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.computefleet.ComputeFleetManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationsClientImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationsClientImpl.java new file mode 100644 index 0000000000000..3d80ee86d3361 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationsClientImpl.java @@ -0,0 +1,235 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.computefleet.fluent.OperationsClient; +import com.azure.resourcemanager.computefleet.fluent.models.OperationInner; +import com.azure.resourcemanager.computefleet.implementation.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final AzureFleetClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(AzureFleetClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureFleetClientOperations to be used by the proxy service to perform + * REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "AzureFleetClientOper") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.AzureFleet/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.listNext(nextLink, this.client.getEndpoint(), accept, context) + .map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), + res.getValue().value(), res.getValue().nextLink(), null)); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationsImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..24cf2c1b5c387 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.computefleet.fluent.OperationsClient; +import com.azure.resourcemanager.computefleet.fluent.models.OperationInner; +import com.azure.resourcemanager.computefleet.models.Operation; +import com.azure.resourcemanager.computefleet.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.computefleet.ComputeFleetManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/ResourceManagerUtils.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000000..c39912a5f0865 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/VirtualMachineScaleSetListResultImpl.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/VirtualMachineScaleSetListResultImpl.java new file mode 100644 index 0000000000000..cf2af2831c15a --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/VirtualMachineScaleSetListResultImpl.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation; + +import com.azure.resourcemanager.computefleet.fluent.models.VirtualMachineScaleSetListResultInner; +import com.azure.resourcemanager.computefleet.models.VirtualMachineScaleSet; +import com.azure.resourcemanager.computefleet.models.VirtualMachineScaleSetListResult; +import java.util.Collections; +import java.util.List; + +public final class VirtualMachineScaleSetListResultImpl implements VirtualMachineScaleSetListResult { + private VirtualMachineScaleSetListResultInner innerObject; + + private final com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager; + + VirtualMachineScaleSetListResultImpl(VirtualMachineScaleSetListResultInner innerObject, + com.azure.resourcemanager.computefleet.ComputeFleetManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public List value() { + List inner = this.innerModel().value(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public String nextLink() { + return this.innerModel().nextLink(); + } + + public VirtualMachineScaleSetListResultInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.computefleet.ComputeFleetManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/models/FleetListResult.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/models/FleetListResult.java new file mode 100644 index 0000000000000..fdf20fa4ef1ba --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/models/FleetListResult.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.computefleet.fluent.models.FleetInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a Fleet list operation. + */ +@Immutable +public final class FleetListResult implements JsonSerializable { + /* + * The Fleet items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of FleetListResult class. + */ + private FleetListResult() { + } + + /** + * Get the value property: The Fleet items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model FleetListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(FleetListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FleetListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FleetListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FleetListResult. + */ + public static FleetListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FleetListResult deserializedFleetListResult = new FleetListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> FleetInner.fromJson(reader1)); + deserializedFleetListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedFleetListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedFleetListResult; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/models/OperationListResult.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/models/OperationListResult.java new file mode 100644 index 0000000000000..dbb0c9a5a9dc6 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/models/OperationListResult.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.computefleet.fluent.models.OperationInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult implements JsonSerializable { + /* + * The Operation items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + private OperationListResult() { + } + + /** + * Get the value property: The Operation items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property value in model OperationListResult")); + } else { + value().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(OperationListResult.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OperationListResult. + */ + public static OperationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationListResult deserializedOperationListResult = new OperationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> OperationInner.fromJson(reader1)); + deserializedOperationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedOperationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationListResult; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/package-info.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/package-info.java new file mode 100644 index 0000000000000..ff2f1862d8c98 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/implementation/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ComputeFleet. + */ +package com.azure.resourcemanager.computefleet.implementation; diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ActionType.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ActionType.java new file mode 100644 index 0000000000000..f6791ec490e14 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ActionType.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Static value Internal for ActionType. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ComputeProfile.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ComputeProfile.java new file mode 100644 index 0000000000000..973d53e2260a8 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ComputeProfile.java @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Compute Profile to use for running user's workloads. + */ +@Fluent +public final class ComputeProfile implements JsonSerializable { + /* + * Base Virtual Machine Profile Properties to be specified according to + * "specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/{computeApiVersion}/virtualMachineScaleSet.json#/definitions/VirtualMachineScaleSetVMProfile" + */ + private Object baseVirtualMachineProfile; + + /* + * Specifies the Microsoft.Compute API version to use when creating underlying Virtual Machine scale sets and + * Virtual Machines. + * The default value will be the latest supported computeApiVersion by Compute Fleet. + */ + private String computeApiVersion; + + /* + * Specifies the number of fault domains to use when creating the underlying VMSS. + * A fault domain is a logical group of hardware within an Azure datacenter. + * VMs in the same fault domain share a common power source and network switch. + * If not specified, defaults to 1, which represents "Max Spreading" (using as many fault domains as possible). + * This property cannot be updated. + */ + private Integer platformFaultDomainCount; + + /** + * Creates an instance of ComputeProfile class. + */ + public ComputeProfile() { + } + + /** + * Get the baseVirtualMachineProfile property: Base Virtual Machine Profile Properties to be specified according to + * "specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/{computeApiVersion}/virtualMachineScaleSet.json#/definitions/VirtualMachineScaleSetVMProfile". + * + * @return the baseVirtualMachineProfile value. + */ + public Object baseVirtualMachineProfile() { + return this.baseVirtualMachineProfile; + } + + /** + * Set the baseVirtualMachineProfile property: Base Virtual Machine Profile Properties to be specified according to + * "specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/{computeApiVersion}/virtualMachineScaleSet.json#/definitions/VirtualMachineScaleSetVMProfile". + * + * @param baseVirtualMachineProfile the baseVirtualMachineProfile value to set. + * @return the ComputeProfile object itself. + */ + public ComputeProfile withBaseVirtualMachineProfile(Object baseVirtualMachineProfile) { + this.baseVirtualMachineProfile = baseVirtualMachineProfile; + return this; + } + + /** + * Get the computeApiVersion property: Specifies the Microsoft.Compute API version to use when creating underlying + * Virtual Machine scale sets and Virtual Machines. + * The default value will be the latest supported computeApiVersion by Compute Fleet. + * + * @return the computeApiVersion value. + */ + public String computeApiVersion() { + return this.computeApiVersion; + } + + /** + * Set the computeApiVersion property: Specifies the Microsoft.Compute API version to use when creating underlying + * Virtual Machine scale sets and Virtual Machines. + * The default value will be the latest supported computeApiVersion by Compute Fleet. + * + * @param computeApiVersion the computeApiVersion value to set. + * @return the ComputeProfile object itself. + */ + public ComputeProfile withComputeApiVersion(String computeApiVersion) { + this.computeApiVersion = computeApiVersion; + return this; + } + + /** + * Get the platformFaultDomainCount property: Specifies the number of fault domains to use when creating the + * underlying VMSS. + * A fault domain is a logical group of hardware within an Azure datacenter. + * VMs in the same fault domain share a common power source and network switch. + * If not specified, defaults to 1, which represents "Max Spreading" (using as many fault domains as possible). + * This property cannot be updated. + * + * @return the platformFaultDomainCount value. + */ + public Integer platformFaultDomainCount() { + return this.platformFaultDomainCount; + } + + /** + * Set the platformFaultDomainCount property: Specifies the number of fault domains to use when creating the + * underlying VMSS. + * A fault domain is a logical group of hardware within an Azure datacenter. + * VMs in the same fault domain share a common power source and network switch. + * If not specified, defaults to 1, which represents "Max Spreading" (using as many fault domains as possible). + * This property cannot be updated. + * + * @param platformFaultDomainCount the platformFaultDomainCount value to set. + * @return the ComputeProfile object itself. + */ + public ComputeProfile withPlatformFaultDomainCount(Integer platformFaultDomainCount) { + this.platformFaultDomainCount = platformFaultDomainCount; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (baseVirtualMachineProfile() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property baseVirtualMachineProfile in model ComputeProfile")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ComputeProfile.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeUntypedField("baseVirtualMachineProfile", this.baseVirtualMachineProfile); + jsonWriter.writeStringField("computeApiVersion", this.computeApiVersion); + jsonWriter.writeNumberField("platformFaultDomainCount", this.platformFaultDomainCount); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ComputeProfile from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ComputeProfile if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ComputeProfile. + */ + public static ComputeProfile fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ComputeProfile deserializedComputeProfile = new ComputeProfile(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("baseVirtualMachineProfile".equals(fieldName)) { + deserializedComputeProfile.baseVirtualMachineProfile = reader.readUntyped(); + } else if ("computeApiVersion".equals(fieldName)) { + deserializedComputeProfile.computeApiVersion = reader.getString(); + } else if ("platformFaultDomainCount".equals(fieldName)) { + deserializedComputeProfile.platformFaultDomainCount = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + + return deserializedComputeProfile; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/EvictionPolicy.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/EvictionPolicy.java new file mode 100644 index 0000000000000..146928fa6f8da --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/EvictionPolicy.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Different kind of eviction policies. + */ +public final class EvictionPolicy extends ExpandableStringEnum { + /** + * Static value Delete for EvictionPolicy. + */ + public static final EvictionPolicy DELETE = fromString("Delete"); + + /** + * Static value Deallocate for EvictionPolicy. + */ + public static final EvictionPolicy DEALLOCATE = fromString("Deallocate"); + + /** + * Creates a new instance of EvictionPolicy value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public EvictionPolicy() { + } + + /** + * Creates or finds a EvictionPolicy from its string representation. + * + * @param name a name to look for. + * @return the corresponding EvictionPolicy. + */ + public static EvictionPolicy fromString(String name) { + return fromString(name, EvictionPolicy.class); + } + + /** + * Gets known EvictionPolicy values. + * + * @return known EvictionPolicy values. + */ + public static Collection values() { + return values(EvictionPolicy.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Fleet.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Fleet.java new file mode 100644 index 0000000000000..f52ef89a2d126 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Fleet.java @@ -0,0 +1,354 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.computefleet.fluent.models.FleetInner; +import java.util.List; +import java.util.Map; + +/** + * An immutable client-side representation of Fleet. + */ +public interface Fleet { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the properties property: The resource-specific properties for this resource. + * + * @return the properties value. + */ + FleetProperties properties(); + + /** + * Gets the zones property: Zones in which the Compute Fleet is available. + * + * @return the zones value. + */ + List zones(); + + /** + * Gets the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the plan property: Details of the resource plan. + * + * @return the plan value. + */ + Plan plan(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.computefleet.fluent.models.FleetInner object. + * + * @return the inner object. + */ + FleetInner innerModel(); + + /** + * The entirety of the Fleet definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The Fleet definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the Fleet definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the Fleet definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the Fleet definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the Fleet definition which contains all the minimum required properties for the resource to be + * created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags, DefinitionStages.WithProperties, + DefinitionStages.WithZones, DefinitionStages.WithIdentity, DefinitionStages.WithPlan { + /** + * Executes the create request. + * + * @return the created resource. + */ + Fleet create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + Fleet create(Context context); + } + + /** + * The stage of the Fleet definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the Fleet definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: The resource-specific properties for this resource.. + * + * @param properties The resource-specific properties for this resource. + * @return the next definition stage. + */ + WithCreate withProperties(FleetProperties properties); + } + + /** + * The stage of the Fleet definition allowing to specify zones. + */ + interface WithZones { + /** + * Specifies the zones property: Zones in which the Compute Fleet is available. + * + * @param zones Zones in which the Compute Fleet is available. + * @return the next definition stage. + */ + WithCreate withZones(List zones); + } + + /** + * The stage of the Fleet definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the Fleet definition allowing to specify plan. + */ + interface WithPlan { + /** + * Specifies the plan property: Details of the resource plan.. + * + * @param plan Details of the resource plan. + * @return the next definition stage. + */ + WithCreate withPlan(Plan plan); + } + } + + /** + * Begins update for the Fleet resource. + * + * @return the stage of resource update. + */ + Fleet.Update update(); + + /** + * The template for Fleet update. + */ + interface Update + extends UpdateStages.WithTags, UpdateStages.WithIdentity, UpdateStages.WithPlan, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + Fleet apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + Fleet apply(Context context); + } + + /** + * The Fleet update stages. + */ + interface UpdateStages { + /** + * The stage of the Fleet update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the Fleet update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: Updatable managed service identity. + * + * @param identity Updatable managed service identity. + * @return the next definition stage. + */ + Update withIdentity(ManagedServiceIdentityUpdate identity); + } + + /** + * The stage of the Fleet update allowing to specify plan. + */ + interface WithPlan { + /** + * Specifies the plan property: Updatable resource plan. + * + * @param plan Updatable resource plan. + * @return the next definition stage. + */ + Update withPlan(ResourcePlanUpdate plan); + } + + /** + * The stage of the Fleet update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: RP-specific updatable properties. + * + * @param properties RP-specific updatable properties. + * @return the next definition stage. + */ + Update withProperties(FleetProperties properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + Fleet refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + Fleet refresh(Context context); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/FleetProperties.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/FleetProperties.java new file mode 100644 index 0000000000000..f90dd4745a16d --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/FleetProperties.java @@ -0,0 +1,218 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Details of the Compute Fleet. + */ +@Fluent +public final class FleetProperties implements JsonSerializable { + /* + * The status of the last operation. + */ + private ProvisioningState provisioningState; + + /* + * Configuration Options for Spot instances in Compute Fleet. + */ + private SpotPriorityProfile spotPriorityProfile; + + /* + * Configuration Options for Regular instances in Compute Fleet. + */ + private RegularPriorityProfile regularPriorityProfile; + + /* + * List of VM sizes supported for Compute Fleet + */ + private List vmSizesProfile; + + /* + * Compute Profile to use for running user's workloads. + */ + private ComputeProfile computeProfile; + + /** + * Creates an instance of FleetProperties class. + */ + public FleetProperties() { + } + + /** + * Get the provisioningState property: The status of the last operation. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the spotPriorityProfile property: Configuration Options for Spot instances in Compute Fleet. + * + * @return the spotPriorityProfile value. + */ + public SpotPriorityProfile spotPriorityProfile() { + return this.spotPriorityProfile; + } + + /** + * Set the spotPriorityProfile property: Configuration Options for Spot instances in Compute Fleet. + * + * @param spotPriorityProfile the spotPriorityProfile value to set. + * @return the FleetProperties object itself. + */ + public FleetProperties withSpotPriorityProfile(SpotPriorityProfile spotPriorityProfile) { + this.spotPriorityProfile = spotPriorityProfile; + return this; + } + + /** + * Get the regularPriorityProfile property: Configuration Options for Regular instances in Compute Fleet. + * + * @return the regularPriorityProfile value. + */ + public RegularPriorityProfile regularPriorityProfile() { + return this.regularPriorityProfile; + } + + /** + * Set the regularPriorityProfile property: Configuration Options for Regular instances in Compute Fleet. + * + * @param regularPriorityProfile the regularPriorityProfile value to set. + * @return the FleetProperties object itself. + */ + public FleetProperties withRegularPriorityProfile(RegularPriorityProfile regularPriorityProfile) { + this.regularPriorityProfile = regularPriorityProfile; + return this; + } + + /** + * Get the vmSizesProfile property: List of VM sizes supported for Compute Fleet. + * + * @return the vmSizesProfile value. + */ + public List vmSizesProfile() { + return this.vmSizesProfile; + } + + /** + * Set the vmSizesProfile property: List of VM sizes supported for Compute Fleet. + * + * @param vmSizesProfile the vmSizesProfile value to set. + * @return the FleetProperties object itself. + */ + public FleetProperties withVmSizesProfile(List vmSizesProfile) { + this.vmSizesProfile = vmSizesProfile; + return this; + } + + /** + * Get the computeProfile property: Compute Profile to use for running user's workloads. + * + * @return the computeProfile value. + */ + public ComputeProfile computeProfile() { + return this.computeProfile; + } + + /** + * Set the computeProfile property: Compute Profile to use for running user's workloads. + * + * @param computeProfile the computeProfile value to set. + * @return the FleetProperties object itself. + */ + public FleetProperties withComputeProfile(ComputeProfile computeProfile) { + this.computeProfile = computeProfile; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (spotPriorityProfile() != null) { + spotPriorityProfile().validate(); + } + if (regularPriorityProfile() != null) { + regularPriorityProfile().validate(); + } + if (vmSizesProfile() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property vmSizesProfile in model FleetProperties")); + } else { + vmSizesProfile().forEach(e -> e.validate()); + } + if (computeProfile() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property computeProfile in model FleetProperties")); + } else { + computeProfile().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(FleetProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("vmSizesProfile", this.vmSizesProfile, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("computeProfile", this.computeProfile); + jsonWriter.writeJsonField("spotPriorityProfile", this.spotPriorityProfile); + jsonWriter.writeJsonField("regularPriorityProfile", this.regularPriorityProfile); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FleetProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FleetProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the FleetProperties. + */ + public static FleetProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FleetProperties deserializedFleetProperties = new FleetProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("vmSizesProfile".equals(fieldName)) { + List vmSizesProfile = reader.readArray(reader1 -> VmSizeProfile.fromJson(reader1)); + deserializedFleetProperties.vmSizesProfile = vmSizesProfile; + } else if ("computeProfile".equals(fieldName)) { + deserializedFleetProperties.computeProfile = ComputeProfile.fromJson(reader); + } else if ("provisioningState".equals(fieldName)) { + deserializedFleetProperties.provisioningState = ProvisioningState.fromString(reader.getString()); + } else if ("spotPriorityProfile".equals(fieldName)) { + deserializedFleetProperties.spotPriorityProfile = SpotPriorityProfile.fromJson(reader); + } else if ("regularPriorityProfile".equals(fieldName)) { + deserializedFleetProperties.regularPriorityProfile = RegularPriorityProfile.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedFleetProperties; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/FleetUpdate.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/FleetUpdate.java new file mode 100644 index 0000000000000..fc76009182c30 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/FleetUpdate.java @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Fleet Update Model. + */ +@Fluent +public final class FleetUpdate implements JsonSerializable { + /* + * Resource tags. + */ + private Map tags; + + /* + * Updatable managed service identity + */ + private ManagedServiceIdentityUpdate identity; + + /* + * Updatable resource plan + */ + private ResourcePlanUpdate plan; + + /* + * RP-specific updatable properties + */ + private FleetProperties properties; + + /** + * Creates an instance of FleetUpdate class. + */ + public FleetUpdate() { + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the FleetUpdate object itself. + */ + public FleetUpdate withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the identity property: Updatable managed service identity. + * + * @return the identity value. + */ + public ManagedServiceIdentityUpdate identity() { + return this.identity; + } + + /** + * Set the identity property: Updatable managed service identity. + * + * @param identity the identity value to set. + * @return the FleetUpdate object itself. + */ + public FleetUpdate withIdentity(ManagedServiceIdentityUpdate identity) { + this.identity = identity; + return this; + } + + /** + * Get the plan property: Updatable resource plan. + * + * @return the plan value. + */ + public ResourcePlanUpdate plan() { + return this.plan; + } + + /** + * Set the plan property: Updatable resource plan. + * + * @param plan the plan value to set. + * @return the FleetUpdate object itself. + */ + public FleetUpdate withPlan(ResourcePlanUpdate plan) { + this.plan = plan; + return this; + } + + /** + * Get the properties property: RP-specific updatable properties. + * + * @return the properties value. + */ + public FleetProperties properties() { + return this.properties; + } + + /** + * Set the properties property: RP-specific updatable properties. + * + * @param properties the properties value to set. + * @return the FleetUpdate object itself. + */ + public FleetUpdate withProperties(FleetProperties properties) { + this.properties = properties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + if (plan() != null) { + plan().validate(); + } + if (properties() != null) { + properties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeJsonField("plan", this.plan); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FleetUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FleetUpdate if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the FleetUpdate. + */ + public static FleetUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FleetUpdate deserializedFleetUpdate = new FleetUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedFleetUpdate.tags = tags; + } else if ("identity".equals(fieldName)) { + deserializedFleetUpdate.identity = ManagedServiceIdentityUpdate.fromJson(reader); + } else if ("plan".equals(fieldName)) { + deserializedFleetUpdate.plan = ResourcePlanUpdate.fromJson(reader); + } else if ("properties".equals(fieldName)) { + deserializedFleetUpdate.properties = FleetProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedFleetUpdate; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Fleets.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Fleets.java new file mode 100644 index 0000000000000..743ef9709c591 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Fleets.java @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** + * Resource collection API of Fleets. + */ +public interface Fleets { + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, String fleetName, Context context); + + /** + * Get a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet. + */ + Fleet getByResourceGroup(String resourceGroupName, String fleetName); + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String fleetName); + + /** + * Delete a Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param fleetName The name of the Compute Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String resourceGroupName, String fleetName, Context context); + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * List Fleet resources by resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * List Fleet resources by subscription ID. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List Fleet resources by subscription ID. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a Fleet list operation as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation along with {@link Response}. + */ + Response listVirtualMachineScaleSetsWithResponse(String resourceGroupName, + String name, Context context); + + /** + * List VirtualMachineScaleSet resources by Fleet. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param name The name of the Fleet. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a VirtualMachineScaleSet list operation. + */ + VirtualMachineScaleSetListResult listVirtualMachineScaleSets(String resourceGroupName, String name); + + /** + * Get a Fleet. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet along with {@link Response}. + */ + Fleet getById(String id); + + /** + * Get a Fleet. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a Fleet along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Fleet. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a Fleet. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new Fleet resource. + * + * @param name resource name. + * @return the first stage of the new Fleet definition. + */ + Fleet.DefinitionStages.Blank define(String name); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentity.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentity.java new file mode 100644 index 0000000000000..6bd83069982c7 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentity.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity implements JsonSerializable { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + private String principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + private String tenantId; + + /* + * The type of managed identity assigned to this resource. + */ + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property type in model ManagedServiceIdentity")); + } + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(ManagedServiceIdentity.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagedServiceIdentity. + */ + public static ManagedServiceIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentity deserializedManagedServiceIdentity = new ManagedServiceIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentity.type = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedManagedServiceIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedManagedServiceIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentity; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentityType.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentityType.java new file mode 100644 index 0000000000000..a2f772284143f --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentityType.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * Static value None for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * Static value SystemAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * Static value UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * Static value SystemAssigned,UserAssigned for ManagedServiceIdentityType. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentityUpdate.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentityUpdate.java new file mode 100644 index 0000000000000..f66d0e528b296 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ManagedServiceIdentityUpdate.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * The template for adding optional properties. + */ +@Fluent +public final class ManagedServiceIdentityUpdate implements JsonSerializable { + /* + * The type of managed identity assigned to this resource. + */ + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentityUpdate class. + */ + public ManagedServiceIdentityUpdate() { + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentityUpdate object itself. + */ + public ManagedServiceIdentityUpdate withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentityUpdate object itself. + */ + public ManagedServiceIdentityUpdate + withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentityUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentityUpdate if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ManagedServiceIdentityUpdate. + */ + public static ManagedServiceIdentityUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentityUpdate deserializedManagedServiceIdentityUpdate = new ManagedServiceIdentityUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentityUpdate.type + = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentityUpdate.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentityUpdate; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Operation.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Operation.java new file mode 100644 index 0000000000000..7aa5d577017d0 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.resourcemanager.computefleet.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.computefleet.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/OperationDisplay.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/OperationDisplay.java new file mode 100644 index 0000000000000..f3fda147c45b2 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/OperationDisplay.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Localized display information for and operation. + */ +@Immutable +public final class OperationDisplay implements JsonSerializable { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + private OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("provider", this.provider); + jsonWriter.writeStringField("resource", this.resource); + jsonWriter.writeStringField("operation", this.operation); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDisplay from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplay if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationDisplay. + */ + public static OperationDisplay fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplay deserializedOperationDisplay = new OperationDisplay(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provider".equals(fieldName)) { + deserializedOperationDisplay.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplay.resource = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplay.operation = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedOperationDisplay.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplay; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Operations.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Operations.java new file mode 100644 index 0000000000000..5bbdabc2beee7 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Origin.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Origin.java new file mode 100644 index 0000000000000..9fd950dc7884c --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Origin.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Static value user for Origin. + */ + public static final Origin USER = fromString("user"); + + /** + * Static value system for Origin. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Static value user,system for Origin. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Plan.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Plan.java new file mode 100644 index 0000000000000..1c8449c849d75 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/Plan.java @@ -0,0 +1,224 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Plan for the resource. + */ +@Fluent +public final class Plan implements JsonSerializable { + /* + * A user defined name of the 3rd Party Artifact that is being procured. + */ + private String name; + + /* + * The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + */ + private String publisher; + + /* + * The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the + * artifact at the time of Data Market onboarding. + */ + private String product; + + /* + * A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + */ + private String promotionCode; + + /* + * The version of the desired product/artifact. + */ + private String version; + + /** + * Creates an instance of Plan class. + */ + public Plan() { + } + + /** + * Get the name property: A user defined name of the 3rd Party Artifact that is being procured. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: A user defined name of the 3rd Party Artifact that is being procured. + * + * @param name the name value to set. + * @return the Plan object itself. + */ + public Plan withName(String name) { + this.name = name; + return this; + } + + /** + * Get the publisher property: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + * + * @return the publisher value. + */ + public String publisher() { + return this.publisher; + } + + /** + * Set the publisher property: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + * + * @param publisher the publisher value to set. + * @return the Plan object itself. + */ + public Plan withPublisher(String publisher) { + this.publisher = publisher; + return this; + } + + /** + * Get the product property: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the + * OfferID specified for the artifact at the time of Data Market onboarding. + * + * @return the product value. + */ + public String product() { + return this.product; + } + + /** + * Set the product property: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the + * OfferID specified for the artifact at the time of Data Market onboarding. + * + * @param product the product value to set. + * @return the Plan object itself. + */ + public Plan withProduct(String product) { + this.product = product; + return this; + } + + /** + * Get the promotionCode property: A publisher provided promotion code as provisioned in Data Market for the said + * product/artifact. + * + * @return the promotionCode value. + */ + public String promotionCode() { + return this.promotionCode; + } + + /** + * Set the promotionCode property: A publisher provided promotion code as provisioned in Data Market for the said + * product/artifact. + * + * @param promotionCode the promotionCode value to set. + * @return the Plan object itself. + */ + public Plan withPromotionCode(String promotionCode) { + this.promotionCode = promotionCode; + return this; + } + + /** + * Get the version property: The version of the desired product/artifact. + * + * @return the version value. + */ + public String version() { + return this.version; + } + + /** + * Set the version property: The version of the desired product/artifact. + * + * @param version the version value to set. + * @return the Plan object itself. + */ + public Plan withVersion(String version) { + this.version = version; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError().log(new IllegalArgumentException("Missing required property name in model Plan")); + } + if (publisher() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property publisher in model Plan")); + } + if (product() == null) { + throw LOGGER.atError().log(new IllegalArgumentException("Missing required property product in model Plan")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(Plan.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("publisher", this.publisher); + jsonWriter.writeStringField("product", this.product); + jsonWriter.writeStringField("promotionCode", this.promotionCode); + jsonWriter.writeStringField("version", this.version); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Plan from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Plan if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Plan. + */ + public static Plan fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Plan deserializedPlan = new Plan(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedPlan.name = reader.getString(); + } else if ("publisher".equals(fieldName)) { + deserializedPlan.publisher = reader.getString(); + } else if ("product".equals(fieldName)) { + deserializedPlan.product = reader.getString(); + } else if ("promotionCode".equals(fieldName)) { + deserializedPlan.promotionCode = reader.getString(); + } else if ("version".equals(fieldName)) { + deserializedPlan.version = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPlan; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ProvisioningState.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ProvisioningState.java new file mode 100644 index 0000000000000..a7bf10ce52948 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ProvisioningState.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The status of the current operation. + */ +public final class ProvisioningState extends ExpandableStringEnum { + /** + * Static value Succeeded for ProvisioningState. + */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for ProvisioningState. + */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Static value Canceled for ProvisioningState. + */ + public static final ProvisioningState CANCELED = fromString("Canceled"); + + /** + * Static value Creating for ProvisioningState. + */ + public static final ProvisioningState CREATING = fromString("Creating"); + + /** + * Static value Updating for ProvisioningState. + */ + public static final ProvisioningState UPDATING = fromString("Updating"); + + /** + * Static value Deleting for ProvisioningState. + */ + public static final ProvisioningState DELETING = fromString("Deleting"); + + /** + * Static value Migrating for ProvisioningState. + */ + public static final ProvisioningState MIGRATING = fromString("Migrating"); + + /** + * Creates a new instance of ProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ProvisioningState() { + } + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** + * Gets known ProvisioningState values. + * + * @return known ProvisioningState values. + */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/RegularPriorityAllocationStrategy.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/RegularPriorityAllocationStrategy.java new file mode 100644 index 0000000000000..a4cfa901b6364 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/RegularPriorityAllocationStrategy.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Regular VM Allocation strategy types for Compute Fleet. + */ +public final class RegularPriorityAllocationStrategy extends ExpandableStringEnum { + /** + * Static value LowestPrice for RegularPriorityAllocationStrategy. + */ + public static final RegularPriorityAllocationStrategy LOWEST_PRICE = fromString("LowestPrice"); + + /** + * Static value Prioritized for RegularPriorityAllocationStrategy. + */ + public static final RegularPriorityAllocationStrategy PRIORITIZED = fromString("Prioritized"); + + /** + * Creates a new instance of RegularPriorityAllocationStrategy value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public RegularPriorityAllocationStrategy() { + } + + /** + * Creates or finds a RegularPriorityAllocationStrategy from its string representation. + * + * @param name a name to look for. + * @return the corresponding RegularPriorityAllocationStrategy. + */ + public static RegularPriorityAllocationStrategy fromString(String name) { + return fromString(name, RegularPriorityAllocationStrategy.class); + } + + /** + * Gets known RegularPriorityAllocationStrategy values. + * + * @return known RegularPriorityAllocationStrategy values. + */ + public static Collection values() { + return values(RegularPriorityAllocationStrategy.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/RegularPriorityProfile.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/RegularPriorityProfile.java new file mode 100644 index 0000000000000..c656108f1e5e8 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/RegularPriorityProfile.java @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Configuration Options for Regular instances in Compute Fleet. + */ +@Fluent +public final class RegularPriorityProfile implements JsonSerializable { + /* + * Total capacity to achieve. It is currently in terms of number of VMs. + */ + private Integer capacity; + + /* + * Minimum capacity to achieve which cannot be updated. If we will not be able to "guarantee" minimum capacity, we + * will reject the request in the sync path itself. + */ + private Integer minCapacity; + + /* + * Allocation strategy to follow when determining the VM sizes distribution for Regular VMs. + */ + private RegularPriorityAllocationStrategy allocationStrategy; + + /** + * Creates an instance of RegularPriorityProfile class. + */ + public RegularPriorityProfile() { + } + + /** + * Get the capacity property: Total capacity to achieve. It is currently in terms of number of VMs. + * + * @return the capacity value. + */ + public Integer capacity() { + return this.capacity; + } + + /** + * Set the capacity property: Total capacity to achieve. It is currently in terms of number of VMs. + * + * @param capacity the capacity value to set. + * @return the RegularPriorityProfile object itself. + */ + public RegularPriorityProfile withCapacity(Integer capacity) { + this.capacity = capacity; + return this; + } + + /** + * Get the minCapacity property: Minimum capacity to achieve which cannot be updated. If we will not be able to + * "guarantee" minimum capacity, we will reject the request in the sync path itself. + * + * @return the minCapacity value. + */ + public Integer minCapacity() { + return this.minCapacity; + } + + /** + * Set the minCapacity property: Minimum capacity to achieve which cannot be updated. If we will not be able to + * "guarantee" minimum capacity, we will reject the request in the sync path itself. + * + * @param minCapacity the minCapacity value to set. + * @return the RegularPriorityProfile object itself. + */ + public RegularPriorityProfile withMinCapacity(Integer minCapacity) { + this.minCapacity = minCapacity; + return this; + } + + /** + * Get the allocationStrategy property: Allocation strategy to follow when determining the VM sizes distribution for + * Regular VMs. + * + * @return the allocationStrategy value. + */ + public RegularPriorityAllocationStrategy allocationStrategy() { + return this.allocationStrategy; + } + + /** + * Set the allocationStrategy property: Allocation strategy to follow when determining the VM sizes distribution for + * Regular VMs. + * + * @param allocationStrategy the allocationStrategy value to set. + * @return the RegularPriorityProfile object itself. + */ + public RegularPriorityProfile withAllocationStrategy(RegularPriorityAllocationStrategy allocationStrategy) { + this.allocationStrategy = allocationStrategy; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("capacity", this.capacity); + jsonWriter.writeNumberField("minCapacity", this.minCapacity); + jsonWriter.writeStringField("allocationStrategy", + this.allocationStrategy == null ? null : this.allocationStrategy.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RegularPriorityProfile from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RegularPriorityProfile if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the RegularPriorityProfile. + */ + public static RegularPriorityProfile fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RegularPriorityProfile deserializedRegularPriorityProfile = new RegularPriorityProfile(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("capacity".equals(fieldName)) { + deserializedRegularPriorityProfile.capacity = reader.getNullable(JsonReader::getInt); + } else if ("minCapacity".equals(fieldName)) { + deserializedRegularPriorityProfile.minCapacity = reader.getNullable(JsonReader::getInt); + } else if ("allocationStrategy".equals(fieldName)) { + deserializedRegularPriorityProfile.allocationStrategy + = RegularPriorityAllocationStrategy.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedRegularPriorityProfile; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ResourcePlanUpdate.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ResourcePlanUpdate.java new file mode 100644 index 0000000000000..3200022e4a706 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/ResourcePlanUpdate.java @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The template for adding optional properties. + */ +@Fluent +public final class ResourcePlanUpdate implements JsonSerializable { + /* + * A user defined name of the 3rd Party Artifact that is being procured. + */ + private String name; + + /* + * The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + */ + private String publisher; + + /* + * The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the + * artifact at the time of Data Market onboarding. + */ + private String product; + + /* + * A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + */ + private String promotionCode; + + /* + * The version of the desired product/artifact. + */ + private String version; + + /** + * Creates an instance of ResourcePlanUpdate class. + */ + public ResourcePlanUpdate() { + } + + /** + * Get the name property: A user defined name of the 3rd Party Artifact that is being procured. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: A user defined name of the 3rd Party Artifact that is being procured. + * + * @param name the name value to set. + * @return the ResourcePlanUpdate object itself. + */ + public ResourcePlanUpdate withName(String name) { + this.name = name; + return this; + } + + /** + * Get the publisher property: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + * + * @return the publisher value. + */ + public String publisher() { + return this.publisher; + } + + /** + * Set the publisher property: The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic. + * + * @param publisher the publisher value to set. + * @return the ResourcePlanUpdate object itself. + */ + public ResourcePlanUpdate withPublisher(String publisher) { + this.publisher = publisher; + return this; + } + + /** + * Get the product property: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the + * OfferID specified for the artifact at the time of Data Market onboarding. + * + * @return the product value. + */ + public String product() { + return this.product; + } + + /** + * Set the product property: The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the + * OfferID specified for the artifact at the time of Data Market onboarding. + * + * @param product the product value to set. + * @return the ResourcePlanUpdate object itself. + */ + public ResourcePlanUpdate withProduct(String product) { + this.product = product; + return this; + } + + /** + * Get the promotionCode property: A publisher provided promotion code as provisioned in Data Market for the said + * product/artifact. + * + * @return the promotionCode value. + */ + public String promotionCode() { + return this.promotionCode; + } + + /** + * Set the promotionCode property: A publisher provided promotion code as provisioned in Data Market for the said + * product/artifact. + * + * @param promotionCode the promotionCode value to set. + * @return the ResourcePlanUpdate object itself. + */ + public ResourcePlanUpdate withPromotionCode(String promotionCode) { + this.promotionCode = promotionCode; + return this; + } + + /** + * Get the version property: The version of the desired product/artifact. + * + * @return the version value. + */ + public String version() { + return this.version; + } + + /** + * Set the version property: The version of the desired product/artifact. + * + * @param version the version value to set. + * @return the ResourcePlanUpdate object itself. + */ + public ResourcePlanUpdate withVersion(String version) { + this.version = version; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("publisher", this.publisher); + jsonWriter.writeStringField("product", this.product); + jsonWriter.writeStringField("promotionCode", this.promotionCode); + jsonWriter.writeStringField("version", this.version); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourcePlanUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourcePlanUpdate if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ResourcePlanUpdate. + */ + public static ResourcePlanUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourcePlanUpdate deserializedResourcePlanUpdate = new ResourcePlanUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedResourcePlanUpdate.name = reader.getString(); + } else if ("publisher".equals(fieldName)) { + deserializedResourcePlanUpdate.publisher = reader.getString(); + } else if ("product".equals(fieldName)) { + deserializedResourcePlanUpdate.product = reader.getString(); + } else if ("promotionCode".equals(fieldName)) { + deserializedResourcePlanUpdate.promotionCode = reader.getString(); + } else if ("version".equals(fieldName)) { + deserializedResourcePlanUpdate.version = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedResourcePlanUpdate; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/SpotAllocationStrategy.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/SpotAllocationStrategy.java new file mode 100644 index 0000000000000..a27f2ccf864f9 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/SpotAllocationStrategy.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Spot allocation strategy types for Compute Fleet. + */ +public final class SpotAllocationStrategy extends ExpandableStringEnum { + /** + * Static value PriceCapacityOptimized for SpotAllocationStrategy. + */ + public static final SpotAllocationStrategy PRICE_CAPACITY_OPTIMIZED = fromString("PriceCapacityOptimized"); + + /** + * Static value LowestPrice for SpotAllocationStrategy. + */ + public static final SpotAllocationStrategy LOWEST_PRICE = fromString("LowestPrice"); + + /** + * Static value CapacityOptimized for SpotAllocationStrategy. + */ + public static final SpotAllocationStrategy CAPACITY_OPTIMIZED = fromString("CapacityOptimized"); + + /** + * Creates a new instance of SpotAllocationStrategy value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SpotAllocationStrategy() { + } + + /** + * Creates or finds a SpotAllocationStrategy from its string representation. + * + * @param name a name to look for. + * @return the corresponding SpotAllocationStrategy. + */ + public static SpotAllocationStrategy fromString(String name) { + return fromString(name, SpotAllocationStrategy.class); + } + + /** + * Gets known SpotAllocationStrategy values. + * + * @return known SpotAllocationStrategy values. + */ + public static Collection values() { + return values(SpotAllocationStrategy.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/SpotPriorityProfile.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/SpotPriorityProfile.java new file mode 100644 index 0000000000000..9897c3a13a952 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/SpotPriorityProfile.java @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Configuration Options for Spot instances in Compute Fleet. + */ +@Fluent +public final class SpotPriorityProfile implements JsonSerializable { + /* + * Total capacity to achieve. It is currently in terms of number of VMs. + */ + private Integer capacity; + + /* + * Minimum capacity to achieve which cannot be updated. If we will not be able to "guarantee" minimum capacity, we + * will reject the request in the sync path itself. + */ + private Integer minCapacity; + + /* + * Price per hour of each Spot VM will never exceed this. + */ + private Double maxPricePerVM; + + /* + * Eviction Policy to follow when evicting Spot VMs. + */ + private EvictionPolicy evictionPolicy; + + /* + * Allocation strategy to follow when determining the VM sizes distribution for Spot VMs. + */ + private SpotAllocationStrategy allocationStrategy; + + /* + * Flag to enable/disable continuous goal seeking for the desired capacity and restoration of evicted Spot VMs. + * If maintain is enabled, AzureFleetRP will use all VM sizes in vmSizesProfile to create new VMs (if VMs are + * evicted deleted) + * or update existing VMs with new VM sizes (if VMs are evicted deallocated or failed to allocate due to capacity + * constraint) in order to achieve the desired capacity. + * Maintain is enabled by default. + */ + private Boolean maintain; + + /** + * Creates an instance of SpotPriorityProfile class. + */ + public SpotPriorityProfile() { + } + + /** + * Get the capacity property: Total capacity to achieve. It is currently in terms of number of VMs. + * + * @return the capacity value. + */ + public Integer capacity() { + return this.capacity; + } + + /** + * Set the capacity property: Total capacity to achieve. It is currently in terms of number of VMs. + * + * @param capacity the capacity value to set. + * @return the SpotPriorityProfile object itself. + */ + public SpotPriorityProfile withCapacity(Integer capacity) { + this.capacity = capacity; + return this; + } + + /** + * Get the minCapacity property: Minimum capacity to achieve which cannot be updated. If we will not be able to + * "guarantee" minimum capacity, we will reject the request in the sync path itself. + * + * @return the minCapacity value. + */ + public Integer minCapacity() { + return this.minCapacity; + } + + /** + * Set the minCapacity property: Minimum capacity to achieve which cannot be updated. If we will not be able to + * "guarantee" minimum capacity, we will reject the request in the sync path itself. + * + * @param minCapacity the minCapacity value to set. + * @return the SpotPriorityProfile object itself. + */ + public SpotPriorityProfile withMinCapacity(Integer minCapacity) { + this.minCapacity = minCapacity; + return this; + } + + /** + * Get the maxPricePerVM property: Price per hour of each Spot VM will never exceed this. + * + * @return the maxPricePerVM value. + */ + public Double maxPricePerVM() { + return this.maxPricePerVM; + } + + /** + * Set the maxPricePerVM property: Price per hour of each Spot VM will never exceed this. + * + * @param maxPricePerVM the maxPricePerVM value to set. + * @return the SpotPriorityProfile object itself. + */ + public SpotPriorityProfile withMaxPricePerVM(Double maxPricePerVM) { + this.maxPricePerVM = maxPricePerVM; + return this; + } + + /** + * Get the evictionPolicy property: Eviction Policy to follow when evicting Spot VMs. + * + * @return the evictionPolicy value. + */ + public EvictionPolicy evictionPolicy() { + return this.evictionPolicy; + } + + /** + * Set the evictionPolicy property: Eviction Policy to follow when evicting Spot VMs. + * + * @param evictionPolicy the evictionPolicy value to set. + * @return the SpotPriorityProfile object itself. + */ + public SpotPriorityProfile withEvictionPolicy(EvictionPolicy evictionPolicy) { + this.evictionPolicy = evictionPolicy; + return this; + } + + /** + * Get the allocationStrategy property: Allocation strategy to follow when determining the VM sizes distribution for + * Spot VMs. + * + * @return the allocationStrategy value. + */ + public SpotAllocationStrategy allocationStrategy() { + return this.allocationStrategy; + } + + /** + * Set the allocationStrategy property: Allocation strategy to follow when determining the VM sizes distribution for + * Spot VMs. + * + * @param allocationStrategy the allocationStrategy value to set. + * @return the SpotPriorityProfile object itself. + */ + public SpotPriorityProfile withAllocationStrategy(SpotAllocationStrategy allocationStrategy) { + this.allocationStrategy = allocationStrategy; + return this; + } + + /** + * Get the maintain property: Flag to enable/disable continuous goal seeking for the desired capacity and + * restoration of evicted Spot VMs. + * If maintain is enabled, AzureFleetRP will use all VM sizes in vmSizesProfile to create new VMs (if VMs are + * evicted deleted) + * or update existing VMs with new VM sizes (if VMs are evicted deallocated or failed to allocate due to capacity + * constraint) in order to achieve the desired capacity. + * Maintain is enabled by default. + * + * @return the maintain value. + */ + public Boolean maintain() { + return this.maintain; + } + + /** + * Set the maintain property: Flag to enable/disable continuous goal seeking for the desired capacity and + * restoration of evicted Spot VMs. + * If maintain is enabled, AzureFleetRP will use all VM sizes in vmSizesProfile to create new VMs (if VMs are + * evicted deleted) + * or update existing VMs with new VM sizes (if VMs are evicted deallocated or failed to allocate due to capacity + * constraint) in order to achieve the desired capacity. + * Maintain is enabled by default. + * + * @param maintain the maintain value to set. + * @return the SpotPriorityProfile object itself. + */ + public SpotPriorityProfile withMaintain(Boolean maintain) { + this.maintain = maintain; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("capacity", this.capacity); + jsonWriter.writeNumberField("minCapacity", this.minCapacity); + jsonWriter.writeNumberField("maxPricePerVM", this.maxPricePerVM); + jsonWriter.writeStringField("evictionPolicy", + this.evictionPolicy == null ? null : this.evictionPolicy.toString()); + jsonWriter.writeStringField("allocationStrategy", + this.allocationStrategy == null ? null : this.allocationStrategy.toString()); + jsonWriter.writeBooleanField("maintain", this.maintain); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpotPriorityProfile from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpotPriorityProfile if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SpotPriorityProfile. + */ + public static SpotPriorityProfile fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SpotPriorityProfile deserializedSpotPriorityProfile = new SpotPriorityProfile(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("capacity".equals(fieldName)) { + deserializedSpotPriorityProfile.capacity = reader.getNullable(JsonReader::getInt); + } else if ("minCapacity".equals(fieldName)) { + deserializedSpotPriorityProfile.minCapacity = reader.getNullable(JsonReader::getInt); + } else if ("maxPricePerVM".equals(fieldName)) { + deserializedSpotPriorityProfile.maxPricePerVM = reader.getNullable(JsonReader::getDouble); + } else if ("evictionPolicy".equals(fieldName)) { + deserializedSpotPriorityProfile.evictionPolicy = EvictionPolicy.fromString(reader.getString()); + } else if ("allocationStrategy".equals(fieldName)) { + deserializedSpotPriorityProfile.allocationStrategy + = SpotAllocationStrategy.fromString(reader.getString()); + } else if ("maintain".equals(fieldName)) { + deserializedSpotPriorityProfile.maintain = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedSpotPriorityProfile; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/UserAssignedIdentity.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/UserAssignedIdentity.java new file mode 100644 index 0000000000000..8c85e55b6aaac --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/UserAssignedIdentity.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the assigned identity. + */ + private String principalId; + + /* + * The client ID of the assigned identity. + */ + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VirtualMachineScaleSet.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VirtualMachineScaleSet.java new file mode 100644 index 0000000000000..9d72782ef7e8b --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VirtualMachineScaleSet.java @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * An AzureFleet's virtualMachineScaleSet. + */ +@Immutable +public final class VirtualMachineScaleSet implements JsonSerializable { + /* + * The compute RP resource id of the virtualMachineScaleSet + * "subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}" + */ + private String id; + + /* + * Type of the virtualMachineScaleSet + */ + private String type; + + /* + * This represents the operationStatus of the VMSS in response to the last operation that was performed on it by + * Azure Fleet resource. + */ + private ProvisioningState operationStatus; + + /* + * Error Information when `operationStatus` is `Failed` + */ + private Object error; + + /** + * Creates an instance of VirtualMachineScaleSet class. + */ + private VirtualMachineScaleSet() { + } + + /** + * Get the id property: The compute RP resource id of the virtualMachineScaleSet + * "subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}". + * + * @return the id value. + */ + public String id() { + return this.id; + } + + /** + * Get the type property: Type of the virtualMachineScaleSet. + * + * @return the type value. + */ + public String type() { + return this.type; + } + + /** + * Get the operationStatus property: This represents the operationStatus of the VMSS in response to the last + * operation that was performed on it by Azure Fleet resource. + * + * @return the operationStatus value. + */ + public ProvisioningState operationStatus() { + return this.operationStatus; + } + + /** + * Get the error property: Error Information when `operationStatus` is `Failed`. + * + * @return the error value. + */ + public Object error() { + return this.error; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VirtualMachineScaleSet from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VirtualMachineScaleSet if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VirtualMachineScaleSet. + */ + public static VirtualMachineScaleSet fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VirtualMachineScaleSet deserializedVirtualMachineScaleSet = new VirtualMachineScaleSet(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedVirtualMachineScaleSet.id = reader.getString(); + } else if ("operationStatus".equals(fieldName)) { + deserializedVirtualMachineScaleSet.operationStatus + = ProvisioningState.fromString(reader.getString()); + } else if ("type".equals(fieldName)) { + deserializedVirtualMachineScaleSet.type = reader.getString(); + } else if ("error".equals(fieldName)) { + deserializedVirtualMachineScaleSet.error = reader.readUntyped(); + } else { + reader.skipChildren(); + } + } + + return deserializedVirtualMachineScaleSet; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VirtualMachineScaleSetListResult.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VirtualMachineScaleSetListResult.java new file mode 100644 index 0000000000000..8ef3442c43295 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VirtualMachineScaleSetListResult.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.resourcemanager.computefleet.fluent.models.VirtualMachineScaleSetListResultInner; +import java.util.List; + +/** + * An immutable client-side representation of VirtualMachineScaleSetListResult. + */ +public interface VirtualMachineScaleSetListResult { + /** + * Gets the value property: The VirtualMachineScaleSet items on this page. + * + * @return the value value. + */ + List value(); + + /** + * Gets the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + String nextLink(); + + /** + * Gets the inner com.azure.resourcemanager.computefleet.fluent.models.VirtualMachineScaleSetListResultInner object. + * + * @return the inner object. + */ + VirtualMachineScaleSetListResultInner innerModel(); +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VmSizeProfile.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VmSizeProfile.java new file mode 100644 index 0000000000000..81ce51244d03a --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/VmSizeProfile.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Specifications about a VM Size. This will also contain the corresponding rank and weight in future. + */ +@Fluent +public final class VmSizeProfile implements JsonSerializable { + /* + * The Sku name (e.g. 'Standard_DS1_v2') + */ + private String name; + + /* + * The rank of the VM size. This is used with 'RegularPriorityAllocationStrategy.Prioritized' + * The lower the number, the higher the priority. Starting with 0. + */ + private Integer rank; + + /** + * Creates an instance of VmSizeProfile class. + */ + public VmSizeProfile() { + } + + /** + * Get the name property: The Sku name (e.g. 'Standard_DS1_v2'). + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The Sku name (e.g. 'Standard_DS1_v2'). + * + * @param name the name value to set. + * @return the VmSizeProfile object itself. + */ + public VmSizeProfile withName(String name) { + this.name = name; + return this; + } + + /** + * Get the rank property: The rank of the VM size. This is used with 'RegularPriorityAllocationStrategy.Prioritized' + * The lower the number, the higher the priority. Starting with 0. + * + * @return the rank value. + */ + public Integer rank() { + return this.rank; + } + + /** + * Set the rank property: The rank of the VM size. This is used with 'RegularPriorityAllocationStrategy.Prioritized' + * The lower the number, the higher the priority. Starting with 0. + * + * @param rank the rank value to set. + * @return the VmSizeProfile object itself. + */ + public VmSizeProfile withRank(Integer rank) { + this.rank = rank; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model VmSizeProfile")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(VmSizeProfile.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeNumberField("rank", this.rank); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VmSizeProfile from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VmSizeProfile if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VmSizeProfile. + */ + public static VmSizeProfile fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VmSizeProfile deserializedVmSizeProfile = new VmSizeProfile(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedVmSizeProfile.name = reader.getString(); + } else if ("rank".equals(fieldName)) { + deserializedVmSizeProfile.rank = reader.getNullable(JsonReader::getInt); + } else { + reader.skipChildren(); + } + } + + return deserializedVmSizeProfile; + }); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/package-info.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/package-info.java new file mode 100644 index 0000000000000..6339c5665b686 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/models/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for ComputeFleet. + */ +package com.azure.resourcemanager.computefleet.models; diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/package-info.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/package-info.java new file mode 100644 index 0000000000000..59bcc2c011424 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/com/azure/resourcemanager/computefleet/package-info.java @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ComputeFleet. + */ +package com.azure.resourcemanager.computefleet; diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/module-info.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/module-info.java new file mode 100644 index 0000000000000..85168a6df1fb2 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/java/module-info.java @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.computefleet { + requires transitive com.azure.core.management; + exports com.azure.resourcemanager.computefleet; + exports com.azure.resourcemanager.computefleet.fluent; + exports com.azure.resourcemanager.computefleet.fluent.models; + exports com.azure.resourcemanager.computefleet.models; + opens com.azure.resourcemanager.computefleet.fluent.models to com.azure.core; + opens com.azure.resourcemanager.computefleet.models to com.azure.core; + opens com.azure.resourcemanager.computefleet.implementation.models to com.azure.core; +} \ No newline at end of file diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-computefleet/proxy-config.json b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-computefleet/proxy-config.json new file mode 100644 index 0000000000000..89db6992fbf4a --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-computefleet/proxy-config.json @@ -0,0 +1 @@ +[ [ "com.azure.resourcemanager.computefleet.implementation.FleetsClientImpl$FleetsService" ], [ "com.azure.resourcemanager.computefleet.implementation.OperationsClientImpl$OperationsService" ] ] \ No newline at end of file diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-computefleet/reflect-config.json b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-computefleet/reflect-config.json new file mode 100644 index 0000000000000..8878e547a7984 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-computefleet/reflect-config.json @@ -0,0 +1 @@ +[ ] \ No newline at end of file diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsCreateOrUpdateSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..f08d7a22ce983 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsCreateOrUpdateSamples.java @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.computefleet.models.ComputeProfile; +import com.azure.resourcemanager.computefleet.models.EvictionPolicy; +import com.azure.resourcemanager.computefleet.models.FleetProperties; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentity; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.computefleet.models.RegularPriorityAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.RegularPriorityProfile; +import com.azure.resourcemanager.computefleet.models.SpotAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.SpotPriorityProfile; +import com.azure.resourcemanager.computefleet.models.UserAssignedIdentity; +import com.azure.resourcemanager.computefleet.models.VmSizeProfile; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Fleets CreateOrUpdate. + */ +public final class FleetsCreateOrUpdateSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_CreateOrUpdate.json + */ + /** + * Sample code: Fleets_CreateOrUpdate. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsCreateOrUpdate(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) + throws IOException { + manager.fleets() + .define("testFleet") + .withRegion("westus") + .withExistingResourceGroup("rgazurefleet") + .withTags(mapOf("key3518", "fakeTokenPlaceholder")) + .withProperties(new FleetProperties() + .withSpotPriorityProfile(new SpotPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withMaxPricePerVM(0.00865D) + .withEvictionPolicy(EvictionPolicy.DELETE) + .withAllocationStrategy(SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED) + .withMaintain(true)) + .withRegularPriorityProfile(new RegularPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withAllocationStrategy(RegularPriorityAllocationStrategy.LOWEST_PRICE)) + .withVmSizesProfile(Arrays.asList(new VmSizeProfile().withName("Standard_d1_v2").withRank(19225))) + .withComputeProfile(new ComputeProfile().withBaseVirtualMachineProfile(SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize( + "{\"osProfile\":{\"computerNamePrefix\":\"o\",\"adminUsername\":\"nrgzqciiaaxjrqldbmjbqkyhntp\",\"adminPassword\":\"adfbrdxpv\",\"customData\":\"xjjib\",\"windowsConfiguration\":{\"provisionVMAgent\":true,\"enableAutomaticUpdates\":true,\"timeZone\":\"hlyjiqcfksgrpjrct\",\"additionalUnattendContent\":[{\"passName\":\"OobeSystem\",\"componentName\":\"Microsoft-Windows-Shell-Setup\",\"settingName\":\"AutoLogon\",\"content\":\"bubmqbxjkj\"}],\"patchSettings\":{\"patchMode\":\"Manual\",\"enableHotpatching\":true,\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"winRM\":{\"listeners\":[{\"protocol\":\"Http\",\"certificateUrl\":\"phwesineizrl\"}]},\"enableVMAgentPlatformUpdates\":true},\"linuxConfiguration\":{\"disablePasswordAuthentication\":true,\"ssh\":{\"publicKeys\":[{\"path\":\"kmqz\",\"keyData\":\"kivgsubusvpprwqaqpjcmhsv\"}]},\"provisionVMAgent\":true,\"patchSettings\":{\"patchMode\":\"ImageDefault\",\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"enableVMAgentPlatformUpdates\":true},\"secrets\":[{\"sourceVault\":{\"id\":\"groxwd\"},\"vaultCertificates\":[{\"certificateUrl\":\"tyldwkzafmnkvpo\",\"certificateStore\":\"nlxrwavpzhueffxsshlun\"}]}],\"allowExtensionOperations\":true,\"requireGuestProvisionSignal\":true},\"storageProfile\":{\"imageReference\":{\"publisher\":\"mqxgwbiyjzmxavhbkd\",\"offer\":\"isxgumkarlkomp\",\"sku\":\"eojmppqcrnpmxirtp\",\"version\":\"wvpcqefgtmqdgltiuz\",\"sharedGalleryImageId\":\"kmkgihoxwlawuuhcinfirktdwkmx\",\"communityGalleryImageId\":\"vlqe\",\"id\":\"aiunknwgksu\"},\"osDisk\":{\"name\":\"wfttw\",\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diffDiskSettings\":{\"option\":\"Local\",\"placement\":\"CacheDisk\"},\"diskSizeGB\":14,\"osType\":\"Windows\",\"image\":{\"uri\":\"thqceubivdrjs\"},\"vhdContainers\":[\"tkzcwddtinkfpnfklatw\"],\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"deleteOption\":\"Delete\"},\"dataDisks\":[{\"name\":\"eogiykmdmeikswxmigjws\",\"lun\":14,\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diskSizeGB\":6,\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"diskIOPSReadWrite\":27,\"diskMBpsReadWrite\":2,\"deleteOption\":\"Delete\"}],\"diskControllerType\":\"uzb\"},\"networkProfile\":{\"healthProbe\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"networkInterfaceConfigurations\":[{\"name\":\"i\",\"properties\":{\"primary\":true,\"enableAcceleratedNetworking\":true,\"disableTcpStateTracking\":true,\"enableFpga\":true,\"networkSecurityGroup\":{\"id\":\"groxwd\"},\"dnsSettings\":{\"dnsServers\":[\"nxmmfolhclsesu\"]},\"ipConfigurations\":[{\"name\":\"oezqhkidfhyywlfzwuotilrpbqnjg\",\"properties\":{\"subnet\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"primary\":true,\"publicIPAddressConfiguration\":{\"name\":\"fvpqf\",\"properties\":{\"idleTimeoutInMinutes\":9,\"dnsSettings\":{\"domainNameLabel\":\"ukrddzvmorpmfsczjwtbvp\",\"domainNameLabelScope\":\"TenantReuse\"},\"ipTags\":[{\"ipTagType\":\"sddgsoemnzgqizale\",\"tag\":\"wufmhrjsakbiaetyara\"}],\"publicIPPrefix\":{\"id\":\"groxwd\"},\"publicIPAddressVersion\":\"IPv4\",\"deleteOption\":\"Delete\"},\"sku\":{\"name\":\"Basic\",\"tier\":\"Regional\"}},\"privateIPAddressVersion\":\"IPv4\",\"applicationGatewayBackendAddressPools\":[{\"id\":\"groxwd\"}],\"applicationSecurityGroups\":[{\"id\":\"groxwd\"}],\"loadBalancerBackendAddressPools\":[{\"id\":\"groxwd\"}],\"loadBalancerInboundNatPools\":[{\"id\":\"groxwd\"}]}}],\"enableIPForwarding\":true,\"deleteOption\":\"Delete\",\"auxiliaryMode\":\"None\",\"auxiliarySku\":\"None\"}}],\"networkApiVersion\":\"2020-11-01\"},\"securityProfile\":{\"uefiSettings\":{\"secureBootEnabled\":true,\"vTpmEnabled\":true},\"encryptionAtHost\":true,\"securityType\":\"TrustedLaunch\",\"encryptionIdentity\":{\"userAssignedIdentityResourceId\":\"qoersmt\"},\"proxyAgentSettings\":{\"enabled\":true,\"mode\":\"Audit\",\"keyIncarnationId\":20}},\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":true,\"storageUri\":\"rzamfwghybpx\"}},\"extensionProfile\":{\"extensions\":[{\"name\":\"bndxuxx\",\"properties\":{\"forceUpdateTag\":\"yhgxw\",\"publisher\":\"kpxtirxjfprhs\",\"type\":\"pgjilctjjwaa\",\"typeHandlerVersion\":\"zevivcoilxmbwlrihhhibq\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"provisionAfterExtensions\":[\"nftzosroolbcwmpupujzqwqe\"],\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}}}}],\"extensionsTimeBudget\":\"mbhjahtdygwgyszdwjtvlvtgchdwil\"},\"licenseType\":\"v\",\"scheduledEventsProfile\":{\"terminateNotificationProfile\":{\"notBeforeTimeout\":\"iljppmmw\",\"enable\":true},\"osImageNotificationProfile\":{\"notBeforeTimeout\":\"olbpadmevekyczfokodtfprxti\",\"enable\":true}},\"userData\":\"s\",\"capacityReservation\":{\"capacityReservationGroup\":{\"id\":\"groxwd\"}},\"applicationProfile\":{\"galleryApplications\":[{\"tags\":\"eyrqjbib\",\"order\":5,\"packageReferenceId\":\"lfxqiadouhmbovcd\",\"configurationReference\":\"ulztmiavpojpbpbddgnuuiimxcpau\",\"treatFailureAsDeploymentFailure\":true,\"enableAutomaticUpgrade\":true}]},\"hardwareProfile\":{\"vmSizeProperties\":{\"vCPUsAvailable\":16,\"vCPUsPerCore\":23}},\"serviceArtifactReference\":{\"id\":\"qlkeeyskyr\"},\"securityPostureReference\":{\"id\":\"mubredelfbshboaxrsxiajihahaa\",\"excludeExtensions\":[{\"properties\":{\"forceUpdateTag\":\"oriasdwawveilgusfrn\",\"publisher\":\"rxoajzb\",\"type\":\"vhrtgbaqdkbrrqxsdiiaqxksmqukl\",\"typeHandlerVersion\":\"bvzbiibps\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"instanceView\":{\"name\":\"ip\",\"type\":\"woadxvobquacooaujyg\",\"typeHandlerVersion\":\"ftkkqxdqiofgsusvxekdcpua\",\"substatuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}],\"statuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}]},\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}},\"provisionAfterExtensions\":[\"lwsfavklrgzuwmyxscskt\"]},\"location\":\"wrqxhbqaebwkzmcdmngyqmhogc\",\"tags\":{\"key7356\":\"apuftleiygpnemfzryiop\"}}]}}", + Object.class, SerializerEncoding.JSON)) + .withComputeApiVersion("2023-07-01") + .withPlatformFaultDomainCount(1))) + .withZones(Arrays.asList("zone1", "zone2")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf("key9851", new UserAssignedIdentity()))) + .create(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsDeleteSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsDeleteSamples.java new file mode 100644 index 0000000000000..933a8b9c3795e --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +/** + * Samples for Fleets Delete. + */ +public final class FleetsDeleteSamples { + /* + * x-ms-original-file: specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_Delete.json + */ + /** + * Sample code: Fleets_Delete. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsDelete(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().delete("rgazurefleet", "testFleet", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsGetByResourceGroupSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..69915346ac3ac --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsGetByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +/** + * Samples for Fleets GetByResourceGroup. + */ +public final class FleetsGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_Get.json + */ + /** + * Sample code: Fleets_Get. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsGet(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().getByResourceGroupWithResponse("rgazurefleet", "testFleet", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListByResourceGroupSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListByResourceGroupSamples.java new file mode 100644 index 0000000000000..417a0c81271e4 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +/** + * Samples for Fleets ListByResourceGroup. + */ +public final class FleetsListByResourceGroupSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_ListByResourceGroup.json + */ + /** + * Sample code: Fleets_ListByResourceGroup. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsListByResourceGroup(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().listByResourceGroup("rgazurefleet", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListSamples.java new file mode 100644 index 0000000000000..63dc47bfea175 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +/** + * Samples for Fleets List. + */ +public final class FleetsListSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_ListBySubscription.json + */ + /** + * Sample code: Fleets_ListBySubscription. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsListBySubscription(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListVirtualMachineScaleSetsSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListVirtualMachineScaleSetsSamples.java new file mode 100644 index 0000000000000..f034f81af85e3 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsListVirtualMachineScaleSetsSamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +/** + * Samples for Fleets ListVirtualMachineScaleSets. + */ +public final class FleetsListVirtualMachineScaleSetsSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_ListVirtualMachineScaleSets. + * json + */ + /** + * Sample code: Fleets_ListVirtualMachineScaleSets. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void + fleetsListVirtualMachineScaleSets(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.fleets() + .listVirtualMachineScaleSetsWithResponse("rgazurefleet", "myFleet", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsUpdateSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsUpdateSamples.java new file mode 100644 index 0000000000000..8a73557f34aba --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/FleetsUpdateSamples.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.computefleet.models.ComputeProfile; +import com.azure.resourcemanager.computefleet.models.EvictionPolicy; +import com.azure.resourcemanager.computefleet.models.Fleet; +import com.azure.resourcemanager.computefleet.models.FleetProperties; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityUpdate; +import com.azure.resourcemanager.computefleet.models.RegularPriorityAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.RegularPriorityProfile; +import com.azure.resourcemanager.computefleet.models.ResourcePlanUpdate; +import com.azure.resourcemanager.computefleet.models.SpotAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.SpotPriorityProfile; +import com.azure.resourcemanager.computefleet.models.VmSizeProfile; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for Fleets Update. + */ +public final class FleetsUpdateSamples { + /* + * x-ms-original-file: specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Fleets_Update.json + */ + /** + * Sample code: Fleets_Update. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void fleetsUpdate(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) + throws IOException { + Fleet resource = manager.fleets() + .getByResourceGroupWithResponse("rgazurefleet", "testFleet", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf()) + .withIdentity(new ManagedServiceIdentityUpdate().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf())) + .withPlan(new ResourcePlanUpdate().withName("jwgrcrnrtfoxn") + .withPublisher("iozjbiqqckqm") + .withProduct("cgopbyvdyqikahwyxfpzwaqk") + .withPromotionCode("fakeTokenPlaceholder") + .withVersion("wa")) + .withProperties(new FleetProperties() + .withSpotPriorityProfile(new SpotPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withMaxPricePerVM(0.00865D) + .withEvictionPolicy(EvictionPolicy.DELETE) + .withAllocationStrategy(SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED) + .withMaintain(true)) + .withRegularPriorityProfile(new RegularPriorityProfile().withCapacity(20) + .withMinCapacity(10) + .withAllocationStrategy(RegularPriorityAllocationStrategy.LOWEST_PRICE)) + .withVmSizesProfile(Arrays.asList(new VmSizeProfile().withName("Standard_d1_v2").withRank(19225))) + .withComputeProfile(new ComputeProfile().withBaseVirtualMachineProfile(SerializerFactory + .createDefaultManagementSerializerAdapter() + .deserialize( + "{\"osProfile\":{\"computerNamePrefix\":\"o\",\"adminUsername\":\"nrgzqciiaaxjrqldbmjbqkyhntp\",\"adminPassword\":\"adfbrdxpv\",\"customData\":\"xjjib\",\"windowsConfiguration\":{\"provisionVMAgent\":true,\"enableAutomaticUpdates\":true,\"timeZone\":\"hlyjiqcfksgrpjrct\",\"additionalUnattendContent\":[{\"passName\":\"OobeSystem\",\"componentName\":\"Microsoft-Windows-Shell-Setup\",\"settingName\":\"AutoLogon\",\"content\":\"bubmqbxjkj\"}],\"patchSettings\":{\"patchMode\":\"Manual\",\"enableHotpatching\":true,\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"winRM\":{\"listeners\":[{\"protocol\":\"Http\",\"certificateUrl\":\"phwesineizrl\"}]},\"enableVMAgentPlatformUpdates\":true},\"linuxConfiguration\":{\"disablePasswordAuthentication\":true,\"ssh\":{\"publicKeys\":[{\"path\":\"kmqz\",\"keyData\":\"kivgsubusvpprwqaqpjcmhsv\"}]},\"provisionVMAgent\":true,\"patchSettings\":{\"patchMode\":\"ImageDefault\",\"assessmentMode\":\"ImageDefault\",\"automaticByPlatformSettings\":{\"rebootSetting\":\"Unknown\",\"bypassPlatformSafetyChecksOnUserSchedule\":true}},\"enableVMAgentPlatformUpdates\":true},\"secrets\":[{\"sourceVault\":{\"id\":\"groxwd\"},\"vaultCertificates\":[{\"certificateUrl\":\"tyldwkzafmnkvpo\",\"certificateStore\":\"nlxrwavpzhueffxsshlun\"}]}],\"allowExtensionOperations\":true,\"requireGuestProvisionSignal\":true},\"storageProfile\":{\"imageReference\":{\"publisher\":\"mqxgwbiyjzmxavhbkd\",\"offer\":\"isxgumkarlkomp\",\"sku\":\"eojmppqcrnpmxirtp\",\"version\":\"wvpcqefgtmqdgltiuz\",\"sharedGalleryImageId\":\"kmkgihoxwlawuuhcinfirktdwkmx\",\"communityGalleryImageId\":\"vlqe\",\"id\":\"aiunknwgksu\"},\"osDisk\":{\"name\":\"wfttw\",\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diffDiskSettings\":{\"option\":\"Local\",\"placement\":\"CacheDisk\"},\"diskSizeGB\":14,\"osType\":\"Windows\",\"image\":{\"uri\":\"thqceubivdrjs\"},\"vhdContainers\":[\"tkzcwddtinkfpnfklatw\"],\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"deleteOption\":\"Delete\"},\"dataDisks\":[{\"name\":\"eogiykmdmeikswxmigjws\",\"lun\":14,\"caching\":\"None\",\"writeAcceleratorEnabled\":true,\"createOption\":\"FromImage\",\"diskSizeGB\":6,\"managedDisk\":{\"storageAccountType\":\"Standard_LRS\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"},\"securityProfile\":{\"securityEncryptionType\":\"VMGuestStateOnly\",\"diskEncryptionSet\":{\"id\":\"vmatqblzjalbatdepyzqmnd\"}}},\"diskIOPSReadWrite\":27,\"diskMBpsReadWrite\":2,\"deleteOption\":\"Delete\"}],\"diskControllerType\":\"uzb\"},\"networkProfile\":{\"healthProbe\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"networkInterfaceConfigurations\":[{\"name\":\"i\",\"properties\":{\"primary\":true,\"enableAcceleratedNetworking\":true,\"disableTcpStateTracking\":true,\"enableFpga\":true,\"networkSecurityGroup\":{\"id\":\"groxwd\"},\"dnsSettings\":{\"dnsServers\":[\"nxmmfolhclsesu\"]},\"ipConfigurations\":[{\"name\":\"oezqhkidfhyywlfzwuotilrpbqnjg\",\"properties\":{\"subnet\":{\"id\":\"cmkfcjhmrwxwqtac\"},\"primary\":true,\"publicIPAddressConfiguration\":{\"name\":\"fvpqf\",\"properties\":{\"idleTimeoutInMinutes\":9,\"dnsSettings\":{\"domainNameLabel\":\"ukrddzvmorpmfsczjwtbvp\",\"domainNameLabelScope\":\"TenantReuse\"},\"ipTags\":[{\"ipTagType\":\"sddgsoemnzgqizale\",\"tag\":\"wufmhrjsakbiaetyara\"}],\"publicIPPrefix\":{\"id\":\"groxwd\"},\"publicIPAddressVersion\":\"IPv4\",\"deleteOption\":\"Delete\"},\"sku\":{\"name\":\"Basic\",\"tier\":\"Regional\"}},\"privateIPAddressVersion\":\"IPv4\",\"applicationGatewayBackendAddressPools\":[{\"id\":\"groxwd\"}],\"applicationSecurityGroups\":[{\"id\":\"groxwd\"}],\"loadBalancerBackendAddressPools\":[{\"id\":\"groxwd\"}],\"loadBalancerInboundNatPools\":[{\"id\":\"groxwd\"}]}}],\"enableIPForwarding\":true,\"deleteOption\":\"Delete\",\"auxiliaryMode\":\"None\",\"auxiliarySku\":\"None\"}}],\"networkApiVersion\":\"2020-11-01\"},\"securityProfile\":{\"uefiSettings\":{\"secureBootEnabled\":true,\"vTpmEnabled\":true},\"encryptionAtHost\":true,\"securityType\":\"TrustedLaunch\",\"encryptionIdentity\":{\"userAssignedIdentityResourceId\":\"qoersmt\"},\"proxyAgentSettings\":{\"enabled\":true,\"mode\":\"Audit\",\"keyIncarnationId\":20}},\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":true,\"storageUri\":\"rzamfwghybpx\"}},\"extensionProfile\":{\"extensions\":[{\"name\":\"bndxuxx\",\"properties\":{\"forceUpdateTag\":\"yhgxw\",\"publisher\":\"kpxtirxjfprhs\",\"type\":\"pgjilctjjwaa\",\"typeHandlerVersion\":\"zevivcoilxmbwlrihhhibq\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"provisionAfterExtensions\":[\"nftzosroolbcwmpupujzqwqe\"],\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}}}}],\"extensionsTimeBudget\":\"mbhjahtdygwgyszdwjtvlvtgchdwil\"},\"licenseType\":\"v\",\"scheduledEventsProfile\":{\"terminateNotificationProfile\":{\"notBeforeTimeout\":\"iljppmmw\",\"enable\":true},\"osImageNotificationProfile\":{\"notBeforeTimeout\":\"olbpadmevekyczfokodtfprxti\",\"enable\":true}},\"userData\":\"s\",\"capacityReservation\":{\"capacityReservationGroup\":{\"id\":\"groxwd\"}},\"applicationProfile\":{\"galleryApplications\":[{\"tags\":\"eyrqjbib\",\"order\":5,\"packageReferenceId\":\"lfxqiadouhmbovcd\",\"configurationReference\":\"ulztmiavpojpbpbddgnuuiimxcpau\",\"treatFailureAsDeploymentFailure\":true,\"enableAutomaticUpgrade\":true}]},\"hardwareProfile\":{\"vmSizeProperties\":{\"vCPUsAvailable\":16,\"vCPUsPerCore\":23}},\"serviceArtifactReference\":{\"id\":\"qlkeeyskyr\"},\"securityPostureReference\":{\"id\":\"mubredelfbshboaxrsxiajihahaa\",\"excludeExtensions\":[{\"properties\":{\"forceUpdateTag\":\"oriasdwawveilgusfrn\",\"publisher\":\"rxoajzb\",\"type\":\"vhrtgbaqdkbrrqxsdiiaqxksmqukl\",\"typeHandlerVersion\":\"bvzbiibps\",\"autoUpgradeMinorVersion\":true,\"enableAutomaticUpgrade\":true,\"settings\":{},\"protectedSettings\":{},\"instanceView\":{\"name\":\"ip\",\"type\":\"woadxvobquacooaujyg\",\"typeHandlerVersion\":\"ftkkqxdqiofgsusvxekdcpua\",\"substatuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}],\"statuses\":[{\"code\":\"kuehuahsdozupmjrtp\",\"level\":\"Info\",\"displayStatus\":\"pomenhgqjoelbxvsqwxxexqxv\",\"message\":\"jxjjmlwbjylzvrislyyflhnmizhiu\",\"time\":\"2024-04-29T21:51:44.042Z\"}]},\"suppressFailures\":true,\"protectedSettingsFromKeyVault\":{\"secretUrl\":\"vyhzfkqsqanacgzjthpjoe\",\"sourceVault\":{\"id\":\"groxwd\"}},\"provisionAfterExtensions\":[\"lwsfavklrgzuwmyxscskt\"]},\"location\":\"wrqxhbqaebwkzmcdmngyqmhogc\",\"tags\":{}}]}}", + Object.class, SerializerEncoding.JSON)) + .withComputeApiVersion("2023-07-01") + .withPlatformFaultDomainCount(1))) + .apply(); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/OperationsListSamples.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/OperationsListSamples.java new file mode 100644 index 0000000000000..63c542ab746d1 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/samples/java/com/azure/resourcemanager/computefleet/generated/OperationsListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: + * specification/azurefleet/AzureFleet.Management/examples/2024-05-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to ComputeFleetManager. + */ + public static void operationsList(com.azure.resourcemanager.computefleet.ComputeFleetManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ComputeProfileTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ComputeProfileTests.java new file mode 100644 index 0000000000000..a882f2043ebd9 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ComputeProfileTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.ComputeProfile; +import org.junit.jupiter.api.Assertions; + +public final class ComputeProfileTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ComputeProfile model = BinaryData.fromString( + "{\"baseVirtualMachineProfile\":\"dataodepoogin\",\"computeApiVersion\":\"amiheognarxz\",\"platformFaultDomainCount\":1879444150}") + .toObject(ComputeProfile.class); + Assertions.assertEquals("amiheognarxz", model.computeApiVersion()); + Assertions.assertEquals(1879444150, model.platformFaultDomainCount()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ComputeProfile model = new ComputeProfile().withBaseVirtualMachineProfile("dataodepoogin") + .withComputeApiVersion("amiheognarxz") + .withPlatformFaultDomainCount(1879444150); + model = BinaryData.fromObject(model).toObject(ComputeProfile.class); + Assertions.assertEquals("amiheognarxz", model.computeApiVersion()); + Assertions.assertEquals(1879444150, model.platformFaultDomainCount()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/FleetPropertiesTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/FleetPropertiesTests.java new file mode 100644 index 0000000000000..25d3fb8e41e9d --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/FleetPropertiesTests.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.ComputeProfile; +import com.azure.resourcemanager.computefleet.models.EvictionPolicy; +import com.azure.resourcemanager.computefleet.models.FleetProperties; +import com.azure.resourcemanager.computefleet.models.RegularPriorityAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.RegularPriorityProfile; +import com.azure.resourcemanager.computefleet.models.SpotAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.SpotPriorityProfile; +import com.azure.resourcemanager.computefleet.models.VmSizeProfile; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class FleetPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + FleetProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Canceled\",\"spotPriorityProfile\":{\"capacity\":375105800,\"minCapacity\":1344443621,\"maxPricePerVM\":50.506181162870455,\"evictionPolicy\":\"Deallocate\",\"allocationStrategy\":\"CapacityOptimized\",\"maintain\":true},\"regularPriorityProfile\":{\"capacity\":1441176241,\"minCapacity\":1286342154,\"allocationStrategy\":\"Prioritized\"},\"vmSizesProfile\":[{\"name\":\"aolthqtrg\",\"rank\":677143395},{\"name\":\"pfzfsinzgvfc\",\"rank\":751944111}],\"computeProfile\":{\"baseVirtualMachineProfile\":\"datazoxxjtf\",\"computeApiVersion\":\"luwfzitonpeqfpjk\",\"platformFaultDomainCount\":1383266559}}") + .toObject(FleetProperties.class); + Assertions.assertEquals(375105800, model.spotPriorityProfile().capacity()); + Assertions.assertEquals(1344443621, model.spotPriorityProfile().minCapacity()); + Assertions.assertEquals(50.506181162870455D, model.spotPriorityProfile().maxPricePerVM()); + Assertions.assertEquals(EvictionPolicy.DEALLOCATE, model.spotPriorityProfile().evictionPolicy()); + Assertions.assertEquals(SpotAllocationStrategy.CAPACITY_OPTIMIZED, + model.spotPriorityProfile().allocationStrategy()); + Assertions.assertEquals(true, model.spotPriorityProfile().maintain()); + Assertions.assertEquals(1441176241, model.regularPriorityProfile().capacity()); + Assertions.assertEquals(1286342154, model.regularPriorityProfile().minCapacity()); + Assertions.assertEquals(RegularPriorityAllocationStrategy.PRIORITIZED, + model.regularPriorityProfile().allocationStrategy()); + Assertions.assertEquals("aolthqtrg", model.vmSizesProfile().get(0).name()); + Assertions.assertEquals(677143395, model.vmSizesProfile().get(0).rank()); + Assertions.assertEquals("luwfzitonpeqfpjk", model.computeProfile().computeApiVersion()); + Assertions.assertEquals(1383266559, model.computeProfile().platformFaultDomainCount()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + FleetProperties model = new FleetProperties() + .withSpotPriorityProfile(new SpotPriorityProfile().withCapacity(375105800) + .withMinCapacity(1344443621) + .withMaxPricePerVM(50.506181162870455D) + .withEvictionPolicy(EvictionPolicy.DEALLOCATE) + .withAllocationStrategy(SpotAllocationStrategy.CAPACITY_OPTIMIZED) + .withMaintain(true)) + .withRegularPriorityProfile(new RegularPriorityProfile().withCapacity(1441176241) + .withMinCapacity(1286342154) + .withAllocationStrategy(RegularPriorityAllocationStrategy.PRIORITIZED)) + .withVmSizesProfile(Arrays.asList(new VmSizeProfile().withName("aolthqtrg").withRank(677143395), + new VmSizeProfile().withName("pfzfsinzgvfc").withRank(751944111))) + .withComputeProfile(new ComputeProfile().withBaseVirtualMachineProfile("datazoxxjtf") + .withComputeApiVersion("luwfzitonpeqfpjk") + .withPlatformFaultDomainCount(1383266559)); + model = BinaryData.fromObject(model).toObject(FleetProperties.class); + Assertions.assertEquals(375105800, model.spotPriorityProfile().capacity()); + Assertions.assertEquals(1344443621, model.spotPriorityProfile().minCapacity()); + Assertions.assertEquals(50.506181162870455D, model.spotPriorityProfile().maxPricePerVM()); + Assertions.assertEquals(EvictionPolicy.DEALLOCATE, model.spotPriorityProfile().evictionPolicy()); + Assertions.assertEquals(SpotAllocationStrategy.CAPACITY_OPTIMIZED, + model.spotPriorityProfile().allocationStrategy()); + Assertions.assertEquals(true, model.spotPriorityProfile().maintain()); + Assertions.assertEquals(1441176241, model.regularPriorityProfile().capacity()); + Assertions.assertEquals(1286342154, model.regularPriorityProfile().minCapacity()); + Assertions.assertEquals(RegularPriorityAllocationStrategy.PRIORITIZED, + model.regularPriorityProfile().allocationStrategy()); + Assertions.assertEquals("aolthqtrg", model.vmSizesProfile().get(0).name()); + Assertions.assertEquals(677143395, model.vmSizesProfile().get(0).rank()); + Assertions.assertEquals("luwfzitonpeqfpjk", model.computeProfile().computeApiVersion()); + Assertions.assertEquals(1383266559, model.computeProfile().platformFaultDomainCount()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/FleetsListVirtualMachineScaleSetsWithResponseMockTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/FleetsListVirtualMachineScaleSetsWithResponseMockTests.java new file mode 100644 index 0000000000000..0d591ce97f5c8 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/FleetsListVirtualMachineScaleSetsWithResponseMockTests.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.computefleet.ComputeFleetManager; +import com.azure.resourcemanager.computefleet.models.VirtualMachineScaleSetListResult; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class FleetsListVirtualMachineScaleSetsWithResponseMockTests { + @Test + public void testListVirtualMachineScaleSetsWithResponse() throws Exception { + String responseStr + = "{\"value\":[{\"id\":\"rrqnbpoczvyifqrv\",\"type\":\"vjsllrmvvdfw\",\"operationStatus\":\"Deleting\",\"error\":\"datapnpulexxbczwtru\"}],\"nextLink\":\"qzbqjvsov\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + ComputeFleetManager manager = ComputeFleetManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + VirtualMachineScaleSetListResult response = manager.fleets() + .listVirtualMachineScaleSetsWithResponse("ryocfsfksymdd", "stkiiuxhqyud", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("qzbqjvsov", response.nextLink()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ManagedServiceIdentityTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ManagedServiceIdentityTests.java new file mode 100644 index 0000000000000..5a8b73de4cd6f --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ManagedServiceIdentityTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentity; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.computefleet.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ManagedServiceIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ManagedServiceIdentity model = BinaryData.fromString( + "{\"principalId\":\"o\",\"tenantId\":\"si\",\"type\":\"None\",\"userAssignedIdentities\":{\"gxg\":{\"principalId\":\"ciqihnhung\",\"clientId\":\"jzrnf\"}}}") + .toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.NONE, model.type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ManagedServiceIdentity model = new ManagedServiceIdentity().withType(ManagedServiceIdentityType.NONE) + .withUserAssignedIdentities(mapOf("gxg", new UserAssignedIdentity())); + model = BinaryData.fromObject(model).toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.NONE, model.type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ManagedServiceIdentityUpdateTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ManagedServiceIdentityUpdateTests.java new file mode 100644 index 0000000000000..b4a92065d4364 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/ManagedServiceIdentityUpdateTests.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.computefleet.models.ManagedServiceIdentityUpdate; +import com.azure.resourcemanager.computefleet.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ManagedServiceIdentityUpdateTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ManagedServiceIdentityUpdate model = BinaryData.fromString( + "{\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"ckbasyypndd\":{\"principalId\":\"fkgiawxk\",\"clientId\":\"ypl\"},\"i\":{\"principalId\":\"gcbacphejkot\",\"clientId\":\"qgoulznd\"}}}") + .toObject(ManagedServiceIdentityUpdate.class); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ManagedServiceIdentityUpdate model + = new ManagedServiceIdentityUpdate().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities( + mapOf("ckbasyypndd", new UserAssignedIdentity(), "i", new UserAssignedIdentity())); + model = BinaryData.fromObject(model).toObject(ManagedServiceIdentityUpdate.class); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, model.type()); + } + + // Use "Map.of" if available + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationDisplayTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationDisplayTests.java new file mode 100644 index 0000000000000..4c1ffdab0e66a --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationDisplayTests.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.OperationDisplay; +import org.junit.jupiter.api.Assertions; + +public final class OperationDisplayTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationDisplay model = BinaryData.fromString( + "{\"provider\":\"cdm\",\"resource\":\"rcryuanzwuxzdxta\",\"operation\":\"lhmwhfpmrqobm\",\"description\":\"kknryrtihf\"}") + .toObject(OperationDisplay.class); + Assertions.assertEquals("cdm", model.provider()); + Assertions.assertEquals("rcryuanzwuxzdxta", model.resource()); + Assertions.assertEquals("lhmwhfpmrqobm", model.operation()); + Assertions.assertEquals("kknryrtihf", model.description()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationInnerTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationInnerTests.java new file mode 100644 index 0000000000000..b41aaddba4650 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationInnerTests.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.fluent.models.OperationInner; +import com.azure.resourcemanager.computefleet.models.ActionType; +import org.junit.jupiter.api.Assertions; + +public final class OperationInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationInner model = BinaryData.fromString( + "{\"name\":\"nygj\",\"isDataAction\":true,\"display\":{\"provider\":\"eqsrdeupewnwreit\",\"resource\":\"yflusarhmofc\",\"operation\":\"smy\",\"description\":\"kdtmlxhekuk\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}") + .toObject(OperationInner.class); + Assertions.assertEquals("eqsrdeupewnwreit", model.display().provider()); + Assertions.assertEquals("yflusarhmofc", model.display().resource()); + Assertions.assertEquals("smy", model.display().operation()); + Assertions.assertEquals("kdtmlxhekuk", model.display().description()); + Assertions.assertEquals(ActionType.INTERNAL, model.actionType()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationListResultTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationListResultTests.java new file mode 100644 index 0000000000000..b6aa292223062 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationListResultTests.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.implementation.models.OperationListResult; +import com.azure.resourcemanager.computefleet.models.ActionType; +import org.junit.jupiter.api.Assertions; + +public final class OperationListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationListResult model = BinaryData.fromString( + "{\"value\":[{\"name\":\"hq\",\"isDataAction\":true,\"display\":{\"provider\":\"pybczmehmtzopb\",\"resource\":\"h\",\"operation\":\"pidgsybbejhphoyc\",\"description\":\"xaobhdxbmtqioqjz\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"fpownoizhwlr\",\"isDataAction\":false,\"display\":{\"provider\":\"oqijgkdmbpaz\",\"resource\":\"bc\",\"operation\":\"pdznrbtcqqjnqgl\",\"description\":\"gnufoooj\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"esaagdfm\",\"isDataAction\":true,\"display\":{\"provider\":\"j\",\"resource\":\"ifkwmrvktsizntoc\",\"operation\":\"a\",\"description\":\"ajpsquc\"},\"origin\":\"system\",\"actionType\":\"Internal\"}],\"nextLink\":\"kfo\"}") + .toObject(OperationListResult.class); + Assertions.assertEquals("pybczmehmtzopb", model.value().get(0).display().provider()); + Assertions.assertEquals("h", model.value().get(0).display().resource()); + Assertions.assertEquals("pidgsybbejhphoyc", model.value().get(0).display().operation()); + Assertions.assertEquals("xaobhdxbmtqioqjz", model.value().get(0).display().description()); + Assertions.assertEquals(ActionType.INTERNAL, model.value().get(0).actionType()); + Assertions.assertEquals("kfo", model.nextLink()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationsListMockTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationsListMockTests.java new file mode 100644 index 0000000000000..33c9f03893c03 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/OperationsListMockTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.computefleet.ComputeFleetManager; +import com.azure.resourcemanager.computefleet.models.ActionType; +import com.azure.resourcemanager.computefleet.models.Operation; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class OperationsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"name\":\"lkhbz\",\"isDataAction\":true,\"display\":{\"provider\":\"zgqexz\",\"resource\":\"c\",\"operation\":\"c\",\"description\":\"ierhhbcsglummaj\"},\"origin\":\"system\",\"actionType\":\"Internal\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + ComputeFleetManager manager = ComputeFleetManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureEnvironment.AZURE)); + + PagedIterable response = manager.operations().list(com.azure.core.util.Context.NONE); + + Assertions.assertEquals("zgqexz", response.iterator().next().display().provider()); + Assertions.assertEquals("c", response.iterator().next().display().resource()); + Assertions.assertEquals("c", response.iterator().next().display().operation()); + Assertions.assertEquals("ierhhbcsglummaj", response.iterator().next().display().description()); + Assertions.assertEquals(ActionType.INTERNAL, response.iterator().next().actionType()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/RegularPriorityProfileTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/RegularPriorityProfileTests.java new file mode 100644 index 0000000000000..03b6eb67a11e9 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/RegularPriorityProfileTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.RegularPriorityAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.RegularPriorityProfile; +import org.junit.jupiter.api.Assertions; + +public final class RegularPriorityProfileTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + RegularPriorityProfile model = BinaryData + .fromString("{\"capacity\":133752710,\"minCapacity\":2146603578,\"allocationStrategy\":\"Prioritized\"}") + .toObject(RegularPriorityProfile.class); + Assertions.assertEquals(133752710, model.capacity()); + Assertions.assertEquals(2146603578, model.minCapacity()); + Assertions.assertEquals(RegularPriorityAllocationStrategy.PRIORITIZED, model.allocationStrategy()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + RegularPriorityProfile model = new RegularPriorityProfile().withCapacity(133752710) + .withMinCapacity(2146603578) + .withAllocationStrategy(RegularPriorityAllocationStrategy.PRIORITIZED); + model = BinaryData.fromObject(model).toObject(RegularPriorityProfile.class); + Assertions.assertEquals(133752710, model.capacity()); + Assertions.assertEquals(2146603578, model.minCapacity()); + Assertions.assertEquals(RegularPriorityAllocationStrategy.PRIORITIZED, model.allocationStrategy()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/SpotPriorityProfileTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/SpotPriorityProfileTests.java new file mode 100644 index 0000000000000..3ea10b024b0ae --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/SpotPriorityProfileTests.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.EvictionPolicy; +import com.azure.resourcemanager.computefleet.models.SpotAllocationStrategy; +import com.azure.resourcemanager.computefleet.models.SpotPriorityProfile; +import org.junit.jupiter.api.Assertions; + +public final class SpotPriorityProfileTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + SpotPriorityProfile model = BinaryData.fromString( + "{\"capacity\":864037829,\"minCapacity\":1536107931,\"maxPricePerVM\":15.607655513941253,\"evictionPolicy\":\"Deallocate\",\"allocationStrategy\":\"PriceCapacityOptimized\",\"maintain\":false}") + .toObject(SpotPriorityProfile.class); + Assertions.assertEquals(864037829, model.capacity()); + Assertions.assertEquals(1536107931, model.minCapacity()); + Assertions.assertEquals(15.607655513941253D, model.maxPricePerVM()); + Assertions.assertEquals(EvictionPolicy.DEALLOCATE, model.evictionPolicy()); + Assertions.assertEquals(SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED, model.allocationStrategy()); + Assertions.assertEquals(false, model.maintain()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + SpotPriorityProfile model = new SpotPriorityProfile().withCapacity(864037829) + .withMinCapacity(1536107931) + .withMaxPricePerVM(15.607655513941253D) + .withEvictionPolicy(EvictionPolicy.DEALLOCATE) + .withAllocationStrategy(SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED) + .withMaintain(false); + model = BinaryData.fromObject(model).toObject(SpotPriorityProfile.class); + Assertions.assertEquals(864037829, model.capacity()); + Assertions.assertEquals(1536107931, model.minCapacity()); + Assertions.assertEquals(15.607655513941253D, model.maxPricePerVM()); + Assertions.assertEquals(EvictionPolicy.DEALLOCATE, model.evictionPolicy()); + Assertions.assertEquals(SpotAllocationStrategy.PRICE_CAPACITY_OPTIMIZED, model.allocationStrategy()); + Assertions.assertEquals(false, model.maintain()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/UserAssignedIdentityTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/UserAssignedIdentityTests.java new file mode 100644 index 0000000000000..4ce6bd848812a --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/UserAssignedIdentityTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.UserAssignedIdentity; + +public final class UserAssignedIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + UserAssignedIdentity model + = BinaryData.fromString("{\"principalId\":\"pemvtzfkufubljof\",\"clientId\":\"eofjaeqjh\"}") + .toObject(UserAssignedIdentity.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + UserAssignedIdentity model = new UserAssignedIdentity(); + model = BinaryData.fromObject(model).toObject(UserAssignedIdentity.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VirtualMachineScaleSetListResultInnerTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VirtualMachineScaleSetListResultInnerTests.java new file mode 100644 index 0000000000000..aa7623dd0403b --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VirtualMachineScaleSetListResultInnerTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.fluent.models.VirtualMachineScaleSetListResultInner; +import org.junit.jupiter.api.Assertions; + +public final class VirtualMachineScaleSetListResultInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + VirtualMachineScaleSetListResultInner model = BinaryData.fromString( + "{\"value\":[{\"id\":\"zcxtbzsgfyccsn\",\"type\":\"mdwzjeiachboo\",\"operationStatus\":\"Failed\",\"error\":\"datanrosfqpte\"},{\"id\":\"hzzvypyq\",\"type\":\"mzinpvswjdk\",\"operationStatus\":\"Canceled\",\"error\":\"dataoodqxhcrm\"},{\"id\":\"ohjtckw\",\"type\":\"soifiyipjxsqw\",\"operationStatus\":\"Creating\",\"error\":\"datajbznorc\"},{\"id\":\"xv\",\"type\":\"byxqabn\",\"operationStatus\":\"Creating\",\"error\":\"datapcyshu\"}],\"nextLink\":\"afbljjgpbtoqcjmk\"}") + .toObject(VirtualMachineScaleSetListResultInner.class); + Assertions.assertEquals("afbljjgpbtoqcjmk", model.nextLink()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VirtualMachineScaleSetTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VirtualMachineScaleSetTests.java new file mode 100644 index 0000000000000..d91cd38e287fb --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VirtualMachineScaleSetTests.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.VirtualMachineScaleSet; + +public final class VirtualMachineScaleSetTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + VirtualMachineScaleSet model = BinaryData + .fromString( + "{\"id\":\"javbqidtqajz\",\"type\":\"l\",\"operationStatus\":\"Canceled\",\"error\":\"datadj\"}") + .toObject(VirtualMachineScaleSet.class); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VmSizeProfileTests.java b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VmSizeProfileTests.java new file mode 100644 index 0000000000000..dbbea2e2c7964 --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/src/test/java/com/azure/resourcemanager/computefleet/generated/VmSizeProfileTests.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.computefleet.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.computefleet.models.VmSizeProfile; +import org.junit.jupiter.api.Assertions; + +public final class VmSizeProfileTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + VmSizeProfile model + = BinaryData.fromString("{\"name\":\"huyb\",\"rank\":1813280112}").toObject(VmSizeProfile.class); + Assertions.assertEquals("huyb", model.name()); + Assertions.assertEquals(1813280112, model.rank()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + VmSizeProfile model = new VmSizeProfile().withName("huyb").withRank(1813280112); + model = BinaryData.fromObject(model).toObject(VmSizeProfile.class); + Assertions.assertEquals("huyb", model.name()); + Assertions.assertEquals(1813280112, model.rank()); + } +} diff --git a/sdk/computefleet/azure-resourcemanager-computefleet/tsp-location.yaml b/sdk/computefleet/azure-resourcemanager-computefleet/tsp-location.yaml new file mode 100644 index 0000000000000..3c409d8ef209e --- /dev/null +++ b/sdk/computefleet/azure-resourcemanager-computefleet/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/azurefleet/AzureFleet.Management +commit: d314db05716c0439d22514b3cdb75d90ae3f64be +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/computefleet/ci.yml b/sdk/computefleet/ci.yml new file mode 100644 index 0000000000000..cb04adc30b9aa --- /dev/null +++ b/sdk/computefleet/ci.yml @@ -0,0 +1,46 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/computefleet/ci.yml + - sdk/computefleet/azure-resourcemanager-computefleet/ + exclude: + - sdk/computefleet/pom.xml + - sdk/computefleet/azure-resourcemanager-computefleet/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/computefleet/ci.yml + - sdk/computefleet/azure-resourcemanager-computefleet/ + exclude: + - sdk/computefleet/pom.xml + - sdk/computefleet/azure-resourcemanager-computefleet/pom.xml + +parameters: + - name: release_azureresourcemanagercomputefleet + displayName: azure-resourcemanager-computefleet + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: computefleet + Artifacts: + - name: azure-resourcemanager-computefleet + groupId: com.azure.resourcemanager + safeName: azureresourcemanagercomputefleet + releaseInBatch: ${{ parameters.release_azureresourcemanagercomputefleet }} diff --git a/sdk/computefleet/pom.xml b/sdk/computefleet/pom.xml new file mode 100644 index 0000000000000..eb6eb6360f5b2 --- /dev/null +++ b/sdk/computefleet/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-computefleet-service + pom + 1.0.0 + + + azure-resourcemanager-computefleet + +