Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR hanaonazure/resource-manager] Add Create HanaInstance API #5359

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
HanaHardwareTypeNamesEnum,
HanaInstanceSizeNamesEnum,
HanaInstancePowerStateEnum,
HanaProvisioningStatesEnum,
)

__all__ = [
Expand All @@ -64,4 +65,5 @@
'HanaHardwareTypeNamesEnum',
'HanaInstanceSizeNamesEnum',
'HanaInstancePowerStateEnum',
'HanaProvisioningStatesEnum',
]
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ class HanaInstance(Resource):
:vartype proximity_placement_group: str
:ivar hw_revision: Hardware revision of a HANA instance
:vartype hw_revision: str
:ivar partner_node_id: ARM ID of another HanaInstance that will share a
network with this HanaInstance
:vartype partner_node_id: str
:ivar provisioning_state: State of provisioning of the HanaInstance.
Possible values include: 'Accepted', 'Creating', 'Updating', 'Failed',
'Succeeded', 'Deleting', 'Migrating'
:vartype provisioning_state: str or
~azure.mgmt.hanaonazure.models.HanaProvisioningStatesEnum
"""

_validation = {
Expand All @@ -62,6 +70,8 @@ class HanaInstance(Resource):
'power_state': {'readonly': True},
'proximity_placement_group': {'readonly': True},
'hw_revision': {'readonly': True},
'partner_node_id': {'readonly': True},
'provisioning_state': {'readonly': True},
}

_attribute_map = {
Expand All @@ -78,6 +88,8 @@ class HanaInstance(Resource):
'power_state': {'key': 'properties.powerState', 'type': 'str'},
'proximity_placement_group': {'key': 'properties.proximityPlacementGroup', 'type': 'str'},
'hw_revision': {'key': 'properties.hwRevision', 'type': 'str'},
'partner_node_id': {'key': 'properties.partnerNodeId', 'type': 'str'},
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
}

def __init__(self, **kwargs):
Expand All @@ -90,3 +102,5 @@ def __init__(self, **kwargs):
self.power_state = None
self.proximity_placement_group = None
self.hw_revision = None
self.partner_node_id = None
self.provisioning_state = None
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ class HanaInstance(Resource):
:vartype proximity_placement_group: str
:ivar hw_revision: Hardware revision of a HANA instance
:vartype hw_revision: str
:ivar partner_node_id: ARM ID of another HanaInstance that will share a
network with this HanaInstance
:vartype partner_node_id: str
:ivar provisioning_state: State of provisioning of the HanaInstance.
Possible values include: 'Accepted', 'Creating', 'Updating', 'Failed',
'Succeeded', 'Deleting', 'Migrating'
:vartype provisioning_state: str or
~azure.mgmt.hanaonazure.models.HanaProvisioningStatesEnum
"""

_validation = {
Expand All @@ -62,6 +70,8 @@ class HanaInstance(Resource):
'power_state': {'readonly': True},
'proximity_placement_group': {'readonly': True},
'hw_revision': {'readonly': True},
'partner_node_id': {'readonly': True},
'provisioning_state': {'readonly': True},
}

_attribute_map = {
Expand All @@ -78,6 +88,8 @@ class HanaInstance(Resource):
'power_state': {'key': 'properties.powerState', 'type': 'str'},
'proximity_placement_group': {'key': 'properties.proximityPlacementGroup', 'type': 'str'},
'hw_revision': {'key': 'properties.hwRevision', 'type': 'str'},
'partner_node_id': {'key': 'properties.partnerNodeId', 'type': 'str'},
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
}

