Skip to content

Commit

Permalink
generate with unflattened code
Browse files Browse the repository at this point in the history
  • Loading branch information
iscai-msft committed Jun 24, 2020
1 parent 4a07b9c commit 3a6591a
Show file tree
Hide file tree
Showing 22 changed files with 1,332 additions and 2,769 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,23 @@ def begin_create_certificate(self, certificate_name, policy, **kwargs):
if polling_interval is None:
polling_interval = 5
enabled = kwargs.pop("enabled", None)
tags = kwargs.pop("tags", None)


if enabled is not None:
attributes = self._models.CertificateAttributes(enabled=enabled)
else:
attributes = None

parameters = self._models.CertificateCreateParameters(
certificate_policy=policy._to_certificate_policy_bundle(),
certificate_attributes=attributes,
tags=kwargs.pop("tags", None)
)

cert_bundle = self._client.create_certificate(
vault_base_url=self.vault_url,
certificate_name=certificate_name,
certificate_policy=policy._to_certificate_policy_bundle(),
certificate_attributes=attributes,
tags=tags,
parameters=parameters,
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -354,21 +358,26 @@ def import_certificate(self, certificate_name, certificate_bytes, **kwargs):
"""

enabled = kwargs.pop("enabled", None)
password = kwargs.pop("password", None)
policy = kwargs.pop("policy", None)

if enabled is not None:
attributes = self._models.CertificateAttributes(enabled=enabled)
else:
attributes = None
base64_encoded_certificate = base64.b64encode(certificate_bytes).decode("utf-8")
bundle = self._client.import_certificate(
vault_base_url=self.vault_url,
certificate_name=certificate_name,

parameters = self._models.CertificateImportParameters(
base64_encoded_certificate=base64_encoded_certificate,
password=password,
password=kwargs.pop("password", None),
certificate_policy=policy._to_certificate_policy_bundle(),
certificate_attributes=attributes,
tags=None,
)

bundle = self._client.import_certificate(
vault_base_url=self.vault_url,
certificate_name=certificate_name,
parameters=parameters,
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -445,11 +454,16 @@ def update_certificate_properties(self, certificate_name, version=None, **kwargs
else:
attributes = None

parameters = self._models.CertificateUpdateParameters(
certificate_attributes=attributes,
tags=kwargs.pop("tags", None)
)

bundle = self._client.update_certificate(
vault_base_url=self.vault_url,
certificate_name=certificate_name,
certificate_version=version or "",
certificate_attributes=attributes,
parameters=parameters,
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -508,7 +522,9 @@ def restore_certificate_backup(self, backup, **kwargs):
:dedent: 8
"""
bundle = self._client.restore_certificate(
vault_base_url=self.vault_url, certificate_bundle_backup=backup, error_map=_error_map, **kwargs
vault_base_url=self.vault_url,
parameters=self._models.CertificateRestoreParameters(certificate_bundle_backup=backup),
error_map=_error_map, **kwargs
)
return KeyVaultCertificate._from_certificate_bundle(certificate_bundle=bundle)

Expand Down Expand Up @@ -632,7 +648,7 @@ def set_contacts(self, contacts, **kwargs):
"""
contacts = self._client.set_certificate_contacts(
vault_base_url=self.vault_url,
contact_list=[c._to_certificate_contacts_item() for c in contacts],
contacts=self._models.Contacts(contact_list=[c._to_certificate_contacts_item() for c in contacts]),
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -728,7 +744,7 @@ def cancel_certificate_operation(self, certificate_name, **kwargs):
bundle = self._client.update_certificate_operation(
vault_base_url=self.vault_url,
certificate_name=certificate_name,
cancellation_requested=True,
certificate_operation=self._models.CertificateOperationUpdateParameter(cancellation_requested=True),
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -762,11 +778,17 @@ def merge_certificate(self, certificate_name, x509_certificates, **kwargs):
attributes = self._models.CertificateAttributes(enabled=enabled)
else:
attributes = None

parameters = self._models.CertificateMergeParameters(
x509_certificates=x509_certificates,
certificate_attributes=attributes,
tags=kwargs.pop("tags", None)
)

bundle = self._client.merge_certificate(
vault_base_url=self.vault_url,
certificate_name=certificate_name,
x509_certificates=x509_certificates,
certificate_attributes=attributes,
parameters=parameters,
error_map=_error_map,
**kwargs
)
Expand Down Expand Up @@ -856,13 +878,18 @@ def create_issuer(self, issuer_name, provider, **kwargs):
issuer_attributes = self._models.IssuerAttributes(enabled=enabled)
else:
issuer_attributes = None
issuer_bundle = self._client.set_certificate_issuer(
vault_base_url=self.vault_url,
issuer_name=issuer_name,

parameters = self._models.CertificateIssuerSetParameters(
provider=provider,
credentials=issuer_credentials,
organization_details=organization_details,
attributes=issuer_attributes,
)

issuer_bundle = self._client.set_certificate_issuer(
vault_base_url=self.vault_url,
issuer_name=issuer_name,
parameter=parameters,
error_map=_error_map,
**kwargs
)
Expand All @@ -887,7 +914,6 @@ def update_issuer(self, issuer_name, **kwargs):
"""

enabled = kwargs.pop("enabled", None)
provider = kwargs.pop("provider", None)
account_id = kwargs.pop("account_id", None)
password = kwargs.pop("password", None)
organization_id = kwargs.pop("organization_id", None)
Expand Down Expand Up @@ -919,13 +945,18 @@ def update_issuer(self, issuer_name, **kwargs):
issuer_attributes = self._models.IssuerAttributes(enabled=enabled)
else:
issuer_attributes = None

parameters = self._models.CertificateIssuerUpdateParameters(
provider=kwargs.pop("provider", None),
credentials=issuer_credentials,
organization_details=organization_details,
attributes=issuer_attributes
)

issuer_bundle = self._client.update_certificate_issuer(
vault_base_url=self.vault_url,
issuer_name=issuer_name,
provider=provider,
credentials=issuer_credentials,
organization_details=organization_details,
attributes=issuer_attributes,
parameter=parameters,
error_map=_error_map,
**kwargs
)
Expand Down
Loading

0 comments on commit 3a6591a

Please sign in to comment.