def __init__(self, *, hardware_profile=None, storage_profile=None, os_profile=None, network_profile=None, **kwargs) -> None:
Expand All @@ -90,3 +102,5 @@ def __init__(self, *, hardware_profile=None, storage_profile=None, os_profile=No
self.power_state = None
self.proximity_placement_group = None
self.hw_revision = None
self.partner_node_id = None
self.provisioning_state = None
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,14 @@ class HanaInstancePowerStateEnum(str, Enum):
stopped = "stopped"
restarting = "restarting"
unknown = "unknown"


class HanaProvisioningStatesEnum(str, Enum):

accepted = "Accepted"
creating = "Creating"
updating = "Updating"
failed = "Failed"
succeeded = "Succeeded"
deleting = "Deleting"
migrating = "Migrating"
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@ class OSProfile(Model):
:vartype os_type: str
:ivar version: Specifies version of operating system.
:vartype version: str
:ivar ssh_public_key: Specifies the SSH public key used to access the
operating system.
:vartype ssh_public_key: str
"""

_validation = {
'computer_name': {'readonly': True},
'os_type': {'readonly': True},
'version': {'readonly': True},
'ssh_public_key': {'readonly': True},
}

_attribute_map = {
'computer_name': {'key': 'computerName', 'type': 'str'},
'os_type': {'key': 'osType', 'type': 'str'},
'version': {'key': 'version', 'type': 'str'},
'ssh_public_key': {'key': 'sshPublicKey', 'type': 'str'},
}

def __init__(self, **kwargs):
super(OSProfile, self).__init__(**kwargs)
self.computer_name = None
self.os_type = None
self.version = None
self.ssh_public_key = None
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@ class OSProfile(Model):
:vartype os_type: str
:ivar version: Specifies version of operating system.
:vartype version: str
:ivar ssh_public_key: Specifies the SSH public key used to access the
operating system.
:vartype ssh_public_key: str
"""

_validation = {
'computer_name': {'readonly': True},
'os_type': {'readonly': True},
'version': {'readonly': True},
'ssh_public_key': {'readonly': True},
}

_attribute_map = {
'computer_name': {'key': 'computerName', 'type': 'str'},
'os_type': {'key': 'osType', 'type': 'str'},
'version': {'key': 'version', 'type': 'str'},
'ssh_public_key': {'key': 'sshPublicKey', 'type': 'str'},
}

def __init__(self, **kwargs) -> None:
super(OSProfile, self).__init__(**kwargs)
self.computer_name = None
self.os_type = None
self.version = None
self.ssh_public_key = None
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,112 @@ def get(
return deserialized
get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/hanaInstances/{hanaInstanceName}'}


def _create_initial(
self, resource_group_name, hana_instance_name, hana_instance_parameter, custom_headers=None, raw=False, **operation_config):
# Construct URL
url = self.create.metadata['url']
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'hanaInstanceName': self._serialize.url("hana_instance_name", hana_instance_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Accept'] = 'application/json'
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct body
body_content = self._serialize.body(hana_instance_parameter, 'HanaInstance')

# Construct and send request
request = self._client.put(url, query_parameters, header_parameters, body_content)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200, 201]:
raise models.ErrorResponseException(self._deserialize, response)

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('HanaInstance', response)
if response.status_code == 201:
deserialized = self._deserialize('HanaInstance', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

def create(
self, resource_group_name, hana_instance_name, hana_instance_parameter, custom_headers=None, raw=False, polling=True, **operation_config):
"""Creates a SAP HANA instance.

Creates a SAP HANA instance for the specified subscription, resource
group, and instance name.

:param resource_group_name: Name of the resource group.
:type resource_group_name: str
:param hana_instance_name: Name of the SAP HANA on Azure instance.
:type hana_instance_name: str
:param hana_instance_parameter: Request body representing a
HanaInstance
:type hana_instance_parameter:
~azure.mgmt.hanaonazure.models.HanaInstance
:param dict custom_headers: headers that will be added to the request
:param bool raw: The poller return type is ClientRawResponse, the
direct response alongside the deserialized response
:param polling: True for ARMPolling, False for no polling, or a
polling object for personal polling strategy
:return: An instance of LROPoller that returns HanaInstance or
ClientRawResponse<HanaInstance> if raw==True
:rtype:
~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.hanaonazure.models.HanaInstance]
or
~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.hanaonazure.models.HanaInstance]]
:raises:
:class:`ErrorResponseException<azure.mgmt.hanaonazure.models.ErrorResponseException>`
"""
raw_result = self._create_initial(
resource_group_name=resource_group_name,
hana_instance_name=hana_instance_name,
hana_instance_parameter=hana_instance_parameter,
custom_headers=custom_headers,
raw=True,
**operation_config
)

def get_long_running_output(response):
deserialized = self._deserialize('HanaInstance', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized

lro_delay = operation_config.get(
'long_running_operation_timeout',
self.config.long_running_operation_timeout)
if polling is True: polling_method = ARMPolling(lro_delay, **operation_config)
elif polling is False: polling_method = NoPolling()
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/hanaInstances/{hanaInstanceName}'}

def update(
self, resource_group_name, hana_instance_name, tags=None, custom_headers=None, raw=False, **operation_config):
"""Patches the Tags field of a SAP HANA instance.
Expand Down